@woosh/meep-engine 2.47.27 → 2.47.29

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.
@@ -45188,7 +45188,7 @@ class Quaternion {
45188
45188
 
45189
45189
  right._crossVectors(ux, uy, uz, forward.x, forward.y, forward.z);
45190
45190
 
45191
- if(right.lengthSq() === 0){
45191
+ if (right.lengthSq() === 0) {
45192
45192
  // up and forward are parallel
45193
45193
 
45194
45194
  /*
@@ -45196,14 +45196,14 @@ class Quaternion {
45196
45196
  code take from : https://github.com/mrdoob/three.js/blob/88e8954b69377dad4ad1ceaf1a383f3536e88e5a/src/math/Matrix4.js#L304
45197
45197
  */
45198
45198
 
45199
- if(Math.abs(uz) === 1){
45199
+ if (Math.abs(uz) === 1) {
45200
45200
  forward.x += 0.001;
45201
- }else {
45201
+ } else {
45202
45202
  forward.z += 0.001;
45203
45203
  }
45204
45204
 
45205
45205
  forward.normalize();
45206
- right._crossVectors(ux,uy,uz, forward.x, forward.y, forward.z);
45206
+ right._crossVectors(ux, uy, uz, forward.x, forward.y, forward.z);
45207
45207
 
45208
45208
  }
45209
45209
 
@@ -45326,8 +45326,6 @@ class Quaternion {
45326
45326
  * @return {number} angle in radians
45327
45327
  */
45328
45328
  angleTo(other) {
45329
- //compute inverse
45330
-
45331
45329
  const x0 = this.x;
45332
45330
  const y0 = this.y;
45333
45331
  const z0 = this.z;
@@ -45338,31 +45336,13 @@ class Quaternion {
45338
45336
  const z1 = other.z;
45339
45337
  const w1 = other.w;
45340
45338
 
45341
- const dot = x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0;
45342
-
45343
- let ix, iy, iz, iw;
45344
-
45345
- if (dot === 0) {
45346
- ix = 0;
45347
- iy = 0;
45348
- iz = 0;
45349
- iw = 0;
45350
- } else {
45351
-
45352
- const invDot = 1.0 / dot;
45339
+ const dot = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1;
45353
45340
 
45354
- ix = -x0 * invDot;
45355
- iy = -y0 * invDot;
45356
- iz = -z0 * invDot;
45357
- iw = w0 * invDot;
45358
- }
45341
+ const dot_clamped = clamp$1(dot, -1, 1);
45359
45342
 
45360
- //compute resulting quaternion
45361
- const w = w1 * iw - x1 * ix - y1 * iy - z1 * iz;
45343
+ const dot_abs = Math.abs(dot_clamped);
45362
45344
 
45363
- const _w = clamp$1(w, -1, 1);
45364
-
45365
- return Math.acos(_w) * 2;
45345
+ return Math.acos(dot_abs) * 2;
45366
45346
  }
45367
45347
 
45368
45348
  /**
@@ -46674,7 +46654,7 @@ class Quaternion {
46674
46654
  * @param {number[]} array
46675
46655
  * @param {number} offset
46676
46656
  */
46677
- readFromArray(array, offset=0) {
46657
+ readFromArray(array, offset = 0) {
46678
46658
  this.set(
46679
46659
  array[offset],
46680
46660
  array[offset + 1],
@@ -46688,7 +46668,7 @@ class Quaternion {
46688
46668
  * @param {number[]} array
46689
46669
  * @param {number} offset
46690
46670
  */
46691
- writeToArray(array, offset=0) {
46671
+ writeToArray(array, offset = 0) {
46692
46672
  array[offset] = this.x;
46693
46673
  array[offset + 1] = this.y;
46694
46674
  array[offset + 2] = this.z;
@@ -54218,9 +54198,8 @@ class Vector1 extends Number {
54218
54198
  constructor(x = 0) {
54219
54199
  super();
54220
54200
 
54221
- assert.equal(typeof x, "number", `X must be of type "number", instead was "${typeof x}"`);
54222
-
54223
- assert.ok(!Number.isNaN(x), `X must be a valid number, instead was NaN`);
54201
+ assert.isNumber( x, 'x');
54202
+ assert.notNaN(x, 'x');
54224
54203
 
54225
54204
  this.x = x;
54226
54205
 
@@ -96856,6 +96835,30 @@ class PointerDevice {
96856
96835
  */
96857
96836
  buttons = new Array(32);
96858
96837
 
96838
+ /**
96839
+ *
96840
+ * @returns {InputDeviceSwitch}
96841
+ */
96842
+ get mouseButtonLeft() {
96843
+ return this.buttons[0];
96844
+ }
96845
+
96846
+ /**
96847
+ *
96848
+ * @returns {InputDeviceSwitch}
96849
+ */
96850
+ get mouseButtonRight() {
96851
+ return this.buttons[2];
96852
+ }
96853
+
96854
+ /**
96855
+ *
96856
+ * @returns {InputDeviceSwitch}
96857
+ */
96858
+ get mouseButtonMiddle() {
96859
+ return this.buttons[1];
96860
+ }
96861
+
96859
96862
  /**
96860
96863
  *
96861
96864
  * @param {EventTarget} domElement html element
@@ -99952,13 +99955,12 @@ const BehaviorStatus = {
99952
99955
  * @template CTX
99953
99956
  */
99954
99957
  class Behavior {
99955
- constructor() {
99956
- /**
99957
- * Any internal state used by the behavior
99958
- * @type {CTX|null}
99959
- */
99960
- this.context = null;
99961
- }
99958
+
99959
+ /**
99960
+ * Any internal state used by the behavior
99961
+ * @type {CTX|null}
99962
+ */
99963
+ context = null;
99962
99964
 
99963
99965
  /**
99964
99966
  * Main update function. Every behavior executes some logic, some behaviors are long-running and some are instantaneous
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.47.27",
8
+ "version": "2.47.29",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -185,7 +185,7 @@ class Quaternion {
185
185
 
186
186
  right._crossVectors(ux, uy, uz, forward.x, forward.y, forward.z);
187
187
 
188
- if(right.lengthSq() === 0){
188
+ if (right.lengthSq() === 0) {
189
189
  // up and forward are parallel
190
190
 
191
191
  /*
@@ -193,14 +193,14 @@ class Quaternion {
193
193
  code take from : https://github.com/mrdoob/three.js/blob/88e8954b69377dad4ad1ceaf1a383f3536e88e5a/src/math/Matrix4.js#L304
194
194
  */
195
195
 
196
- if(Math.abs(uz) === 1){
196
+ if (Math.abs(uz) === 1) {
197
197
  forward.x += 0.001;
198
- }else{
198
+ } else {
199
199
  forward.z += 0.001;
200
200
  }
201
201
 
202
202
  forward.normalize();
203
- right._crossVectors(ux,uy,uz, forward.x, forward.y, forward.z);
203
+ right._crossVectors(ux, uy, uz, forward.x, forward.y, forward.z);
204
204
 
205
205
  }
206
206
 
@@ -323,8 +323,6 @@ class Quaternion {
323
323
  * @return {number} angle in radians
324
324
  */
325
325
  angleTo(other) {
326
- //compute inverse
327
-
328
326
  const x0 = this.x;
329
327
  const y0 = this.y;
330
328
  const z0 = this.z;
@@ -335,31 +333,13 @@ class Quaternion {
335
333
  const z1 = other.z;
336
334
  const w1 = other.w;
337
335
 
338
- const dot = x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0;
339
-
340
- let ix, iy, iz, iw;
341
-
342
- if (dot === 0) {
343
- ix = 0;
344
- iy = 0;
345
- iz = 0;
346
- iw = 0;
347
- } else {
348
-
349
- const invDot = 1.0 / dot;
350
-
351
- ix = -x0 * invDot;
352
- iy = -y0 * invDot;
353
- iz = -z0 * invDot;
354
- iw = w0 * invDot;
355
- }
336
+ const dot = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1;
356
337
 
357
- //compute resulting quaternion
358
- const w = w1 * iw - x1 * ix - y1 * iy - z1 * iz;
338
+ const dot_clamped = clamp(dot, -1, 1);
359
339
 
360
- const _w = clamp(w, -1, 1);
340
+ const dot_abs = Math.abs(dot_clamped);
361
341
 
362
- return Math.acos(_w) * 2;
342
+ return Math.acos(dot_abs) * 2;
363
343
  }
364
344
 
365
345
  /**
@@ -1671,7 +1651,7 @@ class Quaternion {
1671
1651
  * @param {number[]} array
1672
1652
  * @param {number} offset
1673
1653
  */
1674
- readFromArray(array, offset=0) {
1654
+ readFromArray(array, offset = 0) {
1675
1655
  this.set(
1676
1656
  array[offset],
1677
1657
  array[offset + 1],
@@ -1685,7 +1665,7 @@ class Quaternion {
1685
1665
  * @param {number[]} array
1686
1666
  * @param {number} offset
1687
1667
  */
1688
- writeToArray(array, offset=0) {
1668
+ writeToArray(array, offset = 0) {
1689
1669
  array[offset] = this.x;
1690
1670
  array[offset + 1] = this.y;
1691
1671
  array[offset + 2] = this.z;
@@ -20,9 +20,8 @@ class Vector1 extends Number {
20
20
  constructor(x = 0) {
21
21
  super();
22
22
 
23
- assert.equal(typeof x, "number", `X must be of type "number", instead was "${typeof x}"`);
24
-
25
- assert.ok(!Number.isNaN(x), `X must be a valid number, instead was NaN`);
23
+ assert.isNumber( x, 'x');
24
+ assert.notNaN(x, 'x');
26
25
 
27
26
  this.x = x;
28
27
 
@@ -1,3 +1,5 @@
1
+ import {Color} from "../../../../../core/color/Color";
2
+
1
3
  export class Decal {
2
4
  /**
3
5
  * Path to image
@@ -8,4 +10,6 @@ export class Decal {
8
10
  * Draw order, higher values will be drawn on top of lower values when there's an overlap
9
11
  */
10
12
  priority: number
13
+
14
+ color: Color
11
15
  }
@@ -1,15 +1,24 @@
1
1
  import Signal from "../../../core/events/signal/Signal";
2
2
  import Vector2 from "../../../core/geom/Vector2";
3
3
  import Vector3 from "../../../core/geom/Vector3";
4
+ import {InputDeviceSwitch} from "./InputDeviceSwitch";
4
5
 
5
6
  export class PointerDevice {
6
- public start(): void
7
+ constructor(element:EventTarget)
7
8
 
8
- public stop(): void
9
+ start(): void
9
10
 
10
- public readonly position: Vector2
11
+ stop(): void
11
12
 
12
- public readonly on: {
13
+ readonly position: Vector2
14
+
15
+ readonly buttons: InputDeviceSwitch[]
16
+
17
+ readonly mouseButtonLeft: InputDeviceSwitch
18
+ readonly mouseButtonRight: InputDeviceSwitch
19
+ readonly mouseButtonMiddle: InputDeviceSwitch
20
+
21
+ readonly on: {
13
22
  down: Signal<Vector2, MouseEvent | TouchEvent>,
14
23
  up: Signal<Vector2, MouseEvent | TouchEvent>,
15
24
  move: Signal<Vector2 /*position*/, MouseEvent | TouchEvent, Vector2 /*delta*/>,
@@ -379,6 +379,30 @@ export class PointerDevice {
379
379
  */
380
380
  buttons = new Array(32);
381
381
 
382
+ /**
383
+ *
384
+ * @returns {InputDeviceSwitch}
385
+ */
386
+ get mouseButtonLeft() {
387
+ return this.buttons[0];
388
+ }
389
+
390
+ /**
391
+ *
392
+ * @returns {InputDeviceSwitch}
393
+ */
394
+ get mouseButtonRight() {
395
+ return this.buttons[2];
396
+ }
397
+
398
+ /**
399
+ *
400
+ * @returns {InputDeviceSwitch}
401
+ */
402
+ get mouseButtonMiddle() {
403
+ return this.buttons[1];
404
+ }
405
+
382
406
  /**
383
407
  *
384
408
  * @param {EventTarget} domElement html element
@@ -6,13 +6,12 @@ import { BehaviorStatus } from "./BehaviorStatus.js";
6
6
  * @template CTX
7
7
  */
8
8
  export class Behavior {
9
- constructor() {
10
- /**
11
- * Any internal state used by the behavior
12
- * @type {CTX|null}
13
- */
14
- this.context = null;
15
- }
9
+
10
+ /**
11
+ * Any internal state used by the behavior
12
+ * @type {CTX|null}
13
+ */
14
+ context = null;
16
15
 
17
16
  /**
18
17
  * Main update function. Every behavior executes some logic, some behaviors are long-running and some are instantaneous