@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
@@ -2,16 +2,115 @@ import { BinaryClassSerializationAdapter } from "../../ecs/storage/binary/Binary
2
2
  import { GROOM_POINT_WORDS, Groom, GroomGroup } from "./Groom.js";
3
3
  import { groom_root_spacing } from "./groom_root_spacing.js";
4
4
 
5
+ /**
6
+ * Read a group as version 0 wrote it: everything but its guides.
7
+ *
8
+ * @param {import("../../../core/binary/BinaryBuffer.js").BinaryBuffer} buffer
9
+ * @returns {GroomGroup}
10
+ */
11
+ export function groom_read_group_v0(buffer) {
12
+ const group = new GroomGroup();
13
+
14
+ group.name = buffer.readUTF8String();
15
+ group.point_count = buffer.readUint32();
16
+ group.strand_count = buffer.readUint32();
17
+ buffer.readFloat32Array(group.bounds, 0, 6);
18
+ group.width_max = buffer.readFloat32();
19
+ group.width_mean = buffer.readFloat32();
20
+
21
+ group.decimation = new Float32Array(buffer.readUint8());
22
+ buffer.readFloat32Array(group.decimation, 0, group.decimation.length);
23
+
24
+ group.points = new Uint32Array(group.strand_count * group.point_count * GROOM_POINT_WORDS);
25
+ buffer.readUint32Array(group.points, 0, group.points.length);
26
+
27
+ group.variation = new Uint8Array(group.strand_count);
28
+ buffer.readUint8Array(group.variation, 0, group.variation.length);
29
+
30
+ return group;
31
+ }
32
+
33
+ /**
34
+ * Write a group as version 0 did: everything but its guides.
35
+ *
36
+ * @param {import("../../../core/binary/BinaryBuffer.js").BinaryBuffer} buffer
37
+ * @param {GroomGroup} group
38
+ */
39
+ export function groom_write_group_v0(buffer, group) {
40
+ buffer.writeUTF8String(group.name);
41
+ buffer.writeUint32(group.point_count);
42
+ buffer.writeUint32(group.strand_count);
43
+ buffer.writeFloat32Array(group.bounds, 0, 6);
44
+ buffer.writeFloat32(group.width_max);
45
+ buffer.writeFloat32(group.width_mean);
46
+
47
+ buffer.writeUint8(group.decimation.length);
48
+ buffer.writeFloat32Array(group.decimation, 0, group.decimation.length);
49
+
50
+ buffer.writeUint32Array(group.points, 0, group.points.length);
51
+ buffer.writeUint8Array(group.variation, 0, group.variation.length);
52
+ }
53
+
54
+ /**
55
+ * Write a group's guides, as version 1 follows its version 0 fields with them.
56
+ *
57
+ * @param {import("../../../core/binary/BinaryBuffer.js").BinaryBuffer} buffer
58
+ * @param {GroomGroup} group
59
+ */
60
+ export function groom_write_guides(buffer, group) {
61
+ const count = group.guide_count;
62
+
63
+ buffer.writeUint32(group.guide_point_count);
64
+ buffer.writeUint32(count);
65
+ buffer.writeUint32Array(group.guide_strand, 0, count);
66
+ buffer.writeUint32Array(group.guide_strand_count, 0, count);
67
+ buffer.writeFloat32Array(group.guide_diameter, 0, count);
68
+ buffer.writeFloat32Array(group.guide_length, 0, count);
69
+ buffer.writeUint16Array(group.strand_guide, 0, group.strand_count);
70
+ buffer.writeFloat32(group.guide_reach);
71
+ }
72
+
73
+ /**
74
+ * @param {import("../../../core/binary/BinaryBuffer.js").BinaryBuffer} buffer
75
+ * @param {GroomGroup} group
76
+ */
77
+ function read_guides(buffer, group) {
78
+ group.guide_point_count = buffer.readUint32();
79
+
80
+ const count = buffer.readUint32();
81
+
82
+ group.guide_strand = new Uint32Array(count);
83
+ buffer.readUint32Array(group.guide_strand, 0, count);
84
+
85
+ group.guide_strand_count = new Uint32Array(count);
86
+ buffer.readUint32Array(group.guide_strand_count, 0, count);
87
+
88
+ group.guide_diameter = new Float32Array(count);
89
+ buffer.readFloat32Array(group.guide_diameter, 0, count);
90
+
91
+ group.guide_length = new Float32Array(count);
92
+ buffer.readFloat32Array(group.guide_length, 0, count);
93
+
94
+ group.strand_guide = new Uint16Array(group.strand_count);
95
+ buffer.readUint16Array(group.strand_guide, 0, group.strand_count);
96
+
97
+ group.guide_reach = buffer.readFloat32();
98
+ }
99
+
5
100
  /**
6
101
  * A {@link Groom} as bytes: its groups, each as the renderer reads it, so a load is a copy and nothing is rebuilt.
7
102
  *
8
103
  * Per group: its name (UTF-8), point count and strand count (u32 each), the quantization box (six f32), the widest and
9
104
  * the mean width (f32 each), the decimation table (a u8 count, then f32 each), the rest points (u32, `GROOM_POINT_WORDS`
10
- * a point) and the strands' variation bytes. The group count (u32) leads.
105
+ * a point) and the strands' variation bytes; then its guides: the node count and the guide count (u32 each), each
106
+ * guide's strand and strand count (u32 each), wisp diameter and length (f32 each), each strand's guide (u16) and the
107
+ * reach (f32). The group count (u32) leads.
108
+ *
109
+ * Version 0 had no guides; `GroomSerializationUpgrader_0_1` gives its groups theirs.
11
110
  */
12
111
  export class GroomSerializationAdapter extends BinaryClassSerializationAdapter {
13
112
  klass = Groom;
14
- version = 0;
113
+ version = 1;
15
114
 
16
115
  /**
17
116
  * @param {import("../../../core/binary/BinaryBuffer.js").BinaryBuffer} buffer
@@ -23,20 +122,8 @@ export class GroomSerializationAdapter extends BinaryClassSerializationAdapter {
23
122
  buffer.writeUint32(groups.length);
24
123
 
25
124
  for (let g = 0; g < groups.length; g++) {
26
- const group = groups[g];
27
-
28
- buffer.writeUTF8String(group.name);
29
- buffer.writeUint32(group.point_count);
30
- buffer.writeUint32(group.strand_count);
31
- buffer.writeFloat32Array(group.bounds, 0, 6);
32
- buffer.writeFloat32(group.width_max);
33
- buffer.writeFloat32(group.width_mean);
34
-
35
- buffer.writeUint8(group.decimation.length);
36
- buffer.writeFloat32Array(group.decimation, 0, group.decimation.length);
37
-
38
- buffer.writeUint32Array(group.points, 0, group.points.length);
39
- buffer.writeUint8Array(group.variation, 0, group.variation.length);
125
+ groom_write_group_v0(buffer, groups[g]);
126
+ groom_write_guides(buffer, groups[g]);
40
127
  }
41
128
  }
42
129
 
@@ -50,23 +137,9 @@ export class GroomSerializationAdapter extends BinaryClassSerializationAdapter {
50
137
  value.groups.length = 0;
51
138
 
52
139
  for (let g = 0; g < count; g++) {
53
- const group = new GroomGroup();
54
-
55
- group.name = buffer.readUTF8String();
56
- group.point_count = buffer.readUint32();
57
- group.strand_count = buffer.readUint32();
58
- buffer.readFloat32Array(group.bounds, 0, 6);
59
- group.width_max = buffer.readFloat32();
60
- group.width_mean = buffer.readFloat32();
61
-
62
- group.decimation = new Float32Array(buffer.readUint8());
63
- buffer.readFloat32Array(group.decimation, 0, group.decimation.length);
64
-
65
- group.points = new Uint32Array(group.strand_count * group.point_count * GROOM_POINT_WORDS);
66
- buffer.readUint32Array(group.points, 0, group.points.length);
140
+ const group = groom_read_group_v0(buffer);
67
141
 
68
- group.variation = new Uint8Array(group.strand_count);
69
- buffer.readUint8Array(group.variation, 0, group.variation.length);
142
+ read_guides(buffer, group);
70
143
 
71
144
  // derived from the roots, so not written
72
145
  group.root_spacing = groom_root_spacing(group);
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A version 0 groom as version 1: each group as it was, followed by the guides `groom_build_guides` chooses for it at
3
+ * the default tolerance.
4
+ */
5
+ export class GroomSerializationUpgrader_0_1 extends BinaryClassUpgrader {
6
+ }
7
+ import { BinaryClassUpgrader } from "../../ecs/storage/binary/BinaryClassUpgrader.js";
8
+ //# sourceMappingURL=GroomSerializationUpgrader_0_1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GroomSerializationUpgrader_0_1.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/hair/GroomSerializationUpgrader_0_1.js"],"names":[],"mappings":"AAIA;;;GAGG;AACH;CAsBC;oCA9BmC,iDAAiD"}
@@ -0,0 +1,31 @@
1
+ import { BinaryClassUpgrader } from "../../ecs/storage/binary/BinaryClassUpgrader.js";
2
+ import { groom_build_guides, GROOM_GUIDE_DEFAULT_TOLERANCE } from "./groom_build_guides.js";
3
+ import { groom_read_group_v0, groom_write_group_v0, groom_write_guides } from "./GroomSerializationAdapter.js";
4
+
5
+ /**
6
+ * A version 0 groom as version 1: each group as it was, followed by the guides `groom_build_guides` chooses for it at
7
+ * the default tolerance.
8
+ */
9
+ export class GroomSerializationUpgrader_0_1 extends BinaryClassUpgrader {
10
+ __startVersion = 0;
11
+ __targetVersion = 1;
12
+
13
+ /**
14
+ * @param {import("../../../core/binary/BinaryBuffer.js").BinaryBuffer} source
15
+ * @param {import("../../../core/binary/BinaryBuffer.js").BinaryBuffer} target
16
+ */
17
+ upgrade(source, target) {
18
+ const count = source.readUint32();
19
+
20
+ target.writeUint32(count);
21
+
22
+ for (let g = 0; g < count; g++) {
23
+ const group = groom_read_group_v0(source);
24
+
25
+ groom_build_guides(group, GROOM_GUIDE_DEFAULT_TOLERANCE);
26
+
27
+ groom_write_group_v0(target, group);
28
+ groom_write_guides(target, group);
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,85 @@
1
+ /**
2
+ * What binding to a mesh needs of it, made once a geometry and shared by every group bound to it: its triangles at
3
+ * the bind pose as the meshlets hold them, and a triangle BVH over those with an area, the only ones with a frame.
4
+ *
5
+ * @typedef {Object} GroomMeshBinder
6
+ * @property {Float32Array} positions the meshlets' vertices, meshlet after meshlet
7
+ * @property {Uint32Array} indices each meshlet triangle's three, meshlet after meshlet, in each meshlet's order
8
+ * @property {Uint32Array} kept the triangles with an area, by their place in {@link indices}
9
+ * @property {Uint32Array} kept_indices those triangles' three vertices: what the BVH is over
10
+ * @property {Uint32Array} firsts where each meshlet's triangles start in {@link indices}, and the count past the last
11
+ * @property {BinaryUint32BVH|null} bvh null for a mesh with no triangle that has an area
12
+ */
13
+ /**
14
+ * The binder of a mesh: see {@link GroomMeshBinder}.
15
+ *
16
+ * @param {import("../../../shade/renderer/geometry/MeshletGeometry.js").MeshletGeometry} geometry
17
+ * @returns {GroomMeshBinder}
18
+ */
19
+ export function groom_mesh_binder(geometry: import("../../../shade/renderer/geometry/MeshletGeometry.js").MeshletGeometry): GroomMeshBinder;
20
+ /**
21
+ * Bind each strand of a group to the nearest triangle of a mesh at its bind pose: the triangle, the root's
22
+ * barycentrics on it, and the triangle's frame (Unreal's: the tangent along the first edge, the normal of the face,
23
+ * the bitangent between them) with the root's point as its origin. Every frame the same triangle of the deformed
24
+ * mesh gives the frame again, and the strand rides the turn and the move from the rest frame to it.
25
+ *
26
+ * The group's points are taken to be in the mesh's own space at its bind pose: a groom made on the mesh it is worn
27
+ * on. Triangles are numbered as the meshlets hold them, which is how the GPU addresses them, a BLAS build's reorder
28
+ * included. Only triangles with an area are bound to (`groom_mesh_binder`).
29
+ *
30
+ * @param {import("./Groom.js").GroomGroup} group
31
+ * @param {GroomMeshBinder} binder the mesh's
32
+ * @returns {Uint32Array|null} {@link GROOM_BINDING_WORDS} a strand, in rank order; null for a mesh with no
33
+ * triangle that has an area
34
+ */
35
+ export function groom_bind_to_mesh(group: import("./Groom.js").GroomGroup, binder: GroomMeshBinder): Uint32Array | null;
36
+ /**
37
+ * Words of one strand's binding, `u32` with f32 bits where a number:
38
+ *
39
+ * ```
40
+ * 0 the triangle: (meshlet << 8) | triangle, the meshlet counted from the geometry's first, as the
41
+ * GPU's geometry record addresses it
42
+ * 1, 2 the root's barycentric weights of the triangle's first and second corners; the third's is the rest
43
+ * 3 how far the root is from the triangle, metres
44
+ * 4 .. 6 the triangle's rest tangent, first to second corner, unit; 7 the rest origin's x
45
+ * 8 .. 10 its rest bitangent, normal × tangent; 11 the rest origin's y
46
+ * 12 .. 14 its rest normal, unit, along (b − a) × (c − a); 15 the rest origin's z
47
+ * ```
48
+ *
49
+ * The rest origin is the root's point on the triangle, in the mesh's own space at its bind pose.
50
+ *
51
+ * @type {number}
52
+ */
53
+ export const GROOM_BINDING_WORDS: number;
54
+ /**
55
+ * What binding to a mesh needs of it, made once a geometry and shared by every group bound to it: its triangles at
56
+ * the bind pose as the meshlets hold them, and a triangle BVH over those with an area, the only ones with a frame.
57
+ */
58
+ export type GroomMeshBinder = {
59
+ /**
60
+ * the meshlets' vertices, meshlet after meshlet
61
+ */
62
+ positions: Float32Array;
63
+ /**
64
+ * each meshlet triangle's three, meshlet after meshlet, in each meshlet's order
65
+ */
66
+ indices: Uint32Array;
67
+ /**
68
+ * the triangles with an area, by their place in {@link indices }
69
+ */
70
+ kept: Uint32Array;
71
+ /**
72
+ * those triangles' three vertices: what the BVH is over
73
+ */
74
+ kept_indices: Uint32Array;
75
+ /**
76
+ * where each meshlet's triangles start in {@link indices }, and the count past the last
77
+ */
78
+ firsts: Uint32Array;
79
+ /**
80
+ * null for a mesh with no triangle that has an area
81
+ */
82
+ bvh: BinaryUint32BVH | null;
83
+ };
84
+ import { BinaryUint32BVH } from "../../../core/bvh2/binary/2/BinaryUint32BVH.js";
85
+ //# sourceMappingURL=groom_bind_to_mesh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"groom_bind_to_mesh.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/hair/groom_bind_to_mesh.js"],"names":[],"mappings":"AA4BA;;;;;;;;;;;GAWG;AAEH;;;;;GAKG;AACH,4CAHW,OAAO,qDAAqD,EAAE,eAAe,GAC3E,eAAe,CAmD3B;AAED;;;;;;;;;;;;;;GAcG;AACH,0CALW,OAAO,YAAY,EAAE,UAAU,UAC/B,eAAe,GACb,WAAW,GAAC,IAAI,CAyG5B;AA9MD;;;;;;;;;;;;;;;;GAgBG;AACH,kCAFU,MAAM,CAEsB;;;;;;;;;eAOxB,YAAY;;;;aACZ,WAAW;;;;UACX,WAAW;;;;kBACX,WAAW;;;;YACX,WAAW;;;;SACX,eAAe,GAAC,IAAI;;gCArCF,gDAAgD"}
@@ -0,0 +1,216 @@
1
+ import { assert } from "../../../core/assert.js";
2
+ import { BinaryUint32BVH } from "../../../core/bvh2/binary/2/BinaryUint32BVH.js";
3
+ import { SurfacePoint3 } from "../../../core/geom/3d/SurfacePoint3.js";
4
+ import { tri3_closest_point_barycentric_array } from "../../../core/geom/3d/triangle/tri3_closest_point_barycentric.js";
5
+ import { StandardAttributes } from "../../../shade/renderer/geometry/StandardAttributes.js";
6
+ import { geometry_build_from_meshlet_geometry } from "../../../shade/renderer/geometry/geometry_build_from_meshlet_geometry.js";
7
+ import { bvh32_from_indexed_geometry } from "../geometry/bvh/buffered/bvh32_from_indexed_geometry.js";
8
+ import { bvh32_geometry_nearest } from "../geometry/buffered/query/bvh32_geometry_nearest.js";
9
+
10
+ /**
11
+ * Words of one strand's binding, `u32` with f32 bits where a number:
12
+ *
13
+ * ```
14
+ * 0 the triangle: (meshlet << 8) | triangle, the meshlet counted from the geometry's first, as the
15
+ * GPU's geometry record addresses it
16
+ * 1, 2 the root's barycentric weights of the triangle's first and second corners; the third's is the rest
17
+ * 3 how far the root is from the triangle, metres
18
+ * 4 .. 6 the triangle's rest tangent, first to second corner, unit; 7 the rest origin's x
19
+ * 8 .. 10 its rest bitangent, normal × tangent; 11 the rest origin's y
20
+ * 12 .. 14 its rest normal, unit, along (b − a) × (c − a); 15 the rest origin's z
21
+ * ```
22
+ *
23
+ * The rest origin is the root's point on the triangle, in the mesh's own space at its bind pose.
24
+ *
25
+ * @type {number}
26
+ */
27
+ export const GROOM_BINDING_WORDS = 16;
28
+
29
+ /**
30
+ * What binding to a mesh needs of it, made once a geometry and shared by every group bound to it: its triangles at
31
+ * the bind pose as the meshlets hold them, and a triangle BVH over those with an area, the only ones with a frame.
32
+ *
33
+ * @typedef {Object} GroomMeshBinder
34
+ * @property {Float32Array} positions the meshlets' vertices, meshlet after meshlet
35
+ * @property {Uint32Array} indices each meshlet triangle's three, meshlet after meshlet, in each meshlet's order
36
+ * @property {Uint32Array} kept the triangles with an area, by their place in {@link indices}
37
+ * @property {Uint32Array} kept_indices those triangles' three vertices: what the BVH is over
38
+ * @property {Uint32Array} firsts where each meshlet's triangles start in {@link indices}, and the count past the last
39
+ * @property {BinaryUint32BVH|null} bvh null for a mesh with no triangle that has an area
40
+ */
41
+
42
+ /**
43
+ * The binder of a mesh: see {@link GroomMeshBinder}.
44
+ *
45
+ * @param {import("../../../shade/renderer/geometry/MeshletGeometry.js").MeshletGeometry} geometry
46
+ * @returns {GroomMeshBinder}
47
+ */
48
+ export function groom_mesh_binder(geometry) {
49
+ assert.defined(geometry, 'geometry');
50
+
51
+ const flat = geometry_build_from_meshlet_geometry(geometry);
52
+ const positions = flat.getAttribute(StandardAttributes.Position).data;
53
+ const indices = flat.index.data;
54
+
55
+ // the meshlet a flat triangle came from: the meshlets' triangles in order
56
+ const meshlets = geometry.cpu_meshlets ?? geometry.meshlets;
57
+ const firsts = new Uint32Array(meshlets.count + 1);
58
+
59
+ for (let m = 0; m < meshlets.count; m++) {
60
+ firsts[m + 1] = firsts[m] + meshlets.read_header(m).primitive_count;
61
+ }
62
+
63
+ // a triangle of no area has no frame: a root is never bound to one
64
+ const triangle_count = indices.length / 3;
65
+ const kept_list = [];
66
+
67
+ for (let k = 0; k < triangle_count; k++) {
68
+ const a = indices[k * 3] * 3, b = indices[k * 3 + 1] * 3, c = indices[k * 3 + 2] * 3;
69
+
70
+ const ex = positions[b] - positions[a], ey = positions[b + 1] - positions[a + 1], ez = positions[b + 2] - positions[a + 2];
71
+ const fx = positions[c] - positions[a], fy = positions[c + 1] - positions[a + 1], fz = positions[c + 2] - positions[a + 2];
72
+
73
+ const nx = ey * fz - ez * fy, ny = ez * fx - ex * fz, nz = ex * fy - ey * fx;
74
+
75
+ if (nx * nx + ny * ny + nz * nz > 0 && ex * ex + ey * ey + ez * ez > 0) {
76
+ kept_list.push(k);
77
+ }
78
+ }
79
+
80
+ const kept = Uint32Array.from(kept_list);
81
+ const kept_indices = new Uint32Array(kept.length * 3);
82
+
83
+ for (let i = 0; i < kept.length; i++) {
84
+ kept_indices[i * 3] = indices[kept[i] * 3];
85
+ kept_indices[i * 3 + 1] = indices[kept[i] * 3 + 1];
86
+ kept_indices[i * 3 + 2] = indices[kept[i] * 3 + 2];
87
+ }
88
+
89
+ let bvh = null;
90
+
91
+ if (kept.length > 0) {
92
+ bvh = new BinaryUint32BVH();
93
+ bvh32_from_indexed_geometry(bvh, positions, kept_indices);
94
+ }
95
+
96
+ return { positions, indices, kept, kept_indices, firsts, bvh };
97
+ }
98
+
99
+ /**
100
+ * Bind each strand of a group to the nearest triangle of a mesh at its bind pose: the triangle, the root's
101
+ * barycentrics on it, and the triangle's frame (Unreal's: the tangent along the first edge, the normal of the face,
102
+ * the bitangent between them) with the root's point as its origin. Every frame the same triangle of the deformed
103
+ * mesh gives the frame again, and the strand rides the turn and the move from the rest frame to it.
104
+ *
105
+ * The group's points are taken to be in the mesh's own space at its bind pose: a groom made on the mesh it is worn
106
+ * on. Triangles are numbered as the meshlets hold them, which is how the GPU addresses them, a BLAS build's reorder
107
+ * included. Only triangles with an area are bound to (`groom_mesh_binder`).
108
+ *
109
+ * @param {import("./Groom.js").GroomGroup} group
110
+ * @param {GroomMeshBinder} binder the mesh's
111
+ * @returns {Uint32Array|null} {@link GROOM_BINDING_WORDS} a strand, in rank order; null for a mesh with no
112
+ * triangle that has an area
113
+ */
114
+ export function groom_bind_to_mesh(group, binder) {
115
+ assert.defined(group, 'group');
116
+ assert.defined(binder, 'binder');
117
+
118
+ if (binder.bvh === null) {
119
+ return null;
120
+ }
121
+
122
+ const { positions, kept, kept_indices, firsts, bvh } = binder;
123
+ const meshlet_count = firsts.length - 1;
124
+
125
+ const n = group.strand_count;
126
+ const out = new Uint32Array(n * GROOM_BINDING_WORDS);
127
+ const f32 = new Float32Array(out.buffer);
128
+
129
+ const root = new Float64Array(3);
130
+ const triangle = new Float64Array(9);
131
+ const weights = new Float64Array(2);
132
+ const hit = new SurfacePoint3();
133
+
134
+ for (let s = 0; s < n; s++) {
135
+ group.read_point(root, 0, s, 0);
136
+
137
+ bvh32_geometry_nearest(hit, bvh, positions, 0, 3, false, kept_indices, root[0], root[1], root[2]);
138
+
139
+ const i = hit.index;
140
+ const k = kept[i];
141
+
142
+ for (let corner = 0; corner < 3; corner++) {
143
+ const v = kept_indices[i * 3 + corner];
144
+
145
+ triangle[corner * 3] = positions[v * 3];
146
+ triangle[corner * 3 + 1] = positions[v * 3 + 1];
147
+ triangle[corner * 3 + 2] = positions[v * 3 + 2];
148
+ }
149
+
150
+ tri3_closest_point_barycentric_array(weights, 0, root, 0, triangle, 0);
151
+
152
+ const wa = weights[0];
153
+ const wb = weights[1];
154
+ const wc = 1 - wa - wb;
155
+
156
+ const ox = triangle[0] * wa + triangle[3] * wb + triangle[6] * wc;
157
+ const oy = triangle[1] * wa + triangle[4] * wb + triangle[7] * wc;
158
+ const oz = triangle[2] * wa + triangle[5] * wb + triangle[8] * wc;
159
+
160
+ // the meshlet holding flat triangle k, by binary search of the firsts
161
+ let lo = 0;
162
+ let hi = meshlet_count - 1;
163
+
164
+ while (lo < hi) {
165
+ const mid = (lo + hi + 1) >>> 1;
166
+
167
+ if (firsts[mid] <= k) {
168
+ lo = mid;
169
+ } else {
170
+ hi = mid - 1;
171
+ }
172
+ }
173
+
174
+ // the frame: tangent along a→b, normal of the face, bitangent between; the triangle has an area
175
+ const ex = triangle[3] - triangle[0], ey = triangle[4] - triangle[1], ez = triangle[5] - triangle[2];
176
+ const fx = triangle[6] - triangle[0], fy = triangle[7] - triangle[1], fz = triangle[8] - triangle[2];
177
+
178
+ const e_length = Math.hypot(ex, ey, ez);
179
+
180
+ let nx = ey * fz - ez * fy;
181
+ let ny = ez * fx - ex * fz;
182
+ let nz = ex * fy - ey * fx;
183
+
184
+ const n_length = Math.hypot(nx, ny, nz);
185
+
186
+ const tx = ex / e_length, ty = ey / e_length, tz = ez / e_length;
187
+
188
+ nx /= n_length;
189
+ ny /= n_length;
190
+ nz /= n_length;
191
+
192
+ const at = s * GROOM_BINDING_WORDS;
193
+
194
+ out[at] = ((lo << 8) | (k - firsts[lo])) >>> 0;
195
+ f32[at + 1] = wa;
196
+ f32[at + 2] = wb;
197
+ f32[at + 3] = Math.hypot(root[0] - ox, root[1] - oy, root[2] - oz);
198
+
199
+ f32[at + 4] = tx;
200
+ f32[at + 5] = ty;
201
+ f32[at + 6] = tz;
202
+ f32[at + 7] = ox;
203
+
204
+ f32[at + 8] = ny * tz - nz * ty;
205
+ f32[at + 9] = nz * tx - nx * tz;
206
+ f32[at + 10] = nx * ty - ny * tx;
207
+ f32[at + 11] = oy;
208
+
209
+ f32[at + 12] = nx;
210
+ f32[at + 13] = ny;
211
+ f32[at + 14] = nz;
212
+ f32[at + 15] = oz;
213
+ }
214
+
215
+ return out;
216
+ }
@@ -13,6 +13,7 @@
13
13
  * @property {string} [name]
14
14
  * @property {number} point_count points a strand is resampled to, `2^k + 1`
15
15
  * @property {number} [width] metres, for curves that carry no widths
16
+ * @property {number} [guide_tolerance] metres: how far a strand strays from the guide it follows (`groom_build_guides`)
16
17
  */
17
18
  /**
18
19
  * Whether `n` is `2^k + 1` for some `k ≥ 0`, within what a group may hold.
@@ -41,13 +42,13 @@ export function groom_point_count_for(curves: GroomCurves, tolerance: number): n
41
42
  /**
42
43
  * Make a group from curves: each resampled to `point_count` points evenly along its arc length, the strands put in
43
44
  * rank order (`groom_rank_order`), the points quantized inside the group's bounds, and the decimation table taken
44
- * from what was quantized.
45
+ * from what was quantized, and the guides chosen from it (`groom_build_guides`).
45
46
  *
46
47
  * @param {GroomCurves} curves
47
48
  * @param {GroomBuildOptions} options
48
49
  * @returns {GroomGroup}
49
50
  */
50
- export function groom_build_group(curves: GroomCurves, { name, point_count, width }: GroomBuildOptions): GroomGroup;
51
+ export function groom_build_group(curves: GroomCurves, { name, point_count, width, guide_tolerance }: GroomBuildOptions): GroomGroup;
51
52
  /**
52
53
  * Curves as an importer or a generator hands them over: any number of points a curve.
53
54
  */
@@ -80,6 +81,10 @@ export type GroomBuildOptions = {
80
81
  * metres, for curves that carry no widths
81
82
  */
82
83
  width?: number;
84
+ /**
85
+ * metres: how far a strand strays from the guide it follows (`groom_build_guides`)
86
+ */
87
+ guide_tolerance?: number;
83
88
  };
84
89
  import { GroomGroup } from "./Groom.js";
85
90
  //# sourceMappingURL=groom_build_group.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"groom_build_group.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/hair/groom_build_group.js"],"names":[],"mappings":"AAWA;;;;;;;;;GASG;AAEH;;;;;GAKG;AAEH;;;;;GAKG;AACH,8CAHW,MAAM,GACJ,OAAO,CAUnB;AA6ED;;;;;;GAMG;AACH,+CAHW,UAAU,GACR,YAAY,CA6CxB;AAED;;;;;;;GAOG;AACH,8CAJW,WAAW,aACX,MAAM,GACJ,MAAM,CA+ClB;AAkDD;;;;;;;;GAQG;AACH,0CAJW,WAAW,gCACX,iBAAiB,GACf,UAAU,CAiItB;;;;;;;;eA5Ya,YAAY,GAAC,YAAY;;;;YACzB,WAAW,GAAC,MAAM,EAAE;;;;;YACpB,YAAY,GAAC,YAAY,GAAC,IAAI;;;;gBAE9B,UAAU,GAAC,IAAI;;;WAKf,MAAM;;;;iBACN,MAAM;;;;YACN,MAAM;;2BAnBb,YAAY"}
1
+ {"version":3,"file":"groom_build_group.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/hair/groom_build_group.js"],"names":[],"mappings":"AAYA;;;;;;;;;GASG;AAEH;;;;;;GAMG;AAEH;;;;;GAKG;AACH,8CAHW,MAAM,GACJ,OAAO,CAUnB;AA6ED;;;;;;GAMG;AACH,+CAHW,UAAU,GACR,YAAY,CA6CxB;AAED;;;;;;;GAOG;AACH,8CAJW,WAAW,aACX,MAAM,GACJ,MAAM,CA+ClB;AAkDD;;;;;;;;GAQG;AACH,0CAJW,WAAW,iDACX,iBAAiB,GACf,UAAU,CAwItB;;;;;;;;eApZa,YAAY,GAAC,YAAY;;;;YACzB,WAAW,GAAC,MAAM,EAAE;;;;;YACpB,YAAY,GAAC,YAAY,GAAC,IAAI;;;;gBAE9B,UAAU,GAAC,IAAI;;;WAKf,MAAM;;;;iBACN,MAAM;;;;YACN,MAAM;;;;sBACN,MAAM;;2BArBb,YAAY"}
@@ -6,6 +6,7 @@ import {
6
6
  GROOM_POINT_WORDS,
7
7
  GroomGroup
8
8
  } from "./Groom.js";
9
+ import { groom_build_guides, GROOM_GUIDE_DEFAULT_TOLERANCE } from "./groom_build_guides.js";
9
10
  import { groom_rank_order } from "./groom_rank_order.js";
10
11
  import { groom_root_spacing } from "./groom_root_spacing.js";
11
12
 
@@ -25,6 +26,7 @@ import { groom_root_spacing } from "./groom_root_spacing.js";
25
26
  * @property {string} [name]
26
27
  * @property {number} point_count points a strand is resampled to, `2^k + 1`
27
28
  * @property {number} [width] metres, for curves that carry no widths
29
+ * @property {number} [guide_tolerance] metres: how far a strand strays from the guide it follows (`groom_build_guides`)
28
30
  */
29
31
 
30
32
  /**
@@ -276,13 +278,18 @@ function sample_at(positions, lengths, first, count, s, out, out_offset) {
276
278
  /**
277
279
  * Make a group from curves: each resampled to `point_count` points evenly along its arc length, the strands put in
278
280
  * rank order (`groom_rank_order`), the points quantized inside the group's bounds, and the decimation table taken
279
- * from what was quantized.
281
+ * from what was quantized, and the guides chosen from it (`groom_build_guides`).
280
282
  *
281
283
  * @param {GroomCurves} curves
282
284
  * @param {GroomBuildOptions} options
283
285
  * @returns {GroomGroup}
284
286
  */
285
- export function groom_build_group(curves, { name = "", point_count, width = 70e-6 }) {
287
+ export function groom_build_group(curves, {
288
+ name = "",
289
+ point_count,
290
+ width = 70e-6,
291
+ guide_tolerance = GROOM_GUIDE_DEFAULT_TOLERANCE
292
+ }) {
286
293
  assert.ok(groom_point_count_is_valid(point_count), `point_count ${point_count} is not 2^k + 1 within ${GROOM_POINT_COUNT_MAX}`);
287
294
 
288
295
  const counts = curves.counts;
@@ -408,6 +415,8 @@ export function groom_build_group(curves, { name = "", point_count, width = 70e-
408
415
  group.decimation = groom_decimation_errors(group);
409
416
  group.root_spacing = groom_root_spacing(group);
410
417
 
418
+ groom_build_guides(group, guide_tolerance);
419
+
411
420
  return group;
412
421
  }
413
422
 
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The fewest segments a guide of length `length` needs so that bent through a quarter turn along its length, each
3
+ * segment stays within `tolerance` of the arc it cuts: a chord `l` of a circle of radius `R` stands `l² / 8R` off
4
+ * it, and a quarter turn over `L` is `R = 2L / π`, so `l ≤ √(16 L δ / π)`.
5
+ *
6
+ * @param {number} length metres
7
+ * @param {number} tolerance metres
8
+ * @returns {number}
9
+ */
10
+ export function groom_guide_segments_to_bend(length: number, tolerance: number): number;
11
+ /**
12
+ * Give a group its guides, the strands that are simulated, and every strand the guide it follows.
13
+ *
14
+ * **Which strands guide.** In rank order, a strand follows the guide it stays nearest to along its whole length if
15
+ * that is within `tolerance` at every point, and becomes a guide itself otherwise, so the guide count follows the
16
+ * content: a groom of strands combed alike has few, a tousled one many. Rank order spreads the guides as it spreads
17
+ * any prefix. A group never has more than {@link GROOM_GUIDE_LIMIT}; past it, a strand follows the nearest of the
18
+ * guides around its root however far its shape strays.
19
+ *
20
+ * **How finely they are simulated.** Every guide has the same nodes, every `2^j`-th of its points, `j` the largest
21
+ * that keeps both the dropped points within `tolerance` of the kept chord (the decimation table) and a quarter turn
22
+ * along the longest guide within `tolerance` of its chords ({@link groom_guide_segments_to_bend}); never fewer than
23
+ * three nodes while the strands have three points.
24
+ *
25
+ * **The wisp a guide stands for.** Its strand count, and its diameter: the strand's own width plus twice the mean
26
+ * distance of its followers from it, point by point. The group's reach is the farthest any point is from the chord
27
+ * between its guide's nodes either side of it, so the deformed strands lie within the guides' nodes widened by it.
28
+ *
29
+ * Sets `guide_point_count`, `guide_strand`, `guide_strand_count`, `guide_diameter`, `guide_length`, `strand_guide`
30
+ * and `guide_reach` on the group.
31
+ *
32
+ * @param {import("./Groom.js").GroomGroup} group with its points
33
+ * @param {number} tolerance metres
34
+ */
35
+ export function groom_build_guides(group: import("./Groom.js").GroomGroup, tolerance: number): void;
36
+ /**
37
+ * The wisp tolerance an import gives its groups when it is given none, metres: strands that stay within a centimetre
38
+ * of one another along their whole length move as one wisp. On the test scalp, whose strands each wave on their own,
39
+ * a fifth of the strands guide; Unreal makes a tenth of them guides by default.
40
+ * @type {number}
41
+ */
42
+ export const GROOM_GUIDE_DEFAULT_TOLERANCE: number;
43
+ //# sourceMappingURL=groom_build_guides.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"groom_build_guides.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/hair/groom_build_guides.js"],"names":[],"mappings":"AAWA;;;;;;;;GAQG;AACH,qDAJW,MAAM,aACN,MAAM,GACJ,MAAM,CAIlB;AAkCD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,0CAHW,OAAO,YAAY,EAAE,UAAU,aAC/B,MAAM,QA4LhB;AAvQD;;;;;GAKG;AACH,4CAFU,MAAM,CAEkC"}