@woosh/meep-engine 3.76.0 → 3.78.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 (265) hide show
  1. package/editor/particles/effect/ParticleReferenceSimulation.d.ts +11 -0
  2. package/editor/particles/effect/ParticleReferenceSimulation.d.ts.map +1 -1
  3. package/editor/particles/effect/ParticleReferenceSimulation.js +14 -0
  4. package/editor/view/particles/effect/ParticleGraphEditorView.js +1 -1
  5. package/package.json +3 -2
  6. package/src/engine/EngineHarness.d.ts +4 -6
  7. package/src/engine/EngineHarness.d.ts.map +1 -1
  8. package/src/engine/EngineHarness.js +11 -19
  9. package/src/engine/asset/loaders/GroomAssetLoader.d.ts +1 -1
  10. package/src/engine/asset/loaders/GroomAssetLoader.d.ts.map +1 -1
  11. package/src/engine/asset/loaders/GroomAssetLoader.js +16 -2
  12. package/src/engine/graphics/ecs/hair/Hair.d.ts +7 -0
  13. package/src/engine/graphics/ecs/hair/Hair.d.ts.map +1 -1
  14. package/src/engine/graphics/ecs/hair/Hair.js +9 -0
  15. package/src/engine/graphics/ecs/hair/HairDynamics.d.ts +63 -0
  16. package/src/engine/graphics/ecs/hair/HairDynamics.d.ts.map +1 -0
  17. package/src/engine/graphics/ecs/hair/HairDynamics.js +82 -0
  18. package/src/engine/graphics/hair/Groom.d.ts +45 -0
  19. package/src/engine/graphics/hair/Groom.d.ts.map +1 -1
  20. package/src/engine/graphics/hair/Groom.js +56 -0
  21. package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts +27 -1
  22. package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts.map +1 -1
  23. package/src/engine/graphics/hair/GroomSerializationAdapter.js +105 -32
  24. package/src/engine/graphics/hair/GroomSerializationUpgrader_0_1.d.ts +8 -0
  25. package/src/engine/graphics/hair/GroomSerializationUpgrader_0_1.d.ts.map +1 -0
  26. package/src/engine/graphics/hair/GroomSerializationUpgrader_0_1.js +31 -0
  27. package/src/engine/graphics/hair/groom_bind_to_mesh.d.ts +85 -0
  28. package/src/engine/graphics/hair/groom_bind_to_mesh.d.ts.map +1 -0
  29. package/src/engine/graphics/hair/groom_bind_to_mesh.js +216 -0
  30. package/src/engine/graphics/hair/groom_build_group.d.ts +7 -2
  31. package/src/engine/graphics/hair/groom_build_group.d.ts.map +1 -1
  32. package/src/engine/graphics/hair/groom_build_group.js +11 -2
  33. package/src/engine/graphics/hair/groom_build_guides.d.ts +43 -0
  34. package/src/engine/graphics/hair/groom_build_guides.d.ts.map +1 -0
  35. package/src/engine/graphics/hair/groom_build_guides.js +267 -0
  36. package/src/engine/graphics/hair/groom_root_spacing.d.ts +6 -4
  37. package/src/engine/graphics/hair/groom_root_spacing.d.ts.map +1 -1
  38. package/src/engine/graphics/hair/groom_root_spacing.js +199 -66
  39. package/src/engine/graphics3/HairColliderSystem.d.ts +59 -0
  40. package/src/engine/graphics3/HairColliderSystem.d.ts.map +1 -0
  41. package/src/engine/graphics3/HairColliderSystem.js +270 -0
  42. package/src/engine/graphics3/HairSystem.d.ts +21 -4
  43. package/src/engine/graphics3/HairSystem.d.ts.map +1 -1
  44. package/src/engine/graphics3/HairSystem.js +270 -4
  45. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  46. package/src/engine/sound/sopra/runtime/EventInstance.d.ts +0 -1
  47. package/src/engine/sound/sopra/runtime/EventInstance.d.ts.map +1 -1
  48. package/src/engine/sound/sopra/runtime/EventInstance.js +0 -1
  49. package/src/shade/assets/textures/hair_scattering.bin +0 -0
  50. package/src/shade/playground/hair/main.js +27 -4
  51. package/src/shade/playground/hair_skinned/index.html +192 -0
  52. package/src/shade/playground/hair_skinned/main.d.ts +7 -0
  53. package/src/shade/playground/hair_skinned/main.d.ts.map +1 -0
  54. package/src/shade/playground/hair_skinned/main.js +481 -0
  55. package/src/shade/playground/hair_skinned/skinned_hair.d.ts +49 -0
  56. package/src/shade/playground/hair_skinned/skinned_hair.d.ts.map +1 -0
  57. package/src/shade/playground/hair_skinned/skinned_hair.js +362 -0
  58. package/src/shade/playground/sparks/README.md +36 -0
  59. package/src/shade/playground/sparks/index.html +145 -0
  60. package/src/shade/playground/sparks/main.d.ts +7 -0
  61. package/src/shade/playground/sparks/main.d.ts.map +1 -0
  62. package/src/shade/playground/sparks/main.js +312 -0
  63. package/src/shade/playground/sparks/sparks_effect.d.ts +72 -0
  64. package/src/shade/playground/sparks/sparks_effect.d.ts.map +1 -0
  65. package/src/shade/playground/sparks/sparks_effect.js +180 -0
  66. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  67. package/src/shade/renderer/Renderer.js +18 -3
  68. package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
  69. package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts +1 -1
  70. package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
  71. package/src/shade/renderer/animation/GPUAnimationManager.d.ts +3 -2
  72. package/src/shade/renderer/animation/GPUAnimationManager.d.ts.map +1 -1
  73. package/src/shade/renderer/animation/GPUAnimationManager.js +74 -3
  74. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts +13 -3
  75. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts.map +1 -1
  76. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.js +16 -5
  77. package/src/shade/renderer/animation/skinning/shader_meshlet_apply_skinning.js +8 -8
  78. package/src/shade/renderer/deferred/chunk_shade_direct_lights.js +2 -2
  79. package/src/shade/renderer/deferred/chunk_shade_directional_lights.d.ts +4 -2
  80. package/src/shade/renderer/deferred/chunk_shade_directional_lights.d.ts.map +1 -1
  81. package/src/shade/renderer/deferred/chunk_shade_directional_lights.js +7 -3
  82. package/src/shade/renderer/deferred/chunk_standard_material_direct_light_lobe.js +1 -1
  83. package/src/shade/renderer/extension/ShadowAtlas.d.ts +77 -0
  84. package/src/shade/renderer/extension/ShadowAtlas.d.ts.map +1 -0
  85. package/src/shade/renderer/extension/ShadowAtlas.js +135 -0
  86. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
  87. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
  88. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +7 -7
  89. package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
  90. package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
  91. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +1 -1
  92. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.d.ts +37 -7
  93. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.d.ts.map +1 -1
  94. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.js +132 -8
  95. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts +3 -1
  96. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts.map +1 -1
  97. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +6 -2
  98. package/src/shade/renderer/global_illumination/sharc/sharc_constants.d.ts +0 -18
  99. package/src/shade/renderer/global_illumination/sharc/sharc_constants.d.ts.map +1 -1
  100. package/src/shade/renderer/global_illumination/sharc/sharc_constants.js +1 -21
  101. package/src/shade/renderer/hair/GPUHairSystem.d.ts +121 -2
  102. package/src/shade/renderer/hair/GPUHairSystem.d.ts.map +1 -1
  103. package/src/shade/renderer/hair/GPUHairSystem.js +1187 -56
  104. package/src/shade/renderer/hair/HAIR.d.ts +22 -3
  105. package/src/shade/renderer/hair/HAIR.d.ts.map +1 -1
  106. package/src/shade/renderer/hair/HAIR.js +25 -4
  107. package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.d.ts.map +1 -1
  108. package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.js +33 -0
  109. package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.d.ts +4 -0
  110. package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.d.ts.map +1 -1
  111. package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.js +24 -2
  112. package/src/shade/renderer/hair/HAIR_SIMULATION.d.ts +139 -0
  113. package/src/shade/renderer/hair/HAIR_SIMULATION.d.ts.map +1 -0
  114. package/src/shade/renderer/hair/HAIR_SIMULATION.js +160 -0
  115. package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts +9 -2
  116. package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts.map +1 -1
  117. package/src/shade/renderer/hair/chunk_hair_dual_scattering.js +40 -13
  118. package/src/shade/renderer/hair/chunk_hair_guide.d.ts +59 -0
  119. package/src/shade/renderer/hair/chunk_hair_guide.d.ts.map +1 -0
  120. package/src/shade/renderer/hair/chunk_hair_guide.js +179 -0
  121. package/src/shade/renderer/hair/chunk_hair_volume.d.ts +4 -3
  122. package/src/shade/renderer/hair/chunk_hair_volume.d.ts.map +1 -1
  123. package/src/shade/renderer/hair/chunk_hair_volume.js +21 -12
  124. package/src/shade/renderer/hair/hair_lighting.d.ts.map +1 -1
  125. package/src/shade/renderer/hair/hair_lighting.js +16 -7
  126. package/src/shade/renderer/hair/hair_scattering_lut.js +13 -13
  127. package/src/shade/renderer/hair/hair_shadow_draw.d.ts +32 -0
  128. package/src/shade/renderer/hair/hair_shadow_draw.d.ts.map +1 -0
  129. package/src/shade/renderer/hair/hair_shadow_draw.js +123 -0
  130. package/src/shade/renderer/hair/shader_hair_classes.d.ts +2 -1
  131. package/src/shade/renderer/hair/shader_hair_classes.d.ts.map +1 -1
  132. package/src/shade/renderer/hair/shader_hair_classes.js +6 -2
  133. package/src/shade/renderer/hair/shader_hair_cull.d.ts +8 -2
  134. package/src/shade/renderer/hair/shader_hair_cull.d.ts.map +1 -1
  135. package/src/shade/renderer/hair/shader_hair_cull.js +74 -17
  136. package/src/shade/renderer/hair/shader_hair_lod.d.ts +9 -3
  137. package/src/shade/renderer/hair/shader_hair_lod.d.ts.map +1 -1
  138. package/src/shade/renderer/hair/shader_hair_lod.js +125 -31
  139. package/src/shade/renderer/hair/shader_hair_roots.d.ts +36 -0
  140. package/src/shade/renderer/hair/shader_hair_roots.d.ts.map +1 -0
  141. package/src/shade/renderer/hair/shader_hair_roots.js +261 -0
  142. package/src/shade/renderer/hair/shader_hair_shadow_list.d.ts +44 -0
  143. package/src/shade/renderer/hair/shader_hair_shadow_list.d.ts.map +1 -0
  144. package/src/shade/renderer/hair/shader_hair_shadow_list.js +240 -0
  145. package/src/shade/renderer/hair/shader_hair_simulate.d.ts +55 -0
  146. package/src/shade/renderer/hair/shader_hair_simulate.d.ts.map +1 -0
  147. package/src/shade/renderer/hair/shader_hair_simulate.js +563 -0
  148. package/src/shade/renderer/hair/shader_hair_volume.d.ts +3 -3
  149. package/src/shade/renderer/hair/shader_hair_volume.d.ts.map +1 -1
  150. package/src/shade/renderer/hair/shader_hair_volume.js +4 -17
  151. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  152. package/src/shade/renderer/loader/usd/usd_groom_extension.d.ts +8 -3
  153. package/src/shade/renderer/loader/usd/usd_groom_extension.d.ts.map +1 -1
  154. package/src/shade/renderer/loader/usd/usd_groom_extension.js +58 -5
  155. package/src/shade/renderer/particles/GPUParticleSystem.d.ts +8 -0
  156. package/src/shade/renderer/particles/GPUParticleSystem.d.ts.map +1 -1
  157. package/src/shade/renderer/particles/GPUParticleSystem.js +28 -0
  158. package/src/shade/renderer/particles/graph/ParticleNodeRegistry.d.ts.map +1 -1
  159. package/src/shade/renderer/particles/graph/ParticleNodeRegistry.js +22 -0
  160. package/src/shade/renderer/particles/graph/groups/particle_builtin_groups.d.ts.map +1 -1
  161. package/src/shade/renderer/particles/graph/groups/particle_builtin_groups.js +4 -0
  162. package/src/shade/renderer/particles/graph/groups/particle_groups_scene.d.ts +32 -0
  163. package/src/shade/renderer/particles/graph/groups/particle_groups_scene.d.ts.map +1 -0
  164. package/src/shade/renderer/particles/graph/groups/particle_groups_scene.js +80 -0
  165. package/src/shade/renderer/particles/graph/particle_node_parameters.d.ts.map +1 -1
  166. package/src/shade/renderer/particles/graph/particle_node_parameters.js +1 -0
  167. package/src/shade/renderer/particles/graph/particle_node_presentation.d.ts.map +1 -1
  168. package/src/shade/renderer/particles/graph/particle_node_presentation.js +12 -0
  169. package/src/shade/renderer/particles/graph_particles.d.ts +5 -1
  170. package/src/shade/renderer/particles/graph_particles.d.ts.map +1 -1
  171. package/src/shade/renderer/particles/graph_particles.js +18 -3
  172. package/src/shade/renderer/particles/isa/InstructionStream.d.ts +25 -0
  173. package/src/shade/renderer/particles/isa/InstructionStream.d.ts.map +1 -1
  174. package/src/shade/renderer/particles/isa/InstructionStream.js +25 -0
  175. package/src/shade/renderer/particles/isa/ParticleVMISA.d.ts +9 -0
  176. package/src/shade/renderer/particles/isa/ParticleVMISA.d.ts.map +1 -1
  177. package/src/shade/renderer/particles/isa/ParticleVMISA.js +20 -0
  178. package/src/shade/renderer/particles/isa/particle_program_reads_scene_sdf.d.ts +9 -0
  179. package/src/shade/renderer/particles/isa/particle_program_reads_scene_sdf.d.ts.map +1 -0
  180. package/src/shade/renderer/particles/isa/particle_program_reads_scene_sdf.js +29 -0
  181. package/src/shade/renderer/particles/optimizer/particle_program_equivalence.d.ts +2 -1
  182. package/src/shade/renderer/particles/optimizer/particle_program_equivalence.d.ts.map +1 -1
  183. package/src/shade/renderer/particles/optimizer/particle_program_equivalence.js +27 -5
  184. package/src/shade/renderer/particles/optimizer/particle_program_fuzz.js +1 -1
  185. package/src/shade/renderer/particles/optimizer/particle_vm_semantics.d.ts.map +1 -1
  186. package/src/shade/renderer/particles/optimizer/particle_vm_semantics.js +5 -0
  187. package/src/shade/renderer/particles/runtime/EmitterRegistry.d.ts +7 -0
  188. package/src/shade/renderer/particles/runtime/EmitterRegistry.d.ts.map +1 -1
  189. package/src/shade/renderer/particles/runtime/EmitterRegistry.js +10 -0
  190. package/src/shade/renderer/particles/runtime/ParticleEmitter.d.ts +5 -0
  191. package/src/shade/renderer/particles/runtime/ParticleEmitter.d.ts.map +1 -1
  192. package/src/shade/renderer/particles/runtime/ParticleEmitter.js +5 -0
  193. package/src/shade/renderer/particles/runtime/ProgramHeap.d.ts +8 -0
  194. package/src/shade/renderer/particles/runtime/ProgramHeap.d.ts.map +1 -1
  195. package/src/shade/renderer/particles/runtime/ProgramHeap.js +25 -0
  196. package/src/shade/renderer/particles/shaders/shader_particle_emit.d.ts +1 -1
  197. package/src/shade/renderer/particles/shaders/shader_particle_emit.d.ts.map +1 -1
  198. package/src/shade/renderer/particles/shaders/shader_particle_emit.js +9 -3
  199. package/src/shade/renderer/particles/shaders/shader_particle_emit_wide.d.ts.map +1 -1
  200. package/src/shade/renderer/particles/shaders/shader_particle_emit_wide.js +4 -2
  201. package/src/shade/renderer/particles/shaders/shader_particle_simulate.d.ts +2 -2
  202. package/src/shade/renderer/particles/shaders/shader_particle_simulate.d.ts.map +1 -1
  203. package/src/shade/renderer/particles/shaders/shader_particle_simulate.js +10 -4
  204. package/src/shade/renderer/particles/shaders/shader_particle_simulate_wide.d.ts.map +1 -1
  205. package/src/shade/renderer/particles/shaders/shader_particle_simulate_wide.js +4 -2
  206. package/src/shade/renderer/particles/vm/ParticleVMReference.d.ts +14 -1
  207. package/src/shade/renderer/particles/vm/ParticleVMReference.d.ts.map +1 -1
  208. package/src/shade/renderer/particles/vm/ParticleVMReference.js +34 -1
  209. package/src/shade/renderer/particles/vm/chunk_particle_vm.d.ts.map +1 -1
  210. package/src/shade/renderer/particles/vm/chunk_particle_vm.js +10 -0
  211. package/src/shade/renderer/particles/vm/chunk_particle_vm_scene_sdf.d.ts +39 -0
  212. package/src/shade/renderer/particles/vm/chunk_particle_vm_scene_sdf.d.ts.map +1 -0
  213. package/src/shade/renderer/particles/vm/chunk_particle_vm_scene_sdf.js +90 -0
  214. package/src/shade/renderer/particles/warmup/graph_particle_warmup.d.ts +4 -1
  215. package/src/shade/renderer/particles/warmup/graph_particle_warmup.d.ts.map +1 -1
  216. package/src/shade/renderer/particles/warmup/graph_particle_warmup.js +14 -2
  217. package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance.d.ts +1 -1
  218. package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance.d.ts.map +1 -1
  219. package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance.js +9 -3
  220. package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance_wide.d.ts.map +1 -1
  221. package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance_wide.js +4 -2
  222. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  223. package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.d.ts +7 -4
  224. package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.d.ts.map +1 -1
  225. package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.js +26 -16
  226. package/src/shade/renderer/rasterize/draw/chunk_meshlet_draw_vertex.d.ts +7 -4
  227. package/src/shade/renderer/rasterize/draw/chunk_meshlet_draw_vertex.d.ts.map +1 -1
  228. package/src/shade/renderer/rasterize/draw/chunk_meshlet_draw_vertex.js +66 -14
  229. package/src/shade/renderer/rasterize/native/depth/shadow_cascade_rasterization_pass_descriptor.d.ts +20 -0
  230. package/src/shade/renderer/rasterize/native/depth/shadow_cascade_rasterization_pass_descriptor.d.ts.map +1 -0
  231. package/src/shade/renderer/rasterize/native/depth/shadow_cascade_rasterization_pass_descriptor.js +149 -0
  232. package/src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.d.ts +8 -0
  233. package/src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.d.ts.map +1 -1
  234. package/src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.js +100 -33
  235. package/src/shade/renderer/rasterize/native/rasterization_shader_resources.d.ts +11 -0
  236. package/src/shade/renderer/rasterize/native/rasterization_shader_resources.d.ts.map +1 -1
  237. package/src/shade/renderer/rasterize/native/rasterization_shader_resources.js +24 -11
  238. package/src/shade/renderer/scene/GPUSceneContext.d.ts +7 -0
  239. package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
  240. package/src/shade/renderer/scene/GPUSceneContext.js +18 -0
  241. package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_meshlet_vertex_normal.d.ts +13 -0
  242. package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_meshlet_vertex_normal.d.ts.map +1 -0
  243. package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_meshlet_vertex_normal.js +42 -0
  244. package/src/shade/renderer/shader/chunk/sdf/chunk_shape_record_signed_distance_gradient.d.ts +20 -0
  245. package/src/shade/renderer/shader/chunk/sdf/chunk_shape_record_signed_distance_gradient.d.ts.map +1 -0
  246. package/src/shade/renderer/shader/chunk/sdf/chunk_shape_record_signed_distance_gradient.js +134 -0
  247. package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.d.ts +15 -0
  248. package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.d.ts.map +1 -1
  249. package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.js +83 -5
  250. package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.d.ts +34 -0
  251. package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.d.ts.map +1 -0
  252. package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.js +106 -0
  253. package/src/shade/renderer/shadow/map/shader/chunk_shadow_cascade_caster_position.d.ts +16 -0
  254. package/src/shade/renderer/shadow/map/shader/chunk_shadow_cascade_caster_position.d.ts.map +1 -0
  255. package/src/shade/renderer/shadow/map/shader/chunk_shadow_cascade_caster_position.js +50 -0
  256. package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.d.ts +25 -0
  257. package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.d.ts.map +1 -0
  258. package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.js +42 -0
  259. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_directional_atlas_casters.d.ts +10 -0
  260. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_directional_atlas_casters.d.ts.map +1 -0
  261. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_directional_atlas_casters.js +22 -0
  262. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_directional_cascades.d.ts +1 -1
  263. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_directional_cascades.js +5 -5
  264. package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
  265. package/src/shade/renderer/wind/GPUSceneWind.d.ts +1 -1
@@ -0,0 +1,267 @@
1
+ import { assert } from "../../../core/assert.js";
2
+ import { GROOM_GUIDE_LIMIT } from "./Groom.js";
3
+
4
+ /**
5
+ * The wisp tolerance an import gives its groups when it is given none, metres: strands that stay within a centimetre
6
+ * of one another along their whole length move as one wisp. On the test scalp, whose strands each wave on their own,
7
+ * a fifth of the strands guide; Unreal makes a tenth of them guides by default.
8
+ * @type {number}
9
+ */
10
+ export const GROOM_GUIDE_DEFAULT_TOLERANCE = 0.01;
11
+
12
+ /**
13
+ * The fewest segments a guide of length `length` needs so that bent through a quarter turn along its length, each
14
+ * segment stays within `tolerance` of the arc it cuts: a chord `l` of a circle of radius `R` stands `l² / 8R` off
15
+ * it, and a quarter turn over `L` is `R = 2L / π`, so `l ≤ √(16 L δ / π)`.
16
+ *
17
+ * @param {number} length metres
18
+ * @param {number} tolerance metres
19
+ * @returns {number}
20
+ */
21
+ export function groom_guide_segments_to_bend(length, tolerance) {
22
+ return Math.ceil(Math.sqrt(Math.PI * length / (16 * tolerance)));
23
+ }
24
+
25
+ /**
26
+ * The largest distance between two strands of a group at the same point, or `Infinity` once it passes `limit`.
27
+ *
28
+ * @param {Float64Array} a `point_count` points, x y z
29
+ * @param {Float64Array} b
30
+ * @param {number} b_offset
31
+ * @param {number} point_count
32
+ * @param {number} limit
33
+ * @returns {number}
34
+ */
35
+ function shape_distance(a, b, b_offset, point_count, limit) {
36
+ const limit_sqr = limit * limit;
37
+
38
+ let worst = 0;
39
+
40
+ for (let i = 0; i < point_count * 3; i += 3) {
41
+ const dx = a[i] - b[b_offset + i];
42
+ const dy = a[i + 1] - b[b_offset + i + 1];
43
+ const dz = a[i + 2] - b[b_offset + i + 2];
44
+
45
+ const d = dx * dx + dy * dy + dz * dz;
46
+
47
+ if (d > limit_sqr) {
48
+ return Infinity;
49
+ }
50
+
51
+ worst = Math.max(worst, d);
52
+ }
53
+
54
+ return Math.sqrt(worst);
55
+ }
56
+
57
+ /**
58
+ * Give a group its guides, the strands that are simulated, and every strand the guide it follows.
59
+ *
60
+ * **Which strands guide.** In rank order, a strand follows the guide it stays nearest to along its whole length if
61
+ * that is within `tolerance` at every point, and becomes a guide itself otherwise, so the guide count follows the
62
+ * content: a groom of strands combed alike has few, a tousled one many. Rank order spreads the guides as it spreads
63
+ * any prefix. A group never has more than {@link GROOM_GUIDE_LIMIT}; past it, a strand follows the nearest of the
64
+ * guides around its root however far its shape strays.
65
+ *
66
+ * **How finely they are simulated.** Every guide has the same nodes, every `2^j`-th of its points, `j` the largest
67
+ * that keeps both the dropped points within `tolerance` of the kept chord (the decimation table) and a quarter turn
68
+ * along the longest guide within `tolerance` of its chords ({@link groom_guide_segments_to_bend}); never fewer than
69
+ * three nodes while the strands have three points.
70
+ *
71
+ * **The wisp a guide stands for.** Its strand count, and its diameter: the strand's own width plus twice the mean
72
+ * distance of its followers from it, point by point. The group's reach is the farthest any point is from the chord
73
+ * between its guide's nodes either side of it, so the deformed strands lie within the guides' nodes widened by it.
74
+ *
75
+ * Sets `guide_point_count`, `guide_strand`, `guide_strand_count`, `guide_diameter`, `guide_length`, `strand_guide`
76
+ * and `guide_reach` on the group.
77
+ *
78
+ * @param {import("./Groom.js").GroomGroup} group with its points
79
+ * @param {number} tolerance metres
80
+ */
81
+ export function groom_build_guides(group, tolerance) {
82
+ assert.greaterThan(tolerance, 0, 'tolerance');
83
+
84
+ const n = group.strand_count;
85
+ const p = group.point_count;
86
+
87
+ assert.greaterThan(n, 0, 'a group holds strands');
88
+
89
+ const points = new Float64Array(n * p * 3);
90
+
91
+ for (let s = 0; s < n; s++) {
92
+ for (let i = 0; i < p; i++) {
93
+ group.read_point(points, (s * p + i) * 3, s, i);
94
+ }
95
+ }
96
+
97
+ const bounds = group.bounds;
98
+
99
+ const nx = Math.max(1, Math.ceil((bounds[3] - bounds[0]) / tolerance));
100
+ const ny = Math.max(1, Math.ceil((bounds[4] - bounds[1]) / tolerance));
101
+ const nz = Math.max(1, Math.ceil((bounds[5] - bounds[2]) / tolerance));
102
+
103
+ const cell_x = s => Math.min(nx - 1, Math.max(0, Math.floor((points[s * p * 3] - bounds[0]) / tolerance)));
104
+ const cell_y = s => Math.min(ny - 1, Math.max(0, Math.floor((points[s * p * 3 + 1] - bounds[1]) / tolerance)));
105
+ const cell_z = s => Math.min(nz - 1, Math.max(0, Math.floor((points[s * p * 3 + 2] - bounds[2]) / tolerance)));
106
+
107
+ /** guides whose root is in a cell, by the cell's index */
108
+ const cells = new Map();
109
+
110
+ /** @type {number[]} the guides' strands */
111
+ const guides = [];
112
+
113
+ const strand_guide = new Uint16Array(n);
114
+ const shape = new Float64Array(p * 3);
115
+
116
+ for (let s = 0; s < n; s++) {
117
+ shape.set(points.subarray(s * p * 3, (s + 1) * p * 3));
118
+
119
+ const cx = cell_x(s), cy = cell_y(s), cz = cell_z(s);
120
+ const full = guides.length >= GROOM_GUIDE_LIMIT;
121
+
122
+ let best = -1;
123
+ let best_distance = full ? Infinity : tolerance;
124
+
125
+ // a guide within the tolerance has its root within it, so in a cell next to this root's
126
+ for (let z = Math.max(0, cz - 1); z <= Math.min(nz - 1, cz + 1); z++) {
127
+ for (let y = Math.max(0, cy - 1); y <= Math.min(ny - 1, cy + 1); y++) {
128
+ for (let x = Math.max(0, cx - 1); x <= Math.min(nx - 1, cx + 1); x++) {
129
+ const list = cells.get((z * ny + y) * nx + x);
130
+
131
+ if (list === undefined) {
132
+ continue;
133
+ }
134
+
135
+ for (let k = 0; k < list.length; k++) {
136
+ const g = list[k];
137
+ const d = shape_distance(shape, points, guides[g] * p * 3, p, full ? Infinity : best_distance);
138
+
139
+ if (d < best_distance || (full && best < 0)) {
140
+ best = g;
141
+ best_distance = d;
142
+ }
143
+ }
144
+ }
145
+ }
146
+ }
147
+
148
+ if (best < 0 && full) {
149
+ // no guide around the root at all: the one whose root is nearest
150
+ let nearest = Infinity;
151
+
152
+ for (let g = 0; g < guides.length; g++) {
153
+ const o = guides[g] * p * 3;
154
+ const d = Math.hypot(points[o] - shape[0], points[o + 1] - shape[1], points[o + 2] - shape[2]);
155
+
156
+ if (d < nearest) {
157
+ nearest = d;
158
+ best = g;
159
+ }
160
+ }
161
+ }
162
+
163
+ if (best < 0) {
164
+ best = guides.length;
165
+ guides.push(s);
166
+
167
+ const key = (cz * ny + cy) * nx + cx;
168
+ const list = cells.get(key);
169
+
170
+ if (list === undefined) {
171
+ cells.set(key, [best]);
172
+ } else {
173
+ list.push(best);
174
+ }
175
+ }
176
+
177
+ strand_guide[s] = best;
178
+ }
179
+
180
+ const guide_count = guides.length;
181
+
182
+ // the guides' lengths, along their points
183
+ const guide_length = new Float32Array(guide_count);
184
+
185
+ let length_max = 0;
186
+
187
+ for (let g = 0; g < guide_count; g++) {
188
+ const o = guides[g] * p * 3;
189
+
190
+ let length = 0;
191
+
192
+ for (let i = 1; i < p; i++) {
193
+ const a = o + (i - 1) * 3;
194
+ const b = o + i * 3;
195
+
196
+ length += Math.hypot(points[b] - points[a], points[b + 1] - points[a + 1], points[b + 2] - points[a + 2]);
197
+ }
198
+
199
+ guide_length[g] = length;
200
+ length_max = Math.max(length_max, length);
201
+ }
202
+
203
+ // the nodes: every 2^j-th point, the coarsest the tolerance allows
204
+ const segments_max = p - 1;
205
+ const segments_min = Math.min(segments_max, Math.max(2, groom_guide_segments_to_bend(length_max, tolerance)));
206
+ const decimation = group.decimation;
207
+
208
+ let level = 0;
209
+
210
+ while (
211
+ level + 1 < decimation.length
212
+ && decimation[level + 1] <= tolerance
213
+ && (segments_max >> (level + 1)) >= segments_min
214
+ ) {
215
+ level++;
216
+ }
217
+
218
+ const step = 1 << level;
219
+ const node_count = segments_max / step + 1;
220
+
221
+ // the wisps, and how far a point strays from its guide's chord between nodes
222
+ const strand_count = new Uint32Array(guide_count);
223
+ const distance_sum = new Float64Array(guide_count);
224
+
225
+ let reach = 0;
226
+
227
+ for (let s = 0; s < n; s++) {
228
+ const g = strand_guide[s];
229
+ const o = guides[g] * p * 3;
230
+ const so = s * p * 3;
231
+
232
+ let sum = 0;
233
+
234
+ for (let i = 0; i < p; i++) {
235
+ const a = o + Math.min(Math.floor(i / step), node_count - 2) * step * 3;
236
+ const b = a + step * 3;
237
+ const t = i / step - Math.min(Math.floor(i / step), node_count - 2);
238
+
239
+ const px = points[so + i * 3], py = points[so + i * 3 + 1], pz = points[so + i * 3 + 2];
240
+
241
+ const chord_x = points[a] + (points[b] - points[a]) * t;
242
+ const chord_y = points[a + 1] + (points[b + 1] - points[a + 1]) * t;
243
+ const chord_z = points[a + 2] + (points[b + 2] - points[a + 2]) * t;
244
+
245
+ reach = Math.max(reach, Math.hypot(px - chord_x, py - chord_y, pz - chord_z));
246
+
247
+ sum += Math.hypot(px - points[o + i * 3], py - points[o + i * 3 + 1], pz - points[o + i * 3 + 2]);
248
+ }
249
+
250
+ strand_count[g]++;
251
+ distance_sum[g] += sum / p;
252
+ }
253
+
254
+ const guide_diameter = new Float32Array(guide_count);
255
+
256
+ for (let g = 0; g < guide_count; g++) {
257
+ guide_diameter[g] = group.width_mean + 2 * distance_sum[g] / strand_count[g];
258
+ }
259
+
260
+ group.guide_point_count = node_count;
261
+ group.guide_strand = Uint32Array.from(guides);
262
+ group.guide_strand_count = strand_count;
263
+ group.guide_diameter = guide_diameter;
264
+ group.guide_length = guide_length;
265
+ group.strand_guide = strand_guide;
266
+ group.guide_reach = reach;
267
+ }
@@ -1,9 +1,11 @@
1
1
  /**
2
- * How far apart a group's strands grow: the median distance from a root to the nearest other root, metres, from the
3
- * roots as quantized. Zero for a group of one strand.
2
+ * How far apart a group's strands grow: the median, over the strands, of the distance from a strand's root to the
3
+ * nearest root at another place, metres, from the roots as quantized. Strands sharing a root's place (a follicle
4
+ * that grows two) take its distance to the next place. Zero when the roots are all at one place.
4
5
  *
5
- * Found through a grid of cells about as wide as the roots would be apart spread evenly over the roots' box seen as
6
- * a surface, each root against the 27 cells around its own; a root with no other within them takes none.
6
+ * The distinct places are put in a k-d tree, split at the median along the widest side of each node's places, and
7
+ * each finds its nearest by searching the nearer side first and the farther only when its splitting plane is nearer
8
+ * than the best so far: `O(n log n)` however the roots cluster, none of the places sharing a point.
7
9
  *
8
10
  * @param {import("./Groom.js").GroomGroup} group
9
11
  * @returns {number}
@@ -1 +1 @@
1
- {"version":3,"file":"groom_root_spacing.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/hair/groom_root_spacing.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,0CAHW,OAAO,YAAY,EAAE,UAAU,GAC7B,MAAM,CA+GlB"}
1
+ {"version":3,"file":"groom_root_spacing.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/hair/groom_root_spacing.js"],"names":[],"mappings":"AAkDA;;;;;;;;;;;GAWG;AACH,0CAHW,OAAO,YAAY,EAAE,UAAU,GAC7B,MAAM,CAgMlB"}
@@ -1,9 +1,61 @@
1
+ import { GROOM_POINT_COORDINATE_STEPS, GROOM_POINT_WORDS } from "./Groom.js";
2
+
1
3
  /**
2
- * How far apart a group's strands grow: the median distance from a root to the nearest other root, metres, from the
3
- * roots as quantized. Zero for a group of one strand.
4
+ * Reorder `index[lo, hi)` so that `index[k]` holds the element whose `coordinate` is k-th smallest, smaller ones
5
+ * before it and larger ones after it (Hoare's selection).
4
6
  *
5
- * Found through a grid of cells about as wide as the roots would be apart spread evenly over the roots' box seen as
6
- * a surface, each root against the 27 cells around its own; a root with no other within them takes none.
7
+ * @param {Uint32Array} index
8
+ * @param {Float64Array} coordinate
9
+ * @param {number} lo
10
+ * @param {number} hi exclusive
11
+ * @param {number} k
12
+ */
13
+ function select(index, coordinate, lo, hi, k) {
14
+ let left = lo;
15
+ let right = hi - 1;
16
+
17
+ while (left < right) {
18
+ const pivot = coordinate[index[(left + right) >>> 1]];
19
+
20
+ let i = left;
21
+ let j = right;
22
+
23
+ while (i <= j) {
24
+ while (coordinate[index[i]] < pivot) {
25
+ i++;
26
+ }
27
+
28
+ while (coordinate[index[j]] > pivot) {
29
+ j--;
30
+ }
31
+
32
+ if (i <= j) {
33
+ const t = index[i];
34
+ index[i] = index[j];
35
+ index[j] = t;
36
+ i++;
37
+ j--;
38
+ }
39
+ }
40
+
41
+ if (k <= j) {
42
+ right = j;
43
+ } else if (k >= i) {
44
+ left = i;
45
+ } else {
46
+ return;
47
+ }
48
+ }
49
+ }
50
+
51
+ /**
52
+ * How far apart a group's strands grow: the median, over the strands, of the distance from a strand's root to the
53
+ * nearest root at another place, metres, from the roots as quantized. Strands sharing a root's place (a follicle
54
+ * that grows two) take its distance to the next place. Zero when the roots are all at one place.
55
+ *
56
+ * The distinct places are put in a k-d tree, split at the median along the widest side of each node's places, and
57
+ * each finds its nearest by searching the nearer side first and the farther only when its splitting plane is nearer
58
+ * than the best so far: `O(n log n)` however the roots cluster, none of the places sharing a point.
7
59
  *
8
60
  * @param {import("./Groom.js").GroomGroup} group
9
61
  * @returns {number}
@@ -15,106 +67,187 @@ export function groom_root_spacing(group) {
15
67
  return 0;
16
68
  }
17
69
 
18
- const roots = new Float64Array(n * 3);
70
+ const points = group.points;
71
+ const stride = group.point_count * GROOM_POINT_WORDS;
72
+
73
+ // each root's place as its quantized coordinates, exact in a double: x + 2^16 y + 2^32 z
74
+ const keys = new Float64Array(n);
19
75
 
20
76
  for (let s = 0; s < n; s++) {
21
- group.read_point(roots, s * 3, s, 0);
77
+ const w0 = points[s * stride];
78
+ const w1 = points[s * stride + 1];
79
+
80
+ keys[s] = (w0 & 0xFFFF) + (w0 >>> 16) * 0x10000 + (w1 & 0xFFFF) * 0x100000000;
22
81
  }
23
82
 
24
- let x0 = Infinity, y0 = Infinity, z0 = Infinity;
25
- let x1 = -Infinity, y1 = -Infinity, z1 = -Infinity;
83
+ const sorted = keys.slice().sort();
26
84
 
27
- for (let s = 0; s < n; s++) {
28
- const x = roots[s * 3], y = roots[s * 3 + 1], z = roots[s * 3 + 2];
85
+ // the distinct places
86
+ let m = 0;
29
87
 
30
- x0 = Math.min(x0, x); y0 = Math.min(y0, y); z0 = Math.min(z0, z);
31
- x1 = Math.max(x1, x); y1 = Math.max(y1, y); z1 = Math.max(z1, z);
88
+ for (let i = 0; i < n; i++) {
89
+ if (i === 0 || sorted[i] !== sorted[i - 1]) {
90
+ sorted[m++] = sorted[i];
91
+ }
32
92
  }
33
93
 
34
- const diagonal = Math.hypot(x1 - x0, y1 - y0, z1 - z0);
35
-
36
- if (diagonal <= 0) {
94
+ if (m < 2) {
37
95
  return 0;
38
96
  }
39
97
 
40
- // roots lie on a surface: n of them over about the box's diagonal squared
41
- const cell = diagonal / Math.sqrt(n);
98
+ const bounds = group.bounds;
99
+ const scale = 1 / GROOM_POINT_COORDINATE_STEPS;
42
100
 
43
- const nx = Math.max(1, Math.ceil((x1 - x0) / cell));
44
- const ny = Math.max(1, Math.ceil((y1 - y0) / cell));
45
- const nz = Math.max(1, Math.ceil((z1 - z0) / cell));
101
+ const xs = new Float64Array(m);
102
+ const ys = new Float64Array(m);
103
+ const zs = new Float64Array(m);
46
104
 
47
- const cell_of = s => {
48
- const cx = Math.min(nx - 1, Math.floor((roots[s * 3] - x0) / cell));
49
- const cy = Math.min(ny - 1, Math.floor((roots[s * 3 + 1] - y0) / cell));
50
- const cz = Math.min(nz - 1, Math.floor((roots[s * 3 + 2] - z0) / cell));
105
+ for (let i = 0; i < m; i++) {
106
+ const key = sorted[i];
107
+ const z = Math.floor(key / 0x100000000);
108
+ const rest = key - z * 0x100000000;
51
109
 
52
- return [cx, cy, cz];
53
- };
110
+ xs[i] = (rest % 0x10000) * scale * (bounds[3] - bounds[0]);
111
+ ys[i] = Math.floor(rest / 0x10000) * scale * (bounds[4] - bounds[1]);
112
+ zs[i] = z * scale * (bounds[5] - bounds[2]);
113
+ }
54
114
 
55
- const buckets = new Map();
115
+ const coordinates = [xs, ys, zs];
56
116
 
57
- for (let s = 0; s < n; s++) {
58
- const [cx, cy, cz] = cell_of(s);
59
- const key = (cz * ny + cy) * nx + cx;
117
+ // the tree, implicit in the order of `index`: a node is a range, its median the place it splits at
118
+ const index = new Uint32Array(m);
119
+ const axis = new Uint8Array(m);
60
120
 
61
- let bucket = buckets.get(key);
121
+ for (let i = 0; i < m; i++) {
122
+ index[i] = i;
123
+ }
124
+
125
+ // ranges still to split, as pairs
126
+ const ranges = new Uint32Array(2 * m + 2);
127
+
128
+ let top = 0;
129
+
130
+ ranges[top++] = 0;
131
+ ranges[top++] = m;
132
+
133
+ while (top > 0) {
134
+ const hi = ranges[--top];
135
+ const lo = ranges[--top];
136
+
137
+ if (hi - lo < 2) {
138
+ continue;
139
+ }
140
+
141
+ let x0 = Infinity, y0 = Infinity, z0 = Infinity;
142
+ let x1 = -Infinity, y1 = -Infinity, z1 = -Infinity;
143
+
144
+ for (let i = lo; i < hi; i++) {
145
+ const p = index[i];
62
146
 
63
- if (bucket === undefined) {
64
- bucket = [];
65
- buckets.set(key, bucket);
147
+ x0 = Math.min(x0, xs[p]); x1 = Math.max(x1, xs[p]);
148
+ y0 = Math.min(y0, ys[p]); y1 = Math.max(y1, ys[p]);
149
+ z0 = Math.min(z0, zs[p]); z1 = Math.max(z1, zs[p]);
66
150
  }
67
151
 
68
- bucket.push(s);
152
+ const ex = x1 - x0, ey = y1 - y0, ez = z1 - z0;
153
+ const a = ex >= ey && ex >= ez ? 0 : (ey >= ez ? 1 : 2);
154
+ const mid = (lo + hi) >>> 1;
155
+
156
+ select(index, coordinates[a], lo, hi, mid);
157
+
158
+ axis[mid] = a;
159
+
160
+ ranges[top++] = lo;
161
+ ranges[top++] = mid;
162
+ ranges[top++] = mid + 1;
163
+ ranges[top++] = hi;
69
164
  }
70
165
 
71
- const nearest = [];
166
+ // each place's distance to the nearest other, depth first, nearer side first
167
+ const nearest = new Float64Array(m);
168
+ // a range and the squared distance to the plane that bounds it, three numbers an entry; a side is pushed only
169
+ // after the one it shares a node with, so the stack holds two entries a level of the tree's depth at most
170
+ const stack = new Float64Array(6 * 64);
72
171
 
73
- for (let s = 0; s < n; s++) {
74
- const [cx, cy, cz] = cell_of(s);
172
+ for (let place = 0; place < m; place++) {
173
+ const px = xs[place], py = ys[place], pz = zs[place];
75
174
 
76
175
  let best = Infinity;
176
+ let sp = 0;
77
177
 
78
- for (let dz = -1; dz <= 1; dz++) {
79
- for (let dy = -1; dy <= 1; dy++) {
80
- for (let dx = -1; dx <= 1; dx++) {
81
- const x = cx + dx, y = cy + dy, z = cz + dz;
178
+ stack[sp++] = 0;
179
+ stack[sp++] = m;
180
+ stack[sp++] = 0;
82
181
 
83
- if (x < 0 || y < 0 || z < 0 || x >= nx || y >= ny || z >= nz) {
84
- continue;
85
- }
182
+ while (sp > 0) {
183
+ const plane = stack[--sp];
184
+ const hi = stack[--sp];
185
+ const lo = stack[--sp];
86
186
 
87
- const bucket = buckets.get((z * ny + y) * nx + x);
187
+ if (lo >= hi || plane >= best) {
188
+ continue;
189
+ }
88
190
 
89
- if (bucket === undefined) {
90
- continue;
91
- }
191
+ const mid = (lo + hi) >>> 1;
192
+ const q = index[mid];
92
193
 
93
- for (const o of bucket) {
94
- if (o === s) {
95
- continue;
96
- }
194
+ if (q !== place) {
195
+ const dx = xs[q] - px, dy = ys[q] - py, dz = zs[q] - pz;
97
196
 
98
- const d = Math.hypot(roots[o * 3] - roots[s * 3], roots[o * 3 + 1] - roots[s * 3 + 1], roots[o * 3 + 2] - roots[s * 3 + 2]);
197
+ best = Math.min(best, dx * dx + dy * dy + dz * dz);
198
+ }
99
199
 
100
- if (d < best) {
101
- best = d;
102
- }
103
- }
104
- }
200
+ const a = axis[mid];
201
+ const along = a === 0 ? px - xs[q] : (a === 1 ? py - ys[q] : pz - zs[q]);
202
+
203
+ // the farther side first onto the stack, so the nearer is searched first, and the farther only if its
204
+ // plane is still nearer than the best when it is reached
205
+ const far = along * along;
206
+
207
+ if (along < 0) {
208
+ stack[sp++] = mid + 1;
209
+ stack[sp++] = hi;
210
+ stack[sp++] = far;
211
+
212
+ stack[sp++] = lo;
213
+ stack[sp++] = mid;
214
+ stack[sp++] = 0;
215
+ } else {
216
+ stack[sp++] = lo;
217
+ stack[sp++] = mid;
218
+ stack[sp++] = far;
219
+
220
+ stack[sp++] = mid + 1;
221
+ stack[sp++] = hi;
222
+ stack[sp++] = 0;
105
223
  }
106
224
  }
107
225
 
108
- if (best < Infinity) {
109
- nearest.push(best);
110
- }
226
+ nearest[place] = Math.sqrt(best);
111
227
  }
112
228
 
113
- if (nearest.length === 0) {
114
- return 0;
229
+ // over the strands: each takes its place's
230
+ const per_strand = new Float64Array(n);
231
+
232
+ for (let s = 0; s < n; s++) {
233
+ // the place's index among the distinct, by binary search of the sorted keys
234
+ let lo = 0;
235
+ let hi = m - 1;
236
+
237
+ while (lo < hi) {
238
+ const mid = (lo + hi) >>> 1;
239
+
240
+ if (sorted[mid] < keys[s]) {
241
+ lo = mid + 1;
242
+ } else {
243
+ hi = mid;
244
+ }
245
+ }
246
+
247
+ per_strand[s] = nearest[lo];
115
248
  }
116
249
 
117
- nearest.sort((a, b) => a - b);
250
+ per_strand.sort();
118
251
 
119
- return nearest[nearest.length >> 1];
252
+ return per_strand[n >> 1];
120
253
  }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * The colliders hair meets: the set cloth collides with, `(ClothCollider, Collider, Transform64)`, analytic
3
+ * primitives only. Kept in a {@link ClothColliderIndex} of their own, for a groom to gather the ones around it, and
4
+ * each holding its entity's `transforms` row, because the hair reads where a collider is on the GPU, from the row,
5
+ * as the bones' animation leaves it.
6
+ *
7
+ * It does not step. {@link refresh} is called by `HairSystem` once a frame, before any groom gathers: one call site,
8
+ * the poses read at the moment the grooms' are.
9
+ */
10
+ export class HairColliderSystem extends System<any> {
11
+ /**
12
+ * @param {import("./GraphicsEngine.js").GraphicsEngine} graphics
13
+ * @param {import("../../shade/renderer/scene/Scene.js").Scene} scene the scene the colliders are in
14
+ */
15
+ constructor(graphics: import("./GraphicsEngine.js").GraphicsEngine, scene: import("../../shade/renderer/scene/Scene.js").Scene);
16
+ dependencies: (typeof Transform64 | typeof Collider | typeof ClothCollider)[];
17
+ components_used: (ResourceAccessSpecification<typeof Transform64> | ResourceAccessSpecification<typeof Collider> | ResourceAccessSpecification<typeof ClothCollider>)[];
18
+ /** @type {ClothColliderIndex} */
19
+ index: ClothColliderIndex;
20
+ /**
21
+ * @param {ClothCollider} cloth_collider
22
+ * @param {Collider} collider
23
+ * @param {Transform64} transform
24
+ * @param {number} entity
25
+ */
26
+ link(cloth_collider: ClothCollider, collider: Collider, transform: Transform64, entity: number): void;
27
+ /**
28
+ * @param {ClothCollider} cloth_collider
29
+ * @param {Collider} collider
30
+ * @param {Transform64} transform
31
+ * @param {number} entity
32
+ */
33
+ unlink(cloth_collider: ClothCollider, collider: Collider, transform: Transform64, entity: number): void;
34
+ /**
35
+ * Read every collider's pose from the world, and hold its row in the scene context that is current.
36
+ */
37
+ refresh(): void;
38
+ /**
39
+ * The colliders whose bounds meet a box, as the hair's collider records (`HAIR_COLLIDER_WORDS` each, the pose
40
+ * left for the GPU to write): at most `HAIR_COLLIDER_LIMIT`, those whose bounds are nearest the box's centre.
41
+ * Only colliders whose entity holds a row are written.
42
+ *
43
+ * @param {Uint32Array} out
44
+ * @param {Float32Array} out_f32 the same words as floats
45
+ * @param {Float64Array|number[]} box min x, y, z, then max x, y, z, world metres
46
+ * @param {number} layer the hair's
47
+ * @param {number} mask the hair's
48
+ * @returns {number} colliders written
49
+ */
50
+ gather(out: Uint32Array, out_f32: Float32Array, box: Float64Array | number[], layer: number, mask: number): number;
51
+ #private;
52
+ }
53
+ import { System } from "../ecs/System.js";
54
+ import { Transform64 } from "../ecs/transform/Transform64.js";
55
+ import { Collider } from "../physics/ecs/Collider.js";
56
+ import { ClothCollider } from "../physics/cloth/ecs/ClothCollider.js";
57
+ import { ResourceAccessSpecification } from "../../core/model/ResourceAccessSpecification.js";
58
+ import { ClothColliderIndex } from "../physics/cloth/collider/ClothColliderIndex.js";
59
+ //# sourceMappingURL=HairColliderSystem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HairColliderSystem.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics3/HairColliderSystem.js"],"names":[],"mappings":"AAgCA;;;;;;;;GAQG;AACH;IAqCI;;;OAGG;IACH,sBAHW,OAAO,qBAAqB,EAAE,cAAc,SAC5C,OAAO,qCAAqC,EAAE,KAAK,EAU7D;IAhDD,8EAAsD;IAEtD,wKAIE;IAEF,iCAAiC;IACjC,OADW,kBAAkB,CACI;IAyCjC;;;;;OAKG;IACH,qBALW,aAAa,YACb,QAAQ,aACR,WAAW,UACX,MAAM,QAqBhB;IAED;;;;;OAKG;IACH,uBALW,aAAa,YACb,QAAQ,aACR,WAAW,UACX,MAAM,QAuBhB;IAED;;OAEG;IACH,gBAiBC;IAED;;;;;;;;;;;OAWG;IACH,YAPW,WAAW,WACX,YAAY,OACZ,YAAY,GAAC,MAAM,EAAE,SACrB,MAAM,QACN,MAAM,GACJ,MAAM,CAsElB;;CAmBJ;uBAxQsB,kBAAkB;4BAKlC,iCAAiC;yBAmBf,4BAA4B;8BADvB,uCAAuC;4CA1BzB,iDAAiD;mCAS1D,iDAAiD"}