@woosh/meep-engine 2.84.5 → 2.84.8

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 (27) hide show
  1. package/build/meep.cjs +139 -84
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +139 -84
  4. package/package.json +1 -1
  5. package/src/core/collection/array/arrayIndexByEquality.js +1 -0
  6. package/src/core/collection/list/List.js +26 -18
  7. package/src/core/collection/list/List.spec.js +73 -0
  8. package/src/core/primitives/numbers/number_count_decimals.js +30 -0
  9. package/src/core/primitives/numbers/number_pretty_print.js +7 -29
  10. package/src/core/primitives/strings/string_format_camel_to_kebab.js +2 -0
  11. package/src/core/primitives/strings/string_strip_trailing.js +22 -0
  12. package/src/core/primitives/strings/string_strip_trailing.spec.js +27 -0
  13. package/src/core/process/worker/WorkerBuilder.js +5 -1
  14. package/src/core/process/worker/WorkerProxy.js +3 -2
  15. package/src/engine/ecs/Entity.spec.js +33 -0
  16. package/src/engine/ecs/EntityComponentDataset.js +17 -11
  17. package/src/engine/ecs/storage/BinaryBufferDeSerializer.js +8 -1
  18. package/src/engine/graphics/camera/CameraShake.js +1 -127
  19. package/src/engine/graphics/camera/CameraShakeBehavior.js +91 -0
  20. package/src/engine/graphics/camera/CameraShakeTraumaBehavior.js +38 -0
  21. package/src/engine/graphics/ecs/animation/animator/AnimationGraphSystem.js +9 -23
  22. package/src/engine/graphics/ecs/animation/animator/blending/BlendStateMatrix.js +11 -6
  23. package/src/engine/graphics/ecs/animation/animator/graph/AnimationGraph.js +20 -12
  24. package/src/engine/graphics/ecs/animation/animator/graph/AnimationState.js +3 -3
  25. package/src/engine/graphics/ecs/path/tube/build/estimatePathViaIterativeIntegral.js +1 -1
  26. package/src/view/View.js +52 -30
  27. package/src/view/writeCssTransformMatrix.js +26 -0
package/src/view/View.js CHANGED
@@ -3,15 +3,18 @@
3
3
  * @copyright Alex Goldring 2018
4
4
  */
5
5
 
6
- import Vector2 from "../core/geom/Vector2.js";
7
-
8
- import AABB2 from "../core/geom/2d/aabb/AABB2.js";
6
+ import { assert } from "../core/assert.js";
9
7
  import Signal from "../core/events/signal/Signal.js";
10
8
  import { SignalBinding } from "../core/events/signal/SignalBinding.js";
11
- import { assert } from "../core/assert.js";
12
- import Vector1 from "../core/geom/Vector1.js";
9
+
10
+ import AABB2 from "../core/geom/2d/aabb/AABB2.js";
13
11
 
14
12
  import { m3_cm_compose_transform } from "../core/geom/mat3/m3_cm_compose_transform.js";
13
+ import Vector1 from "../core/geom/Vector1.js";
14
+ import Vector2 from "../core/geom/Vector2.js";
15
+ import { epsilonEquals } from "../core/math/epsilonEquals.js";
16
+ import { FLT_EPSILON_32 } from "../core/math/FLT_EPSILON_32.js";
17
+ import { writeCssTransformMatrix } from "./writeCssTransformMatrix.js";
15
18
 
16
19
 
17
20
  const scratch_m3_0 = new Float32Array(9);
@@ -29,26 +32,7 @@ function setElementTransform(domElement, position, scale, rotation) {
29
32
 
30
33
  m3_cm_compose_transform(m3, position.x, position.y, scale.x, scale.y, 0, 0, rotation);
31
34
 
32
-
33
- /*
34
- * CSS matrix is:
35
- * a c e
36
- * b d f
37
- * 0 0 1
38
- */
39
-
40
- const a = m3[0];
41
- const b = m3[3];
42
- const c = m3[1];
43
- const d = m3[4];
44
- const e = m3[2];
45
- const f = m3[5];
46
-
47
- const transform = "matrix(" + a + ',' + b + ',' + c + ',' + d + ',' + e + ',' + f + ")";
48
-
49
- const style = domElement.style;
50
-
51
- style.transform = transform;
35
+ writeCssTransformMatrix(m3, domElement);
52
36
  }
53
37
 
54
38
  /**
@@ -88,6 +72,9 @@ const INITIAL_FLAGS = ViewFlags.Visible;
88
72
  * @class
89
73
  */
90
74
  class View {
75
+ #transform_written = new Float32Array(9);
76
+ #transform_current = new Float32Array(9);
77
+
91
78
  /**
92
79
  * @constructor
93
80
  */
@@ -112,31 +99,32 @@ class View {
112
99
  this.flags = INITIAL_FLAGS;
113
100
 
114
101
  /**
115
- *
102
+ * @readonly
116
103
  * @type {Vector2}
117
104
  */
118
105
  const position = this.position = new Vector2(0, 0);
119
106
 
120
107
  /**
121
- *
108
+ * @readonly
122
109
  * @type {Vector1}
123
110
  */
124
111
  const rotation = this.rotation = new Vector1(0);
125
112
 
126
113
  /**
127
- *
114
+ * @readonly
128
115
  * @type {Vector2}
129
116
  */
130
117
  const scale = this.scale = new Vector2(1, 1);
131
118
 
132
119
  /**
133
- *
120
+ * @readonly
134
121
  * @type {Vector2}
135
122
  */
136
123
  const size = this.size = new Vector2(0, 0);
137
124
 
138
125
  /**
139
126
  * Origin from which rotation and scaling is applied
127
+ * @readonly
140
128
  * @type {Vector2}
141
129
  */
142
130
  this.transformOrigin = new Vector2(0.5, 0.5);
@@ -274,7 +262,41 @@ class View {
274
262
  * @private
275
263
  */
276
264
  __updateTransform() {
277
- setElementTransform(this.el, this.position, this.scale, this.rotation.getValue());
265
+ const position = this.position;
266
+ const scale = this.scale;
267
+ const rotation = this.rotation.getValue();
268
+
269
+ m3_cm_compose_transform(this.#transform_current, position.x, position.y, scale.x, scale.y, 0, 0, rotation);
270
+
271
+ this.#tryWriteTransform();
272
+ }
273
+
274
+ #tryWriteTransform() {
275
+
276
+ const current = this.#transform_current;
277
+ const written = this.#transform_written;
278
+
279
+ for (let i = 0; i < 9; i++) {
280
+ const a = current[i];
281
+ const b = written[i];
282
+
283
+ if (epsilonEquals(a, b, FLT_EPSILON_32)) {
284
+ // common path
285
+ continue;
286
+ }
287
+
288
+ this.#writeTransform();
289
+ return true;
290
+
291
+ }
292
+
293
+ return false;
294
+ }
295
+
296
+ #writeTransform() {
297
+ writeCssTransformMatrix(this.#transform_current, this.el);
298
+
299
+ this.#transform_written.set(this.#transform_current);
278
300
  }
279
301
 
280
302
  /**
@@ -0,0 +1,26 @@
1
+ /**
2
+ *
3
+ * @param {Float32Array} m3
4
+ * @param {HTMLElement} domElement
5
+ */
6
+ export function writeCssTransformMatrix(m3, domElement) {
7
+ /*
8
+ * CSS matrix is:
9
+ * a c e
10
+ * b d f
11
+ * 0 0 1
12
+ */
13
+
14
+ const a = m3[0];
15
+ const b = m3[3];
16
+ const c = m3[1];
17
+ const d = m3[4];
18
+ const e = m3[2];
19
+ const f = m3[5];
20
+
21
+ const transform = "matrix(" + a + ',' + b + ',' + c + ',' + d + ',' + e + ',' + f + ")";
22
+
23
+ const style = domElement.style;
24
+
25
+ style.transform = transform;
26
+ }