babylonjs-gui 5.51.0 → 5.52.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
@@ -4728,17 +4728,37 @@ declare module BABYLON.GUI {
4728
4728
  }
4729
4729
 
4730
4730
 
4731
+ /**
4732
+ * Options used to create a button in 3D
4733
+ */
4734
+ export interface IButton3DCreationOptions {
4735
+ /**
4736
+ * Width of the button. Default: 1
4737
+ */
4738
+ width?: number;
4739
+ /**
4740
+ * Height of the button. Default: 1
4741
+ */
4742
+ height?: number;
4743
+ /**
4744
+ * Depth of the button. Default: 0.08
4745
+ */
4746
+ depth?: number;
4747
+ }
4731
4748
  /**
4732
4749
  * Class used to create a button in 3D
4733
4750
  */
4734
4751
  export class Button3D extends AbstractButton3D {
4735
4752
  /** @internal */
4736
4753
  protected _currentMaterial: BABYLON.Material;
4754
+ protected _options: IButton3DCreationOptions;
4755
+ protected _height: number;
4756
+ protected _depth: number;
4737
4757
  /**
4738
4758
  * Creates a new button
4739
4759
  * @param name defines the control name
4740
4760
  */
4741
- constructor(name?: string);
4761
+ constructor(name?: string, options?: IButton3DCreationOptions);
4742
4762
  /**
4743
4763
  * Apply the facade texture (created from the content property).
4744
4764
  * @param facadeTexture defines the AdvancedDynamicTexture to use
@@ -4832,11 +4852,13 @@ declare module BABYLON.GUI {
4832
4852
  private _facadeTexture;
4833
4853
  protected _contentResolution: number;
4834
4854
  protected _contentScaleRatio: number;
4855
+ protected _contentScaleRatioY?: number;
4835
4856
  /**
4836
4857
  * Gets or sets the GUI 2D content used to display the button's facade
4837
4858
  */
4838
4859
  get content(): Control;
4839
4860
  set content(value: Control);
4861
+ protected _setFacadeTextureScaling(): void;
4840
4862
  /**
4841
4863
  * Gets or sets the texture resolution used to render content (512 by default)
4842
4864
  */
package/babylon.gui.js CHANGED
@@ -5967,7 +5967,8 @@ var Control = /** @class */ (function () {
5967
5967
  }
5968
5968
  var newLeft = projectedPosition.x + this._linkOffsetX.getValue(this._host) - this._currentMeasure.width / 2;
5969
5969
  var newTop = projectedPosition.y + this._linkOffsetY.getValue(this._host) - this._currentMeasure.height / 2;
5970
- if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
5970
+ var leftAndTopIgnoreAdaptiveScaling = this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling;
5971
+ if (leftAndTopIgnoreAdaptiveScaling) {
5971
5972
  if (Math.abs(newLeft - oldLeft) < 0.5) {
5972
5973
  newLeft = oldLeft;
5973
5974
  }
@@ -5975,7 +5976,7 @@ var Control = /** @class */ (function () {
5975
5976
  newTop = oldTop;
5976
5977
  }
5977
5978
  }
5978
- if (oldLeft === newLeft && oldTop === newTop) {
5979
+ if (!leftAndTopIgnoreAdaptiveScaling && oldLeft === newLeft && oldTop === newTop) {
5979
5980
  return;
5980
5981
  }
5981
5982
  this.left = newLeft + "px";
@@ -20067,8 +20068,9 @@ var Button3D = /** @class */ (function (_super) {
20067
20068
  * Creates a new button
20068
20069
  * @param name defines the control name
20069
20070
  */
20070
- function Button3D(name) {
20071
+ function Button3D(name, options) {
20071
20072
  var _this = _super.call(this, name) || this;
20073
+ _this._options = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({ width: 1, height: 1, depth: 0.08 }, options);
20072
20074
  // Default animations
20073
20075
  _this.pointerEnterAnimation = function () {
20074
20076
  if (!_this.mesh) {
@@ -20117,12 +20119,14 @@ var Button3D = /** @class */ (function (_super) {
20117
20119
  faceUV[1].copyFromFloats(0, 0, 1, 1);
20118
20120
  }
20119
20121
  var mesh = (0,core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.CreateBox)(this.name + "_rootMesh", {
20120
- width: 1.0,
20121
- height: 1.0,
20122
- depth: 0.08,
20122
+ width: this._options.width,
20123
+ height: this._options.height,
20124
+ depth: this._options.depth,
20123
20125
  faceUV: faceUV,
20124
20126
  wrap: true,
20125
20127
  }, scene);
20128
+ this._contentScaleRatioY = (this._contentScaleRatio * this._options.width) / this._options.height;
20129
+ this._setFacadeTextureScaling();
20126
20130
  return mesh;
20127
20131
  };
20128
20132
  Button3D.prototype._affectMaterial = function (mesh) {
@@ -20350,8 +20354,7 @@ var ContentDisplay3D = /** @class */ (function (_super) {
20350
20354
  }
20351
20355
  if (!this._facadeTexture) {
20352
20356
  this._facadeTexture = new _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__.AdvancedDynamicTexture("Facade", this._contentResolution, this._contentResolution, this._host.utilityLayer.utilityLayerScene, true, core_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__.Texture.TRILINEAR_SAMPLINGMODE);
20353
- this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
20354
- this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
20357
+ this._setFacadeTextureScaling();
20355
20358
  this._facadeTexture.premulAlpha = true;
20356
20359
  }
20357
20360
  else {
@@ -20363,6 +20366,13 @@ var ContentDisplay3D = /** @class */ (function (_super) {
20363
20366
  enumerable: false,
20364
20367
  configurable: true
20365
20368
  });
20369
+ ContentDisplay3D.prototype._setFacadeTextureScaling = function () {
20370
+ var _a;
20371
+ if (this._facadeTexture) {
20372
+ this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
20373
+ this._facadeTexture.rootContainer.scaleY = (_a = this._contentScaleRatioY) !== null && _a !== void 0 ? _a : this._contentScaleRatio;
20374
+ }
20375
+ };
20366
20376
  Object.defineProperty(ContentDisplay3D.prototype, "contentResolution", {
20367
20377
  /**
20368
20378
  * Gets or sets the texture resolution used to render content (512 by default)