@woosh/meep-engine 2.110.8 → 2.110.10

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 (210) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +116 -107
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +116 -107
  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/2d/aabb/AABB2.d.ts.map +1 -1
  28. package/src/core/geom/2d/aabb/AABB2.js +27 -1
  29. package/src/core/geom/3d/shape/AbstractShape3D.d.ts.map +1 -1
  30. package/src/core/geom/3d/shape/AbstractShape3D.js +14 -0
  31. package/src/core/geom/3d/shape/PointShape3D.d.ts +9 -0
  32. package/src/core/geom/3d/shape/PointShape3D.d.ts.map +1 -0
  33. package/src/core/geom/3d/shape/PointShape3D.js +14 -0
  34. package/src/core/geom/3d/shape/TransformedShape3D.d.ts.map +1 -1
  35. package/src/core/geom/3d/shape/TransformedShape3D.js +26 -8
  36. package/src/core/geom/3d/shape/UnionShape3D.d.ts.map +1 -1
  37. package/src/core/geom/3d/shape/UnionShape3D.js +33 -4
  38. package/src/core/geom/3d/shape/UnitCubeShape3D.d.ts.map +1 -1
  39. package/src/core/geom/3d/shape/UnitCubeShape3D.js +13 -6
  40. package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts.map +1 -1
  41. package/src/core/geom/3d/shape/UnitSphereShape3D.js +10 -0
  42. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts +15 -8
  43. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts.map +1 -1
  44. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +33 -9
  45. package/src/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.d.ts +1 -1
  46. package/src/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.d.ts.map +1 -1
  47. package/src/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js +7 -7
  48. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.spec.d.ts +2 -0
  49. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.spec.d.ts.map +1 -0
  50. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.spec.js +61 -0
  51. package/src/core/geom/3d/tetrahedra/get_tetrahedron_volume.d.ts +9 -0
  52. package/src/core/geom/3d/tetrahedra/get_tetrahedron_volume.d.ts.map +1 -0
  53. package/src/core/geom/3d/tetrahedra/get_tetrahedron_volume.js +18 -0
  54. package/src/core/geom/3d/tetrahedra/is_tetrahedron_degenerate.d.ts +9 -0
  55. package/src/core/geom/3d/tetrahedra/is_tetrahedron_degenerate.d.ts.map +1 -0
  56. package/src/core/geom/3d/tetrahedra/is_tetrahedron_degenerate.js +21 -0
  57. package/src/core/geom/3d/tetrahedra/validate_tetrahedral_mesh.d.ts +2 -10
  58. package/src/core/geom/3d/tetrahedra/validate_tetrahedral_mesh.d.ts.map +1 -1
  59. package/src/core/geom/3d/tetrahedra/validate_tetrahedral_mesh.js +3 -40
  60. package/src/core/geom/3d/v3_compute_triangle_normal.js +1 -1
  61. package/src/core/geom/3d/v3_negate_array.d.ts +9 -0
  62. package/src/core/geom/3d/v3_negate_array.d.ts.map +1 -0
  63. package/src/core/geom/3d/v3_negate_array.js +16 -0
  64. package/src/core/geom/Quaternion.d.ts.map +1 -1
  65. package/src/core/geom/Quaternion.js +30 -77
  66. package/src/core/geom/Vector3.d.ts +4 -0
  67. package/src/core/geom/Vector3.js +4 -4
  68. package/src/core/geom/mat3/m3_cm_invert.d.ts +7 -0
  69. package/src/core/geom/mat3/m3_cm_invert.d.ts.map +1 -0
  70. package/src/core/geom/mat3/m3_cm_invert.js +45 -0
  71. package/src/core/geom/vec2/v2_matrix3_cm_multiply.d.ts +10 -0
  72. package/src/core/geom/vec2/v2_matrix3_cm_multiply.d.ts.map +1 -0
  73. package/src/core/geom/vec2/v2_matrix3_cm_multiply.js +20 -0
  74. package/src/core/geom/vec2/v2_matrix3_rm_multiply.d.ts +10 -0
  75. package/src/core/geom/vec2/v2_matrix3_rm_multiply.d.ts.map +1 -0
  76. package/src/core/geom/vec2/v2_matrix3_rm_multiply.js +21 -0
  77. package/src/core/geom/vec3/v3_cross_array.d.ts +11 -0
  78. package/src/core/geom/vec3/v3_cross_array.d.ts.map +1 -0
  79. package/src/core/geom/vec3/v3_cross_array.js +31 -0
  80. package/src/core/geom/vec3/v3_displace_in_direction.js +3 -2
  81. package/src/core/geom/vec3/v3_displace_in_direction_array.d.ts +12 -0
  82. package/src/core/geom/vec3/v3_displace_in_direction_array.d.ts.map +1 -0
  83. package/src/core/geom/vec3/v3_displace_in_direction_array.js +22 -0
  84. package/src/core/geom/vec3/v3_dot_array_array.d.ts.map +1 -1
  85. package/src/core/geom/vec3/v3_dot_array_array.js +4 -1
  86. package/src/core/geom/vec3/v3_normalize_array.d.ts +3 -3
  87. package/src/core/geom/vec3/v3_normalize_array.d.ts.map +1 -1
  88. package/src/core/geom/vec3/v3_normalize_array.js +3 -3
  89. package/src/core/math/copysign.d.ts +1 -1
  90. package/src/core/math/copysign.js +1 -1
  91. package/src/core/math/epsilonEquals.d.ts.map +1 -1
  92. package/src/core/math/epsilonEquals.js +3 -2
  93. package/src/core/math/linalg/README.md +1 -1
  94. package/src/core/math/random/randomGaussian.spec.js +1 -1
  95. package/src/core/math/spline/spline_hermite3.d.ts +1 -1
  96. package/src/core/math/spline/spline_hermite3.js +3 -2
  97. package/src/core/math/spline/spline_hermite3_to_bezier.d.ts +12 -0
  98. package/src/core/math/spline/spline_hermite3_to_bezier.d.ts.map +1 -0
  99. package/src/core/math/spline/spline_hermite3_to_bezier.js +24 -0
  100. package/src/core/process/delay.d.ts +6 -1
  101. package/src/core/process/delay.d.ts.map +1 -1
  102. package/src/core/process/delay.js +6 -1
  103. package/src/core/process/undo/Mark.d.ts +5 -5
  104. package/src/core/process/undo/Mark.d.ts.map +1 -1
  105. package/src/core/process/undo/Mark.js +6 -5
  106. package/src/core/process/worker/WorkerBuilder.d.ts +13 -2
  107. package/src/core/process/worker/WorkerBuilder.d.ts.map +1 -1
  108. package/src/core/process/worker/WorkerBuilder.js +8 -0
  109. package/src/core/process/worker/WorkerProxy.d.ts +16 -6
  110. package/src/core/process/worker/WorkerProxy.d.ts.map +1 -1
  111. package/src/core/process/worker/WorkerProxy.js +24 -5
  112. package/src/engine/EngineHarness.d.ts +7 -1
  113. package/src/engine/EngineHarness.d.ts.map +1 -1
  114. package/src/engine/EngineHarness.js +12 -1
  115. package/src/engine/animation/clip/AnimationTrack.d.ts.map +1 -1
  116. package/src/engine/animation/clip/AnimationTrack.js +4 -1
  117. package/src/engine/animation/clip/bind_property_writer.d.ts +2 -2
  118. package/src/engine/animation/clip/bind_property_writer.d.ts.map +1 -1
  119. package/src/engine/animation/clip/bind_property_writer.js +22 -13
  120. package/src/engine/animation/clip/curve_from_track_data.d.ts.map +1 -1
  121. package/src/engine/animation/clip/curve_from_track_data.js +9 -1
  122. package/src/engine/animation/clip/ecd_bind_animation_curve.d.ts.map +1 -1
  123. package/src/engine/animation/clip/ecd_bind_animation_curve.js +6 -5
  124. package/src/engine/animation/curve/AnimationCurve.d.ts +32 -0
  125. package/src/engine/animation/curve/AnimationCurve.d.ts.map +1 -1
  126. package/src/engine/animation/curve/AnimationCurve.js +94 -19
  127. package/src/engine/animation/curve/AnimationCurve.spec.js +67 -0
  128. package/src/engine/animation/curve/Keyframe.d.ts +24 -3
  129. package/src/engine/animation/curve/Keyframe.d.ts.map +1 -1
  130. package/src/engine/animation/curve/Keyframe.js +49 -3
  131. package/src/engine/animation/curve/Keyframe.spec.js +11 -0
  132. package/src/engine/animation/curve/animation_curve_compute_aabb.d.ts +7 -0
  133. package/src/engine/animation/curve/animation_curve_compute_aabb.d.ts.map +1 -0
  134. package/src/engine/animation/curve/{compute_curve_aabb.js → animation_curve_compute_aabb.js} +1 -1
  135. package/src/engine/animation/curve/animation_curve_optimize.d.ts +8 -0
  136. package/src/engine/animation/curve/animation_curve_optimize.d.ts.map +1 -0
  137. package/src/engine/animation/curve/animation_curve_optimize.js +89 -0
  138. package/src/engine/animation/curve/animation_curve_optimize.spec.d.ts +2 -0
  139. package/src/engine/animation/curve/animation_curve_optimize.spec.d.ts.map +1 -0
  140. package/src/engine/animation/curve/animation_curve_optimize.spec.js +50 -0
  141. package/src/engine/animation/curve/draw/build_curve_editor.d.ts.map +1 -1
  142. package/src/engine/animation/curve/draw/build_curve_editor.js +17 -11
  143. package/src/engine/animation/curve/evaluate_two_key_curve.d.ts +9 -0
  144. package/src/engine/animation/curve/evaluate_two_key_curve.d.ts.map +1 -0
  145. package/src/engine/animation/curve/evaluate_two_key_curve.js +23 -0
  146. package/src/engine/animation/curve/prototypeGLTF.js +14 -14
  147. package/src/engine/animation/curve/view/AnimationCurveView.d.ts +47 -0
  148. package/src/engine/animation/curve/view/AnimationCurveView.d.ts.map +1 -0
  149. package/src/engine/animation/curve/view/AnimationCurveView.js +343 -0
  150. package/src/engine/animation/curve/view/prototype.d.ts +2 -0
  151. package/src/engine/animation/curve/view/prototype.d.ts.map +1 -0
  152. package/src/engine/animation/curve/view/prototype.js +86 -0
  153. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.d.ts +6 -1
  154. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.d.ts.map +1 -1
  155. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.js +11 -6
  156. package/src/engine/ecs/guid/{GUID.d.ts → UUID.d.ts} +27 -15
  157. package/src/engine/ecs/guid/UUID.d.ts.map +1 -0
  158. package/src/engine/ecs/guid/{GUID.js → UUID.js} +52 -17
  159. package/src/engine/ecs/guid/UUID.spec.d.ts +2 -0
  160. package/src/engine/ecs/guid/UUID.spec.d.ts.map +1 -0
  161. package/src/engine/ecs/guid/{GUID.spec.js → UUID.spec.js} +25 -12
  162. package/src/engine/ecs/guid/UUIDSerializationAdapter.d.ts +18 -0
  163. package/src/engine/ecs/guid/UUIDSerializationAdapter.d.ts.map +1 -0
  164. package/src/engine/ecs/guid/{GUIDSerializationAdapter.js → UUIDSerializationAdapter.js} +5 -5
  165. package/src/engine/ecs/guid/UUIDSerializationAdapter.spec.d.ts +2 -0
  166. package/src/engine/ecs/guid/UUIDSerializationAdapter.spec.d.ts.map +1 -0
  167. package/src/engine/ecs/guid/{GUIDSerializationAdapter.spec.js → UUIDSerializationAdapter.spec.js} +5 -5
  168. package/src/engine/ecs/ik/InverseKinematics.js +3 -3
  169. package/src/engine/ecs/ik/TwoBoneInverseKinematicsSolver.d.ts.map +1 -1
  170. package/src/engine/ecs/ik/TwoBoneInverseKinematicsSolver.js +1 -140
  171. package/src/engine/input/ecs/systems/InputControllerSystem.js +1 -1
  172. package/src/engine/intelligence/blackboard/BlackboardDynamicStorageAdapter.d.ts +1 -1
  173. package/src/engine/intelligence/blackboard/BlackboardDynamicStorageAdapter.js +4 -4
  174. package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts +13 -0
  175. package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts.map +1 -0
  176. package/src/engine/physics/gjk/expanding_polytope_algorithm.js +395 -0
  177. package/src/engine/physics/gjk/expanding_polytope_algorithm.spec.d.ts +2 -0
  178. package/src/engine/physics/gjk/expanding_polytope_algorithm.spec.d.ts.map +1 -0
  179. package/src/engine/physics/gjk/expanding_polytope_algorithm.spec.js +46 -0
  180. package/src/engine/physics/inverse_kinematics/fabrik/fabrik3d_solve_primitive.d.ts +18 -0
  181. package/src/engine/physics/inverse_kinematics/fabrik/fabrik3d_solve_primitive.d.ts.map +1 -0
  182. package/src/engine/physics/inverse_kinematics/fabrik/fabrik3d_solve_primitive.js +277 -0
  183. package/src/engine/physics/inverse_kinematics/fabrik/fabrik3d_solve_primitive.spec.d.ts +2 -0
  184. package/src/engine/physics/inverse_kinematics/fabrik/fabrik3d_solve_primitive.spec.d.ts.map +1 -0
  185. package/src/engine/physics/inverse_kinematics/fabrik/fabrik3d_solve_primitive.spec.js +43 -0
  186. package/src/engine/physics/inverse_kinematics/fabrik/fabrik_solve.d.ts +12 -0
  187. package/src/engine/physics/inverse_kinematics/fabrik/fabrik_solve.d.ts.map +1 -0
  188. package/src/engine/physics/inverse_kinematics/fabrik/fabrik_solve.js +100 -0
  189. package/src/engine/physics/inverse_kinematics/fabrik/prototype.d.ts +2 -0
  190. package/src/engine/physics/inverse_kinematics/fabrik/prototype.d.ts.map +1 -0
  191. package/src/engine/physics/inverse_kinematics/fabrik/prototype.js +112 -0
  192. package/src/engine/physics/inverse_kinematics/two_joint_ik.d.ts +16 -0
  193. package/src/engine/physics/inverse_kinematics/two_joint_ik.d.ts.map +1 -0
  194. package/src/engine/physics/inverse_kinematics/two_joint_ik.js +127 -0
  195. package/src/view/elements/DropDownSelectionView.js +2 -2
  196. package/src/view/elements/tiles2d/Tile.d.ts +1 -1
  197. package/src/view/elements/tiles2d/Tile.d.ts.map +1 -1
  198. package/src/view/elements/tiles2d/Tile.js +3 -3
  199. package/src/core/math/makeSequenceLoop.d.ts.map +0 -1
  200. package/src/engine/animation/curve/compute_curve_aabb.d.ts +0 -7
  201. package/src/engine/animation/curve/compute_curve_aabb.d.ts.map +0 -1
  202. package/src/engine/ecs/guid/GUID.d.ts.map +0 -1
  203. package/src/engine/ecs/guid/GUID.spec.d.ts +0 -2
  204. package/src/engine/ecs/guid/GUID.spec.d.ts.map +0 -1
  205. package/src/engine/ecs/guid/GUIDSerializationAdapter.d.ts +0 -18
  206. package/src/engine/ecs/guid/GUIDSerializationAdapter.d.ts.map +0 -1
  207. package/src/engine/ecs/guid/GUIDSerializationAdapter.spec.d.ts +0 -2
  208. package/src/engine/ecs/guid/GUIDSerializationAdapter.spec.d.ts.map +0 -1
  209. /package/src/core/{math → function}/makeSequenceLoop.d.ts +0 -0
  210. /package/src/core/{math → function}/makeSequenceLoop.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prototype.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/animation/curve/view/prototype.js"],"names":[],"mappings":""}
@@ -0,0 +1,86 @@
1
+ import { randomFloatBetween } from "../../../../core/math/random/randomFloatBetween.js";
2
+ import { seededRandom } from "../../../../core/math/random/seededRandom.js";
3
+ import { CSS_ABSOLUTE_POSITIONING } from "../../../../view/CSS_ABSOLUTE_POSITIONING.js";
4
+ import { AnimationCurve } from "../AnimationCurve.js";
5
+ import { Keyframe } from "../Keyframe.js";
6
+ import { AnimationCurveView } from "./AnimationCurveView.js";
7
+
8
+ let px = 0;
9
+ let py = 0;
10
+
11
+ function addCurve(curve) {
12
+
13
+
14
+ const view = new AnimationCurveView();
15
+ view.curve = curve;
16
+
17
+ view.css(CSS_ABSOLUTE_POSITIONING);
18
+
19
+ view.size.set(460, 288);
20
+
21
+ if (px + view.size.x > window.innerWidth) {
22
+ px = 0;
23
+ py += view.size.y;
24
+ }
25
+
26
+ view.position.set(px, py);
27
+
28
+ px += view.size.x;
29
+
30
+
31
+ document.body.appendChild(view.el);
32
+
33
+ view.css({
34
+ border: "1px solid rgba(255,255,255,0.2)"
35
+ });
36
+
37
+ view.link();
38
+
39
+ }
40
+
41
+ document.body.style.background = "black";
42
+ document.body.style.overflow = "hidden";
43
+ document.body.style.margin = "0";
44
+
45
+ addCurve(AnimationCurve.constant());
46
+ addCurve(AnimationCurve.easeInOut(0,0,1000));
47
+ addCurve(AnimationCurve.linear());
48
+ addCurve(AnimationCurve.from([
49
+ Keyframe.from(0, 0),
50
+ Keyframe.from(1, 1),
51
+ Keyframe.from(2, 0.5)
52
+ ]));
53
+
54
+
55
+ addCurve(AnimationCurve.from([
56
+ Keyframe.from(-5, 7),
57
+ Keyframe.from(-2, -11)
58
+ ]));
59
+ addCurve(AnimationCurve.from([
60
+ Keyframe.from(-1, 1),
61
+ Keyframe.from(1, -1)
62
+ ]));
63
+
64
+
65
+ addCurve(AnimationCurve.from([
66
+ Keyframe.from(-5, 0),
67
+ Keyframe.from(1, 200)
68
+ ]));
69
+
70
+ const random = seededRandom();
71
+
72
+ const array = new Array(8).fill('');
73
+ const keys = array.map(()=> Keyframe.from(
74
+ randomFloatBetween(random,-100,100),
75
+ randomFloatBetween(random,-100,100),
76
+ ));
77
+
78
+ const curve = AnimationCurve.from(keys);
79
+
80
+ for (let i = 0; i < keys.length; i++) {
81
+
82
+ curve.alignTangents(i);
83
+ }
84
+ curve.smoothAllTangents();
85
+
86
+ addCurve(curve)
@@ -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.string(),
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,27 @@
1
1
  /**
2
- * Globally unique identifier
3
- * @class
2
+ * Universally Unique Identifier
3
+ * @see IETF RFC 4122
4
+ *
4
5
  */
5
- export class GUID {
6
+ export class UUID {
6
7
  /**
7
8
  *
8
- * @return {GUID}
9
+ * @return {UUID}
9
10
  */
10
- static v1(): GUID;
11
+ static v1(): UUID;
12
+ static v4(): UUID;
13
+ /**
14
+ * Shortcut to generate string-form ID
15
+ * Uses v4 UUID
16
+ * @return {string}
17
+ */
18
+ static string(): string;
11
19
  /**
12
20
  *
13
21
  * @param {string} string
14
- * @return {GUID}
22
+ * @return {UUID}
15
23
  */
16
- static parse(string: string): GUID;
24
+ static parse(string: string): UUID;
17
25
  /**
18
26
  *
19
27
  * @param {number[]|Uint8Array|ArrayLike<number>} bytes
@@ -26,9 +34,13 @@ export class GUID {
26
34
  get data(): Uint8Array;
27
35
  /**
28
36
  * Generate Variant 1 UUID
29
- * @see https://github.com/uuidjs/uuid/blob/8f028c4ea42ce41a9a9dc5fa634abe525b2e2066/src/v1.js#L17
37
+ *
30
38
  */
31
39
  v1(): void;
40
+ /**
41
+ * Generate Variant 4 UUID (fully random)
42
+ */
43
+ v4(): void;
32
44
  /***
33
45
  * String in UUID format
34
46
  * @see https://github.com/uuidjs/uuid/blob/8f028c4ea42ce41a9a9dc5fa634abe525b2e2066/src/parse.js#L3
@@ -42,15 +54,15 @@ export class GUID {
42
54
  toString(): string;
43
55
  /**
44
56
  *
45
- * @param {GUID} other
57
+ * @param {UUID} other
46
58
  */
47
- copy(other: GUID): void;
59
+ copy(other: UUID): void;
48
60
  /**
49
61
  *
50
- * @param {GUID} other
62
+ * @param {UUID} other
51
63
  * @returns {boolean}
52
64
  */
53
- equals(other: GUID): boolean;
65
+ equals(other: UUID): boolean;
54
66
  /**
55
67
  * @returns {number}
56
68
  */
@@ -61,10 +73,10 @@ export class GUID {
61
73
  * @readonly
62
74
  * @type {boolean}
63
75
  */
64
- readonly isGUID: boolean;
76
+ readonly isUUID: boolean;
65
77
  #private;
66
78
  }
67
- export namespace GUID {
79
+ export namespace UUID {
68
80
  let typeName: string;
69
81
  }
70
- //# sourceMappingURL=GUID.d.ts.map
82
+ //# 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":"AAwBA;;;;GAIG;AACH;IAiHI;;;OAGG;IACH,aAFY,IAAI,CAQf;IAED,kBAMC;IAED;;;;OAIG;IACH,iBAFY,MAAM,CAIjB;IA0CD;;;;OAIG;IACH,qBAHW,MAAM,GACL,IAAI,CAQf;IA9LD;;;OAGG;IACH,0BAKC;IAED;;;OAGG;IACH,uBAEC;IAED;;;OAGG;IACH,WAsEC;IAED;;OAEG;IACH,WAUC;IA+BD;;;;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,14 +1,15 @@
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;
10
10
  let _lastNSecs = 0;
11
11
 
12
+ // seed random with current time to lower potential correlation
12
13
  const random = seededRandom(Date.now());
13
14
 
14
15
  // node and clockseq need to be initialized to random values.
@@ -22,10 +23,11 @@ _nodeId[0] |= 0x01;
22
23
  let _clockseq = ((randomUint8(random) << 8) | randomUint8(random)) & 0x3fff;
23
24
 
24
25
  /**
25
- * Globally unique identifier
26
- * @class
26
+ * Universally Unique Identifier
27
+ * @see IETF RFC 4122
28
+ *
27
29
  */
28
- export class GUID {
30
+ export class UUID {
29
31
  #data = new Uint8Array(16);
30
32
 
31
33
  /**
@@ -34,7 +36,7 @@ export class GUID {
34
36
  */
35
37
  set data(bytes) {
36
38
  assert.isArrayLike(bytes, 'bytes');
37
- assert.greaterThanOrEqual(bytes.length, 16, 'bytes.length >= 16');
39
+ assert.greaterThanOrEqual(bytes.length, 16, 'bytes.length < 16');
38
40
 
39
41
  array_copy(bytes, 0, this.#data, 0, 16);
40
42
  }
@@ -49,9 +51,10 @@ export class GUID {
49
51
 
50
52
  /**
51
53
  * Generate Variant 1 UUID
52
- * @see https://github.com/uuidjs/uuid/blob/8f028c4ea42ce41a9a9dc5fa634abe525b2e2066/src/v1.js#L17
54
+ *
53
55
  */
54
56
  v1() {
57
+ // @see https://github.com/uuidjs/uuid/blob/8f028c4ea42ce41a9a9dc5fa634abe525b2e2066/src/v1.js#L17
55
58
 
56
59
  const b = this.#data;
57
60
 
@@ -83,7 +86,7 @@ export class GUID {
83
86
 
84
87
  // Per 4.2.1.2 Throw error if too many uuids are requested
85
88
  if (nsecs >= 10000) {
86
- throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
89
+ throw new Error(".v1(): Can't create more than 10M uuids/sec");
87
90
  }
88
91
 
89
92
  _lastMSecs = msecs;
@@ -122,18 +125,50 @@ export class GUID {
122
125
  }
123
126
  }
124
127
 
128
+ /**
129
+ * Generate Variant 4 UUID (fully random)
130
+ */
131
+ v4() {
132
+
133
+ const data = this.data;
134
+
135
+ randomBytes(data, 0, random, 16);
136
+
137
+ // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
138
+ data[6] = (data[6] & 0x0f) | 0x40;
139
+ data[8] = (data[8] & 0x3f) | 0x80;
140
+
141
+ }
142
+
125
143
  /**
126
144
  *
127
- * @return {GUID}
145
+ * @return {UUID}
128
146
  */
129
147
  static v1() {
130
- const uuid = new GUID();
148
+ const uuid = new UUID();
131
149
 
132
150
  uuid.v1();
133
151
 
134
152
  return uuid;
135
153
  }
136
154
 
155
+ static v4() {
156
+ const r = new UUID();
157
+
158
+ r.v4();
159
+
160
+ return r;
161
+ }
162
+
163
+ /**
164
+ * Shortcut to generate string-form ID
165
+ * Uses v4 UUID
166
+ * @return {string}
167
+ */
168
+ static string() {
169
+ return UUID.v4().toString();
170
+ }
171
+
137
172
  /***
138
173
  * String in UUID format
139
174
  * @see https://github.com/uuidjs/uuid/blob/8f028c4ea42ce41a9a9dc5fa634abe525b2e2066/src/parse.js#L3
@@ -177,10 +212,10 @@ export class GUID {
177
212
  /**
178
213
  *
179
214
  * @param {string} string
180
- * @return {GUID}
215
+ * @return {UUID}
181
216
  */
182
217
  static parse(string) {
183
- const r = new GUID();
218
+ const r = new UUID();
184
219
 
185
220
  r.parse(string);
186
221
 
@@ -220,7 +255,7 @@ export class GUID {
220
255
 
221
256
  /**
222
257
  *
223
- * @param {GUID} other
258
+ * @param {UUID} other
224
259
  */
225
260
  copy(other) {
226
261
  this.#data.set(other.#data);
@@ -228,7 +263,7 @@ export class GUID {
228
263
 
229
264
  /**
230
265
  *
231
- * @param {GUID} other
266
+ * @param {UUID} other
232
267
  * @returns {boolean}
233
268
  */
234
269
  equals(other) {
@@ -271,10 +306,10 @@ export class GUID {
271
306
  * @readonly
272
307
  * @type {string}
273
308
  */
274
- GUID.typeName = "GUID";
309
+ UUID.typeName = "UUID";
275
310
 
276
311
  /**
277
312
  * @readonly
278
313
  * @type {boolean}
279
314
  */
280
- GUID.prototype.isGUID = true;
315
+ 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,16 @@ 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
+ });
94
+
95
+ test("static 'string' method",()=>{
96
+ const s = UUID.string();
97
+
98
+ expect(typeof s).toBe("string");
99
+ expect(s.length).toBe(36);
100
+ });
@@ -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"}
@@ -1,14 +1,14 @@
1
1
  import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
2
- import { GUID } from "./GUID.js";
2
+ import { UUID } from "./UUID.js";
3
3
 
4
- export class GUIDSerializationAdapter extends BinaryClassSerializationAdapter {
5
- klass = GUID
4
+ export class UUIDSerializationAdapter extends BinaryClassSerializationAdapter {
5
+ klass = UUID
6
6
  version = 0
7
7
 
8
8
  /**
9
9
  *
10
10
  * @param buffer
11
- * @param {GUID} value
11
+ * @param {UUID} value
12
12
  */
13
13
  serialize(buffer, value) {
14
14
  buffer.writeUint8Array(value.data, 0, 16);
@@ -17,7 +17,7 @@ export class GUIDSerializationAdapter extends BinaryClassSerializationAdapter {
17
17
  /**
18
18
  *
19
19
  * @param buffer
20
- * @param {GUID} value
20
+ * @param {UUID} value
21
21
  */
22
22
  deserialize(buffer, value) {
23
23
  buffer.readUint8Array(value.data, 0, 16);
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=UUIDSerializationAdapter.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UUIDSerializationAdapter.spec.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/guid/UUIDSerializationAdapter.spec.js"],"names":[],"mappings":""}
@@ -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
 
@@ -16,11 +16,11 @@ export class InverseKinematics {
16
16
  copy(other) {
17
17
  this.constraints.splice(0, this.constraints.length);
18
18
 
19
- const ikConstraints = other.constraints;
20
- const n = ikConstraints.length;
19
+ const other_constraints = other.constraints;
20
+ const n = other_constraints.length;
21
21
 
22
22
  for (let i = 0; i < n; i++) {
23
- const constraint = ikConstraints[i];
23
+ const constraint = other_constraints[i];
24
24
 
25
25
  const constraintClone = constraint.clone();
26
26
 
@@ -1 +1 @@
1
- {"version":3,"file":"TwoBoneInverseKinematicsSolver.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/ik/TwoBoneInverseKinematicsSolver.js"],"names":[],"mappings":"AAyLA;IAGI,0BAuIC;CACJ;yBAzTwB,eAAe"}
1
+ {"version":3,"file":"TwoBoneInverseKinematicsSolver.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/ik/TwoBoneInverseKinematicsSolver.js"],"names":[],"mappings":"AA8CA;IAGI,0BAuIC;CACJ;yBA9KwB,eAAe"}