@woosh/meep-engine 2.84.2 → 2.84.4

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 (33) hide show
  1. package/build/meep.cjs +82 -88
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +82 -88
  4. package/editor/view/ecs/EntityEditor.js +7 -8
  5. package/package.json +1 -1
  6. package/src/core/math/random/roundFair.js +5 -2
  7. package/src/core/math/random/roundFair.spec.js +12 -0
  8. package/src/core/math/random/seededRandom.d.ts +1 -4
  9. package/src/core/math/random/seededRandom_Mulberry32.spec.js +19 -0
  10. package/src/core/model/node-graph/node/NodeInstancePortReference.spec.js +25 -2
  11. package/src/core/model/node-graph/node/Port.js +8 -6
  12. package/src/core/model/node-graph/node/Port.spec.js +49 -0
  13. package/src/core/process/matcher/and.js +16 -0
  14. package/src/core/process/matcher/isDefined.js +8 -0
  15. package/src/core/process/matcher/isEqualTo.js +10 -0
  16. package/src/core/process/matcher/isGreaterThan.js +10 -0
  17. package/src/core/process/matcher/isGreaterThanOrEqualTo.js +10 -0
  18. package/src/core/process/matcher/isInstanceOf.js +10 -0
  19. package/src/core/process/matcher/isLessThan.js +10 -0
  20. package/src/core/process/matcher/isLessThanOrEqualTo.js +10 -0
  21. package/src/core/process/matcher/isNull.js +8 -0
  22. package/src/core/process/matcher/isTypeOf.js +16 -0
  23. package/src/core/process/matcher/not.js +10 -0
  24. package/src/core/process/matcher/or.js +16 -0
  25. package/src/core/process/task/util/actionTask.spec.js +14 -0
  26. package/src/core/process/task/util/countTask.js +1 -1
  27. package/src/core/process/task/util/countTask.spec.js +18 -0
  28. package/src/engine/ecs/Entity.js +4 -4
  29. package/src/view/common/LabelView.js +3 -1
  30. package/src/view/elements/windrose/WindRoseDiagram.js +3 -3
  31. package/src/core/math/spline/spline_catmullrom_1d.js +0 -120
  32. package/src/core/process/IntervalExecutor.js +0 -78
  33. package/src/core/process/matcher/Matchers.js +0 -145
@@ -1,10 +1,10 @@
1
- import View from "../../View.js";
2
1
  import { assert } from "../../../core/assert.js";
3
- import EmptyView from "../EmptyView.js";
2
+ import { isDefined } from "../../../core/process/matcher/isDefined.js";
4
3
  import LabelView from "../../common/LabelView.js";
5
4
  import SVG from "../../SVG.js";
5
+ import View from "../../View.js";
6
+ import EmptyView from "../EmptyView.js";
6
7
  import ImageView from "../image/ImageView.js";
7
- import { isDefined } from "../../../core/process/matcher/Matchers.js";
8
8
 
9
9
  export class WindRoseDiagram extends View {
10
10
 
@@ -1,120 +0,0 @@
1
-
2
- /**
3
- *
4
- * @param {number} p0
5
- * @param {number} p1
6
- * @param {number} half_alpha between 0..0.5
7
- * @returns {number}
8
- */
9
- function getT(p0, p1, half_alpha) {
10
- const dx = p0 - p1;
11
-
12
- const a = dx * dx;
13
-
14
- return Math.pow(a, half_alpha);
15
- }
16
-
17
-
18
- /**
19
- * Alpha assumed to be 0.5
20
- * @param {number} f
21
- * @param {number} p0
22
- * @param {number} p1
23
- * @param {number} p2
24
- * @param {number} p3
25
- * @returns {number}
26
- */
27
- export function spline_catmullrom_1d(
28
- f,
29
- p0, p1, p2, p3
30
- ) {
31
- const half_alpha = 0.25;
32
-
33
- // calculate T
34
- const t0 = 0;
35
- let t_01 = getT(p0, p1, half_alpha);
36
- let t_02 = getT(p1, p2, half_alpha);
37
- let t_03 = getT(p2, p3, half_alpha);
38
-
39
- // safety check for repeated points, to prevent division by 0
40
- if (t_01 < 1e-5) {
41
- t_01 = 1;
42
- }
43
- if (t_02 < 1e-5) {
44
- t_02 = t_01;
45
- }
46
- if (t_03 < 1e-5) {
47
- t_03 = t_02;
48
- }
49
-
50
- const t1 = t_01 + t0;
51
- const t2 = t_02 + t1;
52
- const t3 = t_03 + t2;
53
-
54
- /**
55
- * Interpolation between points 1 and 2
56
- * @type {number}
57
- */
58
- const t = t1 * (1 - f) + t2 * f;
59
-
60
- /*
61
- Vector2 A1 = (t1-t)/(t1-t0)*p0 + (t-t0)/(t1-t0)*p1;
62
- Vector2 A2 = (t2-t)/(t2-t1)*p1 + (t-t1)/(t2-t1)*p2;
63
- Vector2 A3 = (t3-t)/(t3-t2)*p2 + (t-t2)/(t3-t2)*p3;
64
-
65
- Vector2 B1 = (t2-t)/(t2-t0)*A1 + (t-t0)/(t2-t0)*A2;
66
- Vector2 B2 = (t3-t)/(t3-t1)*A2 + (t-t1)/(t3-t1)*A3;
67
-
68
- Vector2 C = (t2-t)/(t2-t1)*B1 + (t-t1)/(t2-t1)*B2;
69
- */
70
-
71
- const d_t1_t0 = t1 - t0;
72
-
73
- const m_A1_0 = (t1 - t) / d_t1_t0;
74
- const m_A1_1 = (t - t0) / d_t1_t0;
75
-
76
- const d_t2_t1 = t2 - t1;
77
-
78
- const m_A2_0 = (t2 - t) / d_t2_t1;
79
-
80
- const d_t_t1 = t - t1;
81
-
82
- const m_A2_1 = d_t_t1 / d_t2_t1;
83
-
84
- const d_t3_t2 = t3 - t2;
85
-
86
- const d_t3_t = t3 - t;
87
-
88
- const m_A3_0 = d_t3_t / d_t3_t2;
89
- const m_A3_1 = (t - t2) / d_t3_t2;
90
-
91
- const d_t2_t0 = t2 - t0;
92
-
93
- const m_B1_0 = (t2 - t) / d_t2_t0;
94
- const m_B1_1 = (t - t0) / d_t2_t0;
95
-
96
- const d_t3_t1 = t3 - t1;
97
-
98
- const m_B2_0 = d_t3_t / d_t3_t1;
99
- const m_B2_1 = d_t_t1 / d_t3_t1;
100
-
101
- const m_C_0 = (t2 - t) / d_t2_t1;
102
- const m_C_1 = d_t_t1 / d_t2_t1;
103
-
104
- // read vector values for the dimension
105
- const v0 = p0;
106
- const v1 = p1;
107
- const v2 = p2;
108
- const v3 = p3;
109
-
110
- // compute resulting value in this dimension
111
- const A1 = m_A1_0 * v0 + m_A1_1 * v1;
112
- const A2 = m_A2_0 * v1 + m_A2_1 * v2;
113
- const A3 = m_A3_0 * v2 + m_A3_1 * v3;
114
-
115
- const B1 = m_B1_0 * A1 + m_B1_1 * A2;
116
- const B2 = m_B2_0 * A2 + m_B2_1 * A3;
117
-
118
- return m_C_0 * B1 + m_C_1 * B2;
119
-
120
- }
@@ -1,78 +0,0 @@
1
- /**
2
- * Created by Alex on 22/05/2016.
3
- */
4
-
5
- /**
6
- *
7
- * @param {number} quietTime in milliseconds
8
- * @param {number} workTime in milliseconds
9
- * @constructor
10
- */
11
- function IntervalExecutor(quietTime, workTime) {
12
- this.quietTime = quietTime;
13
- this.workTime = workTime;
14
- this.tasks = [];
15
- this.busy = false;
16
- this.timeLastWorkDone = 0;
17
- }
18
-
19
- /**
20
- *
21
- * @param {function} task
22
- */
23
- IntervalExecutor.prototype.add = function (task) {
24
- this.tasks.push(task);
25
- this.prod();
26
- };
27
-
28
- IntervalExecutor.prototype.prod = function () {
29
- const self = this;
30
- const tasks = this.tasks;
31
-
32
- function processCycle() {
33
- const t = Date.now();
34
- let timeNow = t;
35
-
36
- let workTime = 0;
37
-
38
- while (tasks.length > 0) {
39
- const task = tasks.shift();
40
- task();
41
-
42
- timeNow = Date.now();
43
- workTime = timeNow - t;
44
- if (workTime >= self.workTime) {
45
- //time slice ended
46
- break;
47
- }
48
- }
49
-
50
- self.timeLastWorkDone = timeNow;
51
-
52
- if (tasks.length > 0) {
53
- //compute adaptive quiet time based on how long we worked for
54
- const workOverBudget = workTime - self.workTime;
55
- const sleepTime = self.quietTime + Math.max(workOverBudget, 0);
56
-
57
- //still some tasks left, schedule next slice
58
- setTimeout(processCycle, sleepTime);
59
- } else {
60
- //all tasks done, reset the 'busy' flag
61
- self.busy = false;
62
- }
63
- }
64
-
65
- if (!this.busy && tasks.length > 0) {
66
- this.busy = true;
67
- const timeSinceLastWork = Date.now() - this.timeLastWorkDone;
68
- const quietTimeDelta = this.quietTime - timeSinceLastWork;
69
- if (quietTimeDelta < 0) {
70
- processCycle();
71
- } else {
72
- setTimeout(processCycle, quietTimeDelta);
73
- }
74
- }
75
- };
76
-
77
-
78
- export default IntervalExecutor;
@@ -1,145 +0,0 @@
1
- /**
2
- * @author Alex Goldring
3
- * @copyright Alex Goldring 2017
4
- */
5
-
6
- import { assert } from "../../assert.js";
7
-
8
- /**
9
- *
10
- * @param {*} value
11
- * @returns {boolean}
12
- */
13
- export function isNull(value) {
14
- return value === null;
15
- }
16
-
17
- /**
18
- *
19
- * @param {*} value
20
- * @return {boolean}
21
- */
22
- export function isDefined(value) {
23
- return value !== undefined;
24
- }
25
-
26
- /**
27
- * performs instanceof match
28
- * @param {function} type
29
- * @returns {function(*): boolean}
30
- */
31
- export function isInstanceOf(type) {
32
- return function (m) {
33
- return m instanceof type;
34
- }
35
- }
36
-
37
- /**
38
- * performs typeof match
39
- * @param {string} type
40
- * @returns {function(*): boolean}
41
- */
42
- export function isTypeOf(type) {
43
- assert.notEqual(['number', 'boolean', 'string', 'function', 'object', 'undefined'].indexOf(type), -1, `type must be one of [number, boolean, string, function, object, undefined], instead was '${type}'`);
44
-
45
- return function (m) {
46
- return typeof m === type;
47
- }
48
- }
49
-
50
- /**
51
- *
52
- * @param {number} value
53
- * @returns {function(*): boolean}
54
- */
55
- export function isGreaterThan(value) {
56
- return function (x) {
57
- return x > value;
58
- }
59
- }
60
-
61
- /**
62
- *
63
- * @param {number} value
64
- * @returns {function(*): boolean}
65
- */
66
- export function isGreaterThanOrEqualTo(value) {
67
- return function (x) {
68
- return x >= value;
69
- }
70
- }
71
-
72
- /**
73
- *
74
- * @param {number} value
75
- * @returns {function(*): boolean}
76
- */
77
- export function isLessThan(value) {
78
- return function (x) {
79
- return x < value;
80
- }
81
- }
82
-
83
- /**
84
- *
85
- * @param {number} value
86
- * @returns {function(*): boolean}
87
- */
88
- export function isLessThanOrEqualTo(value) {
89
- return function (x) {
90
- return x <= value;
91
- }
92
- }
93
-
94
- /**
95
- *
96
- * @param {number} value
97
- * @returns {function(*): boolean}
98
- */
99
- export function isEqualTo(value) {
100
- return function (x) {
101
- return x === value;
102
- }
103
- }
104
-
105
-
106
- /**
107
- *
108
- * @param {function} m
109
- * @returns {function(*): boolean}
110
- */
111
- export function not(m) {
112
- return function (v) {
113
- return !m(v);
114
- }
115
- }
116
-
117
- /**
118
- * Joins two matchers via AND
119
- * @param {function(*):boolean} a
120
- * @param {function(*):boolean} b
121
- * @returns {function(*):boolean}
122
- */
123
- export function and(a, b) {
124
- assert.typeOf(a, 'function', 'a');
125
- assert.typeOf(b, 'function', 'b');
126
-
127
- return function (m) {
128
- return a(m) && b(m);
129
- }
130
- }
131
-
132
- /**
133
- * Joins two matchers via OR
134
- * @param {function(*):boolean} a
135
- * @param {function(*):boolean} b
136
- * @returns {function(*):boolean}
137
- */
138
- export function or(a, b) {
139
- assert.typeOf(a, 'function', 'a');
140
- assert.typeOf(b, 'function', 'b');
141
-
142
- return function (m) {
143
- return a(m) || b(m);
144
- }
145
- }