@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
@@ -2638,35 +2638,32 @@ let Vector3$1 = class Vector3 {
2638
2638
 
2639
2639
  /**
2640
2640
  *
2641
- * @param {ArrayList<number>|number[]|Float32Array} m4
2641
+ * @param {ArrayLike<number>|number[]|Float32Array} m4
2642
2642
  */
2643
2643
  applyMatrix4(m4) {
2644
2644
  const x = this.x;
2645
2645
  const y = this.y;
2646
2646
  const z = this.z;
2647
2647
 
2648
- const _x = m4[0] * x + m4[4] * y + m4[8] * z + m4[12];
2649
- const _y = m4[1] * x + m4[5] * y + m4[9] * z + m4[13];
2650
- const _z = m4[2] * x + m4[6] * y + m4[10] * z + m4[14];
2648
+ const w = 1 / (m4[3] * x + m4[7] * y + m4[11] * z + m4[15]);
2649
+
2650
+ const _x = (m4[0] * x + m4[4] * y + m4[8] * z + m4[12])* w;
2651
+ const _y = (m4[1] * x + m4[5] * y + m4[9] * z + m4[13])* w;
2652
+ const _z = (m4[2] * x + m4[6] * y + m4[10] * z + m4[14])* w;
2651
2653
 
2652
2654
  this.set(_x, _y, _z);
2653
2655
  }
2654
2656
 
2655
2657
  /**
2656
2658
  * Assume current vector holds a direction, transform using a matrix to produce a new directional unit vector
2657
- * @param {THREE.Matrix4} m
2659
+ * @param {ArrayLike<number>|number[]|Float32Array} m4
2658
2660
  */
2659
- transformDirection_three(m) {
2660
-
2661
- // input: THREE.Matrix4 affine matrix
2662
- // vector interpreted as a direction
2663
-
2661
+ applyDirectionMatrix4(m4){
2664
2662
  const x = this.x, y = this.y, z = this.z;
2665
- const e = m.elements;
2666
2663
 
2667
- const _x = e[0] * x + e[4] * y + e[8] * z;
2668
- const _y = e[1] * x + e[5] * y + e[9] * z;
2669
- const _z = e[2] * x + e[6] * y + e[10] * z;
2664
+ const _x = m4[0] * x + m4[4] * y + m4[8] * z;
2665
+ const _y = m4[1] * x + m4[5] * y + m4[9] * z;
2666
+ const _z = m4[2] * x + m4[6] * y + m4[10] * z;
2670
2667
 
2671
2668
  // normalize the result
2672
2669
  const _l = 1 / v3_length(_x, _y, _z);
@@ -2678,6 +2675,20 @@ let Vector3$1 = class Vector3 {
2678
2675
  );
2679
2676
  }
2680
2677
 
2678
+ /**
2679
+ * @deprecated use non-three.js version instead
2680
+ * @param {THREE.Matrix4} m
2681
+ */
2682
+ transformDirection_three(m) {
2683
+
2684
+ // input: THREE.Matrix4 affine matrix
2685
+ // vector interpreted as a direction
2686
+
2687
+ const e = m.elements;
2688
+
2689
+ this.applyDirectionMatrix4(e);
2690
+ }
2691
+
2681
2692
  /**
2682
2693
  *
2683
2694
  * @param {THREE.Matrix3} m
@@ -4741,7 +4752,7 @@ class Transform {
4741
4752
  get forward() {
4742
4753
  const result = Vector3$1.forward.clone();
4743
4754
 
4744
- result.applyMatrix4(this.matrix);
4755
+ result.applyDirectionMatrix4(this.matrix);
4745
4756
 
4746
4757
  return result;
4747
4758
  }
@@ -47189,44 +47200,8 @@ class SurfacePoint3 {
47189
47200
  */
47190
47201
  applyMatrix4(m) {
47191
47202
 
47192
- // transform position
47193
- const p = this.position;
47194
-
47195
- const p_x = p.x;
47196
- const p_y = p.y;
47197
- const p_z = p.z;
47198
-
47199
- // compute perspective projection
47200
- const w = 1 / (m[3] * p_x + m[7] * p_y + m[11] * p_z + m[15]);
47201
-
47202
- const result_p_x = (m[0] * p_x + m[4] * p_y + m[8] * p_z + m[12]) * w;
47203
- const result_p_y = (m[1] * p_x + m[5] * p_y + m[9] * p_z + m[13]) * w;
47204
- const result_p_z = (m[2] * p_x + m[6] * p_y + m[10] * p_z + m[14]) * w;
47205
-
47206
- p.set(
47207
- result_p_x,
47208
- result_p_y,
47209
- result_p_z
47210
- );
47211
-
47212
- // transform normal
47213
- const n = this.normal;
47214
-
47215
- const n_x = n.x;
47216
- const n_y = n.y;
47217
- const n_z = n.z;
47218
-
47219
- const result_n_x = m[0] * n_x + m[4] * n_y + m[8] * n_z;
47220
- const result_n_y = m[1] * n_x + m[5] * n_y + m[9] * n_z;
47221
- const result_n_z = m[2] * n_x + m[6] * n_y + m[10] * n_z;
47222
-
47223
- const normal_multiplier = 1 / v3_length(result_n_x, result_n_y, result_n_z);
47224
-
47225
- n.set(
47226
- result_n_x * normal_multiplier,
47227
- result_n_y * normal_multiplier,
47228
- result_n_z * normal_multiplier,
47229
- );
47203
+ this.position.applyMatrix4(m);
47204
+ this.normal.applyDirectionMatrix4(m);
47230
47205
  }
47231
47206
 
47232
47207
  /**
@@ -60603,6 +60578,12 @@ class CacheElement {
60603
60578
  */
60604
60579
  this.value = null;
60605
60580
 
60581
+ /**
60582
+ *
60583
+ * @type {number}
60584
+ */
60585
+ this.weight = 0;
60586
+
60606
60587
  /**
60607
60588
  * Link to next element (implements linked list)
60608
60589
  * @type {CacheElement<Key,Value>|null}
@@ -60791,14 +60772,56 @@ class Cache {
60791
60772
  recomputeWeight() {
60792
60773
  let result = 0;
60793
60774
 
60794
- for (let [key, value] of this.data) {
60795
- result += this.keyWeigher(key);
60796
- result += this.valueWeigher(value);
60775
+ for (let [key, record] of this.data) {
60776
+
60777
+ const weight = this.computeElementWeight(key, record.value);
60778
+ record.weight = weight;
60779
+
60780
+ result += weight;
60797
60781
  }
60798
60782
 
60799
60783
  this.weight = result;
60800
60784
  }
60801
60785
 
60786
+ /**
60787
+ * Useful when working with wrapped value types, where contents can change and affect overall weight
60788
+ * Instead of re-inserting element, we can just update weights
60789
+ * NOTE: this method may trigger eviction
60790
+ * @param {Key} key
60791
+ * @returns {boolean} true when weight successfully updated, false if element was not found in cache
60792
+ */
60793
+ updateElementWeight(key) {
60794
+ const record = this.data.get(key);
60795
+
60796
+ if (record === undefined) {
60797
+ return false;
60798
+ }
60799
+
60800
+ const old_weight = record.weight;
60801
+
60802
+ const new_weight = this.computeElementWeight(key, record.value);
60803
+
60804
+ if (new_weight === old_weight) {
60805
+ // we're done, no change
60806
+ return true;
60807
+ }
60808
+
60809
+ record.weight = new_weight;
60810
+
60811
+ const delta_weight = new_weight - old_weight;
60812
+
60813
+ this.weight += delta_weight;
60814
+
60815
+ if (
60816
+ this.weight > this.maxWeight
60817
+ && new_weight >= this.maxWeight //make it less likely to drop entire cache
60818
+ ) {
60819
+ this.evictUntilWeight(this.maxWeight);
60820
+ }
60821
+
60822
+ return true;
60823
+ }
60824
+
60802
60825
  /**
60803
60826
  * @private
60804
60827
  * @param {Key} key
@@ -60806,7 +60829,11 @@ class Cache {
60806
60829
  * @returns {number}
60807
60830
  */
60808
60831
  computeElementWeight(key, value) {
60809
- return this.keyWeigher(key) + this.valueWeigher(value);
60832
+ const key_weight = this.keyWeigher(key);
60833
+
60834
+ const value_weight = this.valueWeigher(value);
60835
+
60836
+ return key_weight + value_weight;
60810
60837
  }
60811
60838
 
60812
60839
  /**
@@ -60879,6 +60906,9 @@ class Cache {
60879
60906
  //compute weight
60880
60907
  const elementWeight = this.computeElementWeight(key, value);
60881
60908
 
60909
+ element.weight = elementWeight;
60910
+
60911
+
60882
60912
  /**
60883
60913
  * It's possible that element being added is larger than cache's capacity,
60884
60914
  * in which case entire cache will be evicted, but there still won't be enough space
@@ -60972,7 +61002,7 @@ class Cache {
60972
61002
  * @private
60973
61003
  */
60974
61004
  __removeElement(element) {
60975
- const value = element.value;
61005
+ element.value;
60976
61006
 
60977
61007
  // remove from the queue
60978
61008
  if (element === this.__first) {
@@ -60987,14 +61017,11 @@ class Cache {
60987
61017
 
60988
61018
  const key = element.key;
60989
61019
 
60990
- //compute weight
60991
- const elementWeight = this.computeElementWeight(key, value);
60992
-
60993
61020
  //remove from cache
60994
61021
  this.data.delete(key);
60995
61022
 
60996
61023
  //update weight
60997
- this.weight -= elementWeight;
61024
+ this.weight -= element.weight;
60998
61025
  }
60999
61026
 
61000
61027
  /**
@@ -66300,7 +66327,14 @@ const ShadedGeometryFlags = {
66300
66327
  /**
66301
66328
  * If set to false will not render
66302
66329
  */
66303
- Visible:16
66330
+ Visible: 16,
66331
+
66332
+ /**
66333
+ * Bounds are updated whenever transforms change, we can defer this until next frame render request
66334
+ * This lets us back updated and do less work overall
66335
+ * TODO implement, currently it's ignored
66336
+ */
66337
+ DeferredBoundsUpdate: 32,
66304
66338
  };
66305
66339
 
66306
66340
  /**
@@ -68392,6 +68426,7 @@ function plane3_compute_ray_intersection(
68392
68426
  const t = -p / denom;
68393
68427
 
68394
68428
  if (t < 0) {
68429
+ // ray starts and points behind the plane
68395
68430
  return false;
68396
68431
  }
68397
68432
 
@@ -68404,9 +68439,10 @@ function plane3_compute_ray_intersection(
68404
68439
  return true;
68405
68440
 
68406
68441
  } else {
68442
+ // ray direction is perpendicular to the plane normal. In other words ray runs parallel to the plane
68407
68443
 
68408
68444
  if (p === 0) {
68409
-
68445
+ // ray origin lies on the plane
68410
68446
  out.set(originX, originY, originZ);
68411
68447
 
68412
68448
  return true;
@@ -73609,6 +73645,39 @@ function assetTypeByPath(url) {
73609
73645
  }
73610
73646
  }
73611
73647
 
73648
+ class Name extends ObservedString {
73649
+ constructor(value = "") {
73650
+ super(value);
73651
+ }
73652
+
73653
+ /**
73654
+ *
73655
+ * @returns {string}
73656
+ */
73657
+ getLocalizationKey() {
73658
+ return `component.name.${this.getValue()}`;
73659
+ }
73660
+
73661
+ /**
73662
+ *
73663
+ * @param {Localization} localization
73664
+ * @returns {string}
73665
+ */
73666
+ getLocalizedValue(localization) {
73667
+ return localization.getString(this.getLocalizationKey());
73668
+ }
73669
+
73670
+ clone() {
73671
+ const clone = new Name();
73672
+
73673
+ clone.copy(this);
73674
+
73675
+ return clone;
73676
+ }
73677
+ }
73678
+
73679
+ Name.typeName = "Name";
73680
+
73612
73681
  /**
73613
73682
  *
73614
73683
  * @param {Transform} transform
@@ -73645,6 +73714,7 @@ function three_object_to_entity_composition(root) {
73645
73714
  transform.fromMatrix4(root.matrixWorld.elements);
73646
73715
 
73647
73716
  entity.add(transform);
73717
+ entity.add(new Name(root.name));
73648
73718
 
73649
73719
  if (root.isMesh) {
73650
73720
  if (root.isSkinnedMesh) ;
@@ -79768,6 +79838,22 @@ function m3_cm_compose_transform(
79768
79838
  */
79769
79839
  const FLT_EPSILON_32 = 1.192092896E-7;
79770
79840
 
79841
+ /**
79842
+ *
79843
+ * @param {HTMLElement} domElement
79844
+ * @param {boolean} visibility
79845
+ */
79846
+ function setElementVisibility(domElement, visibility) {
79847
+ const style = domElement.style;
79848
+
79849
+ if (!visibility) {
79850
+ style.display = 'none';
79851
+ } else {
79852
+ // remove display property, this allows style re-flow whereby previous display type is assumed
79853
+ style.removeProperty('display');
79854
+ }
79855
+ }
79856
+
79771
79857
  /**
79772
79858
  *
79773
79859
  * @param {Float32Array} m3
@@ -79801,21 +79887,6 @@ function writeCssTransformMatrix(m3, domElement) {
79801
79887
  */
79802
79888
 
79803
79889
 
79804
- /**
79805
- *
79806
- * @param {HTMLElement} domElement
79807
- * @param {boolean} visibility
79808
- */
79809
- function setElementVisibility(domElement, visibility) {
79810
- const style = domElement.style;
79811
-
79812
- if (!visibility) {
79813
- style.display = 'none';
79814
- } else {
79815
- // remove display property, this allows style re-flow whereby previous display type is assumed
79816
- style.removeProperty('display');
79817
- }
79818
- }
79819
79890
 
79820
79891
  /**
79821
79892
  *
@@ -79838,84 +79909,86 @@ const INITIAL_FLAGS = ViewFlags.Visible;
79838
79909
  * @class
79839
79910
  */
79840
79911
  class View {
79841
- #transform_written = new Float32Array(9);
79842
- #transform_current = new Float32Array(9);
79843
79912
 
79844
79913
  /**
79845
- * @constructor
79914
+ * Signal bindings, these will be linked and unlinked along with the view
79915
+ * @private
79916
+ * @type {SignalBinding[]}
79846
79917
  */
79847
- constructor() {
79848
- /**
79849
- *
79850
- * @type {Element|NodeDescription|null}
79851
- */
79852
- this.el = null;
79918
+ bindings = [];
79853
79919
 
79854
- /**
79855
- * Signal bindings, these will be linked and unlinked along with the view
79856
- * @private
79857
- * @type {SignalBinding[]}
79858
- */
79859
- this.bindings = [];
79920
+ /**
79921
+ *
79922
+ * @type {ViewFlags|number}
79923
+ */
79924
+ flags = INITIAL_FLAGS;
79860
79925
 
79861
- /**
79862
- *
79863
- * @type {ViewFlags|number}
79864
- */
79865
- this.flags = INITIAL_FLAGS;
79926
+ /**
79927
+ * @readonly
79928
+ * @type {Vector2}
79929
+ */
79930
+ position = new Vector2(0, 0);
79866
79931
 
79867
- /**
79868
- * @readonly
79869
- * @type {Vector2}
79870
- */
79871
- const position = this.position = new Vector2(0, 0);
79932
+ /**
79933
+ * @readonly
79934
+ * @type {Vector1}
79935
+ */
79936
+ rotation = new Vector1(0);
79872
79937
 
79873
- /**
79874
- * @readonly
79875
- * @type {Vector1}
79876
- */
79877
- const rotation = this.rotation = new Vector1(0);
79938
+ /**
79939
+ * @readonly
79940
+ * @type {Vector2}
79941
+ */
79942
+ scale = new Vector2(1, 1);
79878
79943
 
79879
- /**
79880
- * @readonly
79881
- * @type {Vector2}
79882
- */
79883
- const scale = this.scale = new Vector2(1, 1);
79944
+ /**
79945
+ * @readonly
79946
+ * @type {Vector2}
79947
+ */
79948
+ size = new Vector2(0, 0);
79884
79949
 
79885
- /**
79886
- * @readonly
79887
- * @type {Vector2}
79888
- */
79889
- const size = this.size = new Vector2(0, 0);
79950
+ /**
79951
+ * Origin from which rotation and scaling is applied
79952
+ * @readonly
79953
+ * @type {Vector2}
79954
+ */
79955
+ transformOrigin = new Vector2(0.5, 0.5);
79890
79956
 
79891
- /**
79892
- * Origin from which rotation and scaling is applied
79893
- * @readonly
79894
- * @type {Vector2}
79895
- */
79896
- this.transformOrigin = new Vector2(0.5, 0.5);
79957
+ on = {
79958
+ linked: new Signal(),
79959
+ unlinked: new Signal()
79960
+ };
79897
79961
 
79898
- this.on = {
79899
- linked: new Signal(),
79900
- unlinked: new Signal()
79901
- };
79962
+ /**
79963
+ *
79964
+ * @type {View[]}
79965
+ */
79966
+ children = [];
79902
79967
 
79903
- /**
79904
- *
79905
- * @type {View[]}
79906
- */
79907
- this.children = [];
79968
+ /**
79969
+ *
79970
+ * @type {View|null}
79971
+ */
79972
+ parent = null;
79908
79973
 
79974
+
79975
+ #transform_written = new Float32Array(9);
79976
+ #transform_current = new Float32Array(9);
79977
+
79978
+ /**
79979
+ * @constructor
79980
+ */
79981
+ constructor() {
79909
79982
  /**
79910
79983
  *
79911
- * @type {View|null}
79984
+ * @type {Element|NodeDescription|null}
79912
79985
  */
79913
- this.parent = null;
79986
+ this.el = null;
79914
79987
 
79915
- position.onChanged.add(this.__updateTransform, this);
79916
- scale.onChanged.add(this.__updateTransform, this);
79917
- rotation.onChanged.add(this.__updateTransform, this);
79918
- size.onChanged.add(this.__setDimensions, this);
79988
+ this.position.onChanged.add(this.__updateTransform, this);
79989
+ this.scale.onChanged.add(this.__updateTransform, this);
79990
+ this.rotation.onChanged.add(this.__updateTransform, this);
79991
+ this.size.onChanged.add(this.__setDimensions, this);
79919
79992
 
79920
79993
  this.transformOrigin.onChanged.add(this.__setTransformOrigin, this);
79921
79994
  }
@@ -1,9 +1,9 @@
1
- import { assert } from "../../../src/core/assert.js";
2
1
  import { Sprite, SpriteMaterial } from "three";
3
- import { make3DSymbolicDisplay } from "./make3DSymbolicDisplay.js";
2
+ import { assert } from "../../../src/core/assert.js";
4
3
  import Entity from "../../../src/engine/ecs/Entity.js";
5
4
  import Renderable from "../../../src/engine/ecs/renderable/Renderable.js";
6
5
  import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
6
+ import { make3DSymbolicDisplay } from "./make3DSymbolicDisplay.js";
7
7
  import { synchronizeTransform } from "./synchronizeTransform.js";
8
8
 
9
9
  const SPRITE_SIZE = 0.3;
@@ -19,8 +19,6 @@ export function makePositionedIconDisplaySymbol(engine, iconURL, ComponentClass)
19
19
  assert.defined(engine, 'engine');
20
20
  assert.ok(engine.isEngine, 'engine.isEngine');
21
21
 
22
- const entityManager = engine.entityManager;
23
-
24
22
  const assetManager = engine.assetManager;
25
23
 
26
24
  const spriteMaterial = new SpriteMaterial();