@woosh/meep-engine 2.46.34 → 2.46.36

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.
@@ -48165,6 +48165,10 @@ class Sampler2D {
48165
48165
  throw new Error("data was undefined");
48166
48166
  }
48167
48167
 
48168
+ if (data.length < width * height * itemSize) {
48169
+ throw new Error(`Buffer underflow, data.length(=${data.length}) is too small. Expected at least ${width * height * itemSize}`);
48170
+ }
48171
+
48168
48172
  /**
48169
48173
  *
48170
48174
  * @type {Number}
@@ -48208,9 +48212,9 @@ class Sampler2D {
48208
48212
  computeMax(channel = 0) {
48209
48213
  const itemSize = this.itemSize;
48210
48214
 
48211
- assert.typeOf(channel, "number", "channel");
48212
- assert.ok(channel >= 0, `channel must be >= 0, was ${channel}`);
48213
- assert.ok(channel < itemSize, `channel must be less than itemSize(=${itemSize}), was ${channel}`);
48215
+ assert.isNumber(channel, "channel");
48216
+ assert.isNonNegativeInteger(channel , 'channel');
48217
+ assert.lessThan(channel, itemSize, `channel must be less than itemSize(=${itemSize}), was ${channel}`);
48214
48218
 
48215
48219
  const data = this.data;
48216
48220
 
@@ -125751,7 +125755,7 @@ class SelectorBehavior extends CompositeBehavior {
125751
125755
  this.__currentBehaviourIndex = 0;
125752
125756
  this.__currentBehaviour = children[0];
125753
125757
 
125754
- this.__currentBehaviour.initialize();
125758
+ this.__currentBehaviour.initialize(this.context);
125755
125759
 
125756
125760
  } else {
125757
125761
  // no children
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.46.34",
8
+ "version": "2.46.36",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -35,11 +35,11 @@ export function orient3d_fast(points, a, b, c, d) {
35
35
 
36
36
  const bdx = points[b3] - d_x;
37
37
  const bdy = points[b3 + 1] - d_y;
38
- const cdz = points[c3 + 2] - d_z;
38
+ const bdz = points[b3 + 2] - d_z;
39
39
 
40
40
  const cdx = points[c3] - d_x;
41
41
  const cdy = points[c3 + 1] - d_y;
42
- const bdz = points[b3 + 2] - d_z;
42
+ const cdz = points[c3 + 2] - d_z;
43
43
 
44
44
  return adx * (bdy * cdz - bdz * cdy)
45
45
  + bdx * (cdy * adz - cdz * ady)
@@ -40,21 +40,25 @@ export class NodeGraph {
40
40
  */
41
41
  this.on = {
42
42
  /**
43
+ * @readonly
43
44
  * @type {Signal<NodeInstance,number>}
44
45
  */
45
46
  nodeAdded: this.nodes.on.added,
46
47
 
47
48
  /**
49
+ * @readonly
48
50
  * @type {Signal<NodeInstance,number>}
49
51
  */
50
52
  nodeRemoved: this.nodes.on.removed,
51
53
 
52
54
  /**
55
+ * @readonly
53
56
  * @type {Signal<Connection,number>}
54
57
  */
55
58
  connectionAdded: this.connections.on.added,
56
59
 
57
60
  /**
61
+ * @readonly
58
62
  * @type {Signal<Connection,number>}
59
63
  */
60
64
  connectionRemoved: this.connections.on.removed
@@ -3,6 +3,7 @@ import { NodeParameterDataType } from "./parameter/NodeParameterDataType.js";
3
3
  import { NodeParameterDescription } from "./parameter/NodeParameterDescription.js";
4
4
  import { Port } from "./Port.js";
5
5
  import { PortDirection } from "./PortDirection.js";
6
+ import Signal from "../../../events/signal/Signal.js";
6
7
 
7
8
 
8
9
  /**
@@ -38,7 +39,7 @@ let node_id_counter = 0;
38
39
  export class NodeDescription {
39
40
  constructor() {
40
41
  /**
41
- *
42
+ * Useful human-readable label
42
43
  * @type {string}
43
44
  */
44
45
  this.name = "";
@@ -63,6 +64,22 @@ export class NodeDescription {
63
64
  * @type {NodeParameterDescription[]}
64
65
  */
65
66
  this.parameters = [];
67
+
68
+ /**
69
+ * @readonly
70
+ */
71
+ this.on = {
72
+ /**
73
+ * @readonly
74
+ * @type {Signal<Port>}
75
+ */
76
+ portAdded: new Signal(),
77
+ /**
78
+ * @readonly
79
+ * @type {Signal<Port>}
80
+ */
81
+ portRemoved: new Signal()
82
+ };
66
83
  }
67
84
 
68
85
  /**
@@ -70,7 +87,7 @@ export class NodeDescription {
70
87
  * @returns {Port[]}
71
88
  */
72
89
  get outPorts() {
73
- return this.ports.filter(p => p.direction === PortDirection.Out);
90
+ return this.getPortsByDirection(PortDirection.Out);
74
91
  }
75
92
 
76
93
  /**
@@ -78,7 +95,7 @@ export class NodeDescription {
78
95
  * @returns {Port[]}
79
96
  */
80
97
  get inPorts() {
81
- return this.ports.filter(p => p.direction === PortDirection.In);
98
+ return this.getPortsByDirection(PortDirection.In);
82
99
  }
83
100
 
84
101
  /**
@@ -165,6 +182,8 @@ export class NodeDescription {
165
182
  assert.equal(type.isDataType, true, 'type.isDataType !== true');
166
183
 
167
184
  assert.defined(direction, 'direction');
185
+ assert.enum(direction, PortDirection, 'direction');
186
+
168
187
  assert.isString(name, 'name');
169
188
 
170
189
  const port = new Port();
@@ -179,9 +198,38 @@ export class NodeDescription {
179
198
 
180
199
  this.ports.push(port);
181
200
 
201
+ this.on.portAdded.send1(port);
202
+
182
203
  return id;
183
204
  }
184
205
 
206
+ /**
207
+ *
208
+ * @param {number} id port ID
209
+ * @returns {boolean} true if port was deleted, false if port wasn't found
210
+ */
211
+ deletePort(id) {
212
+ assert.defined(id, 'id');
213
+ assert.isNumber(id, 'id');
214
+ assert.isNonNegativeInteger(id, 'id');
215
+
216
+ const ports = this.ports;
217
+ const port_count = ports.length;
218
+ for (let i = 0; i < port_count; i++) {
219
+ const port = ports[i];
220
+
221
+ if (port.id === id) {
222
+ ports.splice(i, 1);
223
+
224
+ this.on.portRemoved.send1(port);
225
+
226
+ return true;
227
+ }
228
+ }
229
+
230
+ return false;
231
+ }
232
+
185
233
  /**
186
234
  *
187
235
  * @param {number} id
@@ -190,7 +238,10 @@ export class NodeDescription {
190
238
  getPortById(id) {
191
239
  assert.isNonNegativeInteger(id, 'id');
192
240
 
193
- for (const port of this.ports) {
241
+ const ports = this.ports;
242
+ const port_count = ports.length;
243
+ for (let i = 0; i < port_count; i++) {
244
+ const port = ports[i];
194
245
  if (port.id === id) {
195
246
  return port;
196
247
  }
@@ -45,6 +45,10 @@ export class Sampler2D {
45
45
  throw new Error("data was undefined");
46
46
  }
47
47
 
48
+ if (data.length < width * height * itemSize) {
49
+ throw new Error(`Buffer underflow, data.length(=${data.length}) is too small. Expected at least ${width * height * itemSize}`);
50
+ }
51
+
48
52
  /**
49
53
  *
50
54
  * @type {Number}
@@ -88,9 +92,9 @@ export class Sampler2D {
88
92
  computeMax(channel = 0) {
89
93
  const itemSize = this.itemSize;
90
94
 
91
- assert.typeOf(channel, "number", "channel");
92
- assert.ok(channel >= 0, `channel must be >= 0, was ${channel}`);
93
- assert.ok(channel < itemSize, `channel must be less than itemSize(=${itemSize}), was ${channel}`);
95
+ assert.isNumber(channel, "channel");
96
+ assert.isNonNegativeInteger(channel , 'channel');
97
+ assert.lessThan(channel, itemSize, `channel must be less than itemSize(=${itemSize}), was ${channel}`);
94
98
 
95
99
  const data = this.data;
96
100
 
@@ -90,7 +90,7 @@ export class SelectorBehavior extends CompositeBehavior {
90
90
  this.__currentBehaviourIndex = 0;
91
91
  this.__currentBehaviour = children[0];
92
92
 
93
- this.__currentBehaviour.initialize();
93
+ this.__currentBehaviour.initialize(this.context);
94
94
 
95
95
  } else {
96
96
  // no children