@woosh/meep-engine 2.84.8 → 2.84.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 (42) hide show
  1. package/README.md +27 -13
  2. package/build/meep.cjs +213 -140
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +213 -140
  5. package/editor/process/symbolic/makePositionedIconDisplaySymbol.js +2 -4
  6. package/editor/view/EditorView.js +48 -204
  7. package/editor/view/ecs/HierarchicalEntityListView.js +191 -0
  8. package/editor/view/ecs/HierarchicalEntityListView.module.scss +13 -0
  9. package/editor/view/prepareMeshLibrary.js +178 -0
  10. package/editor/view/v2/SplitView.js +104 -0
  11. package/editor/view/v2/ViewManagementSystem.js +0 -0
  12. package/editor/view/v2/prototypeEditor.js +127 -0
  13. package/package.json +10 -5
  14. package/src/core/cache/Cache.d.ts +2 -0
  15. package/src/core/cache/Cache.js +58 -8
  16. package/src/core/cache/Cache.spec.js +38 -0
  17. package/src/core/cache/CacheElement.js +6 -0
  18. package/src/core/cache/LoadingCache.js +27 -3
  19. package/src/core/cache/LoadingCache.spec.js +22 -7
  20. package/src/core/collection/array/arraySetSortingDiff.js +6 -6
  21. package/src/core/collection/table/RowFirstTable.js +364 -368
  22. package/src/core/geom/3d/SurfacePoint3.js +3 -40
  23. package/src/core/geom/3d/plane/plane3_compute_ray_intersection.js +3 -1
  24. package/src/core/geom/3d/topology/simplify/prototypeMeshSimplification.js +7 -7
  25. package/src/core/geom/Vector3.js +25 -14
  26. package/src/core/model/stat/LinearModifier.spec.js +5 -6
  27. package/src/core/process/PromiseWatcher.spec.js +27 -23
  28. package/src/engine/animation/behavior/animateProperty.js +4 -4
  29. package/src/engine/animation/curve/ecd_bind_animation_curve.js +9 -0
  30. package/src/engine/ecs/EntityReference.js +12 -0
  31. package/src/engine/ecs/dynamic_actions/actions/definition/SpeakLineActionDescription.js +1 -1
  32. package/src/engine/ecs/transform/Transform.js +1 -1
  33. package/src/engine/ecs/transform/Transform.spec.js +44 -0
  34. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometryFlags.js +8 -1
  35. package/src/engine/graphics/ecs/mesh-v2/aggregate/prototypeSGMesh.js +23 -19
  36. package/src/engine/graphics/ecs/mesh-v2/sg_hierarchy_compute_bounding_box_via_parent_entity.js +2 -2
  37. package/src/engine/graphics/ecs/mesh-v2/three_object_to_entity_composition.js +3 -1
  38. package/src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js +6 -6
  39. package/src/engine/intelligence/behavior/ecs/SendEventBehavior.js +43 -0
  40. package/src/view/View.js +64 -95
  41. package/src/view/setElementTransform.js +20 -0
  42. package/src/view/setElementVisibility.js +15 -0
@@ -1,6 +1,7 @@
1
1
  //
2
2
 
3
3
  import { assert } from "../assert.js";
4
+ import { returnZero } from "../function/returnZero.js";
4
5
  import { current_time_in_seconds } from "../time/current_time_in_seconds.js";
5
6
  import { Cache } from "./Cache.js";
6
7
 
@@ -17,6 +18,7 @@ class Record {
17
18
  this.value = value;
18
19
  this.time = time;
19
20
  this.failed = false;
21
+ this.weight = 0;
20
22
  }
21
23
  }
22
24
 
@@ -27,6 +29,15 @@ class Record {
27
29
  */
28
30
  const DEFAULT_TIME_TO_LIVE = Infinity;
29
31
 
32
+ /**
33
+ * @template T
34
+ * @param {Record<T>} record
35
+ * @returns {number}
36
+ */
37
+ function record_get_value_weight(record) {
38
+ return record.weight;
39
+ }
40
+
30
41
  /**
31
42
  * Asynchronous cache capable of resolving its own values by keys
32
43
  * Modelled on Guava's LoadingCache concept
@@ -54,6 +65,11 @@ export class LoadingCache {
54
65
  * @type {boolean}
55
66
  */
56
67
  #policyRetryFailed = true;
68
+ /**
69
+ *
70
+ * @type {function(V): number}
71
+ */
72
+ #value_weigher;
57
73
 
58
74
  /**
59
75
  * @see {@link Cache} for more details on what each parameter means
@@ -71,7 +87,7 @@ export class LoadingCache {
71
87
  constructor({
72
88
  maxWeight,
73
89
  keyWeigher,
74
- valueWeigher,
90
+ valueWeigher = returnZero,
75
91
  keyHashFunction,
76
92
  keyEqualityFunction,
77
93
  capacity,
@@ -85,7 +101,7 @@ export class LoadingCache {
85
101
  this.#internal = new Cache({
86
102
  maxWeight,
87
103
  keyWeigher,
88
- valueWeigher,
104
+ valueWeigher: record_get_value_weight,
89
105
  keyHashFunction,
90
106
  keyEqualityFunction,
91
107
  capacity,
@@ -94,14 +110,16 @@ export class LoadingCache {
94
110
  this.#timeToLive = timeToLive;
95
111
  this.#load = load;
96
112
  this.#policyRetryFailed = retryFailed;
113
+ this.#value_weigher = valueWeigher;
97
114
  }
98
115
 
99
116
  /**
100
117
  *
101
118
  * @param {K} key
119
+ * @returns {boolean}
102
120
  */
103
121
  invalidate(key) {
104
- this.#internal.remove(key);
122
+ return this.#internal.remove(key);
105
123
  }
106
124
 
107
125
  /**
@@ -131,6 +149,12 @@ export class LoadingCache {
131
149
 
132
150
  this.#internal.put(key, record);
133
151
 
152
+ promise.then((value) => {
153
+ // re-score value based on actual data
154
+ record.weight = this.#value_weigher(value);
155
+ this.#internal.updateElementWeight(key);
156
+ });
157
+
134
158
  promise.catch(() => {
135
159
  // mark as failure
136
160
  record.failed = true;
@@ -1,5 +1,5 @@
1
- import { LoadingCache } from "./LoadingCache.js";
2
1
  import { delay } from "../process/delay.js";
2
+ import { LoadingCache } from "./LoadingCache.js";
3
3
 
4
4
  test("successful load", async () => {
5
5
  const cache = new LoadingCache({
@@ -11,6 +11,18 @@ test("successful load", async () => {
11
11
  expect(await cache.get(1)).toEqual(17);
12
12
  });
13
13
 
14
+ test("when loader throws an exception, we should get a failed promise", async () => {
15
+ const cache = new LoadingCache({
16
+ load(key) {
17
+ throw 1;
18
+ }
19
+ });
20
+
21
+ const promise = cache.get("a");
22
+
23
+ await expect(promise).rejects.toEqual(1);
24
+ });
25
+
14
26
  test("record reuse", async () => {
15
27
  const load = jest.fn(async () => 17);
16
28
 
@@ -32,18 +44,21 @@ test("timeout reload reuse", async () => {
32
44
 
33
45
  const cache = new LoadingCache({
34
46
  load,
35
- timeToLive: 0.00001
47
+ timeToLive: 0.0000001
36
48
  });
37
49
 
38
- expect(await cache.get(1)).toEqual(11);
50
+ const request_1 = await cache.get(1);
51
+ expect(request_1).toEqual(11);
39
52
 
40
- await delay(1);
53
+ await delay(2);
41
54
 
42
- expect(await cache.get(1)).toEqual(5);
55
+ const request_2 = await cache.get(1);
56
+ expect(request_2).toEqual(5);
43
57
 
44
- await delay(1);
58
+ await delay(2);
45
59
 
46
- expect(await cache.get(1)).toEqual(3);
60
+ const request_3 = await cache.get(1);
61
+ expect(request_3).toEqual(3);
47
62
  });
48
63
 
49
64
  test("insert element directly", async () => {
@@ -22,17 +22,17 @@ export function arraySetSortingDiff(a, b, compare) {
22
22
 
23
23
  const common = [];
24
24
 
25
- let lA = uniqueA.length;
26
- let lB = uniqueB.length;
25
+ let length_a = uniqueA.length;
26
+ let length_b = uniqueB.length;
27
27
 
28
28
  let i;
29
29
  let j;
30
30
  let cursor_j = 0;
31
31
 
32
- for (i = 0; i < lA; i++) {
32
+ for (i = 0; i < length_a; i++) {
33
33
  const el_a = uniqueA[i];
34
34
 
35
- for (j = cursor_j; j < lB; j++) {
35
+ for (j = cursor_j; j < length_b; j++) {
36
36
  const el_b = uniqueB[j];
37
37
 
38
38
  const diff = compare(el_a, el_b);
@@ -46,8 +46,8 @@ export function arraySetSortingDiff(a, b, compare) {
46
46
  i--;
47
47
  j--;
48
48
 
49
- lA--;
50
- lB--;
49
+ length_a--;
50
+ length_b--;
51
51
 
52
52
  } else if (diff > 0) {
53
53
  cursor_j++;