@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
@@ -30,6 +30,7 @@ export function plane3_compute_ray_intersection(
30
30
  const t = -p / denom;
31
31
 
32
32
  if (t < 0) {
33
+ // ray starts and points behind the plane
33
34
  return false;
34
35
  }
35
36
 
@@ -42,9 +43,10 @@ export function plane3_compute_ray_intersection(
42
43
  return true;
43
44
 
44
45
  } else {
46
+ // ray direction is perpendicular to the plane normal. In other words ray runs parallel to the plane
45
47
 
46
48
  if (p === 0) {
47
-
49
+ // ray origin lies on the plane
48
50
  out.set(originX, originY, originZ);
49
51
 
50
52
  return true;
@@ -20,23 +20,23 @@ import {
20
20
  VSMShadowMap,
21
21
  WebGLRenderer
22
22
  } from "three";
23
- import { mergeVertices } from "three/examples/jsm/utils/BufferGeometryUtils.js";
24
23
  import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
25
24
  import Stats from "three/examples/jsm/libs/stats.module.js";
26
25
  import { PLYLoader } from "three/examples/jsm/loaders/PLYLoader.js";
27
- import { topo_mesh_to_three_buffer_geometry } from "../topo_mesh_to_three_buffer_geometry.js";
28
- import { TopoMesh } from "../struct/TopoMesh.js";
26
+ import { mergeVertices } from "three/examples/jsm/utils/BufferGeometryUtils.js";
29
27
  import {
30
28
  deinterleaveBufferGeometry
31
29
  } from "../../../../../engine/graphics/geometry/buffered/deinterleaveBufferGeometry.js";
32
- import Vector3 from "../../../Vector3.js";
33
- import { simplifyTopoMesh2 } from "./simplifyTopoMesh2.js";
34
30
  import { scaleGeometryToBox } from "../../../../../engine/graphics/geometry/scaleGeometryToBox.js";
35
- import { computeTopoMeshBoundiningBox } from "../bounds/computeTopoMeshBoundiningBox.js";
36
- import { AABB3 } from "../../../../bvh2/aabb3/AABB3.js";
37
31
  import { Color } from "../../../../color/Color.js";
38
32
  import { clamp } from "../../../../math/clamp.js";
33
+ import Vector3 from "../../../Vector3.js";
34
+ import { AABB3 } from "../../aabb/AABB3.js";
35
+ import { computeTopoMeshBoundiningBox } from "../bounds/computeTopoMeshBoundiningBox.js";
36
+ import { TopoMesh } from "../struct/TopoMesh.js";
39
37
  import { three_buffer_geometry_to_topo_mesh } from "../three_buffer_geometry_to_topo_mesh.js";
38
+ import { topo_mesh_to_three_buffer_geometry } from "../topo_mesh_to_three_buffer_geometry.js";
39
+ import { simplifyTopoMesh2 } from "./simplifyTopoMesh2.js";
40
40
 
41
41
 
42
42
  /**
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Given a root node, bind animation curve to it
3
+ * @param {EntityNode} node
4
+ * @param {string} path
5
+ * @param {AnimationCurve} curve
6
+ */
7
+ export function entity_node_bind_animation_curve(node, path, curve) {
8
+
9
+ }
@@ -16,5 +16,12 @@ export const ShadedGeometryFlags = {
16
16
  /**
17
17
  * If set to false will not render
18
18
  */
19
- Visible:16
19
+ Visible: 16,
20
+
21
+ /**
22
+ * Bounds are updated whenever transforms change, we can defer this until next frame render request
23
+ * This lets us back updated and do less work overall
24
+ * TODO implement, currently it's ignored
25
+ */
26
+ DeferredBoundsUpdate: 32,
20
27
  };
@@ -1,27 +1,29 @@
1
- import { EngineHarness } from "../../../../EngineHarness.js";
2
- import { ShadedGeometrySystem } from "../ShadedGeometrySystem.js";
3
- import { SGMeshSystem } from "./SGMeshSystem.js";
4
- import Entity from "../../../../ecs/Entity.js";
5
- import { Transform } from "../../../../ecs/transform/Transform.js";
6
- import { SGMesh } from "./SGMesh.js";
1
+ import { initializeEditor } from "../../../../../../../model/game/initializeEditor.js";
2
+ import { OrbitingBehavior } from "../../../../../../../model/game/util/behavior/OrbitingBehavior.js";
3
+ import { enableEditor } from "../../../../../../editor/enableEditor.js";
4
+ import { AABB3 } from "../../../../../core/geom/3d/aabb/AABB3.js";
5
+ import Quaternion from "../../../../../core/geom/Quaternion.js";
6
+ import Vector2 from "../../../../../core/geom/Vector2.js";
7
+ import Vector3 from "../../../../../core/geom/Vector3.js";
8
+ import { randomFloatBetween } from "../../../../../core/math/random/randomFloatBetween.js";
9
+ import { seededRandom } from "../../../../../core/math/random/seededRandom.js";
7
10
  import { GameAssetType } from "../../../../asset/GameAssetType.js";
8
11
  import { GLTFAssetLoader } from "../../../../asset/loaders/GLTFAssetLoader.js";
9
- import Vector3 from "../../../../../core/geom/Vector3.js";
10
- import { BehaviorSystem } from "../../../../intelligence/behavior/ecs/BehaviorSystem.js";
12
+ import Entity from "../../../../ecs/Entity.js";
11
13
  import { TransformAttachmentSystem } from "../../../../ecs/transform-attachment/TransformAttachmentSystem.js";
12
- import { SGMeshEvents } from "./SGMeshEvents.js";
13
- import { ShadedGeometry } from "../ShadedGeometry.js";
14
- import { MeshSystem } from "../../mesh/MeshSystem.js";
15
- import { SGMeshHighlightSystem } from "./SGMeshHighlightSystem.js";
14
+ import { Transform } from "../../../../ecs/transform/Transform.js";
15
+ import { EngineHarness } from "../../../../EngineHarness.js";
16
+ import { BehaviorComponent } from "../../../../intelligence/behavior/ecs/BehaviorComponent.js";
17
+ import { BehaviorSystem } from "../../../../intelligence/behavior/ecs/BehaviorSystem.js";
16
18
  import Highlight from "../../highlight/Highlight.js";
17
19
  import { ShadedGeometryHighlightSystem } from "../../highlight/system/ShadedGeometryHighlightSystem.js";
18
- import Quaternion from "../../../../../core/geom/Quaternion.js";
19
- import { seededRandom } from "../../../../../core/math/random/seededRandom.js";
20
- import { BehaviorComponent } from "../../../../intelligence/behavior/ecs/BehaviorComponent.js";
21
- import { OrbitingBehavior } from "../../../../../../../model/game/util/behavior/OrbitingBehavior.js";
22
- import Vector2 from "../../../../../core/geom/Vector2.js";
23
- import { AABB3 } from "../../../../../core/bvh2/aabb3/AABB3.js";
24
- import { randomFloatBetween } from "../../../../../core/math/random/randomFloatBetween.js";
20
+ import { MeshSystem } from "../../mesh/MeshSystem.js";
21
+ import { ShadedGeometry } from "../ShadedGeometry.js";
22
+ import { ShadedGeometrySystem } from "../ShadedGeometrySystem.js";
23
+ import { SGMesh } from "./SGMesh.js";
24
+ import { SGMeshEvents } from "./SGMeshEvents.js";
25
+ import { SGMeshHighlightSystem } from "./SGMeshHighlightSystem.js";
26
+ import { SGMeshSystem } from "./SGMeshSystem.js";
25
27
 
26
28
  new EngineHarness().initialize({
27
29
  configuration(config, engine) {
@@ -137,6 +139,8 @@ function main(engine) {
137
139
  terrainSize: new Vector2(100, 100)
138
140
  });
139
141
 
142
+ enableEditor(engine, initializeEditor);
143
+
140
144
  const ecd = engine.entityManager.dataset;
141
145
 
142
146
  // const mesh = SGMesh.fromURL("data/models/RTS_Buildings_Humans/18/Building_R_18_out/Building_R_18.gltf");
@@ -1,6 +1,6 @@
1
- import { ShadedGeometry } from "./ShadedGeometry.js";
2
- import { AABB3 } from "../../../../core/bvh2/aabb3/AABB3.js";
1
+ import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
3
2
  import { ParentEntitySystem } from "../../../ecs/parent/ParentEntitySystem.js";
3
+ import { ShadedGeometry } from "./ShadedGeometry.js";
4
4
 
5
5
  const scratch_aabb3 = new AABB3();
6
6
 
@@ -1,7 +1,8 @@
1
+ import Name from "../../../../../../model/game/ecs/component/Name.js";
1
2
  import { EntityNode } from "../../../ecs/parent/EntityNode.js";
3
+ import { copy_three_transform } from "../../../ecs/transform/copy_three_transform.js";
2
4
  import { Transform } from "../../../ecs/transform/Transform.js";
3
5
  import { ShadedGeometry } from "./ShadedGeometry.js";
4
- import { copy_three_transform } from "../../../ecs/transform/copy_three_transform.js";
5
6
 
6
7
  /**
7
8
  *
@@ -23,6 +24,7 @@ export function three_object_to_entity_composition(root) {
23
24
  transform.fromMatrix4(root.matrixWorld.elements);
24
25
 
25
26
  entity.add(transform);
27
+ entity.add(new Name(root.name));
26
28
 
27
29
  if (root.isMesh) {
28
30
  if (root.isSkinnedMesh) {
package/src/view/View.js CHANGED
@@ -14,43 +14,10 @@ import Vector1 from "../core/geom/Vector1.js";
14
14
  import Vector2 from "../core/geom/Vector2.js";
15
15
  import { epsilonEquals } from "../core/math/epsilonEquals.js";
16
16
  import { FLT_EPSILON_32 } from "../core/math/FLT_EPSILON_32.js";
17
+ import { setElementVisibility } from "./setElementVisibility.js";
17
18
  import { writeCssTransformMatrix } from "./writeCssTransformMatrix.js";
18
19
 
19
20
 
20
- const scratch_m3_0 = new Float32Array(9);
21
-
22
- /**
23
- * @see https://dev.opera.com/articles/understanding-the-css-transforms-matrix/
24
- * @param domElement
25
- * @param {Vector2} position
26
- * @param {Vector2} scale
27
- * @param {number} rotation angle in radians
28
- */
29
- function setElementTransform(domElement, position, scale, rotation) {
30
-
31
- const m3 = scratch_m3_0;
32
-
33
- m3_cm_compose_transform(m3, position.x, position.y, scale.x, scale.y, 0, 0, rotation);
34
-
35
- writeCssTransformMatrix(m3, domElement);
36
- }
37
-
38
- /**
39
- *
40
- * @param {HTMLElement} domElement
41
- * @param {boolean} visibility
42
- */
43
- function setElementVisibility(domElement, visibility) {
44
- const style = domElement.style;
45
-
46
- if (!visibility) {
47
- style.display = 'none';
48
- } else {
49
- // remove display property, this allows style re-flow whereby previous display type is assumed
50
- style.removeProperty('display');
51
- }
52
- }
53
-
54
21
  /**
55
22
  *
56
23
  * @enum {number}
@@ -72,84 +39,86 @@ const INITIAL_FLAGS = ViewFlags.Visible;
72
39
  * @class
73
40
  */
74
41
  class View {
75
- #transform_written = new Float32Array(9);
76
- #transform_current = new Float32Array(9);
77
42
 
78
43
  /**
79
- * @constructor
44
+ * Signal bindings, these will be linked and unlinked along with the view
45
+ * @private
46
+ * @type {SignalBinding[]}
80
47
  */
81
- constructor() {
82
- /**
83
- *
84
- * @type {Element|NodeDescription|null}
85
- */
86
- this.el = null;
48
+ bindings = [];
87
49
 
88
- /**
89
- * Signal bindings, these will be linked and unlinked along with the view
90
- * @private
91
- * @type {SignalBinding[]}
92
- */
93
- this.bindings = [];
50
+ /**
51
+ *
52
+ * @type {ViewFlags|number}
53
+ */
54
+ flags = INITIAL_FLAGS;
94
55
 
95
- /**
96
- *
97
- * @type {ViewFlags|number}
98
- */
99
- this.flags = INITIAL_FLAGS;
56
+ /**
57
+ * @readonly
58
+ * @type {Vector2}
59
+ */
60
+ position = new Vector2(0, 0);
100
61
 
101
- /**
102
- * @readonly
103
- * @type {Vector2}
104
- */
105
- const position = this.position = new Vector2(0, 0);
62
+ /**
63
+ * @readonly
64
+ * @type {Vector1}
65
+ */
66
+ rotation = new Vector1(0);
106
67
 
107
- /**
108
- * @readonly
109
- * @type {Vector1}
110
- */
111
- const rotation = this.rotation = new Vector1(0);
68
+ /**
69
+ * @readonly
70
+ * @type {Vector2}
71
+ */
72
+ scale = new Vector2(1, 1);
112
73
 
113
- /**
114
- * @readonly
115
- * @type {Vector2}
116
- */
117
- const scale = this.scale = new Vector2(1, 1);
74
+ /**
75
+ * @readonly
76
+ * @type {Vector2}
77
+ */
78
+ size = new Vector2(0, 0);
118
79
 
119
- /**
120
- * @readonly
121
- * @type {Vector2}
122
- */
123
- const size = this.size = new Vector2(0, 0);
80
+ /**
81
+ * Origin from which rotation and scaling is applied
82
+ * @readonly
83
+ * @type {Vector2}
84
+ */
85
+ transformOrigin = new Vector2(0.5, 0.5);
124
86
 
125
- /**
126
- * Origin from which rotation and scaling is applied
127
- * @readonly
128
- * @type {Vector2}
129
- */
130
- this.transformOrigin = new Vector2(0.5, 0.5);
87
+ on = {
88
+ linked: new Signal(),
89
+ unlinked: new Signal()
90
+ };
131
91
 
132
- this.on = {
133
- linked: new Signal(),
134
- unlinked: new Signal()
135
- };
92
+ /**
93
+ *
94
+ * @type {View[]}
95
+ */
96
+ children = [];
97
+
98
+ /**
99
+ *
100
+ * @type {View|null}
101
+ */
102
+ parent = null;
136
103
 
137
- /**
138
- *
139
- * @type {View[]}
140
- */
141
- this.children = [];
142
104
 
105
+ #transform_written = new Float32Array(9);
106
+ #transform_current = new Float32Array(9);
107
+
108
+ /**
109
+ * @constructor
110
+ */
111
+ constructor() {
143
112
  /**
144
113
  *
145
- * @type {View|null}
114
+ * @type {Element|NodeDescription|null}
146
115
  */
147
- this.parent = null;
116
+ this.el = null;
148
117
 
149
- position.onChanged.add(this.__updateTransform, this);
150
- scale.onChanged.add(this.__updateTransform, this);
151
- rotation.onChanged.add(this.__updateTransform, this);
152
- size.onChanged.add(this.__setDimensions, this);
118
+ this.position.onChanged.add(this.__updateTransform, this);
119
+ this.scale.onChanged.add(this.__updateTransform, this);
120
+ this.rotation.onChanged.add(this.__updateTransform, this);
121
+ this.size.onChanged.add(this.__setDimensions, this);
153
122
 
154
123
  this.transformOrigin.onChanged.add(this.__setTransformOrigin, this);
155
124
  }
@@ -0,0 +1,20 @@
1
+ import { m3_cm_compose_transform } from "../core/geom/mat3/m3_cm_compose_transform.js";
2
+ import { writeCssTransformMatrix } from "./writeCssTransformMatrix.js";
3
+
4
+ const scratch_m3_0 = new Float32Array(9);
5
+
6
+ /**
7
+ * @see https://dev.opera.com/articles/understanding-the-css-transforms-matrix/
8
+ * @param domElement
9
+ * @param {Vector2} position
10
+ * @param {Vector2} scale
11
+ * @param {number} rotation angle in radians
12
+ */
13
+ function setElementTransform(domElement, position, scale, rotation) {
14
+
15
+ const m3 = scratch_m3_0;
16
+
17
+ m3_cm_compose_transform(m3, position.x, position.y, scale.x, scale.y, 0, 0, rotation);
18
+
19
+ writeCssTransformMatrix(m3, domElement);
20
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ *
3
+ * @param {HTMLElement} domElement
4
+ * @param {boolean} visibility
5
+ */
6
+ export function setElementVisibility(domElement, visibility) {
7
+ const style = domElement.style;
8
+
9
+ if (!visibility) {
10
+ style.display = 'none';
11
+ } else {
12
+ // remove display property, this allows style re-flow whereby previous display type is assumed
13
+ style.removeProperty('display');
14
+ }
15
+ }