@woosh/meep-engine 2.79.0 → 2.80.1

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 (60) hide show
  1. package/build/meep.cjs +179 -199
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +179 -199
  4. package/package.json +1 -1
  5. package/src/core/geom/2d/aabb/AABB2.js +6 -18
  6. package/src/core/geom/3d/SurfacePoint3.spec.js +1 -1
  7. package/src/core/geom/3d/{matrix → mat4}/m4_multiply.spec.js +3 -4
  8. package/src/core/geom/3d/{matrix → mat4}/m4_multiply_alphatensor.spec.js +3 -3
  9. package/src/core/geom/3d/morton/v3_morton_encode_transformed.spec.js +1 -1
  10. package/src/core/geom/3d/sphere/sphere_radius_sqr_from_v3_array_transformed.spec.js +1 -1
  11. package/src/core/geom/Vector3.js +2 -2
  12. package/src/core/geom/Vector3.spec.js +2 -2
  13. package/src/core/geom/packing/max-rect/{MaxRectangles.js → MaxRectanglesPacker.js} +25 -32
  14. package/src/core/geom/packing/max-rect/MaxRectanglesPacker.spec.js +60 -0
  15. package/src/core/geom/packing/max-rect/packMaxRectangles.js +19 -0
  16. package/src/core/graph/cluster_mesh_metis.js +3 -3
  17. package/src/core/graph/metis/metis.js +16 -1
  18. package/src/core/graph/metis/metis_options.js +32 -29
  19. package/src/core/math/bell_membership_function.js +1 -1
  20. package/src/core/math/computeIsoscelesTriangleApexAngle.js +2 -2
  21. package/src/core/math/computeIsoscelesTriangleApexAngle.spec.js +6 -0
  22. package/src/core/math/interval/overlap1D.js +7 -0
  23. package/src/core/math/noise/create_simplex_noise_2d.js +4 -0
  24. package/src/core/math/spline/computeCatmullRomSplineUniformDistance.js +3 -3
  25. package/src/core/math/spline/v3_computeCatmullRomSplineUniformDistance.js +42 -0
  26. package/src/core/math/statistics/computeStatisticalPartialMedian.js +7 -1
  27. package/src/core/math/statistics/computeStatisticalPercentile.js +12 -3
  28. package/src/core/math/statistics/computeStatisticalPercentile.spec.js +11 -0
  29. package/src/core/math/statistics/computeStatisticalStandardDeviation.js +12 -0
  30. package/src/core/math/statistics/{computeSampleStandardDeviation.js → computeStatisticalVariance.js} +4 -6
  31. package/src/core/math/statistics/computeStatisticalVariance.spec.js +10 -0
  32. package/src/core/model/node-graph/Connection.js +6 -5
  33. package/src/core/model/node-graph/Connection.spec.js +12 -0
  34. package/src/core/model/node-graph/DataType.spec.js +19 -0
  35. package/src/core/model/node-graph/node/NodeDescription.js +12 -10
  36. package/src/core/model/node-graph/node/NodeDescription.spec.js +52 -1
  37. package/src/core/model/node-graph/node/NodeInstancePortReference.spec.js +66 -0
  38. package/src/core/model/node-graph/util/graph_clone_by_node_subset.js +4 -7
  39. package/src/core/model/node-graph/util/graph_collect_connections_amongst_nodes.js +0 -2
  40. package/src/core/model/object/objectKeyByValue.js +3 -2
  41. package/src/engine/ecs/renderable/Renderable.js +1 -1
  42. package/src/engine/ecs/terrain/ecs/TerrainSystem.js +1 -1
  43. package/src/engine/ecs/terrain/tiles/TerrainTile.spec.js +2 -2
  44. package/src/engine/ecs/transform/Transform.js +3 -3
  45. package/src/engine/ecs/transform/Transform.spec.js +3 -3
  46. package/src/engine/graphics/ecs/path/entity/testEntityPath.js +16 -10
  47. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +1 -1
  48. package/src/engine/graphics/texture/atlas/TextureAtlas.js +1 -1
  49. package/src/engine/graphics/texture/atlas/gpu/WebGLTextureAtlas.js +3 -3
  50. package/src/engine/graphics/three/expand_aabb_by_transformed_three_object.js +1 -1
  51. package/src/engine/graphics/three/expand_aabb_by_transformed_three_object.spec.js +2 -2
  52. package/src/engine/navigation/ecs/components/Path.js +5 -12
  53. package/src/engine/simulation/Ticker.js +40 -61
  54. package/src/core/geom/LineSegment.js +0 -207
  55. /package/src/core/geom/3d/{matrix → mat4}/MATRIX_4_IDENTITY.js +0 -0
  56. /package/src/core/geom/3d/{matrix → mat4}/MATRIX_4_IDENTITY.spec.js +0 -0
  57. /package/src/core/geom/3d/{matrix → mat4}/allocate_transform_m4.js +0 -0
  58. /package/src/core/geom/3d/{matrix → mat4}/m4_make_translation.js +0 -0
  59. /package/src/core/geom/3d/{matrix → mat4}/m4_multiply.js +0 -0
  60. /package/src/core/geom/3d/{matrix → mat4}/m4_multiply_alphatensor.js +0 -0
@@ -1,207 +0,0 @@
1
- /**
2
- * Created by Alex on 18/03/14.
3
- */
4
- import Vector3 from "./Vector3.js";
5
- import { clamp01 } from "../math/clamp01.js";
6
-
7
-
8
- const SMALL_NUM = 1e-9;
9
- /**
10
- * @param {Vector3} first
11
- * @param {Vector3} second
12
- * @constructor
13
- */
14
- const LineSegment = function (first, second) {
15
- this.p0 = first || null;
16
- this.p1 = second || null;
17
-
18
- };
19
-
20
- LineSegment.prototype.closestPointToPointParameter = function (point, clampToLine) {
21
-
22
-
23
- const startP = point.clone().sub(this.p0);
24
- const startEnd = this.p1.clone().sub(this.p0);
25
-
26
- const startEnd2 = startEnd.dot(startEnd);
27
- const startEnd_startP = startEnd.dot(startP);
28
-
29
- let t = startEnd_startP / startEnd2;
30
-
31
- if (clampToLine) {
32
-
33
- t = clamp01(t);
34
-
35
- }
36
-
37
- return t;
38
-
39
- };
40
-
41
- LineSegment.prototype.closestPointToPoint = function (point) {
42
-
43
- const t = this.closestPointToPointParameter(point, true);
44
-
45
- const result = this.p1.clone().sub(this.p0);
46
- return result.scale(t).add(this.p0);
47
-
48
- };
49
- /**
50
- * @param {Vector3} p
51
- * @returns {number}
52
- */
53
- LineSegment.prototype.distanceToPoint = function (p) {
54
- const closestPointToPoint = this.closestPointToPoint(p);
55
- return closestPointToPoint.sub(p).length();
56
- };
57
- /**
58
- * @param {LineSegment} other
59
- * @returns {number}
60
- */
61
- LineSegment.prototype.distanceToSegment = function (other) {
62
- const u = this.p1.clone().sub(this.p0);
63
- const v = other.p1.clone().sub(other.p0);
64
- const w = this.p0.clone().sub(other.p0);
65
- const a = u.dot(u); // always >= 0
66
- const b = u.dot(v);
67
- const c = v.dot(v); // always >= 0
68
- let d = u.dot(w);
69
- const e = v.dot(w);
70
- const D = a * c - b * b; // always >= 0
71
- let sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
72
- let tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
73
-
74
- // compute the line parameters of the two closest points
75
- if (D < SMALL_NUM) { // the lines are almost parallel
76
- sN = 0.0; // force using point P0 on segment S1
77
- sD = 1.0; // to prevent possible division by 0.0 later
78
- tN = e;
79
- tD = c;
80
- } else { // get the closest points on the infinite lines
81
- sN = (b * e - c * d);
82
- tN = (a * e - b * d);
83
- if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
84
- sN = 0.0;
85
- tN = e;
86
- tD = c;
87
- } else if (sN > sD) { // sc > 1 => the s=1 edge is visible
88
- sN = sD;
89
- tN = e + b;
90
- tD = c;
91
- }
92
- }
93
-
94
- if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
95
- tN = 0.0;
96
- // recompute sc for this edge
97
- if (-d < 0.0)
98
- sN = 0.0;
99
- else if (-d > a)
100
- sN = sD;
101
- else {
102
- sN = -d;
103
- sD = a;
104
- }
105
- } else if (tN > tD) { // tc > 1 => the t=1 edge is visible
106
- tN = tD;
107
- // recompute sc for this edge
108
- if ((-d + b) < 0.0)
109
- sN = 0;
110
- else if ((-d + b) > a)
111
- sN = sD;
112
- else {
113
- sN = (-d + b);
114
- sD = a;
115
- }
116
- }
117
- // finally do the division to get sc and tc
118
- sc = (Math.abs(sN) < SMALL_NUM ? 0.0 : sN / sD);
119
- tc = (Math.abs(tN) < SMALL_NUM ? 0.0 : tN / tD);
120
-
121
- // get the difference of the two closest points
122
- const dP = w.clone().add(
123
- u.clone().scale(sc).sub(
124
- v.clone().scale(tc)
125
- )
126
- ); // = S1(sc) - S2(tc)
127
-
128
- return dP.length(); // return the closest distance
129
- };
130
- LineSegment.prototype.clone = function () {
131
- return new LineSegment(this.p0, this.p1);
132
- };
133
- LineSegment.prototype.midPoint = function () {
134
- return this.p1.lerp(this.p0, 0.5);
135
- };
136
- LineSegment.prototype.shrinkByScalar = function (scalar) {
137
- const length = this.length();
138
- const newScale = (length - scalar) / length;
139
- const halfScaleDelta = (1 - newScale) / 2;
140
- //find mid point
141
- let midPoint = this.midPoint();
142
- //pull edges towards the midpoint
143
- const newP0 = this.p0.clone().lerp(this.p1, halfScaleDelta);
144
- const newP1 = this.p1.clone().lerp(this.p0, halfScaleDelta);
145
- this.p0 = newP0;
146
- this.p1 = newP1;
147
- //new length should now be equal to oldLength - scalar;
148
- return this;
149
- };
150
- LineSegment.prototype.length = function () {
151
- return this.p0.distanceTo(this.p1);
152
- };
153
- LineSegment.prototype.translate = function (vector) {
154
- this.p0.add(vector);
155
- this.p1.add(vector);
156
- };
157
-
158
-
159
- /**
160
- *
161
- * @param {Vector3} a0
162
- * @param {Vector3} a1
163
- * @param {Vector3} b0
164
- * @param {Vector3} b1
165
- * @param {Vector3} result
166
- * @returns {boolean}
167
- */
168
- LineSegment.intersectionPoint = (function () {
169
- const cross_da_db = new Vector3();
170
- const cross_dc_db = new Vector3();
171
- const dc = new Vector3();
172
- const da = new Vector3();
173
- const db = new Vector3();
174
-
175
- /**
176
- *
177
- * @param {Vector3} a0
178
- * @param {Vector3} a1
179
- * @param {Vector3} b0
180
- * @param {Vector3} b1
181
- * @param {Vector3} result
182
- * @returns {boolean}
183
- */
184
- function intersectionPoint(a0, a1, b0, b1, result) {
185
- da.copy(a1).sub(a0);
186
- db.copy(b1).sub(b0);
187
- dc.copy(b0).sub(a0);
188
-
189
- cross_da_db.copy(da).cross(db);
190
- if (dc.dot(cross_da_db) !== 0.0) {
191
- // lines are not coplanar
192
- return false;
193
- }
194
-
195
- cross_dc_db.copy(dc).cross(db);
196
- const s = cross_dc_db.dot(cross_da_db) / cross_da_db.lengthSqr();
197
- result.copy(da).multiplyScalar(s).add(a0);
198
- if (s >= 0.0 && s <= 1.0) {
199
- return true;
200
- }
201
-
202
- return false;
203
- }
204
-
205
- return intersectionPoint;
206
- })();
207
- export default LineSegment;