babylonjs-gui 5.19.0 → 5.22.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/babylon.gui.d.ts CHANGED
@@ -107,6 +107,8 @@ declare module BABYLON.GUI {
107
107
  private _cursorChanged;
108
108
  private _defaultMousePointerId;
109
109
  /** @hidden */
110
+ _capturedPointerIds: Set<number>;
111
+ /** @hidden */
110
112
  _numLayoutCalls: number;
111
113
  /** Gets the number of layout calls made the last time the ADT has been rendered */
112
114
  get numLayoutCalls(): number;
@@ -389,6 +391,12 @@ declare module BABYLON.GUI {
389
391
  * Unregister the clipboard Events from the canvas
390
392
  */
391
393
  unRegisterClipboardEvents(): void;
394
+ /**
395
+ * Transform uvs from mesh space to texture space, taking the texture into account
396
+ * @param uv the uvs in mesh space
397
+ * @returns the uvs in texture space
398
+ */
399
+ private _transformUvs;
392
400
  /**
393
401
  * Connect the texture to a hosting mesh to enable interactions
394
402
  * @param mesh defines the mesh to attach to
@@ -3519,8 +3527,12 @@ declare module BABYLON.GUI {
3519
3527
  private _thumbHeight;
3520
3528
  private _barImageHeight;
3521
3529
  private _tempMeasure;
3530
+ private _invertScrollDirection;
3522
3531
  /** Number of 90° rotation to apply on the images when in vertical mode */
3523
3532
  num90RotationInVerticalMode: number;
3533
+ /** Inverts the scrolling direction (default: false) */
3534
+ get invertScrollDirection(): boolean;
3535
+ set invertScrollDirection(invert: boolean);
3524
3536
  /**
3525
3537
  * Gets or sets the image used to render the background for horizontal bar
3526
3538
  */
@@ -3575,12 +3587,16 @@ declare module BABYLON.GUI {
3575
3587
  private _background;
3576
3588
  private _borderColor;
3577
3589
  private _tempMeasure;
3590
+ private _invertScrollDirection;
3578
3591
  /** Gets or sets border color */
3579
3592
  get borderColor(): string;
3580
3593
  set borderColor(value: string);
3581
3594
  /** Gets or sets background color */
3582
3595
  get background(): string;
3583
3596
  set background(value: string);
3597
+ /** Inverts the scrolling direction (default: false) */
3598
+ get invertScrollDirection(): boolean;
3599
+ set invertScrollDirection(invert: boolean);
3584
3600
  /**
3585
3601
  * Creates a new Slider
3586
3602
  * @param name defines the control name
package/babylon.gui.js CHANGED
@@ -522,6 +522,8 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
522
522
  _this._cursorChanged = false;
523
523
  _this._defaultMousePointerId = 0;
524
524
  /** @hidden */
525
+ _this._capturedPointerIds = new Set();
526
+ /** @hidden */
525
527
  _this._numLayoutCalls = 0;
526
528
  /** @hidden */
527
529
  _this._numRenderCalls = 0;
@@ -1379,6 +1381,11 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
1379
1381
  }
1380
1382
  var tempViewport = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.Viewport(0, 0, 0, 0);
1381
1383
  this._prePointerObserver = scene.onPrePointerObservable.add(function (pi) {
1384
+ if (scene.isPointerCaptured(pi.event.pointerId) &&
1385
+ pi.type === core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.PointerEventTypes.POINTERUP &&
1386
+ !_this._capturedPointerIds.has(pi.event.pointerId)) {
1387
+ return;
1388
+ }
1382
1389
  if (pi.type !== core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.PointerEventTypes.POINTERMOVE &&
1383
1390
  pi.type !== core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.PointerEventTypes.POINTERUP &&
1384
1391
  pi.type !== core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.PointerEventTypes.POINTERDOWN &&
@@ -1416,6 +1423,55 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
1416
1423
  self.removeEventListener("cut", this._onClipboardCut);
1417
1424
  self.removeEventListener("paste", this._onClipboardPaste);
1418
1425
  };
1426
+ /**
1427
+ * Transform uvs from mesh space to texture space, taking the texture into account
1428
+ * @param uv the uvs in mesh space
1429
+ * @returns the uvs in texture space
1430
+ */
1431
+ AdvancedDynamicTexture.prototype._transformUvs = function (uv) {
1432
+ var textureMatrix = this.getTextureMatrix();
1433
+ var result;
1434
+ if (textureMatrix.isIdentityAs3x2()) {
1435
+ result = uv;
1436
+ }
1437
+ else {
1438
+ var homogeneousTextureMatrix = core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.TmpVectors.Matrix[0];
1439
+ textureMatrix.getRowToRef(0, core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.TmpVectors.Vector4[0]);
1440
+ textureMatrix.getRowToRef(1, core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.TmpVectors.Vector4[1]);
1441
+ textureMatrix.getRowToRef(2, core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.TmpVectors.Vector4[2]);
1442
+ var r0 = core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.TmpVectors.Vector4[0];
1443
+ var r1 = core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.TmpVectors.Vector4[1];
1444
+ var r2 = core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.TmpVectors.Vector4[2];
1445
+ homogeneousTextureMatrix.setRowFromFloats(0, r0.x, r0.y, 0, 0);
1446
+ homogeneousTextureMatrix.setRowFromFloats(1, r1.x, r1.y, 0, 0);
1447
+ homogeneousTextureMatrix.setRowFromFloats(2, 0, 0, 1, 0);
1448
+ homogeneousTextureMatrix.setRowFromFloats(3, r2.x, r2.y, 0, 1);
1449
+ result = core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.TmpVectors.Vector2[0];
1450
+ core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.Vector2.TransformToRef(uv, homogeneousTextureMatrix, result);
1451
+ }
1452
+ // In wrap and mirror mode, the texture coordinate for coordinates more than 1 is the fractional part of the coordinate
1453
+ if (this.wrapU === core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.Texture.WRAP_ADDRESSMODE || this.wrapU === core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.Texture.MIRROR_ADDRESSMODE) {
1454
+ if (result.x > 1) {
1455
+ var fX = result.x - Math.trunc(result.x);
1456
+ // In mirror mode, the sign of the texture coordinate depends on the integer part -
1457
+ // odd integers means it is mirrored from the original coordinate
1458
+ if (this.wrapU === core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.Texture.MIRROR_ADDRESSMODE && Math.trunc(result.x) % 2 === 1) {
1459
+ fX = 1 - fX;
1460
+ }
1461
+ result.x = fX;
1462
+ }
1463
+ }
1464
+ if (this.wrapV === core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.Texture.WRAP_ADDRESSMODE || this.wrapV === core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.Texture.MIRROR_ADDRESSMODE) {
1465
+ if (result.y > 1) {
1466
+ var fY = result.y - Math.trunc(result.y);
1467
+ if (this.wrapV === core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.Texture.MIRROR_ADDRESSMODE && Math.trunc(result.x) % 2 === 1) {
1468
+ fY = 1 - fY;
1469
+ }
1470
+ result.y = fY;
1471
+ }
1472
+ }
1473
+ return result;
1474
+ };
1419
1475
  /**
1420
1476
  * Connect the texture to a hosting mesh to enable interactions
1421
1477
  * @param mesh defines the mesh to attach to
@@ -1442,6 +1498,7 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
1442
1498
  if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
1443
1499
  var uv = pi.pickInfo.getTextureCoordinates();
1444
1500
  if (uv) {
1501
+ uv = _this._transformUvs(uv);
1445
1502
  var size = _this.getSize();
1446
1503
  _this._doPicking(uv.x * size.width, (_this.applyYInversionOnUpdate ? 1.0 - uv.y : uv.y) * size.height, pi, pi.type, pointerId, pi.event.button, pi.event.deltaX, pi.event.deltaY);
1447
1504
  }
@@ -1488,6 +1545,7 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
1488
1545
  if (pick && pick.hit && pick.pickedMesh === mesh) {
1489
1546
  var uv = pick.getTextureCoordinates();
1490
1547
  if (uv) {
1548
+ uv = _this._transformUvs(uv);
1491
1549
  var size = _this.getSize();
1492
1550
  _this._doPicking(uv.x * size.width, (_this.applyYInversionOnUpdate ? 1.0 - uv.y : uv.y) * size.height, null, core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.PointerEventTypes.POINTERMOVE, pointerId, 0);
1493
1551
  }
@@ -6394,6 +6452,9 @@ var Control = /** @class */ (function () {
6394
6452
  if (canNotify && this.parent != null && !this.isPointerBlocker) {
6395
6453
  this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex, pi);
6396
6454
  }
6455
+ if (pi && this.uniqueId !== this._host.rootContainer.uniqueId) {
6456
+ this._host._capturedPointerIds.add(pi.event.pointerId);
6457
+ }
6397
6458
  return true;
6398
6459
  };
6399
6460
  /**
@@ -6419,6 +6480,9 @@ var Control = /** @class */ (function () {
6419
6480
  if (canNotify && this.parent != null && !this.isPointerBlocker) {
6420
6481
  this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick, pi);
6421
6482
  }
6483
+ if (pi && this.uniqueId !== this._host.rootContainer.uniqueId) {
6484
+ this._host._capturedPointerIds.delete(pi.event.pointerId);
6485
+ }
6422
6486
  };
6423
6487
  /**
6424
6488
  * @param pointerId
@@ -12100,17 +12164,18 @@ var Rectangle = /** @class */ (function (_super) {
12100
12164
  var y = this._currentMeasure.top + offset;
12101
12165
  var width = this._currentMeasure.width - offset * 2;
12102
12166
  var height = this._currentMeasure.height - offset * 2;
12103
- var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
12167
+ var radius = Math.min(height / 2, Math.min(width / 2, this._cornerRadius));
12168
+ radius = Math.abs(radius);
12104
12169
  context.beginPath();
12105
12170
  context.moveTo(x + radius, y);
12106
12171
  context.lineTo(x + width - radius, y);
12107
- context.quadraticCurveTo(x + width, y, x + width, y + radius);
12172
+ context.arc(x + width - radius, y + radius, radius, (3 * Math.PI) / 2, Math.PI * 2);
12108
12173
  context.lineTo(x + width, y + height - radius);
12109
- context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
12174
+ context.arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
12110
12175
  context.lineTo(x + radius, y + height);
12111
- context.quadraticCurveTo(x, y + height, x, y + height - radius);
12176
+ context.arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
12112
12177
  context.lineTo(x, y + radius);
12113
- context.quadraticCurveTo(x, y, x + radius, y);
12178
+ context.arc(x + radius, y + radius, radius, Math.PI, (3 * Math.PI) / 2);
12114
12179
  context.closePath();
12115
12180
  };
12116
12181
  Rectangle.prototype._clipForChildren = function (context) {
@@ -14478,10 +14543,22 @@ var ImageScrollBar = /** @class */ (function (_super) {
14478
14543
  _this._thumbHeight = 1;
14479
14544
  _this._barImageHeight = 1;
14480
14545
  _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__.Measure(0, 0, 0, 0);
14546
+ _this._invertScrollDirection = false;
14481
14547
  /** Number of 90° rotation to apply on the images when in vertical mode */
14482
14548
  _this.num90RotationInVerticalMode = 1;
14483
14549
  return _this;
14484
14550
  }
14551
+ Object.defineProperty(ImageScrollBar.prototype, "invertScrollDirection", {
14552
+ /** Inverts the scrolling direction (default: false) */
14553
+ get: function () {
14554
+ return this._invertScrollDirection;
14555
+ },
14556
+ set: function (invert) {
14557
+ this._invertScrollDirection = invert;
14558
+ },
14559
+ enumerable: false,
14560
+ configurable: true
14561
+ });
14485
14562
  Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
14486
14563
  /**
14487
14564
  * Gets or sets the image used to render the background for horizontal bar
@@ -14682,6 +14759,7 @@ var ImageScrollBar = /** @class */ (function (_super) {
14682
14759
  x = this._transformedPosition.x;
14683
14760
  y = this._transformedPosition.y;
14684
14761
  }
14762
+ var sign = this._invertScrollDirection ? -1 : 1;
14685
14763
  if (this._first) {
14686
14764
  this._first = false;
14687
14765
  this._originX = x;
@@ -14707,7 +14785,7 @@ var ImageScrollBar = /** @class */ (function (_super) {
14707
14785
  else {
14708
14786
  delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
14709
14787
  }
14710
- this.value += delta * (this.maximum - this.minimum);
14788
+ this.value += sign * delta * (this.maximum - this.minimum);
14711
14789
  this._originX = x;
14712
14790
  this._originY = y;
14713
14791
  };
@@ -14718,6 +14796,9 @@ var ImageScrollBar = /** @class */ (function (_super) {
14718
14796
  (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
14719
14797
  (0,core_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__.serialize)()
14720
14798
  ], ImageScrollBar.prototype, "num90RotationInVerticalMode", void 0);
14799
+ (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
14800
+ (0,core_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__.serialize)()
14801
+ ], ImageScrollBar.prototype, "invertScrollDirection", null);
14721
14802
  return ImageScrollBar;
14722
14803
  }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__.BaseSlider));
14723
14804
 
@@ -14759,6 +14840,7 @@ var ScrollBar = /** @class */ (function (_super) {
14759
14840
  _this._background = "black";
14760
14841
  _this._borderColor = "white";
14761
14842
  _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__.Measure(0, 0, 0, 0);
14843
+ _this._invertScrollDirection = false;
14762
14844
  return _this;
14763
14845
  }
14764
14846
  Object.defineProperty(ScrollBar.prototype, "borderColor", {
@@ -14791,6 +14873,17 @@ var ScrollBar = /** @class */ (function (_super) {
14791
14873
  enumerable: false,
14792
14874
  configurable: true
14793
14875
  });
14876
+ Object.defineProperty(ScrollBar.prototype, "invertScrollDirection", {
14877
+ /** Inverts the scrolling direction (default: false) */
14878
+ get: function () {
14879
+ return this._invertScrollDirection;
14880
+ },
14881
+ set: function (invert) {
14882
+ this._invertScrollDirection = invert;
14883
+ },
14884
+ enumerable: false,
14885
+ configurable: true
14886
+ });
14794
14887
  ScrollBar.prototype._getTypeName = function () {
14795
14888
  return "Scrollbar";
14796
14889
  };
@@ -14841,6 +14934,7 @@ var ScrollBar = /** @class */ (function (_super) {
14841
14934
  x = this._transformedPosition.x;
14842
14935
  y = this._transformedPosition.y;
14843
14936
  }
14937
+ var sign = this._invertScrollDirection ? -1 : 1;
14844
14938
  if (this._first) {
14845
14939
  this._first = false;
14846
14940
  this._originX = x;
@@ -14866,7 +14960,7 @@ var ScrollBar = /** @class */ (function (_super) {
14866
14960
  else {
14867
14961
  delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
14868
14962
  }
14869
- this.value += delta * (this.maximum - this.minimum);
14963
+ this.value += sign * delta * (this.maximum - this.minimum);
14870
14964
  this._originX = x;
14871
14965
  this._originY = y;
14872
14966
  };
@@ -14880,6 +14974,9 @@ var ScrollBar = /** @class */ (function (_super) {
14880
14974
  (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
14881
14975
  (0,core_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__.serialize)()
14882
14976
  ], ScrollBar.prototype, "background", null);
14977
+ (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
14978
+ (0,core_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__.serialize)()
14979
+ ], ScrollBar.prototype, "invertScrollDirection", null);
14883
14980
  return ScrollBar;
14884
14981
  }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__.BaseSlider));
14885
14982
 
@@ -21517,7 +21614,7 @@ var TouchButton3D = /** @class */ (function (_super) {
21517
21614
  * @hidden
21518
21615
  */
21519
21616
  TouchButton3D.prototype._generatePointerEventType = function (providedType, nearMeshPosition, activeInteractionCount) {
21520
- if (providedType === core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.PointerEventTypes.POINTERDOWN) {
21617
+ if (providedType === core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.PointerEventTypes.POINTERDOWN || providedType === core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.PointerEventTypes.POINTERMOVE) {
21521
21618
  if (!this._isInteractionInFrontOfButton(nearMeshPosition)) {
21522
21619
  // Near interaction mesh is behind the button, don't send a pointer down
21523
21620
  return core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.PointerEventTypes.POINTERMOVE;