@woosh/meep-engine 2.47.27 → 2.47.28

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
- }
45359
-
45360
- //compute resulting quaternion
45361
- const w = w1 * iw - x1 * ix - y1 * iy - z1 * iz;
45341
+ const dot_clamped = clamp$1(dot, -1, 1);
45362
45342
 
45363
- const _w = clamp$1(w, -1, 1);
45343
+ const dot_abs = Math.abs(dot_clamped);
45364
45344
 
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;
@@ -96856,6 +96836,30 @@ class PointerDevice {
96856
96836
  */
96857
96837
  buttons = new Array(32);
96858
96838
 
96839
+ /**
96840
+ *
96841
+ * @returns {InputDeviceSwitch}
96842
+ */
96843
+ get mouseButtonLeft() {
96844
+ return this.buttons[0];
96845
+ }
96846
+
96847
+ /**
96848
+ *
96849
+ * @returns {InputDeviceSwitch}
96850
+ */
96851
+ get mouseButtonRight() {
96852
+ return this.buttons[2];
96853
+ }
96854
+
96855
+ /**
96856
+ *
96857
+ * @returns {InputDeviceSwitch}
96858
+ */
96859
+ get mouseButtonMiddle() {
96860
+ return this.buttons[1];
96861
+ }
96862
+
96859
96863
  /**
96860
96864
  *
96861
96865
  * @param {EventTarget} domElement html element
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.28",
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;
@@ -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