babylonjs-gui 5.20.0 → 5.22.1
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 +14 -0
- package/babylon.gui.js +81 -1
- package/babylon.gui.js.map +1 -1
- package/babylon.gui.min.js +1 -1
- package/babylon.gui.min.js.map +1 -1
- package/babylon.gui.module.d.ts +28 -0
- package/package.json +2 -2
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
|
|
@@ -415,6 +423,12 @@ declare module BABYLON.GUI {
|
|
|
415
423
|
* @param scaleToSize defines whether to scale to texture to the saved size
|
|
416
424
|
*/
|
|
417
425
|
parseSerializedObject(serializedObject: any, scaleToSize?: boolean): void;
|
|
426
|
+
/**
|
|
427
|
+
* Clones the ADT
|
|
428
|
+
* @param newName defines the name of the new ADT
|
|
429
|
+
* @returns the clone of the ADT
|
|
430
|
+
*/
|
|
431
|
+
clone(newName?: string): AdvancedDynamicTexture;
|
|
418
432
|
/**
|
|
419
433
|
* Recreate the content of the ADT from a JSON object
|
|
420
434
|
* @param serializedObject define the JSON serialized object to restore from
|
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
|
}
|
|
@@ -1595,6 +1653,21 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
|
1595
1653
|
}
|
|
1596
1654
|
}
|
|
1597
1655
|
};
|
|
1656
|
+
/**
|
|
1657
|
+
* Clones the ADT
|
|
1658
|
+
* @param newName defines the name of the new ADT
|
|
1659
|
+
* @returns the clone of the ADT
|
|
1660
|
+
*/
|
|
1661
|
+
AdvancedDynamicTexture.prototype.clone = function (newName) {
|
|
1662
|
+
var scene = this.getScene();
|
|
1663
|
+
if (!scene) {
|
|
1664
|
+
return this;
|
|
1665
|
+
}
|
|
1666
|
+
var data = this.serializeContent();
|
|
1667
|
+
var clone = AdvancedDynamicTexture.CreateFullscreenUI(newName || "Clone of " + this.name, this.isForeground, scene, this.samplingMode);
|
|
1668
|
+
clone.parseSerializedObject(data);
|
|
1669
|
+
return clone;
|
|
1670
|
+
};
|
|
1598
1671
|
/**
|
|
1599
1672
|
* Recreate the content of the ADT from a snippet saved by the GUI editor
|
|
1600
1673
|
* @param snippetId defines the snippet to load
|
|
@@ -6394,6 +6467,9 @@ var Control = /** @class */ (function () {
|
|
|
6394
6467
|
if (canNotify && this.parent != null && !this.isPointerBlocker) {
|
|
6395
6468
|
this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex, pi);
|
|
6396
6469
|
}
|
|
6470
|
+
if (pi && this.uniqueId !== this._host.rootContainer.uniqueId) {
|
|
6471
|
+
this._host._capturedPointerIds.add(pi.event.pointerId);
|
|
6472
|
+
}
|
|
6397
6473
|
return true;
|
|
6398
6474
|
};
|
|
6399
6475
|
/**
|
|
@@ -6419,6 +6495,9 @@ var Control = /** @class */ (function () {
|
|
|
6419
6495
|
if (canNotify && this.parent != null && !this.isPointerBlocker) {
|
|
6420
6496
|
this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick, pi);
|
|
6421
6497
|
}
|
|
6498
|
+
if (pi && this.uniqueId !== this._host.rootContainer.uniqueId) {
|
|
6499
|
+
this._host._capturedPointerIds.delete(pi.event.pointerId);
|
|
6500
|
+
}
|
|
6422
6501
|
};
|
|
6423
6502
|
/**
|
|
6424
6503
|
* @param pointerId
|
|
@@ -12101,6 +12180,7 @@ var Rectangle = /** @class */ (function (_super) {
|
|
|
12101
12180
|
var width = this._currentMeasure.width - offset * 2;
|
|
12102
12181
|
var height = this._currentMeasure.height - offset * 2;
|
|
12103
12182
|
var radius = Math.min(height / 2, Math.min(width / 2, this._cornerRadius));
|
|
12183
|
+
radius = Math.abs(radius);
|
|
12104
12184
|
context.beginPath();
|
|
12105
12185
|
context.moveTo(x + radius, y);
|
|
12106
12186
|
context.lineTo(x + width - radius, y);
|
|
@@ -21549,7 +21629,7 @@ var TouchButton3D = /** @class */ (function (_super) {
|
|
|
21549
21629
|
* @hidden
|
|
21550
21630
|
*/
|
|
21551
21631
|
TouchButton3D.prototype._generatePointerEventType = function (providedType, nearMeshPosition, activeInteractionCount) {
|
|
21552
|
-
if (providedType === core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.PointerEventTypes.POINTERDOWN) {
|
|
21632
|
+
if (providedType === core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.PointerEventTypes.POINTERDOWN || providedType === core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.PointerEventTypes.POINTERMOVE) {
|
|
21553
21633
|
if (!this._isInteractionInFrontOfButton(nearMeshPosition)) {
|
|
21554
21634
|
// Near interaction mesh is behind the button, don't send a pointer down
|
|
21555
21635
|
return core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.PointerEventTypes.POINTERMOVE;
|