@woosh/meep-engine 2.110.8 → 2.110.9

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 (175) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +93 -106
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +93 -106
  5. package/editor/tools/v2/TransformControls.js +11 -6
  6. package/package.json +2 -1
  7. package/src/core/UUID.d.ts +3 -0
  8. package/src/core/UUID.d.ts.map +1 -1
  9. package/src/core/UUID.js +9 -7
  10. package/src/core/collection/array/arraySetDiff.d.ts.map +1 -1
  11. package/src/core/collection/array/arraySetDiff.js +0 -1
  12. package/src/core/collection/array/binarySearchHighIndex.d.ts.map +1 -1
  13. package/src/core/collection/array/binarySearchHighIndex.js +7 -1
  14. package/src/core/collection/array/computeHashArray.d.ts.map +1 -1
  15. package/src/core/collection/array/computeHashArray.js +3 -2
  16. package/src/core/collection/array/fastArrayEquals.d.ts +1 -0
  17. package/src/core/collection/array/fastArrayEquals.d.ts.map +1 -1
  18. package/src/core/collection/array/fastArrayEquals.js +1 -0
  19. package/src/core/collection/array/isArrayEqual.d.ts.map +1 -1
  20. package/src/core/collection/array/isArrayEqual.js +9 -12
  21. package/src/core/collection/array/isArrayEqual.spec.d.ts +2 -0
  22. package/src/core/collection/array/isArrayEqual.spec.d.ts.map +1 -0
  23. package/src/core/collection/array/isArrayEqual.spec.js +25 -0
  24. package/src/core/collection/array/typed/is_typed_array_equals.d.ts.map +1 -1
  25. package/src/core/collection/array/typed/is_typed_array_equals.js +1 -0
  26. package/src/core/function/makeSequenceLoop.d.ts.map +1 -0
  27. package/src/core/geom/3d/shape/AbstractShape3D.d.ts.map +1 -1
  28. package/src/core/geom/3d/shape/AbstractShape3D.js +14 -0
  29. package/src/core/geom/3d/shape/PointShape3D.d.ts +9 -0
  30. package/src/core/geom/3d/shape/PointShape3D.d.ts.map +1 -0
  31. package/src/core/geom/3d/shape/PointShape3D.js +14 -0
  32. package/src/core/geom/3d/shape/TransformedShape3D.d.ts.map +1 -1
  33. package/src/core/geom/3d/shape/TransformedShape3D.js +26 -8
  34. package/src/core/geom/3d/shape/UnionShape3D.d.ts.map +1 -1
  35. package/src/core/geom/3d/shape/UnionShape3D.js +33 -4
  36. package/src/core/geom/3d/shape/UnitCubeShape3D.d.ts.map +1 -1
  37. package/src/core/geom/3d/shape/UnitCubeShape3D.js +13 -6
  38. package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts.map +1 -1
  39. package/src/core/geom/3d/shape/UnitSphereShape3D.js +10 -0
  40. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts +15 -8
  41. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts.map +1 -1
  42. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +33 -9
  43. package/src/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.d.ts +1 -1
  44. package/src/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.d.ts.map +1 -1
  45. package/src/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js +7 -7
  46. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.spec.d.ts +2 -0
  47. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.spec.d.ts.map +1 -0
  48. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.spec.js +38 -0
  49. package/src/core/geom/3d/v3_compute_triangle_normal.js +1 -1
  50. package/src/core/geom/3d/v3_negate_array.d.ts +9 -0
  51. package/src/core/geom/3d/v3_negate_array.d.ts.map +1 -0
  52. package/src/core/geom/3d/v3_negate_array.js +16 -0
  53. package/src/core/geom/Quaternion.d.ts.map +1 -1
  54. package/src/core/geom/Quaternion.js +30 -77
  55. package/src/core/geom/Vector3.d.ts +4 -0
  56. package/src/core/geom/Vector3.js +4 -4
  57. package/src/core/geom/vec3/v3_cross_array.d.ts +11 -0
  58. package/src/core/geom/vec3/v3_cross_array.d.ts.map +1 -0
  59. package/src/core/geom/vec3/v3_cross_array.js +31 -0
  60. package/src/core/geom/vec3/v3_displace_in_direction.js +3 -2
  61. package/src/core/geom/vec3/v3_displace_in_direction_array.d.ts +12 -0
  62. package/src/core/geom/vec3/v3_displace_in_direction_array.d.ts.map +1 -0
  63. package/src/core/geom/vec3/v3_displace_in_direction_array.js +22 -0
  64. package/src/core/geom/vec3/v3_dot_array_array.d.ts.map +1 -1
  65. package/src/core/geom/vec3/v3_dot_array_array.js +4 -1
  66. package/src/core/geom/vec3/v3_normalize_array.d.ts +3 -3
  67. package/src/core/geom/vec3/v3_normalize_array.d.ts.map +1 -1
  68. package/src/core/geom/vec3/v3_normalize_array.js +3 -3
  69. package/src/core/math/copysign.d.ts +1 -1
  70. package/src/core/math/copysign.js +1 -1
  71. package/src/core/math/epsilonEquals.d.ts.map +1 -1
  72. package/src/core/math/epsilonEquals.js +3 -2
  73. package/src/core/math/linalg/README.md +1 -1
  74. package/src/core/math/random/randomGaussian.spec.js +1 -1
  75. package/src/core/math/spline/spline_hermite3.d.ts +1 -1
  76. package/src/core/math/spline/spline_hermite3.js +1 -1
  77. package/src/core/process/delay.d.ts +6 -1
  78. package/src/core/process/delay.d.ts.map +1 -1
  79. package/src/core/process/delay.js +6 -1
  80. package/src/core/process/undo/Mark.d.ts +5 -5
  81. package/src/core/process/undo/Mark.d.ts.map +1 -1
  82. package/src/core/process/undo/Mark.js +6 -5
  83. package/src/core/process/worker/WorkerBuilder.d.ts +13 -2
  84. package/src/core/process/worker/WorkerBuilder.d.ts.map +1 -1
  85. package/src/core/process/worker/WorkerBuilder.js +8 -0
  86. package/src/core/process/worker/WorkerProxy.d.ts +16 -6
  87. package/src/core/process/worker/WorkerProxy.d.ts.map +1 -1
  88. package/src/core/process/worker/WorkerProxy.js +24 -5
  89. package/src/engine/EngineHarness.d.ts +7 -1
  90. package/src/engine/EngineHarness.d.ts.map +1 -1
  91. package/src/engine/EngineHarness.js +12 -1
  92. package/src/engine/animation/clip/AnimationTrack.d.ts.map +1 -1
  93. package/src/engine/animation/clip/AnimationTrack.js +3 -0
  94. package/src/engine/animation/clip/bind_property_writer.d.ts +2 -2
  95. package/src/engine/animation/clip/bind_property_writer.d.ts.map +1 -1
  96. package/src/engine/animation/clip/bind_property_writer.js +22 -13
  97. package/src/engine/animation/clip/curve_from_track_data.d.ts.map +1 -1
  98. package/src/engine/animation/clip/curve_from_track_data.js +9 -1
  99. package/src/engine/animation/clip/ecd_bind_animation_curve.d.ts.map +1 -1
  100. package/src/engine/animation/clip/ecd_bind_animation_curve.js +6 -5
  101. package/src/engine/animation/curve/AnimationCurve.d.ts +21 -0
  102. package/src/engine/animation/curve/AnimationCurve.d.ts.map +1 -1
  103. package/src/engine/animation/curve/AnimationCurve.js +43 -15
  104. package/src/engine/animation/curve/AnimationCurve.spec.js +67 -0
  105. package/src/engine/animation/curve/Keyframe.d.ts +24 -3
  106. package/src/engine/animation/curve/Keyframe.d.ts.map +1 -1
  107. package/src/engine/animation/curve/Keyframe.js +49 -3
  108. package/src/engine/animation/curve/Keyframe.spec.js +11 -0
  109. package/src/engine/animation/curve/animation_curve_compute_aabb.d.ts +7 -0
  110. package/src/engine/animation/curve/animation_curve_compute_aabb.d.ts.map +1 -0
  111. package/src/engine/animation/curve/{compute_curve_aabb.js → animation_curve_compute_aabb.js} +1 -1
  112. package/src/engine/animation/curve/animation_curve_optimize.d.ts +8 -0
  113. package/src/engine/animation/curve/animation_curve_optimize.d.ts.map +1 -0
  114. package/src/engine/animation/curve/animation_curve_optimize.js +89 -0
  115. package/src/engine/animation/curve/animation_curve_optimize.spec.d.ts +2 -0
  116. package/src/engine/animation/curve/animation_curve_optimize.spec.d.ts.map +1 -0
  117. package/src/engine/animation/curve/animation_curve_optimize.spec.js +50 -0
  118. package/src/engine/animation/curve/draw/build_curve_editor.js +2 -2
  119. package/src/engine/animation/curve/evaluate_two_key_curve.d.ts +9 -0
  120. package/src/engine/animation/curve/evaluate_two_key_curve.d.ts.map +1 -0
  121. package/src/engine/animation/curve/evaluate_two_key_curve.js +23 -0
  122. package/src/engine/animation/curve/prototypeGLTF.js +14 -14
  123. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.d.ts +6 -1
  124. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.d.ts.map +1 -1
  125. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.js +11 -6
  126. package/src/engine/ecs/guid/GUIDSerializationAdapter.spec.js +5 -5
  127. package/src/engine/ecs/guid/{GUID.d.ts → UUID.d.ts} +17 -12
  128. package/src/engine/ecs/guid/UUID.d.ts.map +1 -0
  129. package/src/engine/ecs/guid/{GUID.js → UUID.js} +35 -12
  130. package/src/engine/ecs/guid/UUID.spec.d.ts +2 -0
  131. package/src/engine/ecs/guid/UUID.spec.d.ts.map +1 -0
  132. package/src/engine/ecs/guid/{GUID.spec.js → UUID.spec.js} +18 -12
  133. package/src/engine/ecs/guid/UUIDSerializationAdapter.d.ts +18 -0
  134. package/src/engine/ecs/guid/UUIDSerializationAdapter.d.ts.map +1 -0
  135. package/src/engine/ecs/guid/{GUIDSerializationAdapter.js → UUIDSerializationAdapter.js} +5 -5
  136. package/src/engine/ecs/ik/InverseKinematics.js +3 -3
  137. package/src/engine/ecs/ik/TwoBoneInverseKinematicsSolver.d.ts.map +1 -1
  138. package/src/engine/ecs/ik/TwoBoneInverseKinematicsSolver.js +1 -140
  139. package/src/engine/input/ecs/systems/InputControllerSystem.js +1 -1
  140. package/src/engine/intelligence/blackboard/BlackboardDynamicStorageAdapter.d.ts +1 -1
  141. package/src/engine/intelligence/blackboard/BlackboardDynamicStorageAdapter.js +4 -4
  142. package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts +13 -0
  143. package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts.map +1 -0
  144. package/src/engine/physics/gjk/expanding_polytope_algorithm.js +395 -0
  145. package/src/engine/physics/gjk/expanding_polytope_algorithm.spec.d.ts +2 -0
  146. package/src/engine/physics/gjk/expanding_polytope_algorithm.spec.d.ts.map +1 -0
  147. package/src/engine/physics/gjk/expanding_polytope_algorithm.spec.js +46 -0
  148. package/src/engine/physics/inverse_kinematics/fabrik/fabrik3d_solve_primitive.d.ts +18 -0
  149. package/src/engine/physics/inverse_kinematics/fabrik/fabrik3d_solve_primitive.d.ts.map +1 -0
  150. package/src/engine/physics/inverse_kinematics/fabrik/fabrik3d_solve_primitive.js +277 -0
  151. package/src/engine/physics/inverse_kinematics/fabrik/fabrik3d_solve_primitive.spec.d.ts +2 -0
  152. package/src/engine/physics/inverse_kinematics/fabrik/fabrik3d_solve_primitive.spec.d.ts.map +1 -0
  153. package/src/engine/physics/inverse_kinematics/fabrik/fabrik3d_solve_primitive.spec.js +43 -0
  154. package/src/engine/physics/inverse_kinematics/fabrik/fabrik_solve.d.ts +12 -0
  155. package/src/engine/physics/inverse_kinematics/fabrik/fabrik_solve.d.ts.map +1 -0
  156. package/src/engine/physics/inverse_kinematics/fabrik/fabrik_solve.js +100 -0
  157. package/src/engine/physics/inverse_kinematics/fabrik/prototype.d.ts +2 -0
  158. package/src/engine/physics/inverse_kinematics/fabrik/prototype.d.ts.map +1 -0
  159. package/src/engine/physics/inverse_kinematics/fabrik/prototype.js +112 -0
  160. package/src/engine/physics/inverse_kinematics/two_joint_ik.d.ts +16 -0
  161. package/src/engine/physics/inverse_kinematics/two_joint_ik.d.ts.map +1 -0
  162. package/src/engine/physics/inverse_kinematics/two_joint_ik.js +127 -0
  163. package/src/view/elements/DropDownSelectionView.js +2 -2
  164. package/src/view/elements/tiles2d/Tile.d.ts.map +1 -1
  165. package/src/view/elements/tiles2d/Tile.js +2 -3
  166. package/src/core/math/makeSequenceLoop.d.ts.map +0 -1
  167. package/src/engine/animation/curve/compute_curve_aabb.d.ts +0 -7
  168. package/src/engine/animation/curve/compute_curve_aabb.d.ts.map +0 -1
  169. package/src/engine/ecs/guid/GUID.d.ts.map +0 -1
  170. package/src/engine/ecs/guid/GUID.spec.d.ts +0 -2
  171. package/src/engine/ecs/guid/GUID.spec.d.ts.map +0 -1
  172. package/src/engine/ecs/guid/GUIDSerializationAdapter.d.ts +0 -18
  173. package/src/engine/ecs/guid/GUIDSerializationAdapter.d.ts.map +0 -1
  174. /package/src/core/{math → function}/makeSequenceLoop.d.ts +0 -0
  175. /package/src/core/{math → function}/makeSequenceLoop.js +0 -0
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Will remove keyframes that do not affect shape of the curve significantly. The significance degree is determined by the error tolerance
3
+ * Intended to reduce complexity of a curve to improve performance and lower memory usage
4
+ * @param {AnimationCurve} curve
5
+ * @param {number} [error_tolerance] how much of a loss to accept, this is relative to normalized value bounds of the curve
6
+ */
7
+ export function animation_curve_optimize(curve: AnimationCurve, error_tolerance?: number): void;
8
+ //# sourceMappingURL=animation_curve_optimize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animation_curve_optimize.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/curve/animation_curve_optimize.js"],"names":[],"mappings":"AA0CA;;;;;GAKG;AACH,kFAFW,MAAM,QA0ChB"}
@@ -0,0 +1,89 @@
1
+ import { assert } from "../../../core/assert.js";
2
+ import AABB2 from "../../../core/geom/2d/aabb/AABB2.js";
3
+ import { animation_curve_compute_aabb } from "./animation_curve_compute_aabb.js";
4
+ import { evaluate_two_key_curve } from "./evaluate_two_key_curve.js";
5
+
6
+ const bounds = new AABB2();
7
+
8
+ const NORMALIZED_CHECK_DISTANCE = 0.07;
9
+
10
+ /**
11
+ * Compute value difference in the curve if the `middle` key between `previous` and `next` is removed
12
+ * @param {Keyframe} key_middle
13
+ * @param {Keyframe} key_previous
14
+ * @param {Keyframe} key_next
15
+ * @return {number} value delta if the middle frame is removed
16
+ */
17
+ function compute_keyframe_value_effect(key_middle, key_previous, key_next) {
18
+ // check if this key contributes to the shape
19
+ const v1_actual = evaluate_two_key_curve(key_middle.time, key_previous, key_next);
20
+ const v1_expected = key_middle.value;
21
+
22
+ const v1_error = Math.abs(v1_actual - v1_expected);
23
+
24
+ // sample just before the current frame
25
+ const v0_time = key_middle.time - (key_middle.time - key_previous.time) * NORMALIZED_CHECK_DISTANCE;
26
+
27
+ const v0_actual = evaluate_two_key_curve(v0_time, key_previous, key_next);
28
+ const v0_expected = evaluate_two_key_curve(v0_time, key_previous, key_middle);
29
+
30
+ const v0_error = Math.abs(v0_actual - v0_expected);
31
+
32
+ // sample just after the current frame
33
+ const v2_time = key_middle.time + (key_next.time - key_middle.time) * NORMALIZED_CHECK_DISTANCE;
34
+
35
+ const v2_actual = evaluate_two_key_curve(v2_time, key_previous, key_next);
36
+ const v2_expected = evaluate_two_key_curve(v2_time, key_middle, key_next);
37
+
38
+ const v2_error = Math.abs(v2_actual - v2_expected);
39
+
40
+ return Math.max(v0_error, v1_error, v2_error);
41
+ }
42
+
43
+ /**
44
+ * Will remove keyframes that do not affect shape of the curve significantly. The significance degree is determined by the error tolerance
45
+ * Intended to reduce complexity of a curve to improve performance and lower memory usage
46
+ * @param {AnimationCurve} curve
47
+ * @param {number} [error_tolerance] how much of a loss to accept, this is relative to normalized value bounds of the curve
48
+ */
49
+ export function animation_curve_optimize(curve, error_tolerance = 1e-3) {
50
+ assert.lessThan(error_tolerance, 1, 'error_tolerance must be less than 1');
51
+
52
+ animation_curve_compute_aabb(bounds, curve);
53
+
54
+ const absolute_error_tolerance = bounds.height * error_tolerance;
55
+
56
+ let key_count = curve.length;
57
+
58
+ const keyframes = curve.keys;
59
+
60
+ for (let i = 1; i < key_count; i++) {
61
+ const key_previous = keyframes[i - 1];
62
+ const key_current = keyframes[i];
63
+
64
+ let should_remove = false;
65
+
66
+ if (key_current.equals(key_previous)) {
67
+ // adds no semantic value
68
+ should_remove = true;
69
+ }
70
+
71
+ if (!should_remove && i < key_count - 1) {
72
+ const key_next = keyframes[i + 1];
73
+
74
+ const max_error = compute_keyframe_value_effect(key_current, key_previous, key_next);
75
+
76
+ if (max_error <= absolute_error_tolerance) {
77
+ // does not significantly affect the curve shape
78
+ should_remove = true;
79
+ }
80
+ }
81
+
82
+
83
+ if (should_remove) {
84
+ curve.remove(key_current);
85
+ i--;
86
+ key_count--;
87
+ }
88
+ }
89
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=animation_curve_optimize.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animation_curve_optimize.spec.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/curve/animation_curve_optimize.spec.js"],"names":[],"mappings":""}
@@ -0,0 +1,50 @@
1
+ import { animation_curve_optimize } from "./animation_curve_optimize.js";
2
+ import { AnimationCurve } from "./AnimationCurve.js";
3
+ import { Keyframe } from "./Keyframe.js";
4
+
5
+ test("single key", () => {
6
+
7
+ const curve = AnimationCurve.from([
8
+ Keyframe.from(1, -2, 3, -5)
9
+ ]);
10
+
11
+ animation_curve_optimize(curve);
12
+
13
+ expect(curve.keys.length).toBe(1);
14
+ });
15
+
16
+ test("repeated key", () => {
17
+
18
+ const curve = AnimationCurve.from([
19
+ Keyframe.from(1, -2, 3, -5),
20
+ Keyframe.from(1, -2, 3, -5),
21
+ Keyframe.from(1, -2, 3, -5)
22
+ ]);
23
+
24
+ animation_curve_optimize(curve);
25
+
26
+ expect(curve.equals(
27
+ AnimationCurve.from([
28
+ Keyframe.from(1, -2, 3, -5)
29
+ ])
30
+ )).toBe(true);
31
+ });
32
+
33
+ test("linear curve", () => {
34
+
35
+ const curve = AnimationCurve.from([
36
+ Keyframe.from(0, 0, 1, 1),
37
+ Keyframe.from(1, 1, 1, 1),
38
+ Keyframe.from(2, 2, 1, 1),
39
+ ])
40
+
41
+ animation_curve_optimize(curve);
42
+
43
+ expect(curve.equals(
44
+ AnimationCurve.from([
45
+ Keyframe.from(0, 0, 1, 1),
46
+ Keyframe.from(2, 2, 1, 1)
47
+ ])
48
+ )).toBe(true);
49
+
50
+ });
@@ -11,8 +11,8 @@ import { canvas2d_plot_data_line } from "../../../graphics/canvas/canvas2d_plot_
11
11
  import { MouseEvents } from "../../../input/devices/events/MouseEvents.js";
12
12
  import { readPositionFromMouseEvent } from "../../../input/devices/PointerDevice.js";
13
13
  import { DraggableAspect } from "../../../ui/DraggableAspect.js";
14
+ import { animation_curve_compute_aabb } from "../animation_curve_compute_aabb.js";
14
15
  import { sample_animation_curve_to_float_array } from "../compression/sample_animation_curve_to_float_array.js";
15
- import { compute_curve_aabb } from "../compute_curve_aabb.js";
16
16
  import { Keyframe } from "../Keyframe.js";
17
17
 
18
18
  /**
@@ -106,7 +106,7 @@ export function build_curve_editor({
106
106
  });
107
107
 
108
108
  function handle_curve_update() {
109
- compute_curve_aabb(frame, curve);
109
+ animation_curve_compute_aabb(frame, curve);
110
110
 
111
111
  frame_updated.send0();
112
112
 
@@ -0,0 +1,9 @@
1
+ /**
2
+ *
3
+ * @param {number} time
4
+ * @param {Keyframe} keyframe0
5
+ * @param {Keyframe} keyframe1
6
+ * @return {number}
7
+ */
8
+ export function evaluate_two_key_curve(time: number, keyframe0: Keyframe, keyframe1: Keyframe): number;
9
+ //# sourceMappingURL=evaluate_two_key_curve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate_two_key_curve.d.ts","sourceRoot":"","sources":["../../../../../src/engine/animation/curve/evaluate_two_key_curve.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,6CALW,MAAM,aACN,QAAQ,aACR,QAAQ,GACP,MAAM,CAcjB"}
@@ -0,0 +1,23 @@
1
+ import { inverseLerp } from "../../../core/math/inverseLerp.js";
2
+ import { spline_hermite3 } from "../../../core/math/spline/spline_hermite3.js";
3
+
4
+ /**
5
+ *
6
+ * @param {number} time
7
+ * @param {Keyframe} keyframe0
8
+ * @param {Keyframe} keyframe1
9
+ * @return {number}
10
+ */
11
+ export function evaluate_two_key_curve(time, keyframe0, keyframe1) {
12
+ // convert to 0..1 region
13
+ const normalized_time = inverseLerp(keyframe0.time, keyframe1.time, time);
14
+
15
+ const time_distance = keyframe1.time - keyframe0.time;
16
+
17
+ return spline_hermite3(
18
+ normalized_time,
19
+ keyframe0.value, keyframe1.value,
20
+ keyframe0.outTangent * time_distance,
21
+ keyframe1.inTangent * time_distance
22
+ );
23
+ }
@@ -38,17 +38,17 @@ async function main(engine) {
38
38
  yaw: 3.123185307179593,
39
39
  });
40
40
  //
41
- // make_sample('data/models/samples/InterpolationTest.glb',[
42
- // 'Step Scale',
43
- // 'Linear Scale',
44
- // 'CubicSpline Scale',
45
- // 'Step Rotation',
46
- // 'CubicSpline Rotation',
47
- // 'Linear Rotation',
48
- // 'Step Translation',
49
- // 'CubicSpline Translation',
50
- // 'Linear Translation'
51
- // ],engine.entityManager.dataset);
41
+ make_sample('data/models/samples/InterpolationTest.glb',[
42
+ 'Step Scale',
43
+ 'Linear Scale',
44
+ 'CubicSpline Scale',
45
+ 'Step Rotation',
46
+ 'CubicSpline Rotation',
47
+ 'Linear Rotation',
48
+ 'Step Translation',
49
+ 'CubicSpline Translation',
50
+ 'Linear Translation'
51
+ ],engine.entityManager.dataset);
52
52
 
53
53
  // make_sample('data/models/samples/BoxAnimated.glb',[
54
54
  // 'animation_0'
@@ -61,9 +61,9 @@ async function main(engine) {
61
61
  // make_sample('moicon/Separated_Cardboard-Box-800x600x400_Roughness0/V1 Cardboard B.gltf', [
62
62
  // 'All Animations'
63
63
  // ], engine.entityManager.dataset);
64
- make_sample('moicon/v26/v26.gltf', [
65
- 'All Animations'
66
- ], engine.entityManager.dataset);
64
+ // make_sample('moicon/v26/v26.gltf', [
65
+ // 'All Animations'
66
+ // ], engine.entityManager.dataset);
67
67
  }
68
68
 
69
69
  /**
@@ -1,5 +1,9 @@
1
1
  export class DynamicRuleDescription {
2
- id: number;
2
+ /**
3
+ *
4
+ * @type {UUID}
5
+ */
6
+ id: UUID;
3
7
  /**
4
8
  *
5
9
  * @type {ReactiveExpression}
@@ -51,5 +55,6 @@ export class DynamicRuleDescription {
51
55
  priority?: number;
52
56
  }): void;
53
57
  }
58
+ import { UUID } from "../../guid/UUID.js";
54
59
  import { DynamicRuleCooldownDescription } from "./DynamicRuleCooldownDescription.js";
55
60
  //# sourceMappingURL=DynamicRuleDescription.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DynamicRuleDescription.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.js"],"names":[],"mappings":"AAQA;IACI,WAAO;IACP;;;OAGG;IACH,8BAAiB;IACjB;;;OAGG;IACH,kCAAc;IACd;;;OAGG;IACH,YAFU,mBAAmB,CAEb;IAChB;;;OAGG;IACH,UAFU,MAAM,CAEH;IACb;;;OAGG;IACH,6BAAyB;IACzB;;;OAGG;IACH,kBAFU,8BAA8B,EAAE,CAEpB;IAEtB;;;;OAIG;IACH,cAHW,sBAAsB,GACpB,OAAO,CAInB;IAED;;;OAGG;IACH,0BAFa,MAAM,CAIlB;IAED,yCAEC;IAED,cA+BC;IAED;;;;;;aA2BC;CACJ;+CArH8C,qCAAqC"}
1
+ {"version":3,"file":"DynamicRuleDescription.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.js"],"names":[],"mappings":"AAQA;IACI;;;OAGG;IACH,IAFU,IAAI,CAEC;IAEf;;;OAGG;IACH,8BAAiB;IACjB;;;OAGG;IACH,kCAAc;IACd;;;OAGG;IACH,YAFU,mBAAmB,CAEb;IAChB;;;OAGG;IACH,UAFU,MAAM,CAEH;IACb;;;OAGG;IACH,6BAAyB;IACzB;;;OAGG;IACH,kBAFU,8BAA8B,EAAE,CAEpB;IAEtB;;;;OAIG;IACH,cAHW,sBAAsB,GACpB,OAAO,CAInB;IAED;;;OAGG;IACH,0BAFa,MAAM,CAIlB;IAED,yCAEC;IAED,cA+BC;IAED;;;;;;aA2BC;CACJ;qBA5HoB,oBAAoB;+CAEM,qCAAqC"}
@@ -1,13 +1,18 @@
1
- import UUID from "../../../../core/UUID.js";
2
1
  import { assert } from "../../../../core/assert.js";
2
+ import { compileReactiveExpression } from "../../../../core/lang/reactive/compileReactiveExpression.js";
3
3
  import { inferReactiveExpressionTypes } from "../../../../core/model/reactive/transform/ReactiveTypeInferrence.js";
4
4
  import DataType from "../../../../core/parser/simple/DataType.js";
5
- import { compileReactiveExpression } from "../../../../core/lang/reactive/compileReactiveExpression.js";
5
+ import { UUID } from "../../guid/UUID.js";
6
6
  import { deserializeActionFromJSON } from "../actions/definition/deserializeActionFromJSON.js";
7
7
  import { DynamicRuleCooldownDescription } from "./DynamicRuleCooldownDescription.js";
8
8
 
9
9
  export class DynamicRuleDescription {
10
- id = 0;
10
+ /**
11
+ *
12
+ * @type {UUID}
13
+ */
14
+ id = UUID.v1();
15
+
11
16
  /**
12
17
  *
13
18
  * @type {ReactiveExpression}
@@ -45,7 +50,7 @@ export class DynamicRuleDescription {
45
50
  * @returns {boolean}
46
51
  */
47
52
  equals(other) {
48
- return this.id === other.id;
53
+ return this.id.equals(other.id);
49
54
  }
50
55
 
51
56
  /**
@@ -94,7 +99,7 @@ export class DynamicRuleDescription {
94
99
  }
95
100
 
96
101
  fromJSON({
97
- id = UUID.generate(),
102
+ id = UUID.v1().toString(),
98
103
  condition,
99
104
  action,
100
105
  global_cooldowns = [],
@@ -113,7 +118,7 @@ export class DynamicRuleDescription {
113
118
 
114
119
  this.action = deserializeActionFromJSON(action);
115
120
 
116
- this.id = id;
121
+ this.id.parse(id);
117
122
 
118
123
  this.priority = priority;
119
124
 
@@ -1,19 +1,19 @@
1
- import { GUID } from "./GUID.js";
2
- import { GUIDSerializationAdapter } from "./GUIDSerializationAdapter.js";
3
1
  import { BinaryBuffer } from "../../../core/binary/BinaryBuffer.js";
2
+ import { UUID } from "./UUID.js";
3
+ import { UUIDSerializationAdapter } from "./UUIDSerializationAdapter.js";
4
4
 
5
5
  test("to/from consistency", () => {
6
6
 
7
- const source = GUID.parse("a88bb73a-c89f-11ed-afa1-0242ac120002");
7
+ const source = UUID.parse("a88bb73a-c89f-11ed-afa1-0242ac120002");
8
8
 
9
- const adapter = new GUIDSerializationAdapter();
9
+ const adapter = new UUIDSerializationAdapter();
10
10
 
11
11
  const buffer = new BinaryBuffer();
12
12
 
13
13
  adapter.serialize(buffer, source);
14
14
  buffer.position = 0; // rewind
15
15
 
16
- const destination = new GUID();
16
+ const destination = new UUID();
17
17
 
18
18
  adapter.deserialize(buffer, destination);
19
19
 
@@ -2,18 +2,19 @@
2
2
  * Globally unique identifier
3
3
  * @class
4
4
  */
5
- export class GUID {
5
+ export class UUID {
6
6
  /**
7
7
  *
8
- * @return {GUID}
8
+ * @return {UUID}
9
9
  */
10
- static v1(): GUID;
10
+ static v1(): UUID;
11
+ static v4(): UUID;
11
12
  /**
12
13
  *
13
14
  * @param {string} string
14
- * @return {GUID}
15
+ * @return {UUID}
15
16
  */
16
- static parse(string: string): GUID;
17
+ static parse(string: string): UUID;
17
18
  /**
18
19
  *
19
20
  * @param {number[]|Uint8Array|ArrayLike<number>} bytes
@@ -29,6 +30,10 @@ export class GUID {
29
30
  * @see https://github.com/uuidjs/uuid/blob/8f028c4ea42ce41a9a9dc5fa634abe525b2e2066/src/v1.js#L17
30
31
  */
31
32
  v1(): void;
33
+ /**
34
+ * Generate Variant 4 UUID (fully random)
35
+ */
36
+ v4(): void;
32
37
  /***
33
38
  * String in UUID format
34
39
  * @see https://github.com/uuidjs/uuid/blob/8f028c4ea42ce41a9a9dc5fa634abe525b2e2066/src/parse.js#L3
@@ -42,15 +47,15 @@ export class GUID {
42
47
  toString(): string;
43
48
  /**
44
49
  *
45
- * @param {GUID} other
50
+ * @param {UUID} other
46
51
  */
47
- copy(other: GUID): void;
52
+ copy(other: UUID): void;
48
53
  /**
49
54
  *
50
- * @param {GUID} other
55
+ * @param {UUID} other
51
56
  * @returns {boolean}
52
57
  */
53
- equals(other: GUID): boolean;
58
+ equals(other: UUID): boolean;
54
59
  /**
55
60
  * @returns {number}
56
61
  */
@@ -61,10 +66,10 @@ export class GUID {
61
66
  * @readonly
62
67
  * @type {boolean}
63
68
  */
64
- readonly isGUID: boolean;
69
+ readonly isUUID: boolean;
65
70
  #private;
66
71
  }
67
- export namespace GUID {
72
+ export namespace UUID {
68
73
  let typeName: string;
69
74
  }
70
- //# sourceMappingURL=GUID.d.ts.map
75
+ //# sourceMappingURL=UUID.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UUID.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/guid/UUID.js"],"names":[],"mappings":"AAuBA;;;GAGG;AACH;IAgHI;;;OAGG;IACH,aAFY,IAAI,CAQf;IAED,kBAMC;IA0CD;;;;OAIG;IACH,qBAHW,MAAM,GACL,IAAI,CAQf;IApLD;;;OAGG;IACH,0BAKC;IAED;;;OAGG;IACH,uBAEC;IAED;;;OAGG;IACH,WAqEC;IAED;;OAEG;IACH,WAUC;IAsBD;;;;OAIG;IACH,cAFW,MAAM,QAmChB;IAeD;;;OAGG;IACH,YAFa,MAAM,CA2BlB;IAED;;;OAGG;IACH,YAFW,IAAI,QAId;IAED;;;;OAIG;IACH,cAHW,IAAI,GACF,OAAO,CAanB;IAED;;OAEG;IACH,QAFa,MAAM,CAWlB;IAED,iBAEC;IAED,uBAEC;IASL;;;OAGG;IACH,iBAFU,OAAO,CAEI;;CAZpB;;kBAIS,MAAM"}
@@ -1,9 +1,9 @@
1
- import { seededRandom } from "../../../core/math/random/seededRandom.js";
2
- import { randomUint8 } from "../../../core/math/random/randomUint8.js";
1
+ import { assert } from "../../../core/assert.js";
3
2
  import { dec2hex } from "../../../core/binary/dec2hex.js";
4
3
  import { array_copy } from "../../../core/collection/array/array_copy.js";
5
4
  import { randomBytes } from "../../../core/math/random/randomBytes.js";
6
- import { assert } from "../../../core/assert.js";
5
+ import { randomUint8 } from "../../../core/math/random/randomUint8.js";
6
+ import { seededRandom } from "../../../core/math/random/seededRandom.js";
7
7
 
8
8
  // Previous uuid creation time
9
9
  let _lastMSecs = 0;
@@ -25,7 +25,7 @@ let _clockseq = ((randomUint8(random) << 8) | randomUint8(random)) & 0x3fff;
25
25
  * Globally unique identifier
26
26
  * @class
27
27
  */
28
- export class GUID {
28
+ export class UUID {
29
29
  #data = new Uint8Array(16);
30
30
 
31
31
  /**
@@ -122,18 +122,41 @@ export class GUID {
122
122
  }
123
123
  }
124
124
 
125
+ /**
126
+ * Generate Variant 4 UUID (fully random)
127
+ */
128
+ v4() {
129
+
130
+ const data = this.data;
131
+
132
+ randomBytes(data, 0, random, 16);
133
+
134
+ // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
135
+ data[6] = (data[6] & 0x0f) | 0x40;
136
+ data[8] = (data[8] & 0x3f) | 0x80;
137
+
138
+ }
139
+
125
140
  /**
126
141
  *
127
- * @return {GUID}
142
+ * @return {UUID}
128
143
  */
129
144
  static v1() {
130
- const uuid = new GUID();
145
+ const uuid = new UUID();
131
146
 
132
147
  uuid.v1();
133
148
 
134
149
  return uuid;
135
150
  }
136
151
 
152
+ static v4() {
153
+ const r = new UUID();
154
+
155
+ r.v4();
156
+
157
+ return r;
158
+ }
159
+
137
160
  /***
138
161
  * String in UUID format
139
162
  * @see https://github.com/uuidjs/uuid/blob/8f028c4ea42ce41a9a9dc5fa634abe525b2e2066/src/parse.js#L3
@@ -177,10 +200,10 @@ export class GUID {
177
200
  /**
178
201
  *
179
202
  * @param {string} string
180
- * @return {GUID}
203
+ * @return {UUID}
181
204
  */
182
205
  static parse(string) {
183
- const r = new GUID();
206
+ const r = new UUID();
184
207
 
185
208
  r.parse(string);
186
209
 
@@ -220,7 +243,7 @@ export class GUID {
220
243
 
221
244
  /**
222
245
  *
223
- * @param {GUID} other
246
+ * @param {UUID} other
224
247
  */
225
248
  copy(other) {
226
249
  this.#data.set(other.#data);
@@ -228,7 +251,7 @@ export class GUID {
228
251
 
229
252
  /**
230
253
  *
231
- * @param {GUID} other
254
+ * @param {UUID} other
232
255
  * @returns {boolean}
233
256
  */
234
257
  equals(other) {
@@ -271,10 +294,10 @@ export class GUID {
271
294
  * @readonly
272
295
  * @type {string}
273
296
  */
274
- GUID.typeName = "GUID";
297
+ UUID.typeName = "UUID";
275
298
 
276
299
  /**
277
300
  * @readonly
278
301
  * @type {boolean}
279
302
  */
280
- GUID.prototype.isGUID = true;
303
+ UUID.prototype.isUUID = true;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=UUID.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UUID.spec.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/guid/UUID.spec.js"],"names":[],"mappings":""}
@@ -1,15 +1,15 @@
1
- import { GUID } from "./GUID.js";
1
+ import { UUID } from "./UUID.js";
2
2
 
3
3
  test("uniqueness out of 2", () => {
4
- const a = GUID.v1();
5
- const b = GUID.v1();
4
+ const a = UUID.v1();
5
+ const b = UUID.v1();
6
6
 
7
7
  expect(a.equals(b)).toBe(false);
8
8
  });
9
9
 
10
10
  test("equality", () => {
11
- const a = GUID.parse("a88bb73a-c89f-11ed-afa1-0242ac120002");
12
- const b = GUID.parse("a88bb73a-c89f-11ed-afa1-0242ac120002");
11
+ const a = UUID.parse("a88bb73a-c89f-11ed-afa1-0242ac120002");
12
+ const b = UUID.parse("a88bb73a-c89f-11ed-afa1-0242ac120002");
13
13
 
14
14
  expect(a.equals(b)).toBe(true);
15
15
 
@@ -19,16 +19,16 @@ test("equality", () => {
19
19
  });
20
20
 
21
21
  test("hash stability", () => {
22
- const guid = new GUID();
22
+ const guid = new UUID();
23
23
 
24
24
  expect(guid.hash()).toBe(guid.hash());
25
25
  });
26
26
 
27
27
  test("copy", () => {
28
- const a = GUID.parse("a88bb73a-c89f-11ed-afa1-0242ac120002");
28
+ const a = UUID.parse("a88bb73a-c89f-11ed-afa1-0242ac120002");
29
29
  const a_string = a.toString();
30
30
 
31
- const b = GUID.parse("bb75b300-c89f-11ed-afa1-0242ac120002");
31
+ const b = UUID.parse("bb75b300-c89f-11ed-afa1-0242ac120002");
32
32
 
33
33
  expect(a.equals(b)).toBe(false);
34
34
 
@@ -41,9 +41,9 @@ test("copy", () => {
41
41
  });
42
42
 
43
43
  test("to/from JSON consistency", () => {
44
- const a = GUID.parse("bb75b300-c89f-11ed-afa1-0242ac120002");
44
+ const a = UUID.parse("bb75b300-c89f-11ed-afa1-0242ac120002");
45
45
 
46
- const b = new GUID();
46
+ const b = new UUID();
47
47
 
48
48
  b.fromJSON(a.toJSON());
49
49
 
@@ -51,7 +51,7 @@ test("to/from JSON consistency", () => {
51
51
  });
52
52
 
53
53
  test(".data setter performs a copy instead of assignment", () => {
54
- const id = new GUID();
54
+ const id = new UUID();
55
55
 
56
56
  const data = new Uint8Array(16);
57
57
 
@@ -61,7 +61,7 @@ test(".data setter performs a copy instead of assignment", () => {
61
61
  });
62
62
 
63
63
  test(".data set/get", () => {
64
- const a = new GUID();
64
+ const a = new UUID();
65
65
 
66
66
  const sample_0 = [
67
67
  0xFF, 0xFF, 0xFF, 0xFF,
@@ -85,3 +85,9 @@ test(".data set/get", () => {
85
85
 
86
86
  expect(Array.from(a.data)).toEqual(sample_1);
87
87
  });
88
+
89
+ test("version bits in v4", () => {
90
+ const uuid = UUID.v4();
91
+
92
+ expect((uuid.data[6] >> 4) & 0xF).toEqual(4);
93
+ });
@@ -0,0 +1,18 @@
1
+ export class UUIDSerializationAdapter extends BinaryClassSerializationAdapter {
2
+ klass: typeof UUID;
3
+ /**
4
+ *
5
+ * @param buffer
6
+ * @param {UUID} value
7
+ */
8
+ serialize(buffer: any, value: UUID): void;
9
+ /**
10
+ *
11
+ * @param buffer
12
+ * @param {UUID} value
13
+ */
14
+ deserialize(buffer: any, value: UUID): void;
15
+ }
16
+ import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
17
+ import { UUID } from "./UUID.js";
18
+ //# sourceMappingURL=UUIDSerializationAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UUIDSerializationAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/guid/UUIDSerializationAdapter.js"],"names":[],"mappings":"AAGA;IACI,mBAAY;IAGZ;;;;OAIG;IACH,8BAFW,IAAI,QAId;IAED;;;;OAIG;IACH,gCAFW,IAAI,QAId;CACJ;gDAxB+C,sDAAsD;qBACjF,WAAW"}