@woosh/meep-engine 2.84.9 → 2.84.11

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 (31) hide show
  1. package/README.md +27 -13
  2. package/build/meep.cjs +185 -87
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +185 -87
  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 +1 -1
  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 +35 -4
  19. package/src/core/cache/LoadingCache.spec.js +44 -6
  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/plane/plane3_compute_ray_intersection.js +3 -1
  23. package/src/core/geom/3d/topology/simplify/prototypeMeshSimplification.js +7 -7
  24. package/src/engine/animation/curve/ecd_bind_animation_curve.js +9 -0
  25. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometryFlags.js +8 -1
  26. package/src/engine/graphics/ecs/mesh-v2/aggregate/prototypeSGMesh.js +23 -19
  27. package/src/engine/graphics/ecs/mesh-v2/sg_hierarchy_compute_bounding_box_via_parent_entity.js +2 -2
  28. package/src/engine/graphics/ecs/mesh-v2/three_object_to_entity_composition.js +3 -1
  29. package/src/view/View.js +64 -95
  30. package/src/view/setElementTransform.js +20 -0
  31. package/src/view/setElementVisibility.js +15 -0
@@ -60578,6 +60578,12 @@ class CacheElement {
60578
60578
  */
60579
60579
  this.value = null;
60580
60580
 
60581
+ /**
60582
+ *
60583
+ * @type {number}
60584
+ */
60585
+ this.weight = 0;
60586
+
60581
60587
  /**
60582
60588
  * Link to next element (implements linked list)
60583
60589
  * @type {CacheElement<Key,Value>|null}
@@ -60766,14 +60772,56 @@ class Cache {
60766
60772
  recomputeWeight() {
60767
60773
  let result = 0;
60768
60774
 
60769
- for (let [key, value] of this.data) {
60770
- result += this.keyWeigher(key);
60771
- 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;
60772
60781
  }
60773
60782
 
60774
60783
  this.weight = result;
60775
60784
  }
60776
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
+
60777
60825
  /**
60778
60826
  * @private
60779
60827
  * @param {Key} key
@@ -60781,7 +60829,11 @@ class Cache {
60781
60829
  * @returns {number}
60782
60830
  */
60783
60831
  computeElementWeight(key, value) {
60784
- 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;
60785
60837
  }
60786
60838
 
60787
60839
  /**
@@ -60854,6 +60906,9 @@ class Cache {
60854
60906
  //compute weight
60855
60907
  const elementWeight = this.computeElementWeight(key, value);
60856
60908
 
60909
+ element.weight = elementWeight;
60910
+
60911
+
60857
60912
  /**
60858
60913
  * It's possible that element being added is larger than cache's capacity,
60859
60914
  * in which case entire cache will be evicted, but there still won't be enough space
@@ -60947,7 +61002,7 @@ class Cache {
60947
61002
  * @private
60948
61003
  */
60949
61004
  __removeElement(element) {
60950
- const value = element.value;
61005
+ element.value;
60951
61006
 
60952
61007
  // remove from the queue
60953
61008
  if (element === this.__first) {
@@ -60962,14 +61017,11 @@ class Cache {
60962
61017
 
60963
61018
  const key = element.key;
60964
61019
 
60965
- //compute weight
60966
- const elementWeight = this.computeElementWeight(key, value);
60967
-
60968
61020
  //remove from cache
60969
61021
  this.data.delete(key);
60970
61022
 
60971
61023
  //update weight
60972
- this.weight -= elementWeight;
61024
+ this.weight -= element.weight;
60973
61025
  }
60974
61026
 
60975
61027
  /**
@@ -66275,7 +66327,14 @@ const ShadedGeometryFlags = {
66275
66327
  /**
66276
66328
  * If set to false will not render
66277
66329
  */
66278
- 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,
66279
66338
  };
66280
66339
 
66281
66340
  /**
@@ -68367,6 +68426,7 @@ function plane3_compute_ray_intersection(
68367
68426
  const t = -p / denom;
68368
68427
 
68369
68428
  if (t < 0) {
68429
+ // ray starts and points behind the plane
68370
68430
  return false;
68371
68431
  }
68372
68432
 
@@ -68379,9 +68439,10 @@ function plane3_compute_ray_intersection(
68379
68439
  return true;
68380
68440
 
68381
68441
  } else {
68442
+ // ray direction is perpendicular to the plane normal. In other words ray runs parallel to the plane
68382
68443
 
68383
68444
  if (p === 0) {
68384
-
68445
+ // ray origin lies on the plane
68385
68446
  out.set(originX, originY, originZ);
68386
68447
 
68387
68448
  return true;
@@ -73584,6 +73645,39 @@ function assetTypeByPath(url) {
73584
73645
  }
73585
73646
  }
73586
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
+
73587
73681
  /**
73588
73682
  *
73589
73683
  * @param {Transform} transform
@@ -73620,6 +73714,7 @@ function three_object_to_entity_composition(root) {
73620
73714
  transform.fromMatrix4(root.matrixWorld.elements);
73621
73715
 
73622
73716
  entity.add(transform);
73717
+ entity.add(new Name(root.name));
73623
73718
 
73624
73719
  if (root.isMesh) {
73625
73720
  if (root.isSkinnedMesh) ;
@@ -79743,6 +79838,22 @@ function m3_cm_compose_transform(
79743
79838
  */
79744
79839
  const FLT_EPSILON_32 = 1.192092896E-7;
79745
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
+
79746
79857
  /**
79747
79858
  *
79748
79859
  * @param {Float32Array} m3
@@ -79776,21 +79887,6 @@ function writeCssTransformMatrix(m3, domElement) {
79776
79887
  */
79777
79888
 
79778
79889
 
79779
- /**
79780
- *
79781
- * @param {HTMLElement} domElement
79782
- * @param {boolean} visibility
79783
- */
79784
- function setElementVisibility(domElement, visibility) {
79785
- const style = domElement.style;
79786
-
79787
- if (!visibility) {
79788
- style.display = 'none';
79789
- } else {
79790
- // remove display property, this allows style re-flow whereby previous display type is assumed
79791
- style.removeProperty('display');
79792
- }
79793
- }
79794
79890
 
79795
79891
  /**
79796
79892
  *
@@ -79813,84 +79909,86 @@ const INITIAL_FLAGS = ViewFlags.Visible;
79813
79909
  * @class
79814
79910
  */
79815
79911
  class View {
79816
- #transform_written = new Float32Array(9);
79817
- #transform_current = new Float32Array(9);
79818
79912
 
79819
79913
  /**
79820
- * @constructor
79914
+ * Signal bindings, these will be linked and unlinked along with the view
79915
+ * @private
79916
+ * @type {SignalBinding[]}
79821
79917
  */
79822
- constructor() {
79823
- /**
79824
- *
79825
- * @type {Element|NodeDescription|null}
79826
- */
79827
- this.el = null;
79918
+ bindings = [];
79828
79919
 
79829
- /**
79830
- * Signal bindings, these will be linked and unlinked along with the view
79831
- * @private
79832
- * @type {SignalBinding[]}
79833
- */
79834
- this.bindings = [];
79920
+ /**
79921
+ *
79922
+ * @type {ViewFlags|number}
79923
+ */
79924
+ flags = INITIAL_FLAGS;
79835
79925
 
79836
- /**
79837
- *
79838
- * @type {ViewFlags|number}
79839
- */
79840
- this.flags = INITIAL_FLAGS;
79926
+ /**
79927
+ * @readonly
79928
+ * @type {Vector2}
79929
+ */
79930
+ position = new Vector2(0, 0);
79841
79931
 
79842
- /**
79843
- * @readonly
79844
- * @type {Vector2}
79845
- */
79846
- const position = this.position = new Vector2(0, 0);
79932
+ /**
79933
+ * @readonly
79934
+ * @type {Vector1}
79935
+ */
79936
+ rotation = new Vector1(0);
79847
79937
 
79848
- /**
79849
- * @readonly
79850
- * @type {Vector1}
79851
- */
79852
- const rotation = this.rotation = new Vector1(0);
79938
+ /**
79939
+ * @readonly
79940
+ * @type {Vector2}
79941
+ */
79942
+ scale = new Vector2(1, 1);
79853
79943
 
79854
- /**
79855
- * @readonly
79856
- * @type {Vector2}
79857
- */
79858
- const scale = this.scale = new Vector2(1, 1);
79944
+ /**
79945
+ * @readonly
79946
+ * @type {Vector2}
79947
+ */
79948
+ size = new Vector2(0, 0);
79859
79949
 
79860
- /**
79861
- * @readonly
79862
- * @type {Vector2}
79863
- */
79864
- 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);
79865
79956
 
79866
- /**
79867
- * Origin from which rotation and scaling is applied
79868
- * @readonly
79869
- * @type {Vector2}
79870
- */
79871
- this.transformOrigin = new Vector2(0.5, 0.5);
79957
+ on = {
79958
+ linked: new Signal(),
79959
+ unlinked: new Signal()
79960
+ };
79872
79961
 
79873
- this.on = {
79874
- linked: new Signal(),
79875
- unlinked: new Signal()
79876
- };
79962
+ /**
79963
+ *
79964
+ * @type {View[]}
79965
+ */
79966
+ children = [];
79877
79967
 
79878
- /**
79879
- *
79880
- * @type {View[]}
79881
- */
79882
- this.children = [];
79968
+ /**
79969
+ *
79970
+ * @type {View|null}
79971
+ */
79972
+ parent = null;
79883
79973
 
79974
+
79975
+ #transform_written = new Float32Array(9);
79976
+ #transform_current = new Float32Array(9);
79977
+
79978
+ /**
79979
+ * @constructor
79980
+ */
79981
+ constructor() {
79884
79982
  /**
79885
79983
  *
79886
- * @type {View|null}
79984
+ * @type {Element|NodeDescription|null}
79887
79985
  */
79888
- this.parent = null;
79986
+ this.el = null;
79889
79987
 
79890
- position.onChanged.add(this.__updateTransform, this);
79891
- scale.onChanged.add(this.__updateTransform, this);
79892
- rotation.onChanged.add(this.__updateTransform, this);
79893
- 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);
79894
79992
 
79895
79993
  this.transformOrigin.onChanged.add(this.__setTransformOrigin, this);
79896
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();