babylonjs-gui 5.42.0 → 5.42.2
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 +2 -0
- package/babylon.gui.js +33 -6
- 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 +4 -0
- package/package.json +2 -2
package/babylon.gui.d.ts
CHANGED
@@ -72,6 +72,7 @@ declare module BABYLON.GUI {
|
|
72
72
|
private _canvasPointerOutObserver;
|
73
73
|
private _canvasBlurObserver;
|
74
74
|
private _controlAddedObserver;
|
75
|
+
private _controlRemovedObserver;
|
75
76
|
private _background;
|
76
77
|
/** @internal */
|
77
78
|
_rootContainer: Container;
|
@@ -107,6 +108,7 @@ declare module BABYLON.GUI {
|
|
107
108
|
private _rootElement;
|
108
109
|
private _cursorChanged;
|
109
110
|
private _defaultMousePointerId;
|
111
|
+
private _rootChildrenHaveChanged;
|
110
112
|
/** @internal */
|
111
113
|
_capturedPointerIds: Set<number>;
|
112
114
|
/** @internal */
|
package/babylon.gui.js
CHANGED
@@ -522,6 +522,7 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
522
522
|
_this._renderScale = 1;
|
523
523
|
_this._cursorChanged = false;
|
524
524
|
_this._defaultMousePointerId = 0;
|
525
|
+
_this._rootChildrenHaveChanged = false;
|
525
526
|
/** @internal */
|
526
527
|
_this._capturedPointerIds = new Set();
|
527
528
|
/** @internal */
|
@@ -617,9 +618,15 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
617
618
|
_this.applyYInversionOnUpdate = invertY;
|
618
619
|
_this._rootElement = scene.getEngine().getInputElement();
|
619
620
|
_this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
|
621
|
+
/** Whenever a control is added or removed to the root, we have to recheck the camera projection as it can have changed */
|
620
622
|
_this._controlAddedObserver = _this._rootContainer.onControlAddedObservable.add(function (control) {
|
621
|
-
if (control
|
622
|
-
_this.
|
623
|
+
if (control) {
|
624
|
+
_this._rootChildrenHaveChanged = true;
|
625
|
+
}
|
626
|
+
});
|
627
|
+
_this._controlRemovedObserver = _this._rootContainer.onControlRemovedObservable.add(function (control) {
|
628
|
+
if (control) {
|
629
|
+
_this._rootChildrenHaveChanged = true;
|
623
630
|
}
|
624
631
|
});
|
625
632
|
_this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
|
@@ -1081,6 +1088,9 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
1081
1088
|
if (this._controlAddedObserver) {
|
1082
1089
|
this._rootContainer.onControlAddedObservable.remove(this._controlAddedObserver);
|
1083
1090
|
}
|
1091
|
+
if (this._controlRemovedObserver) {
|
1092
|
+
this._rootContainer.onControlRemovedObservable.remove(this._controlRemovedObserver);
|
1093
|
+
}
|
1084
1094
|
if (this._layerToDispose) {
|
1085
1095
|
this._layerToDispose.texture = null;
|
1086
1096
|
this._layerToDispose.dispose();
|
@@ -1161,7 +1171,7 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
1161
1171
|
var projectedPosition = core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.Vector3.Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
|
1162
1172
|
return new core_Misc_observable__WEBPACK_IMPORTED_MODULE_1__.Vector3(projectedPosition.x, projectedPosition.y, projectedPosition.z);
|
1163
1173
|
};
|
1164
|
-
AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
|
1174
|
+
AdvancedDynamicTexture.prototype._checkUpdate = function (camera, skipUpdate) {
|
1165
1175
|
if (this._layerToDispose) {
|
1166
1176
|
if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
|
1167
1177
|
return;
|
@@ -1206,16 +1216,27 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
1206
1216
|
return;
|
1207
1217
|
}
|
1208
1218
|
this._isDirty = false;
|
1209
|
-
this._render();
|
1210
|
-
|
1219
|
+
this._render(skipUpdate);
|
1220
|
+
if (!skipUpdate) {
|
1221
|
+
this.update(this.applyYInversionOnUpdate, this.premulAlpha, AdvancedDynamicTexture.AllowGPUOptimizations);
|
1222
|
+
}
|
1211
1223
|
};
|
1212
|
-
AdvancedDynamicTexture.prototype._render = function () {
|
1224
|
+
AdvancedDynamicTexture.prototype._render = function (skipRender) {
|
1225
|
+
var _a;
|
1213
1226
|
var textureSize = this.getSize();
|
1214
1227
|
var renderWidth = textureSize.width;
|
1215
1228
|
var renderHeight = textureSize.height;
|
1216
1229
|
var context = this.getContext();
|
1217
1230
|
context.font = "18px Arial";
|
1218
1231
|
context.strokeStyle = "white";
|
1232
|
+
/** We have to recheck the camera projection in the case the root control's children have changed */
|
1233
|
+
if (this._rootChildrenHaveChanged) {
|
1234
|
+
var camera = (_a = this.getScene()) === null || _a === void 0 ? void 0 : _a.activeCamera;
|
1235
|
+
if (camera) {
|
1236
|
+
this._rootChildrenHaveChanged = false;
|
1237
|
+
this._checkUpdate(camera, true);
|
1238
|
+
}
|
1239
|
+
}
|
1219
1240
|
// Layout
|
1220
1241
|
this.onBeginLayoutObservable.notifyObservers(this);
|
1221
1242
|
var measure = new _measure__WEBPACK_IMPORTED_MODULE_5__.Measure(0, 0, renderWidth, renderHeight);
|
@@ -1223,6 +1244,9 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
1223
1244
|
this._rootContainer._layout(measure, context);
|
1224
1245
|
this.onEndLayoutObservable.notifyObservers(this);
|
1225
1246
|
this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
|
1247
|
+
if (skipRender) {
|
1248
|
+
return;
|
1249
|
+
}
|
1226
1250
|
// Clear
|
1227
1251
|
if (this._invalidatedRectangle) {
|
1228
1252
|
this._clearMeasure.copyFrom(this._invalidatedRectangle);
|
@@ -5859,6 +5883,9 @@ var Control = /** @class */ (function () {
|
|
5859
5883
|
newTop = oldTop;
|
5860
5884
|
}
|
5861
5885
|
}
|
5886
|
+
if (oldLeft === newLeft && oldTop === newTop) {
|
5887
|
+
return;
|
5888
|
+
}
|
5862
5889
|
this.left = newLeft + "px";
|
5863
5890
|
this.top = newTop + "px";
|
5864
5891
|
this._left.ignoreAdaptiveScaling = true;
|