@woosh/meep-engine 3.40.0 → 3.41.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 (203) hide show
  1. package/package.json +1 -1
  2. package/src/core/geom/3d/quaternion/swing_twist_clamp.d.ts +24 -0
  3. package/src/core/geom/3d/quaternion/swing_twist_clamp.d.ts.map +1 -0
  4. package/src/core/geom/3d/quaternion/swing_twist_clamp.js +62 -0
  5. package/src/core/geom/3d/quaternion/swing_twist_compose.d.ts +15 -0
  6. package/src/core/geom/3d/quaternion/swing_twist_compose.d.ts.map +1 -0
  7. package/src/core/geom/3d/quaternion/swing_twist_compose.js +36 -0
  8. package/src/core/geom/3d/quaternion/swing_twist_error.d.ts +39 -0
  9. package/src/core/geom/3d/quaternion/swing_twist_error.d.ts.map +1 -0
  10. package/src/core/geom/3d/quaternion/swing_twist_error.js +85 -0
  11. package/src/core/geom/vec3/v3_rigid_align_paired_unit_vectors.d.ts +11 -6
  12. package/src/core/geom/vec3/v3_rigid_align_paired_unit_vectors.d.ts.map +1 -1
  13. package/src/core/geom/vec3/v3_rigid_align_paired_unit_vectors.js +27 -13
  14. package/src/core/math/linalg/eigen/matrix_symmetric_4x4_eigen.d.ts +25 -0
  15. package/src/core/math/linalg/eigen/matrix_symmetric_4x4_eigen.d.ts.map +1 -0
  16. package/src/core/math/linalg/eigen/matrix_symmetric_4x4_eigen.js +166 -0
  17. package/src/core/math/linalg/eigen/matrix_top_eigenvector_power_iteration.d.ts +5 -3
  18. package/src/core/math/linalg/eigen/matrix_top_eigenvector_power_iteration.d.ts.map +1 -1
  19. package/src/core/math/linalg/eigen/matrix_top_eigenvector_power_iteration.js +5 -3
  20. package/src/engine/animation/curve/AnimationCurve.d.ts +3 -0
  21. package/src/engine/animation/curve/AnimationCurve.d.ts.map +1 -1
  22. package/src/engine/animation/curve/AnimationCurve.js +6 -1
  23. package/src/engine/ecs/EntityManager.d.ts +9 -1
  24. package/src/engine/ecs/EntityManager.d.ts.map +1 -1
  25. package/src/engine/ecs/EntityManager.js +26 -27
  26. package/src/engine/ecs/gpu/GPUStateAuthority.d.ts +20 -0
  27. package/src/engine/ecs/gpu/GPUStateAuthority.d.ts.map +1 -1
  28. package/src/engine/ecs/gpu/GPUStateAuthority.js +21 -0
  29. package/src/engine/ecs/gpu/GPU_AUTHORITY_EVENT_HOLD_CHANGE.d.ts +13 -0
  30. package/src/engine/ecs/gpu/GPU_AUTHORITY_EVENT_HOLD_CHANGE.d.ts.map +1 -0
  31. package/src/engine/ecs/gpu/GPU_AUTHORITY_EVENT_HOLD_CHANGE.js +12 -0
  32. package/src/engine/ecs/gpu/gpu_authority_grant.d.ts +6 -0
  33. package/src/engine/ecs/gpu/gpu_authority_grant.d.ts.map +1 -1
  34. package/src/engine/ecs/gpu/gpu_authority_grant.js +7 -1
  35. package/src/engine/ecs/gpu/gpu_authority_held.d.ts +14 -0
  36. package/src/engine/ecs/gpu/gpu_authority_held.d.ts.map +1 -0
  37. package/src/engine/ecs/gpu/gpu_authority_held.js +23 -0
  38. package/src/engine/ecs/gpu/gpu_authority_hold.d.ts +23 -0
  39. package/src/engine/ecs/gpu/gpu_authority_hold.d.ts.map +1 -0
  40. package/src/engine/ecs/gpu/gpu_authority_hold.js +41 -0
  41. package/src/engine/ecs/gpu/gpu_authority_unhold.d.ts +14 -0
  42. package/src/engine/ecs/gpu/gpu_authority_unhold.d.ts.map +1 -0
  43. package/src/engine/ecs/gpu/gpu_authority_unhold.js +32 -0
  44. package/src/engine/ecs/ik/IKGoal.d.ts +59 -0
  45. package/src/engine/ecs/ik/IKGoal.d.ts.map +1 -0
  46. package/src/engine/ecs/ik/IKGoal.js +83 -0
  47. package/src/engine/ecs/ik/IKGoalSystem.d.ts +75 -0
  48. package/src/engine/ecs/ik/IKGoalSystem.d.ts.map +1 -0
  49. package/src/engine/ecs/ik/IKGoalSystem.js +1456 -0
  50. package/src/engine/ecs/ik/PLAN.md +179 -0
  51. package/src/engine/ecs/speaker/VoiceSystem.d.ts +2 -2
  52. package/src/engine/ecs/speaker/VoiceSystem.d.ts.map +1 -1
  53. package/src/engine/ecs/storage/BinaryBufferSerializer.d.ts.map +1 -1
  54. package/src/engine/ecs/storage/BinaryBufferSerializer.js +4 -5
  55. package/src/engine/ecs/storage/binary/SERIALIZATION_COVERAGE.md +7 -3
  56. package/src/engine/ecs/storage/populateEngineSerializationRegistry.d.ts.map +1 -1
  57. package/src/engine/ecs/storage/populateEngineSerializationRegistry.js +1 -2
  58. package/src/engine/ecs/system/orderSystemsByDeclaredAccess.d.ts +33 -0
  59. package/src/engine/ecs/system/orderSystemsByDeclaredAccess.d.ts.map +1 -0
  60. package/src/engine/ecs/system/orderSystemsByDeclaredAccess.js +282 -0
  61. package/src/engine/ecs/transform/T64WorldCache.js +139 -139
  62. package/src/engine/ecs/transform/t64_evaluate_local.d.ts +25 -0
  63. package/src/engine/ecs/transform/t64_evaluate_local.d.ts.map +1 -0
  64. package/src/engine/ecs/transform/t64_evaluate_local.js +35 -0
  65. package/src/engine/ecs/transform/t64_evaluate_world.d.ts +5 -3
  66. package/src/engine/ecs/transform/t64_evaluate_world.d.ts.map +1 -1
  67. package/src/engine/ecs/transform/t64_evaluate_world.js +128 -126
  68. package/src/engine/graphics3/AnimationGraphSystem.d.ts +2 -0
  69. package/src/engine/graphics3/AnimationGraphSystem.d.ts.map +1 -1
  70. package/src/engine/graphics3/AnimationGraphSystem.js +337 -329
  71. package/src/engine/graphics3/AnimationSystem.d.ts +2 -0
  72. package/src/engine/graphics3/AnimationSystem.d.ts.map +1 -1
  73. package/src/engine/graphics3/AnimationSystem.js +360 -352
  74. package/src/engine/physics/cloth/MEASUREMENTS.md +130 -0
  75. package/src/engine/physics/cloth/PLAN.md +16 -1
  76. package/src/engine/physics/cloth/ecs/ClothColliderSystem.d.ts +5 -6
  77. package/src/engine/physics/cloth/ecs/ClothColliderSystem.d.ts.map +1 -1
  78. package/src/engine/physics/cloth/ecs/ClothColliderSystem.js +5 -6
  79. package/src/engine/physics/cloth/ecs/ClothInstance.d.ts +4 -7
  80. package/src/engine/physics/cloth/ecs/ClothInstance.d.ts.map +1 -1
  81. package/src/engine/physics/cloth/ecs/ClothInstance.js +4 -7
  82. package/src/engine/physics/cloth/ecs/ClothSystem.d.ts +4 -3
  83. package/src/engine/physics/cloth/ecs/ClothSystem.d.ts.map +1 -1
  84. package/src/engine/physics/cloth/ecs/ClothSystem.js +4 -3
  85. package/src/engine/physics/cloth/ecs/ClothWorld.d.ts.map +1 -1
  86. package/src/engine/physics/cloth/ecs/ClothWorld.js +10 -0
  87. package/src/engine/physics/cloth/ecs/cloth_seed_rig.d.ts +24 -24
  88. package/src/engine/physics/cloth/ecs/cloth_seed_rig.d.ts.map +1 -1
  89. package/src/engine/physics/cloth/ecs/cloth_seed_rig.js +46 -43
  90. package/src/engine/physics/cloth/ecs/cloth_write_back.d.ts +1 -1
  91. package/src/engine/physics/cloth/ecs/cloth_write_back.js +1 -1
  92. package/src/engine/physics/constraint/solve_constraints.d.ts +0 -35
  93. package/src/engine/physics/constraint/solve_constraints.d.ts.map +1 -1
  94. package/src/engine/physics/constraint/solve_constraints.js +1 -83
  95. package/src/engine/physics/ecs/ContactProbe.d.ts +73 -0
  96. package/src/engine/physics/ecs/ContactProbe.d.ts.map +1 -0
  97. package/src/engine/physics/ecs/ContactProbe.js +103 -0
  98. package/src/engine/physics/ecs/ContactProbeSystem.d.ts +44 -0
  99. package/src/engine/physics/ecs/ContactProbeSystem.d.ts.map +1 -0
  100. package/src/engine/physics/ecs/ContactProbeSystem.js +397 -0
  101. package/src/engine/physics/fluid/ecs/FluidComponent.d.ts +1 -1
  102. package/src/engine/physics/fluid/ecs/FluidComponent.js +1 -1
  103. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  104. package/src/engine/physics/inverse_kinematics/frame_fabrik/FrameFabrikProblem.d.ts +205 -0
  105. package/src/engine/physics/inverse_kinematics/frame_fabrik/FrameFabrikProblem.d.ts.map +1 -0
  106. package/src/engine/physics/inverse_kinematics/frame_fabrik/FrameFabrikProblem.js +245 -0
  107. package/src/engine/physics/inverse_kinematics/frame_fabrik/frame_fabrik_limit_from_joint.d.ts +21 -0
  108. package/src/engine/physics/inverse_kinematics/frame_fabrik/frame_fabrik_limit_from_joint.d.ts.map +1 -0
  109. package/src/engine/physics/inverse_kinematics/frame_fabrik/frame_fabrik_limit_from_joint.js +63 -0
  110. package/src/engine/physics/inverse_kinematics/frame_fabrik/frame_fabrik_solve.d.ts +33 -0
  111. package/src/engine/physics/inverse_kinematics/frame_fabrik/frame_fabrik_solve.d.ts.map +1 -0
  112. package/src/engine/physics/inverse_kinematics/frame_fabrik/frame_fabrik_solve.js +874 -0
  113. package/src/engine/physics/inverse_kinematics/joint_hinge_mid_axis.d.ts +27 -0
  114. package/src/engine/physics/inverse_kinematics/joint_hinge_mid_axis.d.ts.map +1 -0
  115. package/src/engine/physics/inverse_kinematics/joint_hinge_mid_axis.js +77 -0
  116. package/src/engine/physics/inverse_kinematics/two_bone_path_solve.d.ts +36 -0
  117. package/src/engine/physics/inverse_kinematics/two_bone_path_solve.d.ts.map +1 -0
  118. package/src/engine/physics/inverse_kinematics/two_bone_path_solve.js +97 -0
  119. package/src/engine/physics/inverse_kinematics/two_joint_ik.d.ts +33 -11
  120. package/src/engine/physics/inverse_kinematics/two_joint_ik.d.ts.map +1 -1
  121. package/src/engine/physics/inverse_kinematics/two_joint_ik.js +158 -67
  122. package/src/shade/renderer/animation/ANIMATION_TRACK_BINDING_STRUCT.d.ts.map +1 -1
  123. package/src/shade/renderer/animation/ANIMATION_TRACK_BINDING_STRUCT.js +10 -1
  124. package/src/shade/renderer/animation/GPUAnimationManager.d.ts +10 -4
  125. package/src/shade/renderer/animation/GPUAnimationManager.d.ts.map +1 -1
  126. package/src/shade/renderer/animation/GPUAnimationManager.js +251 -23
  127. package/src/shade/renderer/animation/POSE_ACCUMULATOR_LAYOUT.d.ts +12 -4
  128. package/src/shade/renderer/animation/POSE_ACCUMULATOR_LAYOUT.d.ts.map +1 -1
  129. package/src/shade/renderer/animation/POSE_ACCUMULATOR_LAYOUT.js +12 -4
  130. package/src/shade/renderer/animation/chunk_pose_accumulator.d.ts.map +1 -1
  131. package/src/shade/renderer/animation/chunk_pose_accumulator.js +14 -1
  132. package/src/shade/renderer/animation/pose/PoseChannelIndex.d.ts +78 -0
  133. package/src/shade/renderer/animation/pose/PoseChannelIndex.d.ts.map +1 -0
  134. package/src/shade/renderer/animation/pose/PoseChannelIndex.js +274 -0
  135. package/src/shade/renderer/animation/pose/PosePlayback.d.ts +40 -3
  136. package/src/shade/renderer/animation/pose/PosePlayback.d.ts.map +1 -1
  137. package/src/shade/renderer/animation/pose/PosePlayback.js +77 -3
  138. package/src/shade/renderer/animation/pose/pose_evaluate_local.d.ts +21 -3
  139. package/src/shade/renderer/animation/pose/pose_evaluate_local.d.ts.map +1 -1
  140. package/src/shade/renderer/animation/pose/pose_evaluate_local.js +79 -11
  141. package/src/shade/renderer/animation/shader_animation_apply.js +1 -1
  142. package/src/shade/renderer/animation/shader_animation_pose_resolve.d.ts +3 -2
  143. package/src/shade/renderer/animation/shader_animation_pose_resolve.d.ts.map +1 -1
  144. package/src/shade/renderer/animation/shader_animation_pose_resolve.js +187 -176
  145. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  146. package/src/shade/renderer/object_property/chunk_write_object_property.d.ts +3 -1
  147. package/src/shade/renderer/object_property/chunk_write_object_property.d.ts.map +1 -1
  148. package/src/shade/renderer/object_property/chunk_write_object_property.js +5 -2
  149. package/src/shade/renderer/object_property/chunk_write_object_property_node3d.d.ts +4 -0
  150. package/src/shade/renderer/object_property/chunk_write_object_property_node3d.d.ts.map +1 -1
  151. package/src/shade/renderer/object_property/chunk_write_object_property_node3d.js +6 -1
  152. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  153. package/src/shade/renderer/scene/optimization/geometry/geometry_deduplicate.d.ts +1 -1
  154. package/src/shade/renderer/scene/optimization/geometry/geometry_deduplicate.d.ts.map +1 -1
  155. package/src/shade/renderer/scene/optimization/geometry/geometry_deduplicate.js +135 -73
  156. package/src/shade/renderer/scene/optimization/geometry/internal/cover_greedy.d.ts +7 -0
  157. package/src/shade/renderer/scene/optimization/geometry/internal/cover_greedy.d.ts.map +1 -1
  158. package/src/shade/renderer/scene/optimization/geometry/internal/cover_greedy.js +29 -1
  159. package/src/shade/renderer/scene/optimization/geometry/internal/face_neighbourhood_hash.d.ts +19 -0
  160. package/src/shade/renderer/scene/optimization/geometry/internal/face_neighbourhood_hash.d.ts.map +1 -0
  161. package/src/shade/renderer/scene/optimization/geometry/internal/face_neighbourhood_hash.js +167 -0
  162. package/src/shade/renderer/scene/optimization/geometry/internal/neighbourhood_anchor_index.d.ts +25 -0
  163. package/src/shade/renderer/scene/optimization/geometry/internal/neighbourhood_anchor_index.d.ts.map +1 -0
  164. package/src/shade/renderer/scene/optimization/geometry/internal/neighbourhood_anchor_index.js +124 -0
  165. package/src/shade/renderer/scene/optimization/geometry/internal/seed_correspondence_from_face_pair.d.ts +19 -0
  166. package/src/shade/renderer/scene/optimization/geometry/internal/seed_correspondence_from_face_pair.d.ts.map +1 -0
  167. package/src/shade/renderer/scene/optimization/geometry/internal/seed_correspondence_from_face_pair.js +48 -0
  168. package/src/shade/renderer/scene/rows/GPUSceneRows.d.ts +17 -1
  169. package/src/shade/renderer/scene/rows/GPUSceneRows.d.ts.map +1 -1
  170. package/src/shade/renderer/scene/rows/GPUSceneRows.js +29 -3
  171. package/src/engine/ecs/ik/IKConstraint.d.ts +0 -52
  172. package/src/engine/ecs/ik/IKConstraint.d.ts.map +0 -1
  173. package/src/engine/ecs/ik/IKConstraint.js +0 -95
  174. package/src/engine/ecs/ik/IKProblem.d.ts +0 -45
  175. package/src/engine/ecs/ik/IKProblem.d.ts.map +0 -1
  176. package/src/engine/ecs/ik/IKProblem.js +0 -58
  177. package/src/engine/ecs/ik/IKSolver.d.ts +0 -8
  178. package/src/engine/ecs/ik/IKSolver.d.ts.map +0 -1
  179. package/src/engine/ecs/ik/IKSolver.js +0 -9
  180. package/src/engine/ecs/ik/InverseKinematics.d.ts +0 -48
  181. package/src/engine/ecs/ik/InverseKinematics.d.ts.map +0 -1
  182. package/src/engine/ecs/ik/InverseKinematics.js +0 -119
  183. package/src/engine/ecs/ik/InverseKinematicsSerializationAdapter.d.ts +0 -19
  184. package/src/engine/ecs/ik/InverseKinematicsSerializationAdapter.d.ts.map +0 -1
  185. package/src/engine/ecs/ik/InverseKinematicsSerializationAdapter.js +0 -72
  186. package/src/engine/ecs/ik/InverseKinematicsSystem.d.ts +0 -54
  187. package/src/engine/ecs/ik/InverseKinematicsSystem.d.ts.map +0 -1
  188. package/src/engine/ecs/ik/InverseKinematicsSystem.js +0 -212
  189. package/src/engine/ecs/ik/OneBoneSurfaceAlignmentSolver.d.ts +0 -8
  190. package/src/engine/ecs/ik/OneBoneSurfaceAlignmentSolver.d.ts.map +0 -1
  191. package/src/engine/ecs/ik/OneBoneSurfaceAlignmentSolver.js +0 -153
  192. package/src/engine/ecs/ik/TwoBoneInverseKinematicsSolver.d.ts +0 -5
  193. package/src/engine/ecs/ik/TwoBoneInverseKinematicsSolver.d.ts.map +0 -1
  194. package/src/engine/ecs/ik/TwoBoneInverseKinematicsSolver.js +0 -120
  195. package/src/engine/ecs/ik/ik_bone_chain.d.ts +0 -64
  196. package/src/engine/ecs/ik/ik_bone_chain.d.ts.map +0 -1
  197. package/src/engine/ecs/ik/ik_bone_chain.js +0 -142
  198. package/src/engine/ecs/ik/ik_probe_terrain_contact.d.ts +0 -42
  199. package/src/engine/ecs/ik/ik_probe_terrain_contact.d.ts.map +0 -1
  200. package/src/engine/ecs/ik/ik_probe_terrain_contact.js +0 -123
  201. package/src/engine/ecs/ik/ik_write_local_rotation.d.ts +0 -18
  202. package/src/engine/ecs/ik/ik_write_local_rotation.d.ts.map +0 -1
  203. package/src/engine/ecs/ik/ik_write_local_rotation.js +0 -32
@@ -1,119 +0,0 @@
1
- import { IKConstraint } from "./IKConstraint.js";
2
-
3
-
4
- export class InverseKinematics {
5
-
6
- /**
7
- * @readonly
8
- * @type {IKConstraint[]}
9
- */
10
- constraints = [];
11
-
12
- /**
13
- *
14
- * @param {InverseKinematics} other
15
- */
16
- copy(other) {
17
- this.constraints.splice(0, this.constraints.length);
18
-
19
- const other_constraints = other.constraints;
20
- const n = other_constraints.length;
21
-
22
- for (let i = 0; i < n; i++) {
23
- const constraint = other_constraints[i];
24
-
25
- const constraintClone = constraint.clone();
26
-
27
- this.constraints.push(constraintClone);
28
- }
29
- }
30
-
31
- clone() {
32
- const r = new InverseKinematics();
33
-
34
- r.copy(this);
35
-
36
- return r;
37
- }
38
-
39
- /**
40
- *
41
- * @param {Object} options
42
- * @param {String} options.effector
43
- * @param {number} options.offset
44
- * @param {number} options.distanceMin
45
- * @param {number} options.distanceMax
46
- * @param {number} options.strength
47
- * @param {number} options.limit
48
- * @param {String} options.solver
49
- */
50
- add({
51
- effector,
52
- offset = 0,
53
- distanceMin = 0,
54
- distanceMax = 0.1,
55
- strength = 1,
56
- limit = Math.PI * 0.9,
57
- solver = "2BIK"
58
- }) {
59
- const c = new IKConstraint();
60
-
61
- c.effector = effector;
62
- c.offset = offset;
63
- c.strength = strength;
64
- c.distance.set(distanceMin, distanceMax);
65
- c.solver = solver;
66
- c.limit = limit;
67
-
68
- this.constraints.push(c);
69
- }
70
-
71
- /**
72
- *
73
- * @param {InverseKinematics} other
74
- * @returns {boolean}
75
- */
76
- equals(other) {
77
- const cs0 = this.constraints;
78
- const cs1 = other.constraints;
79
-
80
- const n0 = cs0.length;
81
- const n1 = cs1.length;
82
-
83
- if (n0 !== n1) {
84
- return false;
85
- }
86
-
87
- for (let i = 0; i < n0; i++) {
88
- const c0 = cs0[i];
89
- const c1 = cs1[i];
90
- if (!c0.equals(c1)) {
91
- return false;
92
- }
93
- }
94
-
95
- return true;
96
- }
97
-
98
- /**
99
- * @returns {number}
100
- */
101
- hash() {
102
-
103
- let hash = 0;
104
- const constraints = this.constraints;
105
- const length = constraints.length;
106
-
107
- for (let i = 0; i < length; i++) {
108
- const constraint = constraints[i];
109
- const singleValue = constraint.hash();
110
- hash = ((hash << 5) - hash) + singleValue;
111
- hash |= 0; // Convert to 32bit integer
112
- }
113
-
114
- return hash;
115
- }
116
- }
117
-
118
- InverseKinematics.typeName = "InverseKinematics";
119
-
@@ -1,19 +0,0 @@
1
- export class InverseKinematicsSerializationAdapter extends BinaryClassSerializationAdapter<any> {
2
- constructor();
3
- klass: typeof InverseKinematics;
4
- /**
5
- *
6
- * @param {BinaryBuffer} buffer
7
- * @param {InverseKinematics} value
8
- */
9
- serialize(buffer: BinaryBuffer, value: InverseKinematics): void;
10
- /**
11
- *
12
- * @param {BinaryBuffer} buffer
13
- * @param {InverseKinematics} value
14
- */
15
- deserialize(buffer: BinaryBuffer, value: InverseKinematics): void;
16
- }
17
- import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
18
- import { InverseKinematics } from "./InverseKinematics.js";
19
- //# sourceMappingURL=InverseKinematicsSerializationAdapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InverseKinematicsSerializationAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/ik/InverseKinematicsSerializationAdapter.js"],"names":[],"mappings":"AAIA;;IAEI,gCAA0B;IAG1B;;;;OAIG;IACH,uCAFW,iBAAiB,QAqB3B;IAED;;;;OAIG;IACH,yCAFW,iBAAiB,QAgC3B;CACJ;gDAvE+C,sDAAsD;kCAEpE,wBAAwB"}
@@ -1,72 +0,0 @@
1
- import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
2
- import { IKConstraint } from "./IKConstraint.js";
3
- import { InverseKinematics } from "./InverseKinematics.js";
4
-
5
- export class InverseKinematicsSerializationAdapter extends BinaryClassSerializationAdapter {
6
-
7
- klass = InverseKinematics;
8
- version = 0;
9
-
10
- /**
11
- *
12
- * @param {BinaryBuffer} buffer
13
- * @param {InverseKinematics} value
14
- */
15
- serialize(buffer, value) {
16
- const constraints = value.constraints;
17
- const n = constraints.length;
18
- buffer.writeUintVar(n);
19
-
20
- for (let i = 0; i < n; i++) {
21
- const constraint = constraints[i];
22
-
23
- buffer.writeUTF8String(constraint.effector);
24
-
25
- buffer.writeFloat32(constraint.offset);
26
- buffer.writeFloat32(constraint.strength);
27
- buffer.writeFloat32(constraint.limit);
28
-
29
- buffer.writeFloat32(constraint.distance.min);
30
- buffer.writeFloat32(constraint.distance.max);
31
-
32
- buffer.writeUTF8String(constraint.solver);
33
- }
34
- }
35
-
36
- /**
37
- *
38
- * @param {BinaryBuffer} buffer
39
- * @param {InverseKinematics} value
40
- */
41
- deserialize(buffer, value) {
42
- const n = buffer.readUintVar();
43
-
44
- const constraints = [];
45
-
46
- for (let i = 0; i < n; i++) {
47
- const effector = buffer.readUTF8String();
48
-
49
- const offset = buffer.readFloat32();
50
- const strength = buffer.readFloat32();
51
- const limit = buffer.readFloat32();
52
-
53
- const distanceMin = buffer.readFloat32();
54
- const distanceMax = buffer.readFloat32();
55
-
56
- const solver = buffer.readUTF8String();
57
-
58
- const ikConstraint = new IKConstraint();
59
-
60
- ikConstraint.effector = effector;
61
- ikConstraint.offset = offset;
62
- ikConstraint.strength = strength;
63
- ikConstraint.limit = limit;
64
- ikConstraint.distance.set(distanceMin, distanceMax);
65
- ikConstraint.solver = solver;
66
-
67
- constraints.push(ikConstraint);
68
- }
69
-
70
- value.constraints = constraints;
71
- }
72
- }
@@ -1,54 +0,0 @@
1
- /**
2
- * Places bones of an entity's hierarchy against the terrain — a foot onto the slope it stands on,
3
- * rather than through it.
4
- *
5
- * **A bone is an entity here.** The constraint names one, the name is resolved to an entity beneath
6
- * the constrained entity, and the chain above it is the {@link TransformAttachment} parent walk. So
7
- * this system knows nothing about renderers: it reads world {@link Transform64}s the hierarchy has
8
- * already composed and writes local ones back, which is the whole of what a joint angle is.
9
- */
10
- export class InverseKinematicsSystem extends System<any> {
11
- constructor();
12
- dependencies: (typeof Transform64 | typeof InverseKinematics)[];
13
- components_used: ResourceAccessSpecification<typeof Transform64>[];
14
- /**
15
- *
16
- * @type {{"2BIK": TwoBoneInverseKinematicsSolver, "1BSA": OneBoneSurfaceAlignmentSolver}}
17
- */
18
- solvers: {
19
- "2BIK": TwoBoneInverseKinematicsSolver;
20
- "1BSA": OneBoneSurfaceAlignmentSolver;
21
- };
22
- problems: {};
23
- get componentClass(): typeof InverseKinematics;
24
- /**
25
- *
26
- * @param {InverseKinematics} ik
27
- * @param {Transform64} transform
28
- * @param {number} entity
29
- */
30
- link(ik: InverseKinematics, transform: Transform64, entity: number): void;
31
- /**
32
- *
33
- * @param {InverseKinematics} ik
34
- * @param {Transform64} transform
35
- * @param {number} entity
36
- */
37
- unlink(ik: InverseKinematics, transform: Transform64, entity: number): void;
38
- /**
39
- *
40
- * @param {InverseKinematics} ik
41
- * @param {Transform64} transform
42
- * @param {number} entity
43
- */
44
- recordEntityProblems(ik: InverseKinematics, transform: Transform64, entity: number): void;
45
- update(timeDelta: any): void;
46
- #private;
47
- }
48
- import { System } from "../System.js";
49
- import { Transform64 } from "../transform/Transform64.js";
50
- import { InverseKinematics } from "./InverseKinematics.js";
51
- import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
52
- import { TwoBoneInverseKinematicsSolver } from "./TwoBoneInverseKinematicsSolver.js";
53
- import { OneBoneSurfaceAlignmentSolver } from "./OneBoneSurfaceAlignmentSolver.js";
54
- //# sourceMappingURL=InverseKinematicsSystem.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InverseKinematicsSystem.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/ik/InverseKinematicsSystem.js"],"names":[],"mappings":"AAeA;;;;;;;;GAQG;AACH;;IAEI,gEAAgD;IAEhD,mEAEE;IAEF;;;OAGG;IACH,SAFU;QAAC,MAAM,EAAE,8BAA8B,CAAC;QAAC,MAAM,EAAE,6BAA6B,CAAA;KAAC,CAKvF;IAEF,aAAc;IA8Bd,+CAEC;IAED;;;;;OAKG;IACH,SAJW,iBAAiB,aACjB,WAAW,UACX,MAAM,QAIhB;IAED;;;;;OAKG;IACH,WAJW,iBAAiB,aACjB,WAAW,UACX,MAAM,QAIhB;IAED;;;;;OAKG;IACH,yBAJW,iBAAiB,aACjB,WAAW,UACX,MAAM,QAuDhB;IAED,6BAsDC;;CACJ;uBAhNsB,cAAc;4BAMT,6BAA6B;kCAEvB,wBAAwB;4CAVd,oDAAoD;+CAYjD,qCAAqC;8CADtC,oCAAoC"}
@@ -1,212 +0,0 @@
1
- import { ResourceAccessKind } from "../../../core/model/ResourceAccessKind.js";
2
- import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
3
- import { collect_entity_playbacks } from "../../graphics3/pose/collect_entity_playbacks.js";
4
- import { System } from "../System.js";
5
- import { obtainTerrain } from "../terrain/util/obtainTerrain.js";
6
- import {
7
- transform_attachment_find_descendant_by_name
8
- } from "../transform-attachment/transform_attachment_find_descendant_by_name.js";
9
- import { T64WorldCache } from "../transform/T64WorldCache.js";
10
- import { Transform64 } from "../transform/Transform64.js";
11
- import { IKProblem } from "./IKProblem.js";
12
- import { InverseKinematics } from "./InverseKinematics.js";
13
- import { OneBoneSurfaceAlignmentSolver } from "./OneBoneSurfaceAlignmentSolver.js";
14
- import { TwoBoneInverseKinematicsSolver } from "./TwoBoneInverseKinematicsSolver.js";
15
-
16
- /**
17
- * Places bones of an entity's hierarchy against the terrain — a foot onto the slope it stands on,
18
- * rather than through it.
19
- *
20
- * **A bone is an entity here.** The constraint names one, the name is resolved to an entity beneath
21
- * the constrained entity, and the chain above it is the {@link TransformAttachment} parent walk. So
22
- * this system knows nothing about renderers: it reads world {@link Transform64}s the hierarchy has
23
- * already composed and writes local ones back, which is the whole of what a joint angle is.
24
- */
25
- export class InverseKinematicsSystem extends System {
26
-
27
- dependencies = [InverseKinematics, Transform64];
28
-
29
- components_used = [
30
- ResourceAccessSpecification.from(Transform64, ResourceAccessKind.Read | ResourceAccessKind.Write)
31
- ];
32
-
33
- /**
34
- *
35
- * @type {{"2BIK": TwoBoneInverseKinematicsSolver, "1BSA": OneBoneSurfaceAlignmentSolver}}
36
- */
37
- solvers = {
38
- "2BIK": new TwoBoneInverseKinematicsSolver(),
39
- "1BSA": new OneBoneSurfaceAlignmentSolver()
40
- };
41
-
42
- problems = {};
43
-
44
- /**
45
- * Effector entities already found, per constrained entity, indexed the same way its constraints
46
- * are. A name is resolved by searching the hierarchy, which is worth doing once — a model's
47
- * bones do not move between entities.
48
- *
49
- * An entry is absent while the search has not succeeded, and the search is retried until it
50
- * does, because the hierarchy a constraint names arrives with the model rather than with the
51
- * component.
52
- *
53
- * @type {Array<number[]>}
54
- */
55
- #effectors = [];
56
-
57
- /**
58
- *
59
- * @type {Terrain}
60
- */
61
- #terrain = null;
62
-
63
- /**
64
- * Evaluated worlds of the tick, for chains the GPU composes: the constraints on one model
65
- * share its spine, and a socket asked twice is evaluated once.
66
- *
67
- * @type {T64WorldCache}
68
- */
69
- #cache = new T64WorldCache();
70
-
71
-
72
- get componentClass() {
73
- return InverseKinematics;
74
- }
75
-
76
- /**
77
- *
78
- * @param {InverseKinematics} ik
79
- * @param {Transform64} transform
80
- * @param {number} entity
81
- */
82
- link(ik, transform, entity) {
83
- this.#effectors[entity] = [];
84
- }
85
-
86
- /**
87
- *
88
- * @param {InverseKinematics} ik
89
- * @param {Transform64} transform
90
- * @param {number} entity
91
- */
92
- unlink(ik, transform, entity) {
93
- delete this.#effectors[entity];
94
- }
95
-
96
- /**
97
- *
98
- * @param {InverseKinematics} ik
99
- * @param {Transform64} transform
100
- * @param {number} entity
101
- */
102
- recordEntityProblems(ik, transform, entity) {
103
- const ecd = this.entityManager.dataset;
104
-
105
- const effectors = this.#effectors[entity];
106
-
107
- const ikConstraints = ik.constraints;
108
-
109
- const n = ikConstraints.length;
110
-
111
- for (let i = 0; i < n; i++) {
112
- /**
113
- *
114
- * @type {IKConstraint}
115
- */
116
- const c = ikConstraints[i];
117
-
118
- let effector = effectors[i];
119
-
120
- if (effector === undefined) {
121
- effector = transform_attachment_find_descendant_by_name(ecd, entity, c.effector);
122
-
123
- if (effector === -1) {
124
- // the hierarchy carries no such bone yet
125
- continue;
126
- }
127
-
128
- effectors[i] = effector;
129
- }
130
-
131
- const solverID = c.solver;
132
-
133
- //define problem
134
- const problem = IKProblem.pool.create();
135
- problem.constraint = c;
136
- problem.dataset = ecd;
137
- problem.effector = effector;
138
- problem.terrain = this.#terrain;
139
-
140
- // what the chain is evaluated against if the GPU composes it; a pooled problem keeps
141
- // its list, so it is emptied before it is filled
142
- problem.playbacks.length = 0;
143
- collect_entity_playbacks(problem.playbacks, this.entityManager, entity);
144
- problem.cache = this.#cache;
145
-
146
- const problemSet = this.problems[solverID];
147
-
148
- if (problemSet === undefined) {
149
- this.problems[solverID] = [problem];
150
- } else {
151
- problemSet.push(problem);
152
- }
153
- }
154
-
155
- }
156
-
157
- update(timeDelta) {
158
-
159
-
160
- const em = this.entityManager;
161
-
162
- const ecd = em.dataset;
163
-
164
- if (ecd == null) {
165
- return;
166
- }
167
-
168
- this.#terrain = obtainTerrain(ecd);
169
-
170
- if (this.#terrain === null) {
171
- return;
172
- }
173
-
174
-
175
- // last tick's answers are last tick's
176
- this.#cache.invalidate();
177
-
178
- ecd.traverseEntities([InverseKinematics, Transform64], this.recordEntityProblems, this);
179
-
180
- //solve problems
181
- for (const solverID in this.solvers) {
182
- const problemSet = this.problems[solverID];
183
-
184
- if (problemSet === undefined) {
185
- continue;
186
- }
187
-
188
- const n = problemSet.length;
189
-
190
- if (n === 0) {
191
- continue;
192
- }
193
-
194
- const solver = this.solvers[solverID];
195
-
196
- for (let i = 0; i < n; i++) {
197
- const problem = problemSet[i];
198
-
199
- solver.solve(problem);
200
-
201
- IKProblem.pool.release(problem);
202
- }
203
- }
204
-
205
- //clear problem set
206
- for (const solverID in this.problems) {
207
- const problemSet = this.problems[solverID];
208
-
209
- problemSet.splice(0, problemSet.length);
210
- }
211
- }
212
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Align a single bone onto terrain surface
3
- */
4
- export class OneBoneSurfaceAlignmentSolver extends IKSolver {
5
- solve(problem: any): void;
6
- }
7
- import { IKSolver } from "./IKSolver.js";
8
- //# sourceMappingURL=OneBoneSurfaceAlignmentSolver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OneBoneSurfaceAlignmentSolver.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/ik/OneBoneSurfaceAlignmentSolver.js"],"names":[],"mappings":"AA4CA;;GAEG;AACH;IACI,0BAuGC;CACJ;yBA/IwB,eAAe"}
@@ -1,153 +0,0 @@
1
- import { SurfacePoint3 } from "../../../core/geom/3d/SurfacePoint3.js";
2
- import Quaternion from "../../../core/geom/Quaternion.js";
3
- import Vector3 from "../../../core/geom/Vector3.js";
4
- import { clamp } from "../../../core/math/clamp.js";
5
- import { inverseLerp } from "../../../core/math/inverseLerp.js";
6
- import { t64_read_rotation } from "../transform/t64_read_rotation.js";
7
- import { t64_read_translation } from "../transform/t64_read_translation.js";
8
- import { IKBone, ik_bone_chain } from "./ik_bone_chain.js";
9
- import { ik_probe_terrain_contact } from "./ik_probe_terrain_contact.js";
10
- import { IKSolver } from "./IKSolver.js";
11
- import { ik_write_local_rotation } from "./ik_write_local_rotation.js";
12
-
13
- const contact = new SurfacePoint3();
14
-
15
- const targetPosition = new Vector3();
16
-
17
- const bonePosition = new Vector3();
18
- const parentPosition = new Vector3();
19
-
20
- const boneWorldRotation = new Quaternion();
21
- const parentLocalRotation = new Quaternion();
22
-
23
- const v3 = new Vector3();
24
-
25
- const ONE_OVER_SQRT_3 = 0.57735026919;
26
-
27
- const r = new Quaternion();
28
- const up = new Vector3();
29
-
30
- const r_i = new Quaternion();
31
-
32
- const axis = new Vector3();
33
-
34
- const x = new Quaternion();
35
-
36
- const target = new Quaternion();
37
-
38
- /**
39
- * the bone, and its parent — needed for the "down" direction the probe casts along
40
- *
41
- * @type {IKBone[]}
42
- */
43
- const CHAIN = [new IKBone(), new IKBone()];
44
-
45
- /**
46
- * Align a single bone onto terrain surface
47
- */
48
- export class OneBoneSurfaceAlignmentSolver extends IKSolver {
49
- solve(problem) {
50
- const { dataset, effector, constraint, terrain, playbacks, cache } = problem;
51
-
52
- if (!ik_bone_chain(CHAIN, dataset, effector, 2, playbacks, cache)) {
53
- // the hierarchy does not hold the bone and a parent to cast from
54
- return;
55
- }
56
-
57
- const bone = CHAIN[0];
58
- const boneParent = CHAIN[1];
59
-
60
- /*
61
- Read straight off the components: `TransformAttachmentSystem` composes a world transform as
62
- soon as anything it depends on moves, so nothing has to be brought up to date first.
63
-
64
- They are read OUT of the transforms rather than used in place, the same way the two-bone
65
- solver reads its chain: what follows is vector and quaternion math, and a Transform64 is an
66
- array carrying none of those methods.
67
- */
68
- const world = bone.world;
69
-
70
- t64_read_translation(bonePosition, world);
71
- t64_read_translation(parentPosition, boneParent.world);
72
-
73
- // the magnitude of a uniform scale, which is what the limb's lengths are expressed in
74
- const bone_scale = Math.hypot(world.scale_x, world.scale_y, world.scale_z) * ONE_OVER_SQRT_3;
75
-
76
- //cast from the parent towards the bone to find the surface underneath it
77
- let influence = ik_probe_terrain_contact(
78
- targetPosition,
79
- contact,
80
- terrain,
81
- parentPosition.x, parentPosition.y, parentPosition.z,
82
- bonePosition.x, bonePosition.y, bonePosition.z,
83
- constraint,
84
- bone_scale
85
- );
86
-
87
- if (influence <= 0) {
88
- //no contact, or no influence
89
- return;
90
- }
91
-
92
- const contactNormal = contact.normal;
93
-
94
- t64_read_rotation(r, bone.local);
95
- t64_read_rotation(boneWorldRotation, world);
96
-
97
- //we want to make bone align orthogonally to surface contact normal
98
-
99
-
100
- //convert bone UP vector to world space
101
- up.copy(Vector3.forward);
102
- up.applyQuaternion(boneWorldRotation);
103
- up.normalize();
104
-
105
- r_i.copyInverse(boneWorldRotation);
106
-
107
- v3.copy(contactNormal);
108
- v3.applyQuaternion(r_i);
109
-
110
-
111
- //
112
- axis.crossVectors(v3, Vector3.forward);
113
-
114
- const betaSine = axis.length();
115
-
116
- //compute angle between normal and up vector of the bone
117
- const beta = Math.asin(clamp(betaSine, -1, 1));
118
-
119
- //
120
- axis.normalize();
121
-
122
- x.fromAxisAngle(axis, beta);
123
-
124
- target.copy(r);
125
- target.multiply(x);
126
-
127
- //compute angle between quaternions
128
- t64_read_rotation(parentLocalRotation, boneParent.local);
129
-
130
- const a = target.angleTo(parentLocalRotation);
131
-
132
- const a_abs = Math.abs(a);
133
- if (a_abs >= constraint.limit) {
134
- const b = target.angleTo(r);
135
-
136
- const b_abs = Math.abs(b);
137
- if (b_abs < constraint.limit) {
138
-
139
- const l = inverseLerp(a_abs, b_abs, constraint.limit);
140
-
141
- influence *= l;
142
- } else {
143
- return;
144
- }
145
- }
146
-
147
- //slerp, not lerp: see ClingToTerrainSystem.alignToVector. A componentwise blend is not a
148
- //unit quaternion, and `ik_write_local_rotation` writes it straight into the Transform64.
149
- r.slerp(target, constraint.strength * influence);
150
-
151
- ik_write_local_rotation(dataset, bone, r);
152
- }
153
- }
@@ -1,5 +0,0 @@
1
- export class TwoBoneInverseKinematicsSolver extends IKSolver {
2
- solve(problem: any): void;
3
- }
4
- import { IKSolver } from "./IKSolver.js";
5
- //# sourceMappingURL=TwoBoneInverseKinematicsSolver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TwoBoneInverseKinematicsSolver.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/ik/TwoBoneInverseKinematicsSolver.js"],"names":[],"mappings":"AAsCA;IAGI,0BA6EC;CACJ;yBA/GwB,eAAe"}