laymur 0.14.2 → 0.15.0

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/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { MathUtils, Color, Vector4, Texture, Vector2, Vector3, Matrix3, Matrix4, PlaneGeometry, InstancedBufferGeometry, ShaderMaterial, InstancedBufferAttribute, Mesh, Scene, OrthographicCamera, Quaternion, CanvasTexture, UVMapping, ClampToEdgeWrapping, LinearFilter, RGBAFormat, UnsignedByteType, SRGBColorSpace, NoColorSpace, WebGLRenderTarget, PerspectiveCamera, Ray } from 'three';
2
2
 
3
- class t{constructor(t,i,r=0){this.t=new WeakMap,this.i=new Map,void 0!==t&&(void 0===i?this.i.set(t,r):this.t.set(i,new Map([[t,r]])));}insert(t,i,r=0){if(void 0===i){if(this.i.has(t))return;return void this.i.set(t,r)}const s=this.t.get(i);void 0===s?this.t.set(i,new Map([[t,r]])):s.has(t)||s.set(t,r);}remove(t,i){if(void 0===i)return void this.i.delete(t);const r=this.t.get(i);void 0!==r&&(r.delete(t),0===r.size&&this.t.delete(i));}has(t,i){if(void 0===i)return this.i.has(t);const r=this.t.get(i);return void 0!==r&&r.has(t)}getPriority(t,i){if(void 0===i)return this.i.get(t);const r=this.t.get(i);return void 0!==r?r.get(t):void 0}}class i{constructor(){this.o=new Map;}on(t,i,r,s=0){return this.h(t,false,s,i,r),this}once(t,i,r,s=0){return this.h(t,true,s,i,r),this}off(t,i,r){const s=this.o.get(t);if(void 0===s)return this;s.u&&(s.u=false,s.v=s.v.slice());const o=s.v;if(0===o.length)return this.o.delete(t),this;if(void 0===i){this.o.delete(t);for(let t=0;o.length>t;t++){const i=o[t];s.l.remove(i._,i.p);}return this}{const e=o.length;if(o[0]._===i&&o[0].p===r)return 1===e?this.o.delete(t):o.shift(),this;const n=e-1;if(o[n]._===i&&o[n].p===r)return o.pop(),this;if(10>e||o[0].M===o[n].M)for(let t=1;n>t;t++){const s=o[t];if(s._===i&&s.p===r)return o.splice(t,1),this}else {const t=s.l.getPriority(i,r);if(void 0===t)return this;let e=0,n=o.length-1;for(;n>=e;){const i=e+n>>>1;t>o[i].M?e=i+1:n=i-1;}const c=e;for(n=o.length-1;n>=e;){const i=e+n>>>1;o[i].M>t?n=i-1:e=i+1;}const h=n;for(let t=c;h>=t;t++)if(o[t]._===i&&o[t].p===r)return o.splice(t,1),this}}return this}emit(t,...i){const r=this.o.get(t);if(void 0===r)return false;if(0===r.v.length)return false;r.u?r.v=r.v.slice():r.u=true;const s=r.v;let o=false;for(let t=0;s.length>t;t++){const r=s[t];r._.apply(r.p,i),r.k&&(o=true,r.m=true);}const e=this.o.get(t);if(void 0===e)return true;e.v===s&&(e.u=false);const n=e.v;if(o){let i=0;for(let t=0;n.length>t;t++){const r=n[t];r.m?e.l.remove(r._,r.p):n[i++]=r;}0===i?this.o.delete(t):n.length=i;}return true}h(i,r,s,o,e){let n=this.o.get(i);if(void 0===n)return void this.o.set(i,{v:[{_:o,p:e,M:s,k:r,m:false}],u:false,l:new t(o,e,s)});if(n.l.has(o,e))throw Error("Event listener already exists");n.l.insert(o,e,s);const c={_:o,p:e,M:s,k:r,m:false};n.u&&(n.u=false,n.v=n.v.slice());{const t=n.v,i=c.M;if(0===t.length||i>=t[t.length-1].M)return void t.push(c);if(t[0].M>=i)return void t.unshift(c);{let r=0,s=t.length;for(;s>r;){const o=r+s>>>1;i>t[o].M?r=o+1:s=o;}t.splice(r,0,c);}}}}
3
+ class i{constructor(){this.i=0,this.t=false;}on(i){this.i>0?(this.h??(this.h=[])).push(i):this.o(i);}once(i){if(this.i>0)return (this.h??(this.h=[])).push(i),void(this.v??(this.v=new Set)).add(i);(this.l??(this.l=new Set)).add(i),this.o(i);}off(i){if(void 0!==this.h){const t=this.h.indexOf(i);if(-1!==t)return this.h.splice(t,1),void this.v?.delete(i)}this.l?.delete(i),this.i>0?this._(i):this.u(i);}m(){if(void 0!==this.l&&this.l.size>0&&(this.l.forEach(i=>{this._(i);}),this.l=void 0),this.t&&(this.t=false,this.p()),void 0!==this.h&&this.h.length>0){for(let i=0;this.h.length>i;i++){const t=this.h[i];true===this.v?.has(t)&&(this.l??(this.l=new Set)).add(t),this.o(t);}this.h=void 0,this.v=void 0;}}o(i){ void 0!==this.S?void 0!==this.I?void 0!==this.R?void 0!==this.k?void 0!==this.C?void 0!==this.F?void 0!==this.N?void 0!==this.j?void 0!==this.q?void 0!==this.A?(this.B??(this.B=[])).push(i):this.A=i:this.q=i:this.j=i:this.N=i:this.F=i:this.C=i:this.k=i:this.R=i:this.I=i:this.S=i;}_(i){if(this.t=true,this.S!==i)if(this.I!==i)if(this.R!==i)if(this.k!==i)if(this.C!==i)if(this.F!==i)if(this.N!==i)if(this.j!==i)if(this.q!==i)if(this.A!==i){if(void 0!==this.B){const t=this.B.indexOf(i);-1!==t&&(this.B[t]=void 0);}}else this.A=void 0;else this.q=void 0;else this.j=void 0;else this.N=void 0;else this.F=void 0;else this.C=void 0;else this.k=void 0;else this.R=void 0;else this.I=void 0;else this.S=void 0;}u(i){if(this.S===i)return this.S=void 0,void this.p();if(this.I===i)return this.I=void 0,void this.p();if(this.R===i)return this.R=void 0,void this.p();if(this.k===i)return this.k=void 0,void this.p();if(this.C===i)return this.C=void 0,void this.p();if(this.F===i)return this.F=void 0,void this.p();if(this.N===i)return this.N=void 0,void this.p();if(this.j===i)return this.j=void 0,void this.p();if(this.q===i)return this.q=void 0,void this.p();if(this.A===i)return this.A=void 0,void this.p();if(void 0!==this.B){const t=this.B.indexOf(i);-1!==t&&(this.B.splice(t,1),0===this.B.length&&(this.B=void 0));}}p(){const i=[];if(void 0!==this.S&&i.push(this.S),void 0!==this.I&&i.push(this.I),void 0!==this.R&&i.push(this.R),void 0!==this.k&&i.push(this.k),void 0!==this.C&&i.push(this.C),void 0!==this.F&&i.push(this.F),void 0!==this.N&&i.push(this.N),void 0!==this.j&&i.push(this.j),void 0!==this.q&&i.push(this.q),void 0!==this.A&&i.push(this.A),void 0!==this.B){for(let t=0;this.B.length>t;t++){const s=this.B[t];void 0!==s&&i.push(s);}this.B=void 0;}const t=i.length;this.S=t>0?i[0]:void 0,this.I=t>1?i[1]:void 0,this.R=t>2?i[2]:void 0,this.k=t>3?i[3]:void 0,this.C=t>4?i[4]:void 0,this.F=t>5?i[5]:void 0,this.N=t>6?i[6]:void 0,this.j=t>7?i[7]:void 0,this.q=t>8?i[8]:void 0,this.A=t>9?i[9]:void 0,t>10&&(this.B=i.slice(10));}D(i){return this.S===i||this.I===i||this.R===i||this.k===i||this.C===i||this.F===i||this.N===i||this.j===i||this.q===i||this.A===i}G(i){return !!this.D(i)||true===this.B?.includes(i)||true===this.h?.includes(i)}H(i){}J(i){}}class t extends i{emit(){if(this.i++,this.S?.(),this.I?.(),this.R?.(),this.k?.(),this.C?.(),this.F?.(),this.N?.(),this.j?.(),this.q?.(),this.A?.(),void 0!==this.B)for(let i=0;this.B.length>i;i++)this.B[i]?.();this.i--,0===this.i&&this.m();}}class s extends i{emit(i){if(this.i++,this.S?.(i),this.I?.(i),this.R?.(i),this.k?.(i),this.C?.(i),this.F?.(i),this.N?.(i),this.j?.(i),this.q?.(i),this.A?.(i),void 0!==this.B)for(let t=0;this.B.length>t;t++)this.B[t]?.(i);this.i--,0===this.i&&this.m();}}class h extends i{emit(i,t){if(this.i++,this.S?.(i,t),this.I?.(i,t),this.R?.(i,t),this.k?.(i,t),this.C?.(i,t),this.F?.(i,t),this.N?.(i,t),this.j?.(i,t),this.q?.(i,t),this.A?.(i,t),void 0!==this.B)for(let s=0;this.B.length>s;s++){const h=this.B[s];h?.(i,t);}this.i--,0===this.i&&this.m();}}class o extends i{emit(i,t,s){if(this.i++,this.S?.(i,t,s),this.I?.(i,t,s),this.R?.(i,t,s),this.k?.(i,t,s),this.C?.(i,t,s),this.F?.(i,t,s),this.N?.(i,t,s),this.j?.(i,t,s),this.q?.(i,t,s),this.A?.(i,t,s),void 0!==this.B)for(let h=0;this.B.length>h;h++){const o=this.B[h];o?.(i,t,s);}this.i--,0===this.i&&this.m();}}
4
4
 
5
5
  /** Visibility and interactivity state */
6
6
  var UIMode;
@@ -4329,28 +4329,20 @@ class UISolverWrapper {
4329
4329
  }
4330
4330
  }
4331
4331
 
4332
- /** Layer lifecycle and state events */
4333
- var UILayerEvent;
4334
- (function (UILayerEvent) {
4335
- /** Fired when orientation changes */
4336
- UILayerEvent["ORIENTATION_CHANGED"] = "orientation_changed";
4337
- /** Fired when mode changes */
4338
- UILayerEvent["MODE_CHANGED"] = "mode_changed";
4339
- /** Fired during rendering */
4340
- UILayerEvent["RENDERING"] = "rendering";
4341
- })(UILayerEvent || (UILayerEvent = {}));
4342
4332
  const LAYER_DEFAULT_SIZE = 1024;
4343
4333
  const LAYER_DEFAULT_NAME = "";
4344
4334
  const LAYER_DEFAULT_MODE = UIMode.VISIBLE;
4345
4335
 
4346
4336
  /** Base layer for UI rendering and layout management */
4347
- class UILayer extends i {
4337
+ class UILayer {
4348
4338
  constructor(options) {
4349
- super();
4350
4339
  /** Optional layer name */
4351
4340
  this.name = "";
4352
4341
  this.inputWrapperInternal = new UIInputWrapper();
4353
4342
  this._private_solverWrapperInternal = new UISolverWrapper();
4343
+ this._private_signalOrientationChangedInternal = new h();
4344
+ this._private_signalModeChangedInternal = new h();
4345
+ this._private_signalRenderingInternal = new o();
4354
4346
  if (options.width !== undefined) {
4355
4347
  assertValidPositiveNumber(options.width, "UILayer.constructor.options.width");
4356
4348
  }
@@ -4405,11 +4397,23 @@ class UILayer extends i {
4405
4397
  get orientation() {
4406
4398
  return this._private_orientationInternal;
4407
4399
  }
4400
+ /** Signal fired when orientation changes */
4401
+ get signalOrientationChanged() {
4402
+ return this._private_signalOrientationChangedInternal;
4403
+ }
4404
+ /** Signal fired when mode changes */
4405
+ get signalModeChanged() {
4406
+ return this._private_signalModeChangedInternal;
4407
+ }
4408
+ /** Signal fired during rendering */
4409
+ get signalRendering() {
4410
+ return this._private_signalRenderingInternal;
4411
+ }
4408
4412
  /** Updates visibility and interactivity mode */
4409
4413
  set mode(value) {
4410
4414
  if (value !== this._private_modeInternal) {
4411
4415
  this._private_modeInternal = value;
4412
- this.emit(UILayerEvent.MODE_CHANGED, this._private_modeInternal, this);
4416
+ this._private_signalModeChangedInternal.emit(this._private_modeInternal, this);
4413
4417
  }
4414
4418
  }
4415
4419
  resizeInternal(width, height) {
@@ -4419,12 +4423,12 @@ class UILayer extends i {
4419
4423
  const orientation = width > height ? UIOrientation.HORIZONTAL : UIOrientation.VERTICAL;
4420
4424
  if (orientation !== this._private_orientationInternal) {
4421
4425
  this._private_orientationInternal = orientation;
4422
- this.emit(UILayerEvent.ORIENTATION_CHANGED, this._private_orientationInternal, this);
4426
+ this._private_signalOrientationChangedInternal.emit(this._private_orientationInternal, this);
4423
4427
  }
4424
4428
  }
4425
4429
  renderInternal(renderer, deltaTime) {
4426
4430
  if (isUIModeVisible(this.mode)) {
4427
- this.emit(UILayerEvent.RENDERING, renderer, deltaTime, this);
4431
+ this._private_signalRenderingInternal.emit(renderer, deltaTime, this);
4428
4432
  this._private_sceneWrapperInternal.render(renderer);
4429
4433
  }
4430
4434
  this._private_solverWrapperInternal.dirty = false;
@@ -4654,7 +4658,7 @@ class UISingleParameterConstraint extends UIConstraint {
4654
4658
  this._private_priorityInternal = resolvePriority(options?.priority);
4655
4659
  this._private_relationInternal = resolveRelation(options?.relation);
4656
4660
  this._private_orientationInternal = resolveOrientation(options?.orientation);
4657
- this.layer.on(UILayerEvent.ORIENTATION_CHANGED, this._private_onOrientationChange);
4661
+ this.layer.signalOrientationChanged.on(this._private_onOrientationChange);
4658
4662
  }
4659
4663
  /** Constraint priority */
4660
4664
  get priority() {
@@ -4691,7 +4695,7 @@ class UISingleParameterConstraint extends UIConstraint {
4691
4695
  }
4692
4696
  /** Removes constraint from solver and cleans up listeners */
4693
4697
  destroy() {
4694
- this.layer.off(UILayerEvent.ORIENTATION_CHANGED, this._private_onOrientationChange);
4698
+ this.layer.signalOrientationChanged.off(this._private_onOrientationChange);
4695
4699
  this.solverWrapper.removeConstraint(this.constraint);
4696
4700
  }
4697
4701
  /**
@@ -5615,7 +5619,7 @@ const ANCHOR_DEFAULT_X = 0;
5615
5619
  const ANCHOR_DEFAULT_Y = 0;
5616
5620
 
5617
5621
  /** Point in 2D space with constraint-based positioning */
5618
- class UIAnchor extends i {
5622
+ class UIAnchor {
5619
5623
  /**
5620
5624
  * Creates a new UIAnchor instance.
5621
5625
  *
@@ -5623,14 +5627,13 @@ class UIAnchor extends i {
5623
5627
  * @param options - Configuration options
5624
5628
  */
5625
5629
  constructor(layer, options) {
5630
+ this.layer = layer;
5631
+ /** Optional identifier for debugging */
5632
+ this.name = "";
5626
5633
  const x = options?.x ?? ANCHOR_DEFAULT_X;
5627
5634
  const y = options?.y ?? ANCHOR_DEFAULT_Y;
5628
5635
  assertValidNumber(x, "UIAnchor.constructor.options.x");
5629
5636
  assertValidNumber(y, "UIAnchor.constructor.options.y");
5630
- super();
5631
- this.layer = layer;
5632
- /** Optional identifier for debugging */
5633
- this.name = "";
5634
5637
  this.solverWrapper = this.layer.solverWrapper;
5635
5638
  this.xVariable = this.solverWrapper.createVariable(x, UIPriority.P7);
5636
5639
  this.yVariable = this.solverWrapper.createVariable(y, UIPriority.P7);
@@ -5756,18 +5759,11 @@ function computeTrimmedTransformMatrix(x, y, width, height, zIndex, microX, micr
5756
5759
 
5757
5760
  const TEXTURE_DEFAULT_TEXTURE = new Texture();
5758
5761
  const TEXTURE_DEFAULT_SIZE = 2;
5759
- /** Events emitted by UITexture */
5760
- var UITextureViewEvent;
5761
- (function (UITextureViewEvent) {
5762
- /** Emitted when width or height changes */
5763
- UITextureViewEvent[UITextureViewEvent["DIMENSIONS_CHANGED"] = 0] = "DIMENSIONS_CHANGED";
5764
- })(UITextureViewEvent || (UITextureViewEvent = {}));
5765
5762
 
5766
5763
  /** Wrapper for Three.js texture with atlas and trim support. Does not own the underlying texture; user must dispose it. */
5767
- class UITextureView extends i {
5764
+ class UITextureView {
5768
5765
  /** @param config Texture or atlas configuration */
5769
5766
  constructor(config) {
5770
- super();
5771
5767
  this._private_textureInternal = TEXTURE_DEFAULT_TEXTURE;
5772
5768
  this._private_sourceWidth = TEXTURE_DEFAULT_SIZE;
5773
5769
  this._private_sourceHeight = TEXTURE_DEFAULT_SIZE;
@@ -5784,6 +5780,7 @@ class UITextureView extends i {
5784
5780
  this._private_textureDirtyInternal = false;
5785
5781
  this._private_uvTransformDirtyInternal = false;
5786
5782
  this._private_trimDirtyInternal = false;
5783
+ this._private_signalDiminsionsChangedInternal = new o();
5787
5784
  if (config !== undefined) {
5788
5785
  this.set(config);
5789
5786
  }
@@ -5839,6 +5836,9 @@ class UITextureView extends i {
5839
5836
  get trimDirty() {
5840
5837
  return this._private_trimDirtyInternal;
5841
5838
  }
5839
+ get signalDiminsionsChanged() {
5840
+ return this._private_signalDiminsionsChangedInternal;
5841
+ }
5842
5842
  setTextureDirtyFalse() {
5843
5843
  this._private_textureDirtyInternal = false;
5844
5844
  }
@@ -5898,7 +5898,7 @@ class UITextureView extends i {
5898
5898
  this._private_setFromAtlasConfig(config);
5899
5899
  }
5900
5900
  if (this.width !== lastWidth || this.height !== lastHeight) {
5901
- this.emit(UITextureViewEvent.DIMENSIONS_CHANGED, this.width, this.height, this);
5901
+ this._private_signalDiminsionsChangedInternal.emit(this.width, this.height, this);
5902
5902
  }
5903
5903
  }
5904
5904
  _private_setFromTexture(texture) {
@@ -6202,21 +6202,6 @@ class UIAreaRectangle extends UIArea {
6202
6202
  }
6203
6203
  }
6204
6204
 
6205
- /** Input events emitted by UI elements */
6206
- var UIInputEvent;
6207
- (function (UIInputEvent) {
6208
- /** Pointer pressed */
6209
- UIInputEvent["PRESSED"] = "pointerdown";
6210
- /** Pointer moved */
6211
- UIInputEvent["MOVED"] = "pointermove";
6212
- /** Pointer released */
6213
- UIInputEvent["RELEASED"] = "pointerup";
6214
- /** Pointer entered element */
6215
- UIInputEvent["ENTERED"] = "pointerenter";
6216
- /** Pointer left element */
6217
- UIInputEvent["LEFT"] = "pointerleave";
6218
- })(UIInputEvent || (UIInputEvent = {}));
6219
-
6220
6205
  const DUMMY_DEFAULT_WIDTH = 64;
6221
6206
  const DUMMY_DEFAULT_HEIGHT = 32;
6222
6207
  const DUMMY_DEFAULT_MODE = UIMode.VISIBLE;
@@ -6237,14 +6222,19 @@ class UIInputDummy extends UIAnchor {
6237
6222
  assertValidPositiveNumber(h, "UIInputDummy.constructor.height");
6238
6223
  super(layer, options);
6239
6224
  this._private_wasPointerInside = false;
6225
+ this._private_signalPressedInternal = new s();
6226
+ this._private_signalMovedInternal = new s();
6227
+ this._private_signalReleasedInternal = new s();
6228
+ this._private_signalEnteredInternal = new s();
6229
+ this._private_signalLeftInternal = new s();
6240
6230
  this.catchPointerDown = (x, y, identifier) => {
6241
- return this.handleInputEvent(x, y, identifier, UIInputEvent.PRESSED);
6231
+ return this.handleInputEvent(x, y, identifier, this._private_signalPressedInternal);
6242
6232
  };
6243
6233
  this.catchPointerMove = (x, y, identifier) => {
6244
- return this.handleInputEvent(x, y, identifier, UIInputEvent.MOVED);
6234
+ return this.handleInputEvent(x, y, identifier, this._private_signalMovedInternal);
6245
6235
  };
6246
6236
  this.catchPointerUp = (x, y, identifier) => {
6247
- return this.handleInputEvent(x, y, identifier, UIInputEvent.RELEASED);
6237
+ return this.handleInputEvent(x, y, identifier, this._private_signalReleasedInternal);
6248
6238
  };
6249
6239
  this.interactionArea =
6250
6240
  options?.interactionArea ?? new UIAreaRectangle(0, 0, 1, 1);
@@ -6287,6 +6277,26 @@ class UIInputDummy extends UIAnchor {
6287
6277
  get zIndex() {
6288
6278
  return this.inputWrapper.getZIndex(this._private_catcherHandler);
6289
6279
  }
6280
+ /** Signal fired when pointer is pressed */
6281
+ get signalPressed() {
6282
+ return this._private_signalPressedInternal;
6283
+ }
6284
+ /** Signal fired when pointer is moved */
6285
+ get signalMoved() {
6286
+ return this._private_signalMovedInternal;
6287
+ }
6288
+ /** Signal fired when pointer is released */
6289
+ get signalReleased() {
6290
+ return this._private_signalReleasedInternal;
6291
+ }
6292
+ /** Signal fired when pointer enters element */
6293
+ get signalEntered() {
6294
+ return this._private_signalEnteredInternal;
6295
+ }
6296
+ /** Signal fired when pointer leaves element */
6297
+ get signalLeft() {
6298
+ return this._private_signalLeftInternal;
6299
+ }
6290
6300
  /** Width in world units */
6291
6301
  set width(value) {
6292
6302
  assertValidPositiveNumber(value, "UIInputDummy.width");
@@ -6337,19 +6347,19 @@ class UIInputDummy extends UIAnchor {
6337
6347
  this.inputWrapper.destroyInputCatcher(this._private_catcherHandler);
6338
6348
  super.destroy();
6339
6349
  }
6340
- handleInputEvent(x, y, identifier, inputEvent) {
6350
+ handleInputEvent(x, y, identifier, signal) {
6341
6351
  assertValidNumber(x, "UIInputDummy.handleInputEvent.x");
6342
6352
  assertValidNumber(y, "UIInputDummy.handleInputEvent.y");
6343
6353
  assertValidNumber(identifier, "UIInputDummy.handleInputEvent.identifier");
6344
6354
  const isPointerInside = this.interactionArea.contains(MathUtils.mapLinear(x, this.x, this.oppositeX, 0, 1), MathUtils.mapLinear(y, this.y, this.oppositeY, 0, 1));
6345
6355
  if (isPointerInside) {
6346
- this.emit(inputEvent, x, y, identifier, this);
6356
+ signal.emit({ x, y, identifier, element: this });
6347
6357
  }
6348
6358
  if (this._private_wasPointerInside && !isPointerInside) {
6349
- this.emit(UIInputEvent.LEFT, x, y, identifier, this);
6359
+ this._private_signalLeftInternal.emit({ x, y, identifier, element: this });
6350
6360
  }
6351
6361
  else if (!this._private_wasPointerInside && isPointerInside) {
6352
- this.emit(UIInputEvent.ENTERED, x, y, identifier, this);
6362
+ this._private_signalEnteredInternal.emit({ x, y, identifier, element: this });
6353
6363
  }
6354
6364
  this._private_wasPointerInside = isPointerInside;
6355
6365
  return (this.modeInternal !== UIMode.INTERACTIVE_TRANSPARENT && isPointerInside);
@@ -6377,7 +6387,7 @@ class UIElement extends UIInputDummy {
6377
6387
  options?.transparencyMode ?? ELEMENT_DEFAULT_TRANSPARENCY_MODE;
6378
6388
  this.sceneWrapper = this.layer.sceneWrapper;
6379
6389
  this.planeHandler = this.sceneWrapper.createPlane(source, properties, new Matrix4().identity(), isUIModeVisible(options?.mode ?? this.mode), this._private_transparencyModeInternal);
6380
- this.layer.on(UILayerEvent.RENDERING, this.onWillRender, this);
6390
+ this.layer.signalRendering.on(this.onWillRender);
6381
6391
  }
6382
6392
  /** Alpha blending mode */
6383
6393
  get transparencyMode() {
@@ -6399,7 +6409,7 @@ class UIElement extends UIInputDummy {
6399
6409
  }
6400
6410
  /** Removes element and frees resources */
6401
6411
  destroy() {
6402
- this.layer.off(UILayerEvent.RENDERING, this.onWillRender, this);
6412
+ this.layer.signalRendering.off(this.onWillRender);
6403
6413
  this.sceneWrapper.destroyPlane(this.planeHandler);
6404
6414
  super.destroy();
6405
6415
  }
@@ -6425,16 +6435,6 @@ class UIElement extends UIInputDummy {
6425
6435
  }
6426
6436
  }
6427
6437
 
6428
- /** Animation playback events */
6429
- var UIAnimatedImageEvent;
6430
- (function (UIAnimatedImageEvent) {
6431
- /** Animation started or resumed */
6432
- UIAnimatedImageEvent[UIAnimatedImageEvent["PLAYED"] = 0] = "PLAYED";
6433
- /** Animation paused */
6434
- UIAnimatedImageEvent[UIAnimatedImageEvent["PAUSED"] = 1] = "PAUSED";
6435
- /** Animation stopped and reset */
6436
- UIAnimatedImageEvent[UIAnimatedImageEvent["STOPPED"] = 2] = "STOPPED";
6437
- })(UIAnimatedImageEvent || (UIAnimatedImageEvent = {}));
6438
6438
  /** Animation loop behavior */
6439
6439
  var UIAnimatedImageLoopMode;
6440
6440
  (function (UIAnimatedImageLoopMode) {
@@ -6476,6 +6476,9 @@ class UIAnimatedImage extends UIElement {
6476
6476
  this._private_sequenceFrameIndex = 0;
6477
6477
  this._private_currentFrameIndexDirty = false;
6478
6478
  this._private_accumulatedTime = 0;
6479
+ this._private_signalPlayedInternal = new t();
6480
+ this._private_signalPausedInternal = new t();
6481
+ this._private_signalStoppedInternal = new t();
6479
6482
  this._private_onTextureDimensionsChanged = (width, height, texture) => {
6480
6483
  if (this._private_sequenceInternal[this._private_sequenceFrameIndex] === texture) {
6481
6484
  this.width = width;
@@ -6520,6 +6523,18 @@ class UIAnimatedImage extends UIElement {
6520
6523
  get timeScale() {
6521
6524
  return this._private_timeScaleInternal;
6522
6525
  }
6526
+ /** Signal fired when animation starts or resumes */
6527
+ get signalPlayed() {
6528
+ return this._private_signalPlayedInternal;
6529
+ }
6530
+ /** Signal fired when animation pauses */
6531
+ get signalPaused() {
6532
+ return this._private_signalPausedInternal;
6533
+ }
6534
+ /** Signal fired when animation stops and resets */
6535
+ get signalStopped() {
6536
+ return this._private_signalStoppedInternal;
6537
+ }
6523
6538
  /** Multiplicative tint. Alpha channel controls opacity. */
6524
6539
  set color(value) {
6525
6540
  this._private_colorInternal.set(value);
@@ -6566,14 +6581,14 @@ class UIAnimatedImage extends UIElement {
6566
6581
  play() {
6567
6582
  if (!this._private_isPlaying) {
6568
6583
  this._private_isPlaying = true;
6569
- this.emit(UIAnimatedImageEvent.PLAYED);
6584
+ this._private_signalPlayedInternal.emit();
6570
6585
  }
6571
6586
  }
6572
6587
  /** Pauses animation at current frame */
6573
6588
  pause() {
6574
6589
  if (this._private_isPlaying) {
6575
6590
  this._private_isPlaying = false;
6576
- this.emit(UIAnimatedImageEvent.PAUSED);
6591
+ this._private_signalPausedInternal.emit();
6577
6592
  }
6578
6593
  }
6579
6594
  /** Stops animation and resets to first frame */
@@ -6585,7 +6600,7 @@ class UIAnimatedImage extends UIElement {
6585
6600
  this._private_accumulatedTime = 0;
6586
6601
  this._private_sequenceFrameIndex = 0;
6587
6602
  this._private_currentFrameIndexDirty = true;
6588
- this.emit(UIAnimatedImageEvent.STOPPED);
6603
+ this._private_signalStoppedInternal.emit();
6589
6604
  }
6590
6605
  }
6591
6606
  onWillRender(renderer, deltaTime) {
@@ -6609,7 +6624,7 @@ class UIAnimatedImage extends UIElement {
6609
6624
  else {
6610
6625
  this._private_sequenceFrameIndex = lastFrameIndex;
6611
6626
  this._private_isPlaying = false;
6612
- this.emit(UIAnimatedImageEvent.PAUSED);
6627
+ this._private_signalPausedInternal.emit();
6613
6628
  break;
6614
6629
  }
6615
6630
  }
@@ -6631,7 +6646,7 @@ class UIAnimatedImage extends UIElement {
6631
6646
  else {
6632
6647
  this._private_sequenceFrameIndex = 0;
6633
6648
  this._private_isPlaying = false;
6634
- this.emit(UIAnimatedImageEvent.PAUSED);
6649
+ this._private_signalPausedInternal.emit();
6635
6650
  break;
6636
6651
  }
6637
6652
  }
@@ -6678,12 +6693,12 @@ class UIAnimatedImage extends UIElement {
6678
6693
  }
6679
6694
  _private_subscribeSequenceEvents() {
6680
6695
  for (const frame of this._private_sequenceInternal) {
6681
- frame.on(UITextureViewEvent.DIMENSIONS_CHANGED, this._private_onTextureDimensionsChanged);
6696
+ frame.signalDiminsionsChanged.on(this._private_onTextureDimensionsChanged);
6682
6697
  }
6683
6698
  }
6684
6699
  _private_unsubscribeSequenceEvents() {
6685
6700
  for (const frame of this._private_sequenceInternal) {
6686
- frame.off(UITextureViewEvent.DIMENSIONS_CHANGED, this._private_onTextureDimensionsChanged);
6701
+ frame.signalDiminsionsChanged.off(this._private_onTextureDimensionsChanged);
6687
6702
  }
6688
6703
  }
6689
6704
  }
@@ -6872,7 +6887,7 @@ class UIImage extends UIElement {
6872
6887
  this.texture = textureView;
6873
6888
  this._private_textureTransform = textureTransform;
6874
6889
  this._private_colorInternal = color;
6875
- this.texture.on(UITextureViewEvent.DIMENSIONS_CHANGED, this._private_onTextureDimensionsChanged);
6890
+ this.texture.signalDiminsionsChanged.on(this._private_onTextureDimensionsChanged);
6876
6891
  }
6877
6892
  /** Multiplicative tint. Alpha channel controls opacity. */
6878
6893
  get color() {
@@ -6884,7 +6899,7 @@ class UIImage extends UIElement {
6884
6899
  }
6885
6900
  /** Removes image and frees resources */
6886
6901
  destroy() {
6887
- this.texture.off(UITextureViewEvent.DIMENSIONS_CHANGED, this._private_onTextureDimensionsChanged);
6902
+ this.texture.signalDiminsionsChanged.off(this._private_onTextureDimensionsChanged);
6888
6903
  super.destroy();
6889
6904
  }
6890
6905
  setPlaneTransform() {
@@ -7201,7 +7216,7 @@ class UINineSlice extends UIElement {
7201
7216
  this._private_sliceRegionsVector = sliceRegionsVector;
7202
7217
  this._private_lastElementWidth = this.width;
7203
7218
  this._private_lastElementHeight = this.height;
7204
- this.texture.on(UITextureViewEvent.DIMENSIONS_CHANGED, this._private_onTextureDimensionsChanged);
7219
+ this.texture.signalDiminsionsChanged.on(this._private_onTextureDimensionsChanged);
7205
7220
  }
7206
7221
  /** Multiplicative tint. Alpha channel controls opacity. */
7207
7222
  get color() {
@@ -7240,7 +7255,7 @@ class UINineSlice extends UIElement {
7240
7255
  }
7241
7256
  /** Removes nine slice and frees resources */
7242
7257
  destroy() {
7243
- this.texture.off(UITextureViewEvent.DIMENSIONS_CHANGED, this._private_onTextureDimensionsChanged);
7258
+ this.texture.signalDiminsionsChanged.off(this._private_onTextureDimensionsChanged);
7244
7259
  super.destroy();
7245
7260
  }
7246
7261
  setPlaneTransform() {
@@ -7447,7 +7462,7 @@ class UIProgress extends UIElement {
7447
7462
  this._private_colorInternal = color;
7448
7463
  this._private_progressInternal = progress;
7449
7464
  this._private_maskFunctionInternal = maskFunction;
7450
- this.texture.on(UITextureViewEvent.DIMENSIONS_CHANGED, this._private_onTextureDimensionsChanged);
7465
+ this.texture.signalDiminsionsChanged.on(this._private_onTextureDimensionsChanged);
7451
7466
  }
7452
7467
  /** Multiplicative tint. Alpha channel controls opacity. */
7453
7468
  get color() {
@@ -8656,6 +8671,9 @@ class UIFullscreenLayer extends UILayer {
8656
8671
  ...options,
8657
8672
  });
8658
8673
  this._private_resizePolicyDirty = false;
8674
+ this._private_signalPressedInternal = new s();
8675
+ this._private_signalMovedInternal = new s();
8676
+ this._private_signalReleasedInternal = new s();
8659
8677
  this._private_onResize = () => {
8660
8678
  const scale = this.resizePolicy.calculateScale(window.innerWidth, window.innerHeight);
8661
8679
  this.resizePolicy.dirty = false;
@@ -8663,13 +8681,13 @@ class UIFullscreenLayer extends UILayer {
8663
8681
  this.resizeInternal(window.innerWidth * scale, window.innerHeight * scale);
8664
8682
  };
8665
8683
  this._private_onPointerDown = (event) => {
8666
- this._private_handleWindowInput(event, "onPointerDown", UIInputEvent.PRESSED);
8684
+ this._private_handleWindowInput(event, "onPointerDown", this._private_signalPressedInternal);
8667
8685
  };
8668
8686
  this._private_onPointerMove = (event) => {
8669
- this._private_handleWindowInput(event, "onPointerMove", UIInputEvent.MOVED);
8687
+ this._private_handleWindowInput(event, "onPointerMove", this._private_signalMovedInternal);
8670
8688
  };
8671
8689
  this._private_onPointerUp = (event) => {
8672
- this._private_handleWindowInput(event, "onPointerUp", UIInputEvent.RELEASED);
8690
+ this._private_handleWindowInput(event, "onPointerUp", this._private_signalReleasedInternal);
8673
8691
  };
8674
8692
  this._private_resizePolicyInternal = resizePolicy;
8675
8693
  window.addEventListener("resize", this._private_onResize);
@@ -8681,6 +8699,18 @@ class UIFullscreenLayer extends UILayer {
8681
8699
  get resizePolicy() {
8682
8700
  return this._private_resizePolicyInternal;
8683
8701
  }
8702
+ /** Signal fired when pointer is pressed */
8703
+ get signalPressed() {
8704
+ return this._private_signalPressedInternal;
8705
+ }
8706
+ /** Signal fired when pointer is moved */
8707
+ get signalMoved() {
8708
+ return this._private_signalMovedInternal;
8709
+ }
8710
+ /** Signal fired when pointer is released */
8711
+ get signalReleased() {
8712
+ return this._private_signalReleasedInternal;
8713
+ }
8684
8714
  /** Updates resize policy */
8685
8715
  set resizePolicy(value) {
8686
8716
  if (this._private_resizePolicyInternal !== value) {
@@ -8746,7 +8776,7 @@ class UIFullscreenLayer extends UILayer {
8746
8776
  const direction = far.sub(near).normalize();
8747
8777
  return result.set(near, direction);
8748
8778
  }
8749
- _private_handleWindowInput(event, pointerFunctionName, inputEvent) {
8779
+ _private_handleWindowInput(event, pointerFunctionName, signal) {
8750
8780
  const rect = event.target instanceof HTMLElement
8751
8781
  ? event.target.getBoundingClientRect()
8752
8782
  : null;
@@ -8758,7 +8788,12 @@ class UIFullscreenLayer extends UILayer {
8758
8788
  const scaledX = x * scale;
8759
8789
  const scaledY = y * scale;
8760
8790
  if (isUIModeInteractive(this.mode)) {
8761
- this.emit(inputEvent, scaledX, scaledY, event.pointerId);
8791
+ signal.emit({
8792
+ x: scaledX,
8793
+ y: scaledY,
8794
+ identifier: event.pointerId,
8795
+ layer: this,
8796
+ });
8762
8797
  this.inputWrapperInternal[pointerFunctionName](scaledX, scaledY, event.pointerId);
8763
8798
  }
8764
8799
  }
@@ -9231,5 +9266,5 @@ class UIResizePolicyFixedWidth extends UIResizePolicy {
9231
9266
  }
9232
9267
  }
9233
9268
 
9234
- export { UIAnchor, UIAnimatedImage, UIAnimatedImageLoopMode, UIAreaCircle, UIAreaPolygon, UIAreaRectangle, UIAreaRoundedRectangle, UIAspectConstraint, UIColor, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint, UIExpression, UIFitConstraintBuilder, UIFullscreenLayer, UIGraphics, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalInterpolationConstraint, UIHorizontalProportionConstraint, UIImage, UIInputDummy, UIInputEvent, UIMicro, UIMicroAnchorMode, UIMode, UINineSlice, UINineSliceRegionMode, UIOrientation, UIPriority, UIProgress, UIProgressMaskFunctionCircular, UIProgressMaskFunctionDirectional, UIRelation, UIResizePolicyCover, UIResizePolicyCross, UIResizePolicyCrossInverted, UIResizePolicyFit, UIResizePolicyFixedHeight, UIResizePolicyFixedWidth, UIResizePolicyNone, UIScene, UISceneUpdateMode, UISingleParameterConstraint, UIText, UITextResizeMode, UITransparencyMode, UIVerticalDistanceConstraint, UIVerticalInterpolationConstraint, UIVerticalProportionConstraint, UIWidthConstraint };
9269
+ export { UIAnchor, UIAnimatedImage, UIAnimatedImageLoopMode, UIAreaCircle, UIAreaPolygon, UIAreaRectangle, UIAreaRoundedRectangle, UIAspectConstraint, UIColor, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint, UIExpression, UIFitConstraintBuilder, UIFullscreenLayer, UIGraphics, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalInterpolationConstraint, UIHorizontalProportionConstraint, UIImage, UIInputDummy, UIMicro, UIMicroAnchorMode, UIMode, UINineSlice, UINineSliceRegionMode, UIOrientation, UIPriority, UIProgress, UIProgressMaskFunctionCircular, UIProgressMaskFunctionDirectional, UIRelation, UIResizePolicyCover, UIResizePolicyCross, UIResizePolicyCrossInverted, UIResizePolicyFit, UIResizePolicyFixedHeight, UIResizePolicyFixedWidth, UIResizePolicyNone, UIScene, UISceneUpdateMode, UISingleParameterConstraint, UIText, UITextResizeMode, UITransparencyMode, UIVerticalDistanceConstraint, UIVerticalInterpolationConstraint, UIVerticalProportionConstraint, UIWidthConstraint };
9235
9270
  //# sourceMappingURL=index.js.map