@woosh/meep-engine 3.44.0 → 3.45.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 (233) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/package.json +1 -1
  3. package/src/core/collection/array/array_sort_insertion_ascending.d.ts +19 -0
  4. package/src/core/collection/array/array_sort_insertion_ascending.d.ts.map +1 -0
  5. package/src/core/collection/array/array_sort_insertion_ascending.js +31 -0
  6. package/src/core/geom/3d/aabb/aabb3_array_round_outward_f32.d.ts +27 -0
  7. package/src/core/geom/3d/aabb/aabb3_array_round_outward_f32.d.ts.map +1 -0
  8. package/src/core/geom/3d/aabb/aabb3_array_round_outward_f32.js +39 -0
  9. package/src/core/geom/3d/aabb/aabb3_from_v3_array.d.ts.map +1 -1
  10. package/src/core/geom/3d/aabb/aabb3_from_v3_array.js +4 -1
  11. package/src/core/geom/3d/aabb/aabb3_transform_oriented.d.ts +2 -2
  12. package/src/core/geom/3d/aabb/aabb3_transform_oriented.d.ts.map +1 -1
  13. package/src/core/geom/3d/aabb/aabb3_transform_oriented.js +1 -1
  14. package/src/core/geom/3d/pose/pose3_apply_inverse_point_array.d.ts +21 -0
  15. package/src/core/geom/3d/pose/pose3_apply_inverse_point_array.d.ts.map +1 -0
  16. package/src/core/geom/3d/pose/pose3_apply_inverse_point_array.js +36 -0
  17. package/src/core/geom/3d/pose/pose3_apply_point_array.d.ts +25 -0
  18. package/src/core/geom/3d/pose/pose3_apply_point_array.d.ts.map +1 -0
  19. package/src/core/geom/3d/pose/pose3_apply_point_array.js +40 -0
  20. package/src/core/geom/3d/pose/pose3_compose_array.d.ts +28 -0
  21. package/src/core/geom/3d/pose/pose3_compose_array.d.ts.map +1 -0
  22. package/src/core/geom/3d/pose/pose3_compose_array.js +41 -0
  23. package/src/core/geom/3d/pose/pose3_to_local_array.d.ts +29 -0
  24. package/src/core/geom/3d/pose/pose3_to_local_array.d.ts.map +1 -0
  25. package/src/core/geom/3d/pose/pose3_to_local_array.js +42 -0
  26. package/src/core/geom/3d/quaternion/quat3_clamp_angle_array.d.ts +28 -0
  27. package/src/core/geom/3d/quaternion/quat3_clamp_angle_array.d.ts.map +1 -0
  28. package/src/core/geom/3d/quaternion/quat3_clamp_angle_array.js +66 -0
  29. package/src/core/geom/3d/quaternion/quat3_multiply_conjugate_left_array.d.ts +22 -0
  30. package/src/core/geom/3d/quaternion/quat3_multiply_conjugate_left_array.d.ts.map +1 -0
  31. package/src/core/geom/3d/quaternion/quat3_multiply_conjugate_left_array.js +30 -0
  32. package/src/core/geom/3d/quaternion/quat3_multiply_conjugate_right_array.d.ts +23 -0
  33. package/src/core/geom/3d/quaternion/quat3_multiply_conjugate_right_array.d.ts.map +1 -0
  34. package/src/core/geom/3d/quaternion/quat3_multiply_conjugate_right_array.js +31 -0
  35. package/src/core/geom/3d/triangle/tri3_compute_normal_area_weighted_array.d.ts +26 -0
  36. package/src/core/geom/3d/triangle/tri3_compute_normal_area_weighted_array.d.ts.map +1 -0
  37. package/src/core/geom/3d/triangle/tri3_compute_normal_area_weighted_array.js +46 -0
  38. package/src/core/geom/vec3/v3_distance_array.d.ts +11 -0
  39. package/src/core/geom/vec3/v3_distance_array.d.ts.map +1 -0
  40. package/src/core/geom/vec3/v3_distance_array.js +19 -0
  41. package/src/core/geom/vec3/v3_normalize_array_checked.d.ts +23 -0
  42. package/src/core/geom/vec3/v3_normalize_array_checked.d.ts.map +1 -0
  43. package/src/core/geom/vec3/v3_normalize_array_checked.js +49 -0
  44. package/src/core/geom/vec3/v3_reject_array.d.ts +15 -0
  45. package/src/core/geom/vec3/v3_reject_array.d.ts.map +1 -0
  46. package/src/core/geom/vec3/v3_reject_array.js +32 -0
  47. package/src/core/graph/csr/csr_build_incidence.d.ts +26 -0
  48. package/src/core/graph/csr/csr_build_incidence.d.ts.map +1 -0
  49. package/src/core/graph/csr/csr_build_incidence.js +71 -0
  50. package/src/core/graph/csr/csr_graph_color_greedy.d.ts +25 -0
  51. package/src/core/graph/csr/csr_graph_color_greedy.d.ts.map +1 -0
  52. package/src/core/graph/csr/csr_graph_color_greedy.js +83 -0
  53. package/src/core/graph/csr/csr_graph_validate_coloring.d.ts +15 -0
  54. package/src/core/graph/csr/csr_graph_validate_coloring.d.ts.map +1 -0
  55. package/src/core/graph/csr/csr_graph_validate_coloring.js +33 -0
  56. package/src/core/math/linalg/matrix_symmetric_3x3_solve_ldlt.d.ts +26 -0
  57. package/src/core/math/linalg/matrix_symmetric_3x3_solve_ldlt.d.ts.map +1 -0
  58. package/src/core/math/linalg/matrix_symmetric_3x3_solve_ldlt.js +71 -0
  59. package/src/core/math/max2_exact.d.ts +15 -0
  60. package/src/core/math/max2_exact.d.ts.map +1 -0
  61. package/src/core/math/max2_exact.js +30 -0
  62. package/src/core/math/min2_exact.d.ts +20 -0
  63. package/src/core/math/min2_exact.d.ts.map +1 -0
  64. package/src/core/math/min2_exact.js +35 -0
  65. package/src/engine/ecs/ik/IKGoalSystem.d.ts.map +1 -1
  66. package/src/engine/ecs/ik/IKGoalSystem.js +3 -19
  67. package/src/engine/ecs/parent/parent_entity_model_of.d.ts +17 -0
  68. package/src/engine/ecs/parent/parent_entity_model_of.d.ts.map +1 -0
  69. package/src/engine/ecs/parent/parent_entity_model_of.js +26 -0
  70. package/src/engine/ecs/transform/t64_read_pose_array.d.ts +15 -0
  71. package/src/engine/ecs/transform/t64_read_pose_array.d.ts.map +1 -0
  72. package/src/engine/ecs/transform/t64_read_pose_array.js +24 -0
  73. package/src/engine/graphics/geometry/geometry_construct_triangle_normal_area_weighted.d.ts +2 -0
  74. package/src/engine/graphics/geometry/geometry_construct_triangle_normal_area_weighted.d.ts.map +1 -1
  75. package/src/engine/graphics/geometry/geometry_construct_triangle_normal_area_weighted.js +10 -21
  76. package/src/engine/graphics3/AnimationGraphSystem.d.ts +5 -0
  77. package/src/engine/graphics3/AnimationGraphSystem.d.ts.map +1 -1
  78. package/src/engine/graphics3/AnimationGraphSystem.js +48 -2
  79. package/src/engine/graphics3/AnimationSystem.d.ts +5 -0
  80. package/src/engine/graphics3/AnimationSystem.d.ts.map +1 -1
  81. package/src/engine/graphics3/AnimationSystem.js +47 -2
  82. package/src/engine/graphics3/register_clips.d.ts +29 -0
  83. package/src/engine/graphics3/register_clips.d.ts.map +1 -1
  84. package/src/engine/graphics3/register_clips.js +52 -0
  85. package/src/engine/physics/broadphase/compute_fat_world_aabb.d.ts +9 -0
  86. package/src/engine/physics/broadphase/compute_fat_world_aabb.d.ts.map +1 -1
  87. package/src/engine/physics/broadphase/compute_fat_world_aabb.js +3 -1
  88. package/src/engine/physics/cloth/PLAN.md +10 -8
  89. package/src/engine/physics/cloth/build/cloth_bind_in_frame.d.ts +22 -0
  90. package/src/engine/physics/cloth/build/cloth_bind_in_frame.d.ts.map +1 -1
  91. package/src/engine/physics/cloth/build/cloth_bind_in_frame.js +51 -19
  92. package/src/engine/physics/cloth/build/cloth_proxy_from_joints.d.ts.map +1 -1
  93. package/src/engine/physics/cloth/build/cloth_proxy_from_joints.js +16 -2
  94. package/src/engine/physics/cloth/build/cloth_proxy_from_mesh.d.ts.map +1 -1
  95. package/src/engine/physics/cloth/build/cloth_proxy_from_mesh.js +19 -24
  96. package/src/engine/physics/cloth/collider/ClothColliderIndex.d.ts +7 -0
  97. package/src/engine/physics/cloth/collider/ClothColliderIndex.d.ts.map +1 -1
  98. package/src/engine/physics/cloth/collider/ClothColliderIndex.js +85 -67
  99. package/src/engine/physics/cloth/collider/cloth_collider_bounds.d.ts.map +1 -1
  100. package/src/engine/physics/cloth/collider/cloth_collider_bounds.js +19 -101
  101. package/src/engine/physics/cloth/collider/cloth_collider_pack.d.ts +2 -5
  102. package/src/engine/physics/cloth/collider/cloth_collider_pack.d.ts.map +1 -1
  103. package/src/engine/physics/cloth/collider/cloth_collider_pack.js +7 -15
  104. package/src/engine/physics/cloth/collider/cloth_collider_sdf.d.ts.map +1 -1
  105. package/src/engine/physics/cloth/collider/cloth_collider_sdf.js +16 -61
  106. package/src/engine/physics/cloth/ecs/ClothColliderFlags.d.ts +0 -1
  107. package/src/engine/physics/cloth/ecs/ClothColliderFlags.js +6 -19
  108. package/src/engine/physics/cloth/ecs/ClothColliderSystem.d.ts +1 -2
  109. package/src/engine/physics/cloth/ecs/ClothColliderSystem.d.ts.map +1 -1
  110. package/src/engine/physics/cloth/ecs/ClothColliderSystem.js +3 -12
  111. package/src/engine/physics/cloth/ecs/ClothWorld.d.ts.map +1 -1
  112. package/src/engine/physics/cloth/ecs/ClothWorld.js +40 -130
  113. package/src/engine/physics/cloth/ecs/cloth_build_rows.d.ts.map +1 -1
  114. package/src/engine/physics/cloth/ecs/cloth_build_rows.js +17 -58
  115. package/src/engine/physics/cloth/ecs/cloth_dynamics_map.d.ts.map +1 -1
  116. package/src/engine/physics/cloth/ecs/cloth_dynamics_map.js +3 -3
  117. package/src/engine/physics/cloth/ecs/cloth_gather_colliders.d.ts.map +1 -1
  118. package/src/engine/physics/cloth/ecs/cloth_gather_colliders.js +44 -104
  119. package/src/engine/physics/cloth/ecs/cloth_geodesic.d.ts.map +1 -1
  120. package/src/engine/physics/cloth/ecs/cloth_geodesic.js +6 -13
  121. package/src/engine/physics/cloth/ecs/cloth_holds.d.ts.map +1 -1
  122. package/src/engine/physics/cloth/ecs/cloth_holds.js +15 -40
  123. package/src/engine/physics/cloth/ecs/cloth_reconstruct_pose.d.ts.map +1 -1
  124. package/src/engine/physics/cloth/ecs/cloth_reconstruct_pose.js +45 -79
  125. package/src/engine/physics/cloth/ecs/cloth_seed_subtree.d.ts.map +1 -1
  126. package/src/engine/physics/cloth/ecs/cloth_seed_subtree.js +7 -27
  127. package/src/engine/physics/cloth/ecs/cloth_write_back.d.ts.map +1 -1
  128. package/src/engine/physics/cloth/ecs/cloth_write_back.js +30 -62
  129. package/src/engine/physics/cloth/playground/cloth_playground_build.d.ts.map +1 -1
  130. package/src/engine/physics/cloth/playground/cloth_playground_build.js +2 -3
  131. package/src/engine/physics/cloth/playground/collide_main.js +2 -28
  132. package/src/engine/physics/cloth/playground/garment_main.js +4 -19
  133. package/src/engine/physics/cloth/playground/main.js +6 -48
  134. package/src/engine/physics/cloth/playground/rig_main.js +947 -955
  135. package/src/engine/physics/cloth/playground/wind_main.js +8 -7
  136. package/src/engine/physics/cloth/solver/ClothState.d.ts.map +1 -1
  137. package/src/engine/physics/cloth/solver/ClothState.js +16 -76
  138. package/src/engine/physics/cloth/solver/cloth_color_particles.d.ts +10 -8
  139. package/src/engine/physics/cloth/solver/cloth_color_particles.d.ts.map +1 -1
  140. package/src/engine/physics/cloth/solver/cloth_color_particles.js +30 -102
  141. package/src/engine/physics/cloth/solver/cloth_contact_find.d.ts.map +1 -1
  142. package/src/engine/physics/cloth/solver/cloth_contact_find.js +3 -2
  143. package/src/engine/physics/cloth/solver/cloth_hold_line.d.ts.map +1 -1
  144. package/src/engine/physics/cloth/solver/cloth_hold_line.js +2 -14
  145. package/src/engine/physics/cloth/solver/cloth_kinetic_energy.d.ts +21 -0
  146. package/src/engine/physics/cloth/solver/cloth_kinetic_energy.d.ts.map +1 -0
  147. package/src/engine/physics/cloth/solver/cloth_kinetic_energy.js +45 -0
  148. package/src/engine/physics/cloth/solver/cloth_particle_coupling.d.ts +32 -0
  149. package/src/engine/physics/cloth/solver/cloth_particle_coupling.d.ts.map +1 -0
  150. package/src/engine/physics/cloth/solver/cloth_particle_coupling.js +133 -0
  151. package/src/engine/physics/cloth/solver/cloth_particle_of_source.d.ts +16 -0
  152. package/src/engine/physics/cloth/solver/cloth_particle_of_source.d.ts.map +1 -0
  153. package/src/engine/physics/cloth/solver/cloth_particle_of_source.js +19 -0
  154. package/src/engine/physics/cloth/solver/cloth_self_find.d.ts.map +1 -1
  155. package/src/engine/physics/cloth/solver/cloth_self_find.js +6 -55
  156. package/src/engine/physics/cloth/solver/cloth_solve_vertex.d.ts.map +1 -1
  157. package/src/engine/physics/cloth/solver/cloth_solve_vertex.js +30 -65
  158. package/src/engine/physics/cloth/solver/cloth_step.d.ts.map +1 -1
  159. package/src/engine/physics/cloth/solver/cloth_step.js +6 -28
  160. package/src/engine/physics/cloth/solver/cloth_step_instance.d.ts.map +1 -1
  161. package/src/engine/physics/cloth/solver/cloth_step_instance.js +2 -3
  162. package/src/engine/physics/cloth/solver/cloth_stretch_residual.d.ts +21 -0
  163. package/src/engine/physics/cloth/solver/cloth_stretch_residual.d.ts.map +1 -0
  164. package/src/engine/physics/cloth/solver/cloth_stretch_residual.js +54 -0
  165. package/src/engine/physics/cloth/solver/cloth_vertex_accumulator.d.ts +15 -0
  166. package/src/engine/physics/cloth/solver/cloth_vertex_accumulator.d.ts.map +1 -1
  167. package/src/engine/physics/cloth/solver/cloth_vertex_accumulator.js +28 -0
  168. package/src/engine/physics/cloth/solver/cloth_worst_tether_ratio.d.ts +30 -0
  169. package/src/engine/physics/cloth/solver/cloth_worst_tether_ratio.d.ts.map +1 -0
  170. package/src/engine/physics/cloth/solver/cloth_worst_tether_ratio.js +56 -0
  171. package/src/engine/physics/cloth/solver/constraint/cloth_contact_row.d.ts.map +1 -1
  172. package/src/engine/physics/cloth/solver/constraint/cloth_contact_row.js +3 -17
  173. package/src/engine/physics/cloth/wind/ClothFluidWind.d.ts +2 -1
  174. package/src/engine/physics/cloth/wind/ClothFluidWind.d.ts.map +1 -1
  175. package/src/engine/physics/cloth/wind/ClothFluidWind.js +7 -25
  176. package/src/engine/physics/cloth/wind/cloth_sample_air.d.ts +3 -1
  177. package/src/engine/physics/cloth/wind/cloth_sample_air.d.ts.map +1 -1
  178. package/src/engine/physics/cloth/wind/cloth_sample_air.js +40 -62
  179. package/src/engine/physics/ecs/ContactProbeSystem.d.ts.map +1 -1
  180. package/src/engine/physics/ecs/ContactProbeSystem.js +2 -18
  181. package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
  182. package/src/engine/physics/ecs/PhysicsSystem.js +9 -50
  183. package/src/engine/physics/fluid/ecs/fluid_sample_domain_bounds.d.ts +24 -0
  184. package/src/engine/physics/fluid/ecs/fluid_sample_domain_bounds.d.ts.map +1 -0
  185. package/src/engine/physics/fluid/ecs/fluid_sample_domain_bounds.js +42 -0
  186. package/src/engine/physics/fluid/ecs/fluid_sample_velocity_world_mps.d.ts +25 -0
  187. package/src/engine/physics/fluid/ecs/fluid_sample_velocity_world_mps.d.ts.map +1 -0
  188. package/src/engine/physics/fluid/ecs/fluid_sample_velocity_world_mps.js +40 -0
  189. package/src/engine/physics/inverse_kinematics/frame_fabrik/frame_fabrik_solve.d.ts.map +1 -1
  190. package/src/engine/physics/inverse_kinematics/frame_fabrik/frame_fabrik_solve.js +40 -90
  191. package/src/engine/physics/narrowphase/capsule_contacts.d.ts.map +1 -1
  192. package/src/engine/physics/narrowphase/capsule_contacts.js +3 -5
  193. package/src/engine/physics/narrowphase/decomposition/mesh_enumerate_triangles.d.ts.map +1 -1
  194. package/src/engine/physics/narrowphase/decomposition/mesh_enumerate_triangles.js +2 -14
  195. package/src/engine/physics/narrowphase/hull_sphere_contact.d.ts.map +1 -1
  196. package/src/engine/physics/narrowphase/hull_sphere_contact.js +2 -5
  197. package/src/engine/physics/narrowphase/narrowphase_step.d.ts.map +1 -1
  198. package/src/engine/physics/narrowphase/narrowphase_step.js +13 -32
  199. package/src/engine/physics/narrowphase/sphere_box_contact.d.ts.map +1 -1
  200. package/src/engine/physics/narrowphase/sphere_box_contact.js +2 -5
  201. package/src/format/texture/basis/transcode/etc1s_to_astc.d.ts.map +1 -1
  202. package/src/format/texture/basis/transcode/etc1s_to_astc.js +2 -1
  203. package/src/shade/playground/image_decode_bench/main.js +2 -1
  204. package/src/shade/playground/skinned_blas_refit/diff_traced_against_rasterized.d.ts.map +1 -1
  205. package/src/shade/playground/skinned_blas_refit/diff_traced_against_rasterized.js +2 -1
  206. package/src/shade/playground/skinned_mesh_soup/verify_clone_vertices.d.ts.map +1 -1
  207. package/src/shade/playground/skinned_mesh_soup/verify_clone_vertices.js +2 -1
  208. package/src/shade/playground/ssr_variance/statistics.d.ts.map +1 -1
  209. package/src/shade/playground/ssr_variance/statistics.js +2 -1
  210. package/src/shade/playground/texture_encode/main.d.ts.map +1 -1
  211. package/src/shade/playground/texture_encode/main.js +2 -1
  212. package/src/shade/playground/volumetrics_froxel/measure.d.ts.map +1 -1
  213. package/src/shade/playground/volumetrics_froxel/measure.js +2 -1
  214. package/src/shade/renderer/buffer/table/gpu_database_check_links.d.ts.map +1 -1
  215. package/src/shade/renderer/buffer/table/gpu_database_check_links.js +2 -1
  216. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.d.ts.map +1 -1
  217. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.js +3 -2
  218. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_leaf_frontier.d.ts.map +1 -1
  219. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_leaf_frontier.js +2 -1
  220. package/src/shade/renderer/geometry/virtual/build/level/vgeo_partition_into_groups.d.ts.map +1 -1
  221. package/src/shade/renderer/geometry/virtual/build/level/vgeo_partition_into_groups.js +2 -1
  222. package/src/shade/renderer/geometry/virtual/build/level/vgeo_run_round.d.ts.map +1 -1
  223. package/src/shade/renderer/geometry/virtual/build/level/vgeo_run_round.js +2 -1
  224. package/src/shade/renderer/geometry/virtual/build/level/vgeo_try_repack.d.ts.map +1 -1
  225. package/src/shade/renderer/geometry/virtual/build/level/vgeo_try_repack.js +3 -2
  226. package/src/shade/renderer/geometry/virtual/build/partition/vgeo_graph_components.d.ts.map +1 -1
  227. package/src/shade/renderer/geometry/virtual/build/partition/vgeo_graph_components.js +2 -1
  228. package/src/shade/renderer/geometry/virtual/build/partition/vgeo_split_face_set_packed.d.ts.map +1 -1
  229. package/src/shade/renderer/geometry/virtual/build/partition/vgeo_split_face_set_packed.js +2 -1
  230. package/src/shade/renderer/geometry/virtual/format/vgeo_write_container.d.ts.map +1 -1
  231. package/src/shade/renderer/geometry/virtual/format/vgeo_write_container.js +3 -2
  232. package/src/shade/renderer/particles/optimizer/dag/particle_vector_extract.d.ts.map +1 -1
  233. package/src/shade/renderer/particles/optimizer/dag/particle_vector_extract.js +3 -2
@@ -1,8 +1,5 @@
1
- import { quat3_multiply_array } from "../../../../core/geom/3d/quaternion/quat3_multiply.js";
2
- import { v3_quaternion_apply_array } from "../../../../core/geom/vec3/v3_quaternion_apply.js";
3
- import {
4
- v3_quaternion_apply_inverse_array
5
- } from "../../../../core/geom/vec3/v3_quaternion_apply_inverse.js";
1
+ import { pose3_compose_array } from "../../../../core/geom/3d/pose/pose3_compose_array.js";
2
+ import { pose3_to_local_array } from "../../../../core/geom/3d/pose/pose3_to_local_array.js";
6
3
  import { t64_announce_change } from "../../../ecs/transform/t64_announce_change.js";
7
4
  import {
8
5
  TRANSFORM64_ROTATION_OFFSET,
@@ -86,12 +83,10 @@ export function cloth_write_back(instance, ecd) {
86
83
  // transforms either way (§4.1) — but a **nested** cloth reads this pose as
87
84
  // its own anchor, and then the two systems hand it different numbers.
88
85
  // `MEASUREMENTS.md` §56.
89
- const ax = instance.frame_translation[0];
90
- const ay = instance.frame_translation[1];
91
- const az = instance.frame_translation[2];
92
-
93
- // The rotations go in as arrays, read where they sit: handed over as seven and eight numbers,
94
- // each was boxed into a heap object wherever the call was not inlined.
86
+ //
87
+ // The frame goes in as arrays, read where it sits: handed over as seven and eight numbers, each
88
+ // was boxed into a heap object wherever the call was not inlined.
89
+ const frame_translation = instance.frame_translation;
95
90
  const frame_rotation = instance.frame_rotation;
96
91
 
97
92
  const parent = instance.node_parent;
@@ -106,15 +101,14 @@ export function cloth_write_back(instance, ecd) {
106
101
 
107
102
  const transform = instance.node_transform[node];
108
103
 
109
- const n = node * 3;
110
-
111
- v3_quaternion_apply_array(transform, TRANSFORM64_TRANSLATION_OFFSET, blended, n, frame_rotation, 0);
112
-
113
- transform[TRANSFORM64_TRANSLATION_OFFSET] += ax;
114
- transform[TRANSFORM64_TRANSLATION_OFFSET + 1] += ay;
115
- transform[TRANSFORM64_TRANSLATION_OFFSET + 2] += az;
116
-
117
- quat3_multiply_array(transform, TRANSFORM64_ROTATION_OFFSET, frame_rotation, 0, reconstructed, node * 4);
104
+ pose3_compose_array(
105
+ transform, TRANSFORM64_TRANSLATION_OFFSET,
106
+ transform, TRANSFORM64_ROTATION_OFFSET,
107
+ frame_translation, 0,
108
+ frame_rotation, 0,
109
+ blended, node * 3,
110
+ reconstructed, node * 4
111
+ );
118
112
 
119
113
  transform.updateMatrix();
120
114
 
@@ -166,12 +160,6 @@ export function cloth_write_local_pose(local, instance, node, parent) {
166
160
  const blended = instance.blended_position;
167
161
  const rotation = instance.blended_rotation;
168
162
 
169
- // Operands go in as arrays, the parent's rotation and the node's straight from the instance, the
170
- // offset and the conjugate through scratch: handed over as seven and eight numbers, each was
171
- // boxed into a heap object wherever the call was not inlined.
172
- const offset = scratch_local_offset;
173
- const conjugate = scratch_parent_conjugate;
174
-
175
163
  if (parent < 0) {
176
164
  // A joint hanging straight off the frame — every joint of a generated
177
165
  // skin — is written in the frame, which is the identity in itself.
@@ -190,34 +178,28 @@ export function cloth_write_local_pose(local, instance, node, parent) {
190
178
  }
191
179
 
192
180
  if (instance.node_output[parent] !== 0) {
193
- offset[0] = blended[node * 3] - blended[parent * 3];
194
- offset[1] = blended[node * 3 + 1] - blended[parent * 3 + 1];
195
- offset[2] = blended[node * 3 + 2] - blended[parent * 3 + 2];
196
-
197
- v3_quaternion_apply_inverse_array(local, TRANSFORM64_TRANSLATION_OFFSET, offset, 0, rotation, parent * 4);
198
-
199
- conjugate[0] = -rotation[parent * 4];
200
- conjugate[1] = -rotation[parent * 4 + 1];
201
- conjugate[2] = -rotation[parent * 4 + 2];
202
- conjugate[3] = rotation[parent * 4 + 3];
181
+ pose3_to_local_array(
182
+ local, TRANSFORM64_TRANSLATION_OFFSET,
183
+ local, TRANSFORM64_ROTATION_OFFSET,
184
+ blended, parent * 3,
185
+ rotation, parent * 4,
186
+ blended, node * 3,
187
+ rotation, node * 4
188
+ );
203
189
  } else {
204
190
  const boundary = instance.boundary_pose;
205
191
  const b = parent * 7;
206
192
 
207
- offset[0] = blended[node * 3] - boundary[b];
208
- offset[1] = blended[node * 3 + 1] - boundary[b + 1];
209
- offset[2] = blended[node * 3 + 2] - boundary[b + 2];
210
-
211
- v3_quaternion_apply_inverse_array(local, TRANSFORM64_TRANSLATION_OFFSET, offset, 0, boundary, b + 3);
212
-
213
- conjugate[0] = -boundary[b + 3];
214
- conjugate[1] = -boundary[b + 4];
215
- conjugate[2] = -boundary[b + 5];
216
- conjugate[3] = boundary[b + 6];
193
+ pose3_to_local_array(
194
+ local, TRANSFORM64_TRANSLATION_OFFSET,
195
+ local, TRANSFORM64_ROTATION_OFFSET,
196
+ boundary, b,
197
+ boundary, b + 3,
198
+ blended, node * 3,
199
+ rotation, node * 4
200
+ );
217
201
  }
218
202
 
219
- quat3_multiply_array(local, TRANSFORM64_ROTATION_OFFSET, conjugate, 0, rotation, node * 4);
220
-
221
203
  // `multiplyTransforms` reads the matrix, not the components, so a local
222
204
  // transform that is not refreshed here composes the pose it had last time.
223
205
  local.updateMatrix();
@@ -253,17 +235,3 @@ function pose_pruned(instance, ecd) {
253
235
  t64_announce_change(ecd, instance.pruned_entity[i]);
254
236
  }
255
237
  }
256
-
257
- /**
258
- * {@link cloth_write_local_pose}'s node position less its parent's, in the cloth's frame.
259
- * @type {Float64Array}
260
- * @private
261
- */
262
- const scratch_local_offset = new Float64Array(3);
263
-
264
- /**
265
- * {@link cloth_write_local_pose}'s parent rotation, conjugated: `[-x, -y, -z, w]`.
266
- * @type {Float64Array}
267
- * @private
268
- */
269
- const scratch_parent_conjugate = new Float64Array(4);
@@ -1 +1 @@
1
- {"version":3,"file":"cloth_playground_build.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/physics/cloth/playground/cloth_playground_build.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;;;GAaG;AACH;IAZoC,KAAK,EAA9B,OAAO,GAAC,OAAO;IACC,KAAK,EAArB,MAAM;IACU,MAAM,EAAtB,MAAM;IACU,OAAO,EAAvB,MAAM;IACU,IAAI,EAApB,MAAM;IACU,iBAAiB,EAAjC,MAAM;IACU,YAAY,EAA5B,MAAM;IACkC,MAAM,EAA9C,KAAK,GAAC,SAAS,GAAC,OAAO,GAAC,MAAM;IACb,IAAI,EAArB,OAAO;IAEL,oBAAoB,CAgBhC;;WAjCa,UAAU;;;;;cACV,UAAU;;2BAxBG,yBAAyB"}
1
+ {"version":3,"file":"cloth_playground_build.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/physics/cloth/playground/cloth_playground_build.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;;;GAaG;AACH;IAZoC,KAAK,EAA9B,OAAO,GAAC,OAAO;IACC,KAAK,EAArB,MAAM;IACU,MAAM,EAAtB,MAAM;IACU,OAAO,EAAvB,MAAM;IACU,IAAI,EAApB,MAAM;IACU,iBAAiB,EAAjC,MAAM;IACU,YAAY,EAA5B,MAAM;IACkC,MAAM,EAA9C,KAAK,GAAC,SAAS,GAAC,OAAO,GAAC,MAAM;IACb,IAAI,EAArB,OAAO;IAEL,oBAAoB,CAgBhC;;WAjCa,UAAU;;;;;cACV,UAAU;;2BAzBG,yBAAyB"}
@@ -1,5 +1,6 @@
1
1
  import { ClothState } from "../solver/ClothState.js";
2
2
  import { cloth_bend_stencil_weights } from "../solver/constraint/cloth_bend_row.js";
3
+ import { cloth_particle_of_source } from "../solver/cloth_particle_of_source.js";
3
4
 
4
5
  /**
5
6
  * # Building the playground's cloth
@@ -289,9 +290,7 @@ function extract_edges_and_hinges(triangle) {
289
290
  function permute_triangles(triangle, state) {
290
291
  const particle_of_source = new Int32Array(state.particle_count);
291
292
 
292
- for (let i = 0; i < state.particle_count; i++) {
293
- particle_of_source[state.source_of_particle[i]] = i;
294
- }
293
+ cloth_particle_of_source(particle_of_source, state.source_of_particle, state.particle_count);
295
294
 
296
295
  const out = new Int32Array(triangle.length);
297
296
 
@@ -23,6 +23,7 @@ import { find_non_finite_cloth_state } from "../solver/find_non_finite_cloth_sta
23
23
  import { build_cloth_playground_scene } from "./cloth_playground_build.js";
24
24
  import { COLLIDER_SCENES, unsweep } from "./collide_build.js";
25
25
  import { draw_cloth, PlaygroundCamera, project } from "./cloth_playground_draw.js";
26
+ import { cloth_kinetic_energy } from "../solver/cloth_kinetic_energy.js";
26
27
 
27
28
  /**
28
29
  * # Cloth collision playground — M2
@@ -227,33 +228,6 @@ function penetration() {
227
228
  return worst;
228
229
  }
229
230
 
230
- /**
231
- * @returns {number} kinetic energy, J
232
- */
233
- function kinetic() {
234
- const state = cloth.state;
235
-
236
- let total = 0;
237
-
238
- for (let i = 0; i < state.particle_count; i++) {
239
- const w = state.mass_inverse[i];
240
-
241
- if (w === 0) {
242
- continue;
243
- }
244
-
245
- const p = i * 3;
246
-
247
- total += 0.5 * (
248
- state.velocity[p] * state.velocity[p] +
249
- state.velocity[p + 1] * state.velocity[p + 1] +
250
- state.velocity[p + 2] * state.velocity[p + 2]
251
- ) / w;
252
- }
253
-
254
- return total;
255
- }
256
-
257
231
  // ------------------------------------------------------------------- draw
258
232
 
259
233
  /**
@@ -464,7 +438,7 @@ function refresh_readout() {
464
438
  element('r_contacts').textContent = String(contact_rows);
465
439
  element('r_pen').textContent = `${(worst_penetration * 1000).toFixed(2)} mm`;
466
440
  element('r_rest').textContent = `${(penetration() * 1000).toFixed(2)} mm`;
467
- element('r_energy').textContent = kinetic().toExponential(2);
441
+ element('r_energy').textContent = cloth_kinetic_energy(cloth.state).toExponential(2);
468
442
 
469
443
  const offender = find_non_finite_cloth_state(cloth.state);
470
444
 
@@ -5,6 +5,7 @@ import { GARMENT_PRESETS, build_garment, garment_sync_colliders } from "./garmen
5
5
  import { TRANSFORM_ATTACHMENT_EVENT_CHANGE } from "../../../ecs/transform-attachment/TRANSFORM_ATTACHMENT_EVENT_CHANGE.js";
6
6
  import { TransformAttachment } from "../../../ecs/transform-attachment/TransformAttachment.js";
7
7
  import { Transform64 } from "../../../ecs/transform/Transform64.js";
8
+ import { cloth_worst_tether_ratio } from "../solver/cloth_worst_tether_ratio.js";
8
9
 
9
10
  /**
10
11
  * # Skinned garments playground — M3
@@ -417,25 +418,9 @@ function refresh_readout() {
417
418
  element('r_self').textContent = String(instance.self_pairs);
418
419
  element('r_step').textContent = `${step_ms.toFixed(3)} ms`;
419
420
 
420
- let worst = 0;
421
-
422
- const anchor = instance.particle_of_node[0] * 3;
423
-
424
- for (let node = 1; node < instance.node_count; node++) {
425
- const p = instance.particle_of_node[node] * 3;
426
-
427
- const distance = Math.hypot(
428
- state.position[p] - state.position[anchor],
429
- state.position[p + 1] - state.position[anchor + 1],
430
- state.position[p + 2] - state.position[anchor + 2]
431
- );
432
-
433
- const ratio = distance / instance.geodesic[node];
434
-
435
- if (ratio > worst) {
436
- worst = ratio;
437
- }
438
- }
421
+ const worst = cloth_worst_tether_ratio(
422
+ state.position, instance.particle_of_node, instance.geodesic, instance.node_count
423
+ );
439
424
 
440
425
  const reach = element('r_reach');
441
426
 
@@ -10,6 +10,9 @@ import {
10
10
  project,
11
11
  unproject
12
12
  } from "./cloth_playground_draw.js";
13
+ import { number_compare_ascending } from "../../../../core/primitives/numbers/number_compare_ascending.js";
14
+ import { cloth_kinetic_energy } from "../solver/cloth_kinetic_energy.js";
15
+ import { cloth_stretch_residual } from "../solver/cloth_stretch_residual.js";
13
16
 
14
17
  /**
15
18
  * # Cloth solver playground
@@ -239,7 +242,7 @@ function step_once() {
239
242
  timing.shift();
240
243
  }
241
244
 
242
- energy_history.push(kinetic_energy(scene.state));
245
+ energy_history.push(cloth_kinetic_energy(scene.state));
243
246
 
244
247
  if (energy_history.length > ENERGY_WINDOW) {
245
248
  energy_history.shift();
@@ -272,58 +275,13 @@ function frame() {
272
275
 
273
276
  // ---------------------------------------------------------------- readouts
274
277
 
275
- function kinetic_energy(state) {
276
- let energy = 0;
277
-
278
- for (let i = 0; i < state.particle_count; i++) {
279
- const inverse_mass = state.mass_inverse[i];
280
-
281
- if (inverse_mass === 0) {
282
- continue;
283
- }
284
-
285
- const p = i * 3;
286
-
287
- energy += 0.5 / inverse_mass * (
288
- state.velocity[p] * state.velocity[p] +
289
- state.velocity[p + 1] * state.velocity[p + 1] +
290
- state.velocity[p + 2] * state.velocity[p + 2]
291
- );
292
- }
293
-
294
- return energy;
295
- }
296
-
297
- function stretch_residual(state) {
298
- let worst = 0;
299
-
300
- for (let row = 0; row < state.stretch_count; row++) {
301
- const a = state.stretch_particle[row * 2] * 3;
302
- const b = state.stretch_particle[row * 2 + 1] * 3;
303
-
304
- const length = Math.hypot(
305
- state.position[a] - state.position[b],
306
- state.position[a + 1] - state.position[b + 1],
307
- state.position[a + 2] - state.position[b + 2]
308
- );
309
-
310
- const rest = state.stretch_rest[row];
311
-
312
- if (rest > 0) {
313
- worst = Math.max(worst, Math.abs(length - rest) / rest);
314
- }
315
- }
316
-
317
- return worst;
318
- }
319
-
320
278
  function refresh_readout() {
321
279
  const state = scene.state;
322
280
 
323
281
  element('ms').textContent = last_ms.toFixed(3);
324
282
 
325
283
  if (timing.length > 0) {
326
- const sorted = timing.slice().sort((a, b) => a - b);
284
+ const sorted = timing.slice().sort(number_compare_ascending);
327
285
 
328
286
  element('ms_min').textContent = `(min ${sorted[0].toFixed(3)})`;
329
287
 
@@ -333,7 +291,7 @@ function refresh_readout() {
333
291
  bar.classList.toggle('over', sorted[0] > BUDGET_MS);
334
292
  }
335
293
 
336
- element('residual').textContent = (stretch_residual(state) * 100).toFixed(2) + '%';
294
+ element('residual').textContent = (cloth_stretch_residual(state) * 100).toFixed(2) + '%';
337
295
 
338
296
  const energy = energy_history.length > 0 ? energy_history[energy_history.length - 1] : 0;
339
297