@woosh/meep-engine 2.94.6 → 2.94.8

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.
package/build/meep.cjs CHANGED
@@ -56605,6 +56605,10 @@ class AABB3 {
56605
56605
  return (this.x1 - this.x0);
56606
56606
  }
56607
56607
 
56608
+ get width() {
56609
+ return this.getExtentsX();
56610
+ }
56611
+
56608
56612
  /**
56609
56613
  *
56610
56614
  * @returns {number}
@@ -56613,6 +56617,10 @@ class AABB3 {
56613
56617
  return (this.y1 - this.y0);
56614
56618
  }
56615
56619
 
56620
+ get height() {
56621
+ return this.getExtentsY();
56622
+ }
56623
+
56616
56624
  /**
56617
56625
  *
56618
56626
  * @returns {number}
@@ -56621,6 +56629,10 @@ class AABB3 {
56621
56629
  return (this.z1 - this.z0);
56622
56630
  }
56623
56631
 
56632
+ get depth() {
56633
+ return this.getExtentsZ();
56634
+ }
56635
+
56624
56636
  /**
56625
56637
  * half-width in X axis
56626
56638
  * @returns {number}
@@ -56665,6 +56677,10 @@ class AABB3 {
56665
56677
  return (this.x0 + this.x1) * 0.5;
56666
56678
  }
56667
56679
 
56680
+ get centerX() {
56681
+ return this.getCenterX();
56682
+ }
56683
+
56668
56684
  /**
56669
56685
  *
56670
56686
  * @returns {number}
@@ -56673,6 +56689,10 @@ class AABB3 {
56673
56689
  return (this.y0 + this.y1) * 0.5;
56674
56690
  }
56675
56691
 
56692
+ get centerY() {
56693
+ return this.getCenterY();
56694
+ }
56695
+
56676
56696
  /**
56677
56697
  *
56678
56698
  * @returns {number}
@@ -56681,6 +56701,10 @@ class AABB3 {
56681
56701
  return (this.z0 + this.z1) * 0.5;
56682
56702
  }
56683
56703
 
56704
+ get centerZ() {
56705
+ return this.getCenterZ();
56706
+ }
56707
+
56684
56708
  /**
56685
56709
  * Get center position of the box
56686
56710
  * @param {Vector3} target where to write result
@@ -95582,6 +95606,8 @@ class Ticker {
95582
95606
  */
95583
95607
  #isRunning = false;
95584
95608
 
95609
+ #animationFrameHandle = -1;
95610
+ #timeoutHandle = -1;
95585
95611
 
95586
95612
  /**
95587
95613
  * Dispatches time delta in seconds since last tick
@@ -95611,6 +95637,7 @@ class Ticker {
95611
95637
  * @param {*} [thisArg]
95612
95638
  */
95613
95639
  subscribe(callback, thisArg) {
95640
+
95614
95641
  this.onTick.add(callback, thisArg);
95615
95642
  }
95616
95643
 
@@ -95620,17 +95647,23 @@ class Ticker {
95620
95647
  * @param {*} [thisArg]
95621
95648
  */
95622
95649
  unsubscribe(callback, thisArg) {
95650
+
95623
95651
  this.onTick.remove(callback, thisArg);
95624
95652
  }
95625
95653
 
95654
+ #isUpdateLoopActive() {
95655
+ return this.#timeoutHandle !== -1 && this.#animationFrameHandle !== -1;
95656
+ }
95657
+
95626
95658
  /**
95627
95659
  *
95628
95660
  * @param {number} [maxTimeout]
95629
95661
  */
95630
95662
  start({ maxTimeout = 100 } = {}) {
95631
95663
 
95632
- let timeout = null;
95633
- let animationFrame = null;
95664
+ if (this.#isUpdateLoopActive()) {
95665
+ throw new Error("Already running");
95666
+ }
95634
95667
 
95635
95668
  this.#isRunning = true;
95636
95669
 
@@ -95644,23 +95677,25 @@ class Ticker {
95644
95677
  this.onTick.send1(delta);
95645
95678
  };
95646
95679
 
95647
- function timeoutCallback() {
95648
- cancelAnimationFrame(animationFrame);
95680
+ const timeoutCallback = () => {
95681
+ cancelAnimationFrame(this.#animationFrameHandle);
95649
95682
  animate();
95650
- }
95683
+ };
95651
95684
 
95652
- function animationFrameCallback() {
95653
- clearTimeout(timeout);
95685
+ const animationFrameCallback = () => {
95686
+ clearTimeout(this.#timeoutHandle);
95654
95687
 
95655
95688
  //push tick beyond animation frame stack allowing draw to happen
95656
- setTimeout(animate, 0);
95657
- }
95689
+ this.#timeoutHandle = setTimeout(animate, 0);
95690
+ };
95691
+
95692
+ const animate = () => {
95693
+ this.#animationFrameHandle = requestAnimationFrame(animationFrameCallback);
95658
95694
 
95659
- function animate() {
95660
- animationFrame = requestAnimationFrame(animationFrameCallback);
95661
95695
  update();
95662
- timeout = setTimeout(timeoutCallback, maxTimeout);
95663
- }
95696
+
95697
+ this.#timeoutHandle = setTimeout(timeoutCallback, maxTimeout);
95698
+ };
95664
95699
 
95665
95700
  this.clock.getDelta(); //purge delta
95666
95701
  this.clock.start();
@@ -95669,12 +95704,32 @@ class Ticker {
95669
95704
  }
95670
95705
 
95671
95706
  pause() {
95707
+
95708
+ if (!this.#isUpdateLoopActive()) {
95709
+ throw new Error("Not currently running");
95710
+ }
95711
+
95672
95712
  this.#isRunning = false;
95673
95713
  }
95674
95714
 
95675
95715
  resume() {
95716
+
95717
+ if (!this.#isUpdateLoopActive()) {
95718
+ throw new Error("Not currently running");
95719
+ }
95720
+
95721
+
95676
95722
  this.#isRunning = true;
95677
95723
  }
95724
+
95725
+ stop() {
95726
+ clearTimeout(this.#timeoutHandle);
95727
+ cancelAnimationFrame(this.#animationFrameHandle);
95728
+ this.#isRunning = false;
95729
+
95730
+ this.#timeoutHandle = -1;
95731
+ this.#animationFrameHandle = -1;
95732
+ }
95678
95733
  }
95679
95734
 
95680
95735
  /**