@woosh/meep-engine 2.59.0 → 2.59.2

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 (67) hide show
  1. package/build/meep.cjs +710 -644
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +710 -644
  4. package/editor/process/symbolic/SymbolicDisplayInternalAPI.js +3 -3
  5. package/editor/process/symbolic/makeParticleEmitterSymbolicDisplay.js +1 -1
  6. package/editor/process/symbolic/makePathSymbolicDisplay.js +1 -1
  7. package/editor/process/symbolic/makeSoundEmitterSymbolicDisplay.js +1 -1
  8. package/editor/tools/TopDownCameraControlTool.js +2 -2
  9. package/editor/tools/v2/TransformControls.js +1 -1
  10. package/editor/tools/v2/prototypeTransformControls.js +1 -1
  11. package/package.json +1 -1
  12. package/samples/generation/main.js +1 -1
  13. package/samples/terrain/editor.js +1 -1
  14. package/src/core/collection/array/arraySetDiff.js +11 -7
  15. package/src/core/geom/3d/aabb/aabb3_array_intersects_point.spec.js +48 -0
  16. package/src/core/geom/3d/aabb/aabb3_array_intersects_ray.js +5 -1
  17. package/src/core/geom/3d/aabb/aabb3_expand_array.spec.js +16 -0
  18. package/src/core/geom/3d/aabb/aabb3_raycast.spec.js +37 -0
  19. package/src/core/geom/3d/aabb/aabb3_score_boxes_SAH.js +11 -12
  20. package/src/core/geom/3d/aabb/aabb3_score_boxes_SAH.spec.js +14 -0
  21. package/src/core/geom/3d/aabb/aabb3_transformed_compute_plane_side.js +6 -4
  22. package/src/core/geom/3d/aabb/compute_aabb_from_points.js +6 -3
  23. package/src/core/geom/3d/matrix/m4_multiply.spec.js +24 -0
  24. package/src/core/geom/3d/matrix/m4_multiply_alphatensor.js +56 -40
  25. package/src/core/geom/3d/matrix/m4_multiply_alphatensor.spec.js +24 -0
  26. package/src/core/geom/3d/shape/util/shape_to_visual_entity.js +2 -2
  27. package/src/core/geom/Vector3.spec.js +24 -14
  28. package/src/engine/EngineHarness.js +1 -1
  29. package/src/engine/control/ControlContext.js +1 -1
  30. package/src/engine/ecs/Entity.d.ts +2 -0
  31. package/src/engine/ecs/Entity.js +40 -37
  32. package/src/engine/ecs/Entity.spec.js +2 -2
  33. package/src/engine/ecs/EntityBuilderUtils.js +2 -2
  34. package/src/engine/ecs/EntityComponentDataset.js +91 -89
  35. package/src/engine/ecs/EntityFlags.js +4 -4
  36. package/src/engine/ecs/attachment/Attachment.js +5 -2
  37. package/src/engine/ecs/binding/ComponentPropertyBinding.js +13 -13
  38. package/src/engine/ecs/dynamic_actions/RuleExecution.js +1 -1
  39. package/src/engine/ecs/parent/EntityNode.js +2 -2
  40. package/src/engine/ecs/parent/EntityNode.spec.js +2 -2
  41. package/src/engine/ecs/tooltip/testTooltipComponentSystem.js +1 -1
  42. package/src/engine/ecs/util/hideEntityGracefully.js +6 -6
  43. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +1 -0
  44. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.d.ts +3 -0
  45. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.js +69 -28
  46. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.js +21 -15
  47. package/src/engine/graphics/ecs/mesh-v2/render/SGThreeObjectCache.js +30 -7
  48. package/src/engine/graphics/ecs/mesh-v2/sample/load_gltf.js +1 -1
  49. package/src/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +71 -34
  50. package/src/engine/graphics/ecs/mesh-v2/sample/prototype_sg_raycast.js +1 -1
  51. package/src/engine/graphics/ecs/path/PathDisplaySystem.js +4 -4
  52. package/src/engine/graphics/ecs/path/entity/EntityPathMarker.js +1 -1
  53. package/src/engine/graphics/ecs/path/highlight/PathDisplayHighlightSystem.js +3 -3
  54. package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +5 -5
  55. package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +2 -2
  56. package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +1 -1
  57. package/src/engine/graphics/sh3/prototypeSH3Probe.js +2 -2
  58. package/src/engine/intelligence/behavior/ecs/EntityBehavior.js +14 -17
  59. package/src/engine/intelligence/behavior/util/DelayBehavior.js +6 -6
  60. package/src/engine/ui/GUIEngine.js +368 -371
  61. package/src/engine/ui/notification/NotificationManager.js +1 -1
  62. package/src/generation/markers/actions/placement/MarkerNodeEntityProcessor.js +1 -1
  63. package/src/view/tooltip/gml/TooltipParser.js +21 -28
  64. package/src/view/tooltip/gml/compiler/GMLReferenceCompiler.js +3 -2
  65. package/src/core/geom/3d/aabb/aabb3_intersects_ray_branchless.js +0 -52
  66. package/src/core/geom/3d/aabb/aabb3_intersects_ray_fast.js +0 -176
  67. package/src/core/geom/3d/aabb/aabb3_intersects_ray_slab.js +0 -91
@@ -160,7 +160,7 @@ export class NotificationManager {
160
160
  //find existing entry
161
161
  for (const [view, builder] of views) {
162
162
 
163
- if (builder.entity === entity) {
163
+ if (builder.id === entity) {
164
164
  //clear from the map
165
165
  views.delete(view);
166
166
  break;
@@ -10,7 +10,7 @@ export class MarkerNodeEntityProcessor {
10
10
 
11
11
  /**
12
12
  *
13
- * @param {EntityBuilder} entity
13
+ * @param {Entity} entity
14
14
  * @param {MarkerNode} node
15
15
  * @param {GridData} data
16
16
  * @param {EntityComponentDataset} ecd
@@ -1,33 +1,26 @@
1
- import { Cache } from "../../../core/cache/Cache.js";
2
- import { strictEquals } from "../../../core/function/Functions.js";
3
- import { parseTooltipString } from "./parser/parseTooltipString.js";
4
- import { computeStringHash } from "../../../core/primitives/strings/computeStringHash.js";
5
- import { string_compute_byte_size } from "../../../core/primitives/strings/string_compute_byte_size.js";
1
+ import {Cache} from "../../../core/cache/Cache.js";
2
+ import {strictEquals} from "../../../core/function/Functions.js";
3
+ import {parseTooltipString} from "./parser/parseTooltipString.js";
4
+ import {computeStringHash} from "../../../core/primitives/strings/computeStringHash.js";
5
+ import {string_compute_byte_size} from "../../../core/primitives/strings/string_compute_byte_size.js";
6
6
 
7
7
  export class TooltipParser {
8
8
 
9
- constructor() {
10
-
11
- /**
12
- *
13
- * @type {Cache<String,Token[]>}
14
- * @private
15
- */
16
- this.__cache = new Cache({
17
- maxWeight: 1048576,
18
- keyWeigher: string_compute_byte_size,
19
- valueWeigher(tokens) {
20
- return tokens.length * 256;
21
- },
22
- keyHashFunction: computeStringHash,
23
- keyEqualityFunction: strictEquals
24
- });
25
9
 
26
- }
27
-
28
- resetCache() {
29
- this.__cache.clear();
30
- }
10
+ /**
11
+ *
12
+ * @type {Cache<String,Token[]>}
13
+ * @private
14
+ */
15
+ #cache = new Cache({
16
+ maxWeight: 1048576,
17
+ keyWeigher: string_compute_byte_size,
18
+ valueWeigher(tokens) {
19
+ return tokens.length * 256;
20
+ },
21
+ keyHashFunction: computeStringHash,
22
+ keyEqualityFunction: strictEquals
23
+ });
31
24
 
32
25
  /**
33
26
  *
@@ -36,7 +29,7 @@ export class TooltipParser {
36
29
  */
37
30
  parse(code) {
38
31
 
39
- const existing = this.__cache.get(code);
32
+ const existing = this.#cache.get(code);
40
33
 
41
34
  if (existing !== null) {
42
35
  // result is cached, reuse
@@ -47,7 +40,7 @@ export class TooltipParser {
47
40
  const tokens = parseTooltipString(code);
48
41
 
49
42
  // cache result
50
- this.__cache.put(code, tokens);
43
+ this.#cache.put(code, tokens);
51
44
 
52
45
  return tokens;
53
46
  }
@@ -1,4 +1,4 @@
1
- import { assert } from "../../../../core/assert.js";
1
+ import {assert} from "../../../../core/assert.js";
2
2
 
3
3
  /**
4
4
  * @template T
@@ -14,7 +14,8 @@ export class GMLReferenceCompiler {
14
14
  * @returns {T}
15
15
  */
16
16
  compile(options, database, localization, gml, tooltips) {
17
-
17
+ // override when implementing
18
+ throw new Error('Not Implemented');
18
19
  }
19
20
 
20
21
 
@@ -1,52 +0,0 @@
1
- import { min2 } from "../../../math/min2.js";
2
- import { max2 } from "../../../math/max2.js";
3
-
4
- /**
5
- * SLOW, don't use in production
6
- * It is branchless on systems where min/max instructions exist.
7
- * Unfortunately in JS that's not the case, so this is just a curiosity
8
- * @see https://tavianator.com/2011/ray_box.html
9
- * @param {number} x0
10
- * @param {number} y0
11
- * @param {number} z0
12
- * @param {number} x1
13
- * @param {number} y1
14
- * @param {number} z1
15
- * @param {number} oX
16
- * @param {number} oY
17
- * @param {number} oZ
18
- * @param {number} dirX
19
- * @param {number} dirY
20
- * @param {number} dirZ
21
- * @returns {boolean}
22
- */
23
- export function aabb3_intersects_ray_branchless(
24
- x0, y0, z0,
25
- x1, y1, z1,
26
- oX, oY, oZ,
27
- dirX, dirY, dirZ
28
- ) {
29
- const inv_dir_x = 1 / dirX;
30
- const inv_dir_y = 1 / dirY;
31
- const inv_dir_z = 1 / dirZ;
32
-
33
- const tx1 = (x0 - oX) * inv_dir_x;
34
- const tx2 = (x1 - oX) * inv_dir_x;
35
-
36
- let tmin = min2(tx1, tx2);
37
- let tmax = max2(tx1, tx2);
38
-
39
- const ty1 = (y0 - oY) * inv_dir_y;
40
- const ty2 = (y1 - oY) * inv_dir_y;
41
-
42
- tmin = max2(tmin, min2(ty1, ty2));
43
- tmax = min2(tmax, max2(ty1, ty2));
44
-
45
- const tz1 = (z0 - oZ) * inv_dir_z;
46
- const tz2 = (z1 - oZ) * inv_dir_z;
47
-
48
- tmin = max2(tmin, min2(tz1, tz2));
49
- tmax = min2(tmax, max2(tz1, tz2));
50
-
51
- return tmax >= tmin;
52
- }
@@ -1,176 +0,0 @@
1
- /**
2
- * Fast Ray-Box intersection
3
- * From "Graphics Gems", Academic Press, 1990
4
- * ported from C
5
- * see: https://web.archive.org/web/20090803054252/http://tog.acm.org/resources/GraphicsGems/gems/RayBox.c
6
- * @param {number} x0
7
- * @param {number} y0
8
- * @param {number} z0
9
- * @param {number} x1
10
- * @param {number} y1
11
- * @param {number} z1
12
- * @param {number} oX
13
- * @param {number} oY
14
- * @param {number} oZ
15
- * @param {number} dirX
16
- * @param {number} dirY
17
- * @param {number} dirZ
18
- * @returns {boolean}
19
- */
20
- export function aabb3_intersects_ray_fast(x0, y0, z0, x1, y1, z1, oX, oY, oZ, dirX, dirY, dirZ) {
21
- let inside = true;
22
-
23
- let quadrantX = 0;
24
- let quadrantY = 0;
25
- let quadrantZ = 0;
26
-
27
- let maxTX = 0;
28
- let maxTY = 0;
29
- let maxTZ = 0;
30
-
31
- let maxT = 0;
32
-
33
- let candidatePlaneX = 0;
34
- let candidatePlaneY = 0;
35
- let candidatePlaneZ = 0;
36
-
37
- let coordX = 0;
38
- let coordY = 0;
39
- let coordZ = 0;
40
-
41
- /*
42
- find candidate planes
43
- */
44
- if (oX < x0) {
45
- quadrantX = 1; //LEFT
46
- candidatePlaneX = x0;
47
- inside = false;
48
- } else if (oX > x1) {
49
- quadrantX = 0; //RIGHT
50
- candidatePlaneX = x1;
51
- inside = false;
52
- } else {
53
- quadrantX = 2; //MIDDLE
54
- }
55
-
56
- if (oY < y0) {
57
- quadrantY = 1; //LEFT
58
- candidatePlaneY = y0;
59
- inside = false;
60
- } else if (oY > y1) {
61
- quadrantY = 0; //RIGHT
62
- candidatePlaneY = y1;
63
- inside = false;
64
- } else {
65
- quadrantY = 2; //MIDDLE
66
- }
67
-
68
- if (oZ < z0) {
69
- quadrantZ = 1; //LEFT
70
- candidatePlaneZ = z0;
71
- inside = false;
72
- } else if (oZ > z1) {
73
- quadrantZ = 0; //RIGHT
74
- candidatePlaneZ = z1;
75
- inside = false;
76
- } else {
77
- quadrantZ = 2; //MIDDLE
78
- }
79
-
80
- // Ray origin inside the bounding box
81
- if (inside) {
82
- return true;
83
- }
84
-
85
- // Calculate T distances to candidate planes
86
- if (quadrantX !== 2 && dirX !== 0) {
87
- maxTX = (candidatePlaneX - oX) / dirX;
88
- } else {
89
- maxTX = -1;
90
- }
91
-
92
- if (quadrantY !== 2 && dirY !== 0) {
93
- maxTY = (candidatePlaneY - oY) / dirY;
94
- } else {
95
- maxTY = -1;
96
- }
97
-
98
- if (quadrantZ !== 2 && dirZ !== 0) {
99
- maxTZ = (candidatePlaneZ - oZ) / dirZ;
100
- } else {
101
- maxTZ = -1;
102
- }
103
-
104
- // Get largest of maxT's for final choice of intersection
105
- if (maxTX < maxTY) {
106
- if (maxTY < maxTZ) {
107
- maxT = maxTZ;
108
- // Check if final candidate actually inside the box
109
- if (maxT < 0) {
110
- return false;
111
- }
112
-
113
- coordX = oX + maxT * dirX;
114
- if (coordX < x0 || coordX > x1) {
115
- return false;
116
- }
117
-
118
- coordY = oY + maxT * dirY;
119
- if (coordY < y0 || coordY > y1) {
120
- return false;
121
- }
122
-
123
- } else {
124
- maxT = maxTY;
125
- // Check if final candidate actually inside the box
126
- if (maxT < 0) {
127
- return false;
128
- }
129
-
130
- coordX = oX + maxT * dirX;
131
- if (coordX < x0 || coordX > x1) {
132
- return false;
133
- }
134
-
135
- coordZ = oZ + maxT * dirZ;
136
- if (coordZ < z0 || coordZ > z1) {
137
- return false;
138
- }
139
- }
140
- } else if (maxTX < maxTZ) {
141
- maxT = maxTZ;
142
- // Check if final candidate actually inside the box
143
- if (maxT < 0) {
144
- return false;
145
- }
146
-
147
- coordX = oX + maxT * dirX;
148
- if (coordX < x0 || coordX > x1) {
149
- return false;
150
- }
151
-
152
- coordY = oY + maxT * dirY;
153
- if (coordY < y0 || coordY > y1) {
154
- return false;
155
- }
156
- } else {
157
- maxT = maxTX;
158
- // Check if final candidate actually inside the box
159
- if (maxT < 0) {
160
- return false;
161
- }
162
-
163
- coordY = oY + maxT * dirY;
164
- if (coordY < y0 || coordY > y1) {
165
- return false;
166
- }
167
-
168
- coordZ = oZ + maxT * dirZ;
169
- if (coordZ < z0 || coordZ > z1) {
170
- return false;
171
- }
172
- }
173
-
174
- //ray hits the box
175
- return true;
176
- }
@@ -1,91 +0,0 @@
1
- import { max3 } from "../../../math/max3.js";
2
- import { min3 } from "../../../math/min3.js";
3
-
4
- /**
5
- * @see https://tavianator.com/fast-branchless-raybounding-box-intersections-part-2-nans/
6
- * NOTE: this solution forgoes consistent handling of NaNs in favor of execution speed
7
- * @param {number} x0
8
- * @param {number} y0
9
- * @param {number} z0
10
- * @param {number} x1
11
- * @param {number} y1
12
- * @param {number} z1
13
- * @param {number} oX
14
- * @param {number} oY
15
- * @param {number} oZ
16
- * @param {number} dirX
17
- * @param {number} dirY
18
- * @param {number} dirZ
19
- * @returns {boolean}
20
- */
21
- export function aabb3_intersects_ray_slab(
22
- x0, y0, z0,
23
- x1, y1, z1,
24
- oX, oY, oZ,
25
- dirX, dirY, dirZ
26
- ) {
27
- /*
28
- Java CODE:
29
- bool intersection(box b, ray r) {
30
- double t1 = (b.min[0] - r.origin[0])*r.dir_inv[0];
31
- double t2 = (b.max[0] - r.origin[0])*r.dir_inv[0];
32
-
33
- double tmin = min(t1, t2);
34
- double tmax = max(t1, t2);
35
-
36
- for (int i = 1; i < 3; ++i) {
37
- t1 = (b.min[i] - r.origin[i])*r.dir_inv[i];
38
- t2 = (b.max[i] - r.origin[i])*r.dir_inv[i];
39
-
40
- tmin = max(tmin, min(t1, t2));
41
- tmax = min(tmax, max(t1, t2));
42
- }
43
-
44
- return tmax > max(tmin, 0.0);
45
- }
46
-
47
- */
48
-
49
- let tmin_x, tmax_x, tmin_y, tmax_y, tmin_z, tmax_z;
50
- const dir_inv_x = 1 / dirX;
51
- const dir_inv_y = 1 / dirY;
52
- const dir_inv_z = 1 / dirZ;
53
-
54
- const t1_x = (x0 - oX) * dir_inv_x;
55
- const t2_x = (x1 - oX) * dir_inv_x;
56
-
57
- const t1_y = (y0 - oY) * dir_inv_y;
58
- const t2_y = (y1 - oY) * dir_inv_y;
59
-
60
- const t1_z = (z0 - oZ) * dir_inv_z;
61
- const t2_z = (z1 - oZ) * dir_inv_z;
62
-
63
-
64
- if (t1_x > t2_x) {
65
- tmin_x = t2_x;
66
- tmax_x = t1_x;
67
- } else {
68
- tmin_x = t1_x;
69
- tmax_x = t2_x;
70
- }
71
- if (t1_y > t2_y) {
72
- tmin_y = t2_y;
73
- tmax_y = t1_y;
74
- } else {
75
- tmin_y = t1_y;
76
- tmax_y = t2_y;
77
- }
78
- if (t1_z > t2_z) {
79
- tmin_z = t2_z;
80
- tmax_z = t1_z;
81
- } else {
82
- tmin_z = t1_z;
83
- tmax_z = t2_z;
84
- }
85
-
86
- const tmin = max3(tmin_x, tmin_y, tmin_z);
87
- const tmax = min3(tmax_x, tmax_y, tmax_z);
88
-
89
-
90
- return tmax >= tmin;
91
- }