babylonjs-gui 5.39.0 → 5.40.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 CHANGED
@@ -71,6 +71,7 @@ declare module BABYLON.GUI {
71
71
  private _pointerObserver;
72
72
  private _canvasPointerOutObserver;
73
73
  private _canvasBlurObserver;
74
+ private _controlAddedObserver;
74
75
  private _background;
75
76
  /** @internal */
76
77
  _rootContainer: Container;
@@ -4075,6 +4076,25 @@ declare module BABYLON.GUI {
4075
4076
  */
4076
4077
  static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
4077
4078
  }
4079
+ /**
4080
+ * Useful math functions
4081
+ */
4082
+ export class MathTools {
4083
+ /**
4084
+ * Default rounding precision for GUI elements. It should be
4085
+ * set to a power of ten, where the exponent means the number
4086
+ * of decimal digits to round to, i.e, 100 means 2 decimal digits,
4087
+ * 1000 means 3 decimal digits, etc. Default is 100 (2 decimal digits).
4088
+ */
4089
+ static DefaultRoundingPrecision: number;
4090
+ /**
4091
+ * Rounds a number to the nearest multiple of a given precision
4092
+ * @param value the value to be rounded
4093
+ * @param precision the multiple to which the value will be rounded. Default is 100 (2 decimal digits)
4094
+ * @returns
4095
+ */
4096
+ static Round(value: number, precision?: number): number;
4097
+ }
4078
4098
 
4079
4099
 
4080
4100
  /**
package/babylon.gui.js CHANGED
@@ -617,6 +617,11 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
617
617
  _this.applyYInversionOnUpdate = invertY;
618
618
  _this._rootElement = scene.getEngine().getInputElement();
619
619
  _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
620
+ _this._controlAddedObserver = _this._rootContainer.onControlAddedObservable.add(function (control) {
621
+ if (control && _this._scene && _this._scene.activeCamera) {
622
+ _this._checkUpdate(_this._scene.activeCamera);
623
+ }
624
+ });
620
625
  _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
621
626
  if (!_this._focusedControl) {
622
627
  return;
@@ -1073,6 +1078,9 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
1073
1078
  if (this._canvasBlurObserver) {
1074
1079
  scene.getEngine().onCanvasBlurObservable.remove(this._canvasBlurObserver);
1075
1080
  }
1081
+ if (this._controlAddedObserver) {
1082
+ this._rootContainer.onControlAddedObservable.remove(this._controlAddedObserver);
1083
+ }
1076
1084
  if (this._layerToDispose) {
1077
1085
  this._layerToDispose.texture = null;
1078
1086
  this._layerToDispose.dispose();
@@ -16876,6 +16884,7 @@ __webpack_require__.r(__webpack_exports__);
16876
16884
  /* harmony export */ "InputTextArea": () => (/* reexport safe */ _controls_index__WEBPACK_IMPORTED_MODULE_0__.InputTextArea),
16877
16885
  /* harmony export */ "KeyPropertySet": () => (/* reexport safe */ _controls_index__WEBPACK_IMPORTED_MODULE_0__.KeyPropertySet),
16878
16886
  /* harmony export */ "Line": () => (/* reexport safe */ _controls_index__WEBPACK_IMPORTED_MODULE_0__.Line),
16887
+ /* harmony export */ "MathTools": () => (/* reexport safe */ _math2D__WEBPACK_IMPORTED_MODULE_3__.MathTools),
16879
16888
  /* harmony export */ "Matrix2D": () => (/* reexport safe */ _math2D__WEBPACK_IMPORTED_MODULE_3__.Matrix2D),
16880
16889
  /* harmony export */ "Measure": () => (/* reexport safe */ _measure__WEBPACK_IMPORTED_MODULE_4__.Measure),
16881
16890
  /* harmony export */ "MultiLine": () => (/* reexport safe */ _controls_index__WEBPACK_IMPORTED_MODULE_0__.MultiLine),
@@ -16932,6 +16941,7 @@ __webpack_require__.r(__webpack_exports__);
16932
16941
 
16933
16942
  __webpack_require__.r(__webpack_exports__);
16934
16943
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
16944
+ /* harmony export */ "MathTools": () => (/* binding */ MathTools),
16935
16945
  /* harmony export */ "Matrix2D": () => (/* binding */ Matrix2D),
16936
16946
  /* harmony export */ "Vector2WithInfo": () => (/* binding */ Vector2WithInfo)
16937
16947
  /* harmony export */ });
@@ -17159,6 +17169,32 @@ var Matrix2D = /** @class */ (function () {
17159
17169
  return Matrix2D;
17160
17170
  }());
17161
17171
 
17172
+ /**
17173
+ * Useful math functions
17174
+ */
17175
+ var MathTools = /** @class */ (function () {
17176
+ function MathTools() {
17177
+ }
17178
+ /**
17179
+ * Rounds a number to the nearest multiple of a given precision
17180
+ * @param value the value to be rounded
17181
+ * @param precision the multiple to which the value will be rounded. Default is 100 (2 decimal digits)
17182
+ * @returns
17183
+ */
17184
+ MathTools.Round = function (value, precision) {
17185
+ if (precision === void 0) { precision = MathTools.DefaultRoundingPrecision; }
17186
+ return Math.round(value * precision) / precision;
17187
+ };
17188
+ /**
17189
+ * Default rounding precision for GUI elements. It should be
17190
+ * set to a power of ten, where the exponent means the number
17191
+ * of decimal digits to round to, i.e, 100 means 2 decimal digits,
17192
+ * 1000 means 3 decimal digits, etc. Default is 100 (2 decimal digits).
17193
+ */
17194
+ MathTools.DefaultRoundingPrecision = 100;
17195
+ return MathTools;
17196
+ }());
17197
+
17162
17198
 
17163
17199
 
17164
17200
  /***/ }),
@@ -29891,6 +29927,7 @@ __webpack_require__.r(__webpack_exports__);
29891
29927
  /* harmony export */ "MRDLBackplateMaterial": () => (/* reexport safe */ _3D_index__WEBPACK_IMPORTED_MODULE_1__.MRDLBackplateMaterial),
29892
29928
  /* harmony export */ "MRDLSliderBarMaterial": () => (/* reexport safe */ _3D_index__WEBPACK_IMPORTED_MODULE_1__.MRDLSliderBarMaterial),
29893
29929
  /* harmony export */ "MRDLSliderThumbMaterial": () => (/* reexport safe */ _3D_index__WEBPACK_IMPORTED_MODULE_1__.MRDLSliderThumbMaterial),
29930
+ /* harmony export */ "MathTools": () => (/* reexport safe */ _2D_index__WEBPACK_IMPORTED_MODULE_0__.MathTools),
29894
29931
  /* harmony export */ "Matrix2D": () => (/* reexport safe */ _2D_index__WEBPACK_IMPORTED_MODULE_0__.Matrix2D),
29895
29932
  /* harmony export */ "Measure": () => (/* reexport safe */ _2D_index__WEBPACK_IMPORTED_MODULE_0__.Measure),
29896
29933
  /* harmony export */ "MeshButton3D": () => (/* reexport safe */ _3D_index__WEBPACK_IMPORTED_MODULE_1__.MeshButton3D),
@@ -29991,6 +30028,7 @@ __webpack_require__.r(__webpack_exports__);
29991
30028
  /* harmony export */ "MRDLBackplateMaterial": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.MRDLBackplateMaterial),
29992
30029
  /* harmony export */ "MRDLSliderBarMaterial": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.MRDLSliderBarMaterial),
29993
30030
  /* harmony export */ "MRDLSliderThumbMaterial": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.MRDLSliderThumbMaterial),
30031
+ /* harmony export */ "MathTools": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.MathTools),
29994
30032
  /* harmony export */ "Matrix2D": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.Matrix2D),
29995
30033
  /* harmony export */ "Measure": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.Measure),
29996
30034
  /* harmony export */ "MeshButton3D": () => (/* reexport safe */ _index__WEBPACK_IMPORTED_MODULE_0__.MeshButton3D),