@needle-tools/engine 3.21.1-alpha.1 → 3.21.3

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/CHANGELOG.md CHANGED
@@ -4,6 +4,15 @@ All notable changes to this package will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [3.21.3] - 2023-10-23
8
+ - Fix: Issue where Chrome touch emulation caused "onPointerClick" being called twice per click
9
+ - Fix: EventList instances are now not shared anymore between components created via `instantiate`
10
+ - Fix: Regression where SphereCollider radius was not being applied
11
+
12
+ ## [3.21.2] - 2023-10-23
13
+ - Change: Expose EventList subscriber count
14
+ - Change: `PointerEventArgs.use()` should not stop propagation
15
+
7
16
  ## [3.21.1-alpha] - 2023-10-20
8
17
  - Add: Multitouch support on `input` events, our EventSystem implementation now handles multitouch cases and is using the browser events directly and immediately (before events via `window` where deferred and hanlded during the engine update loop)
9
18
 
@@ -22100,8 +22100,10 @@ class LV extends EventTarget {
22100
22100
  }
22101
22101
  // moveEvent?: Event;
22102
22102
  onMove(e) {
22103
- const t = this.getPointerPressed(e.button);
22104
- t === !1 && !this.isInRect(e) || e.pointerType === "touch" && !t || (co && console.log(e.pointerType, "MOVE", e.button), this.updatePointerPosition(e), this.setPointerStateT(e.button, this._pointerEvent, e.source), this.onDispatchEvent(e));
22103
+ const t = e.button;
22104
+ this._pointerClick[t] = !1, this._pointerDoubleClick[t] = !1;
22105
+ const g = this.getPointerPressed(t);
22106
+ g === !1 && !this.isInRect(e) || e.pointerType === "touch" && !g || (co && console.log(e.pointerType, "MOVE", t), this.updatePointerPosition(e), this.setPointerStateT(t, this._pointerEvent, e.source), this.onDispatchEvent(e));
22105
22107
  }
22106
22108
  onUp(e) {
22107
22109
  var o;
@@ -30186,7 +30188,7 @@ function Zz(i) {
30186
30188
  }
30187
30189
  function KK(i, A, e, t) {
30188
30190
  var g, I;
30189
- if (e != null) {
30191
+ if (e != null)
30190
30192
  if (e.isComponent === !0) {
30191
30193
  const o = e.gameObject;
30192
30194
  if (o) {
@@ -30209,9 +30211,12 @@ function KK(i, A, e, t) {
30209
30211
  if (C)
30210
30212
  return Ip && console.log(A, "old", e, "new", C), C;
30211
30213
  }
30212
- } else if (e.isVector4 || e.isVector3 || e.isVector2 || e.isQuaternion || e.isEuler)
30213
- return e.clone();
30214
- }
30214
+ } else {
30215
+ if (e.isVector4 || e.isVector3 || e.isVector2 || e.isQuaternion || e.isEuler)
30216
+ return e.clone();
30217
+ if (e.isEventList === !0)
30218
+ return new e.constructor();
30219
+ }
30215
30220
  }
30216
30221
  const oG = sA("debugnewscripts"), Xz = sA("debughierarchy"), _t = [];
30217
30222
  function $z() {
@@ -45939,6 +45944,8 @@ class HM extends Event {
45939
45944
  }
45940
45945
  class qg {
45941
45946
  constructor(A) {
45947
+ /** checked during instantiate to create a new instance */
45948
+ r(this, "isEventList", !0);
45942
45949
  r(this, "target");
45943
45950
  r(this, "key");
45944
45951
  r(this, "_isInvoking", !1);
@@ -45958,25 +45965,36 @@ class qg {
45958
45965
  this.key = t;
45959
45966
  }
45960
45967
  }
45968
+ /** How many callback methods are subscribed to this event */
45969
+ get listenerCount() {
45970
+ var A;
45971
+ return ((A = this.methods) == null ? void 0 : A.length) ?? 0;
45972
+ }
45973
+ /** If the event is currently being invoked */
45974
+ get isInvoking() {
45975
+ return this._isInvoking;
45976
+ }
45961
45977
  invoke(...A) {
45962
- if (this._isInvoking) {
45963
- console.warn("Circular event invocation detected. Please check your event listeners for circular references.", this);
45964
- return;
45965
- }
45978
+ var e;
45979
+ if (this._isInvoking)
45980
+ return console.warn("Circular event invocation detected. Please check your event listeners for circular references.", this), !1;
45981
+ if (((e = this.methods) == null ? void 0 : e.length) <= 0)
45982
+ return !1;
45966
45983
  this._isInvoking = !0;
45967
45984
  try {
45968
- for (const e of this.methods)
45969
- e.invoke(...A);
45985
+ for (const t of this.methods)
45986
+ t.invoke(...A);
45970
45987
  if (typeof this.target == "object" && typeof this.key == "string") {
45971
- const e = this.target.dispatchEvent;
45972
- if (typeof e == "function") {
45973
- const t = new HM(this.key);
45974
- t.args = A, e.call(this.target, t);
45988
+ const t = this.target.dispatchEvent;
45989
+ if (typeof t == "function") {
45990
+ const g = new HM(this.key);
45991
+ g.args = A, t.call(this.target, g);
45975
45992
  }
45976
45993
  }
45977
45994
  } finally {
45978
45995
  this._isInvoking = !1;
45979
45996
  }
45997
+ return !0;
45980
45998
  }
45981
45999
  addEventListener(A) {
45982
46000
  return this.methods.push(new Lh(A, !0)), A;
@@ -61285,10 +61303,15 @@ const Us = class extends NA {
61285
61303
  * Propagate up in hiearchy and call the callback for each component that is possibly a handler
61286
61304
  */
61287
61305
  propagate(e, t, g) {
61288
- for (; !(t.used || (IA.foreachComponent(e, (I) => {
61289
- g(I);
61290
- }, !1), !e.parent)); )
61306
+ for (; ; ) {
61307
+ if (t.used)
61308
+ return;
61309
+ if (IA.foreachComponent(e, (I) => {
61310
+ g(I);
61311
+ }, !1), !e.parent)
61312
+ break;
61291
61313
  e = e.parent;
61314
+ }
61292
61315
  }
61293
61316
  /**
61294
61317
  * Propagate up in hiearchy and call handlers based on the pointer event data
@@ -64698,8 +64721,7 @@ class ma extends NA {
64698
64721
  bB && console.warn("Button Up", (t = this.animationTriggers) == null ? void 0 : t.highlightedTrigger, this.animator, this._isHovered), this.interactable && (this.transition == 3 && this.animationTriggers && this.animator ? this.animator.setTrigger(this._isHovered ? this.animationTriggers.highlightedTrigger : this.animationTriggers.normalTrigger) : this.transition === 1 && this.colors && ((g = this._image) == null || g.setState(this._isHovered ? "hovered" : "normal")));
64699
64722
  }
64700
64723
  onPointerClick(e) {
64701
- var t;
64702
- !this.interactable || e.pointerId === void 0 || e.pointerId !== 0 && this.context.input.getIsMouse(e.pointerId) || (bB && (console.warn("Button Click", this.onClick), Fi("CLICKED button " + this.name + " at " + this.context.time.frameCount)), (t = this.onClick) == null || t.invoke(), e.use());
64724
+ !this.interactable || e.pointerId === void 0 || e.pointerId !== 0 && this.context.input.getIsMouse(e.pointerId) || (bB && (console.warn("Button Click", this.onClick), Fi("CLICKED button " + this.name + " at " + this.context.time.frameCount)), this.onClick && this.onClick.listenerCount > 0 && (this.onClick.invoke(), e.use()));
64703
64725
  }
64704
64726
  set interactable(e) {
64705
64727
  this._interactable = e, this._image && (this._image.setInteractable(e), e ? this._image.setState("normal") : this._image.setState("disabled"));
@@ -89620,8 +89642,8 @@ const lh = class {
89620
89642
  const t = e.shape;
89621
89643
  switch (t.type) {
89622
89644
  case Ve.Ball: {
89623
- const o = t, s = A, C = o.radius !== s.radius, n = A.gameObject, a = Ng(n, this._tempPosition).multiplyScalar(s.radius);
89624
- o.radius = Math.abs(a.x), C && e.setShape(o);
89645
+ const o = t, s = A, C = A.gameObject, n = Ng(C, this._tempPosition).multiplyScalar(s.radius), a = s.radius * Math.abs(n.x), B = o.radius !== a;
89646
+ o.radius = a, B && e.setShape(o);
89625
89647
  break;
89626
89648
  }
89627
89649
  case Ve.Cuboid: