@babylonjs/gui 5.0.0-beta.1 → 5.0.0-beta.12

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.
Files changed (74) hide show
  1. package/2D/advancedDynamicTexture.d.ts +13 -1
  2. package/2D/advancedDynamicTexture.js +26 -2
  3. package/2D/advancedDynamicTexture.js.map +1 -1
  4. package/2D/controls/colorpicker.js +2 -2
  5. package/2D/controls/colorpicker.js.map +1 -1
  6. package/2D/controls/container.js +8 -2
  7. package/2D/controls/container.js.map +1 -1
  8. package/2D/controls/control.d.ts +12 -3
  9. package/2D/controls/control.js +47 -17
  10. package/2D/controls/control.js.map +1 -1
  11. package/2D/controls/grid.js +9 -9
  12. package/2D/controls/grid.js.map +1 -1
  13. package/2D/controls/image.js +5 -5
  14. package/2D/controls/image.js.map +1 -1
  15. package/2D/controls/inputText.d.ts +2 -0
  16. package/2D/controls/inputText.js +2 -1
  17. package/2D/controls/inputText.js.map +1 -1
  18. package/2D/controls/sliders/baseSlider.js +1 -1
  19. package/2D/controls/sliders/baseSlider.js.map +1 -1
  20. package/2D/controls/stackPanel.js +2 -2
  21. package/2D/controls/stackPanel.js.map +1 -1
  22. package/2D/controls/textBlock.d.ts +1 -0
  23. package/2D/controls/textBlock.js +20 -10
  24. package/2D/controls/textBlock.js.map +1 -1
  25. package/2D/xmlLoader.js +8 -1
  26. package/2D/xmlLoader.js.map +1 -1
  27. package/3D/controls/contentDisplay3D.js +1 -1
  28. package/3D/controls/contentDisplay3D.js.map +1 -1
  29. package/3D/controls/holographicBackplate.js +1 -1
  30. package/3D/controls/holographicBackplate.js.map +1 -1
  31. package/3D/controls/holographicSlate.d.ts +45 -35
  32. package/3D/controls/holographicSlate.js +174 -110
  33. package/3D/controls/holographicSlate.js.map +1 -1
  34. package/3D/controls/index.d.ts +0 -1
  35. package/3D/controls/index.js +0 -1
  36. package/3D/controls/index.js.map +1 -1
  37. package/3D/controls/nearMenu.d.ts +0 -1
  38. package/3D/controls/nearMenu.js +8 -6
  39. package/3D/controls/nearMenu.js.map +1 -1
  40. package/3D/controls/slider3D.js +7 -7
  41. package/3D/controls/slider3D.js.map +1 -1
  42. package/3D/controls/touchButton3D.d.ts +33 -1
  43. package/3D/controls/touchButton3D.js +100 -5
  44. package/3D/controls/touchButton3D.js.map +1 -1
  45. package/3D/controls/touchHolographicButton.d.ts +10 -1
  46. package/3D/controls/touchHolographicButton.js +49 -11
  47. package/3D/controls/touchHolographicButton.js.map +1 -1
  48. package/3D/controls/touchHolographicMenu.js +1 -1
  49. package/3D/controls/touchHolographicMenu.js.map +1 -1
  50. package/3D/gizmos/slateGizmo.d.ts +2 -4
  51. package/3D/gizmos/slateGizmo.js +24 -18
  52. package/3D/gizmos/slateGizmo.js.map +1 -1
  53. package/3D/materials/fluent/fluentMaterial.d.ts +1 -1
  54. package/3D/materials/fluent/fluentMaterial.js +2 -2
  55. package/3D/materials/fluent/fluentMaterial.js.map +1 -1
  56. package/3D/materials/fluentBackplate/fluentBackplateMaterial.d.ts +1 -1
  57. package/3D/materials/fluentBackplate/fluentBackplateMaterial.js +3 -3
  58. package/3D/materials/fluentBackplate/fluentBackplateMaterial.js.map +1 -1
  59. package/3D/materials/fluentButton/fluentButtonMaterial.d.ts +1 -1
  60. package/3D/materials/fluentButton/fluentButtonMaterial.js +2 -2
  61. package/3D/materials/fluentButton/fluentButtonMaterial.js.map +1 -1
  62. package/3D/materials/mrdl/mrdlBackplateMaterial.d.ts +1 -1
  63. package/3D/materials/mrdl/mrdlBackplateMaterial.js +2 -2
  64. package/3D/materials/mrdl/mrdlBackplateMaterial.js.map +1 -1
  65. package/3D/materials/mrdl/mrdlSliderBarMaterial.d.ts +1 -1
  66. package/3D/materials/mrdl/mrdlSliderBarMaterial.js +2 -2
  67. package/3D/materials/mrdl/mrdlSliderBarMaterial.js.map +1 -1
  68. package/3D/materials/mrdl/mrdlSliderThumbMaterial.d.ts +1 -1
  69. package/3D/materials/mrdl/mrdlSliderThumbMaterial.js +1 -1
  70. package/3D/materials/mrdl/mrdlSliderThumbMaterial.js.map +1 -1
  71. package/package.json +2 -5
  72. package/3D/controls/touchToggleButton3D.d.ts +0 -35
  73. package/3D/controls/touchToggleButton3D.js +0 -60
  74. package/3D/controls/touchToggleButton3D.js.map +0 -1
@@ -1,13 +1,13 @@
1
- import { AbstractMesh } from "@babylonjs/core/Meshes/abstractMesh";
2
- import { Scene } from "@babylonjs/core/scene";
3
- import { TransformNode } from "@babylonjs/core/Meshes/transformNode";
4
- import { Mesh } from "@babylonjs/core/Meshes/mesh";
5
- import { TouchHolographicButton } from "./touchHolographicButton";
6
- import { Vector3 } from "@babylonjs/core/Maths/math.vector";
7
1
  import { ContentDisplay3D } from "./contentDisplay3D";
2
+ import { TouchHolographicButton } from "./touchHolographicButton";
8
3
  import { AdvancedDynamicTexture } from "../../2D/advancedDynamicTexture";
9
- import { SlateGizmo } from "../gizmos/slateGizmo";
10
4
  import { DefaultBehavior } from "../behaviors/defaultBehavior";
5
+ import { SlateGizmo } from "../gizmos/slateGizmo";
6
+ import { Vector2, Vector3 } from "@babylonjs/core/Maths/math.vector";
7
+ import { AbstractMesh } from "@babylonjs/core/Meshes/abstractMesh";
8
+ import { TransformNode } from "@babylonjs/core/Meshes/transformNode";
9
+ import { Mesh } from "@babylonjs/core/Meshes/mesh";
10
+ import { Scene } from "@babylonjs/core/scene";
11
11
  /**
12
12
  * Class used to create a holographic slate
13
13
  * @since 5.0.0
@@ -25,35 +25,24 @@ export declare class HolographicSlate extends ContentDisplay3D {
25
25
  * File name for the close icon.
26
26
  */
27
27
  static FOLLOW_ICON_FILENAME: string;
28
+ private static DEFAULT_TEXT_RESOLUTION_Y;
28
29
  /**
29
- * Dimensions of the slate
30
- */
31
- dimensions: Vector3;
32
- /**
33
- * Minimum dimensions of the slate
34
- */
35
- minDimensions: Vector3;
36
- /**
37
- * Default dimensions of the slate
30
+ * Margin between title bar and contentplate
38
31
  */
39
- readonly defaultDimensions: Vector3;
40
- /**
41
- * Dimensions of the backplate
42
- */
43
- backplateDimensions: Vector3;
44
- /**
45
- * Margin between backplate and contentplate
46
- */
47
- backPlateMargin: number;
32
+ titleBarMargin: number;
48
33
  /**
49
34
  * Origin in local coordinates (top left corner)
50
35
  */
51
36
  origin: Vector3;
52
- private _backPlateMaterial;
37
+ private _dimensions;
38
+ private _titleBarHeight;
39
+ private _titleBarMaterial;
40
+ private _backMaterial;
53
41
  private _contentMaterial;
54
42
  private _pickedPointObserver;
55
43
  private _positionChangedObserver;
56
- private _imageUrl;
44
+ private _titleText;
45
+ private _titleTextComponent;
57
46
  private _contentViewport;
58
47
  private _contentDragBehavior;
59
48
  private _defaultBehavior;
@@ -63,21 +52,42 @@ export declare class HolographicSlate extends ContentDisplay3D {
63
52
  get defaultBehavior(): DefaultBehavior;
64
53
  /** @hidden */
65
54
  _gizmo: SlateGizmo;
66
- protected _backPlate: Mesh;
55
+ protected _titleBar: Mesh;
56
+ protected _titleBarTitle: Mesh;
67
57
  protected _contentPlate: Mesh;
68
- protected _followButton: TouchHolographicButton;
58
+ protected _backPlate: Mesh;
59
+ /** @hidden */
60
+ _followButton: TouchHolographicButton;
69
61
  protected _closeButton: TouchHolographicButton;
70
62
  protected _contentScaleRatio: number;
71
63
  /**
72
- * Rendering ground id of all the mesh in the button
64
+ * 2D dimensions of the slate
65
+ */
66
+ get dimensions(): Vector2;
67
+ set dimensions(value: Vector2);
68
+ /**
69
+ * Minimum dimensions of the slate
70
+ */
71
+ minDimensions: Vector2;
72
+ /**
73
+ * Default dimensions of the slate
74
+ */
75
+ readonly defaultDimensions: Vector2;
76
+ /**
77
+ * Height of the title bar component
78
+ */
79
+ get titleBarHeight(): number;
80
+ set titleBarHeight(value: number);
81
+ /**
82
+ * Rendering ground id of all the meshes
73
83
  */
74
84
  set renderingGroupId(id: number);
75
85
  get renderingGroupId(): number;
76
86
  /**
77
- * Gets or sets the image url for the button
87
+ * The title text displayed at the top of the slate
78
88
  */
79
- get imageUrl(): string;
80
- set imageUrl(value: string);
89
+ set title(title: string);
90
+ get title(): string;
81
91
  /**
82
92
  * Creates a new slate
83
93
  * @param name defines the control name
@@ -89,7 +99,6 @@ export declare class HolographicSlate extends ContentDisplay3D {
89
99
  * @param facadeTexture defines the AdvancedDynamicTexture to use
90
100
  */
91
101
  protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
92
- private _rebuildContent;
93
102
  private _addControl;
94
103
  protected _getTypeName(): string;
95
104
  /**
@@ -109,8 +118,9 @@ export declare class HolographicSlate extends ContentDisplay3D {
109
118
  _prepareNode(scene: Scene): void;
110
119
  /**
111
120
  * Resets the aspect and pose of the slate so it is right in front of the active camera, facing towards it.
121
+ * @param resetAspect Should the slate's dimensions/aspect ratio be reset as well
112
122
  */
113
- resetDefaultAspectAndPose(): void;
123
+ resetDefaultAspectAndPose(resetAspect?: boolean): void;
114
124
  /**
115
125
  * Releases all associated resources
116
126
  */
@@ -1,19 +1,23 @@
1
1
  import { __extends } from "tslib";
2
- import { CreateBox } from "@babylonjs/core/Meshes/Builders/boxBuilder.js";
3
- import { Mesh } from "@babylonjs/core/Meshes/mesh.js";
4
- import { FluentMaterial } from "../materials/fluent/fluentMaterial.js";
5
- import { TouchHolographicButton } from "./touchHolographicButton.js";
6
- import { Quaternion, Vector2, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
7
2
  import { ContentDisplay3D } from "./contentDisplay3D.js";
8
- import { Image } from "../../2D/controls/image.js";
9
- import { SlateGizmo } from "../gizmos/slateGizmo.js";
3
+ import { TouchHolographicButton } from "./touchHolographicButton.js";
4
+ import { AdvancedDynamicTexture } from "../../2D/advancedDynamicTexture.js";
5
+ import { Control } from "../../2D/controls/control.js";
6
+ import { TextBlock, TextWrapping } from "../../2D/controls/textBlock.js";
10
7
  import { DefaultBehavior } from "../behaviors/defaultBehavior.js";
11
- import { Viewport } from "@babylonjs/core/Maths/math.viewport.js";
12
- import { PointerDragBehavior } from "@babylonjs/core/Behaviors/Meshes/pointerDragBehavior.js";
13
- import { Scalar } from "@babylonjs/core/Maths/math.scalar.js";
8
+ import { SlateGizmo } from "../gizmos/slateGizmo.js";
9
+ import { FluentMaterial } from "../materials/fluent/fluentMaterial.js";
14
10
  import { FluentBackplateMaterial } from "../materials/fluentBackplate/fluentBackplateMaterial.js";
15
- import { DomManagement } from "@babylonjs/core/Misc/domManagement.js";
11
+ import { PointerDragBehavior } from "@babylonjs/core/Behaviors/Meshes/pointerDragBehavior.js";
16
12
  import { Vector4 } from "@babylonjs/core/Maths/math.js";
13
+ import { Epsilon } from "@babylonjs/core/Maths/math.constants.js";
14
+ import { Scalar } from "@babylonjs/core/Maths/math.scalar.js";
15
+ import { Quaternion, Vector2, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
16
+ import { Viewport } from "@babylonjs/core/Maths/math.viewport.js";
17
+ import { CreateBox } from "@babylonjs/core/Meshes/Builders/boxBuilder.js";
18
+ import { CreatePlane } from "@babylonjs/core/Meshes/Builders/planeBuilder.js";
19
+ import { Mesh } from "@babylonjs/core/Meshes/mesh.js";
20
+ import { VertexData } from "@babylonjs/core/Meshes/mesh.vertexData.js";
17
21
  /**
18
22
  * Class used to create a holographic slate
19
23
  * @since 5.0.0
@@ -27,31 +31,27 @@ var HolographicSlate = /** @class */ (function (_super) {
27
31
  function HolographicSlate(name) {
28
32
  var _this = _super.call(this, name) || this;
29
33
  /**
30
- * Dimensions of the slate
34
+ * Margin between title bar and contentplate
31
35
  */
32
- _this.dimensions = new Vector3(21.875, 12.5, 0.001);
36
+ _this.titleBarMargin = 0.005;
33
37
  /**
34
- * Minimum dimensions of the slate
35
- */
36
- _this.minDimensions = new Vector3(15.625, 6.25, 0.001);
37
- /**
38
- * Default dimensions of the slate
39
- */
40
- _this.defaultDimensions = _this.dimensions.clone();
41
- /**
42
- * Dimensions of the backplate
38
+ * Origin in local coordinates (top left corner)
43
39
  */
44
- _this.backplateDimensions = new Vector3(21.875, 0.625, 0.001);
40
+ _this.origin = new Vector3(0, 0, 0);
41
+ _this._dimensions = new Vector2(21.875, 12.5);
42
+ _this._titleBarHeight = 0.625;
43
+ _this._titleText = "";
44
+ _this._contentScaleRatio = 1;
45
45
  /**
46
- * Margin between backplate and contentplate
46
+ * Minimum dimensions of the slate
47
47
  */
48
- _this.backPlateMargin = 0.005;
48
+ _this.minDimensions = new Vector2(15.625, 6.25);
49
49
  /**
50
- * Origin in local coordinates (top left corner)
50
+ * Default dimensions of the slate
51
51
  */
52
- _this.origin = new Vector3(0, 0, 0);
53
- _this._contentScaleRatio = 1;
52
+ _this.defaultDimensions = _this._dimensions.clone();
54
53
  _this._followButton = new TouchHolographicButton("followButton" + _this.name);
54
+ _this._followButton.isToggleButton = true;
55
55
  _this._closeButton = new TouchHolographicButton("closeButton" + _this.name);
56
56
  _this._contentViewport = new Viewport(0, 0, 1, 1);
57
57
  _this._contentDragBehavior = new PointerDragBehavior({
@@ -69,35 +69,76 @@ var HolographicSlate = /** @class */ (function (_super) {
69
69
  enumerable: false,
70
70
  configurable: true
71
71
  });
72
+ Object.defineProperty(HolographicSlate.prototype, "dimensions", {
73
+ /**
74
+ * 2D dimensions of the slate
75
+ */
76
+ get: function () {
77
+ return this._dimensions;
78
+ },
79
+ set: function (value) {
80
+ //clamp, respecting ratios
81
+ var scale = 1.0;
82
+ if (value.x < this.minDimensions.x || value.y < this.minDimensions.y) {
83
+ var newRatio = value.x / value.y;
84
+ var minRatio = this.minDimensions.x / this.minDimensions.y;
85
+ if (minRatio > newRatio) {
86
+ // We just need to make sure the x-val is greater than the min
87
+ scale = this.minDimensions.x / value.x;
88
+ }
89
+ else {
90
+ // We just need to make sure the y-val is greater than the min
91
+ scale = this.minDimensions.y / value.y;
92
+ }
93
+ }
94
+ this._dimensions.copyFrom(value).scaleInPlace(scale);
95
+ this._updatePivot();
96
+ this._positionElements();
97
+ },
98
+ enumerable: false,
99
+ configurable: true
100
+ });
101
+ Object.defineProperty(HolographicSlate.prototype, "titleBarHeight", {
102
+ /**
103
+ * Height of the title bar component
104
+ */
105
+ get: function () {
106
+ return this._titleBarHeight;
107
+ },
108
+ set: function (value) {
109
+ this._titleBarHeight = value;
110
+ },
111
+ enumerable: false,
112
+ configurable: true
113
+ });
72
114
  Object.defineProperty(HolographicSlate.prototype, "renderingGroupId", {
73
115
  get: function () {
74
- return this._backPlate.renderingGroupId;
116
+ return this._titleBar.renderingGroupId;
75
117
  },
76
118
  /**
77
- * Rendering ground id of all the mesh in the button
119
+ * Rendering ground id of all the meshes
78
120
  */
79
121
  set: function (id) {
80
- this._backPlate.renderingGroupId = id;
122
+ this._titleBar.renderingGroupId = id;
123
+ this._titleBarTitle.renderingGroupId = id;
81
124
  this._contentPlate.renderingGroupId = id;
125
+ this._backPlate.renderingGroupId = id;
82
126
  },
83
127
  enumerable: false,
84
128
  configurable: true
85
129
  });
86
- Object.defineProperty(HolographicSlate.prototype, "imageUrl", {
87
- /**
88
- * Gets or sets the image url for the button
89
- */
130
+ Object.defineProperty(HolographicSlate.prototype, "title", {
90
131
  get: function () {
91
- return this._imageUrl;
132
+ return this._titleText;
92
133
  },
93
- set: function (value) {
94
- if (this._imageUrl === value) {
95
- return;
134
+ /**
135
+ * The title text displayed at the top of the slate
136
+ */
137
+ set: function (title) {
138
+ this._titleText = title;
139
+ if (this._titleTextComponent) {
140
+ this._titleTextComponent.text = title;
96
141
  }
97
- this._imageUrl = value;
98
- this._rebuildContent();
99
- this._resetContentPositionAndZoom();
100
- this._applyContentViewport();
101
142
  },
102
143
  enumerable: false,
103
144
  configurable: true
@@ -109,18 +150,9 @@ var HolographicSlate = /** @class */ (function (_super) {
109
150
  */
110
151
  HolographicSlate.prototype._applyFacade = function (facadeTexture) {
111
152
  this._contentMaterial.albedoTexture = facadeTexture;
112
- };
113
- HolographicSlate.prototype._rebuildContent = function () {
114
- this._disposeFacadeTexture();
115
- if (DomManagement.IsDocumentAvailable() && !!document.createElement) {
116
- if (this._imageUrl) {
117
- var image = new Image();
118
- image.source = this._imageUrl;
119
- if (this._contentPlate) {
120
- this.content = image;
121
- }
122
- }
123
- }
153
+ this._resetContentPositionAndZoom();
154
+ this._applyContentViewport();
155
+ facadeTexture.attachToMesh(this._contentPlate, true);
124
156
  };
125
157
  HolographicSlate.prototype._addControl = function (control) {
126
158
  control._host = this._host;
@@ -135,36 +167,45 @@ var HolographicSlate = /** @class */ (function (_super) {
135
167
  * @hidden
136
168
  */
137
169
  HolographicSlate.prototype._positionElements = function () {
138
- var followButtonMesh = this._followButton.mesh;
139
- var closeButtonMesh = this._closeButton.mesh;
140
- var backPlate = this._backPlate;
170
+ var followButton = this._followButton;
171
+ var closeButton = this._closeButton;
172
+ var titleBar = this._titleBar;
173
+ var titleBarTitle = this._titleBarTitle;
141
174
  var contentPlate = this._contentPlate;
142
- if (followButtonMesh && closeButtonMesh && backPlate) {
143
- // World size of a button with 1 scaling
144
- var buttonBaseSize = 1;
145
- // Buttons take full backPlate on Y axis
146
- var backPlateYScale = this.backplateDimensions.y / buttonBaseSize;
147
- closeButtonMesh.scaling.setAll(backPlateYScale);
148
- followButtonMesh.scaling.setAll(backPlateYScale);
149
- closeButtonMesh.position
150
- .copyFromFloats(this.backplateDimensions.x - backPlateYScale / 2, -this.backplateDimensions.y / 2, (-this.backplateDimensions.z / 2) * (this._host.scene.useRightHandedSystem ? -1 : 1))
175
+ var backPlate = this._backPlate;
176
+ if (followButton && closeButton && titleBar) {
177
+ closeButton.scaling.setAll(this.titleBarHeight);
178
+ followButton.scaling.setAll(this.titleBarHeight);
179
+ closeButton.position
180
+ .copyFromFloats(this.dimensions.x - this.titleBarHeight / 2, -this.titleBarHeight / 2, 0)
151
181
  .addInPlace(this.origin);
152
- followButtonMesh.position
153
- .copyFromFloats(this.backplateDimensions.x - (3 * backPlateYScale) / 2, -this.backplateDimensions.y / 2, (-this.backplateDimensions.z / 2) * (this._host.scene.useRightHandedSystem ? -1 : 1))
182
+ followButton.position
183
+ .copyFromFloats(this.dimensions.x - (3 * this.titleBarHeight) / 2, -this.titleBarHeight / 2, 0)
154
184
  .addInPlace(this.origin);
155
- var contentPlateHeight = this.dimensions.y - this.backplateDimensions.y - this.backPlateMargin;
156
- backPlate.scaling.copyFrom(this.backplateDimensions);
157
- contentPlate.scaling.copyFromFloats(this.dimensions.x, contentPlateHeight, this.dimensions.z);
158
- backPlate.position.copyFromFloats(this.backplateDimensions.x / 2, -(this.backplateDimensions.y / 2), 0).addInPlace(this.origin);
159
- contentPlate.position.copyFromFloats(this.dimensions.x / 2, -(this.backplateDimensions.y + this.backPlateMargin + contentPlateHeight / 2), 0).addInPlace(this.origin);
185
+ var contentPlateHeight = this.dimensions.y - this.titleBarHeight - this.titleBarMargin;
186
+ var rightHandScene = contentPlate.getScene().useRightHandedSystem;
187
+ titleBar.scaling.set(this.dimensions.x, this.titleBarHeight, Epsilon);
188
+ titleBarTitle.scaling.set(this.dimensions.x - (2 * this.titleBarHeight), this.titleBarHeight, Epsilon);
189
+ contentPlate.scaling.copyFromFloats(this.dimensions.x, contentPlateHeight, Epsilon);
190
+ backPlate.scaling.copyFromFloats(this.dimensions.x, contentPlateHeight, Epsilon);
191
+ titleBar.position.copyFromFloats(this.dimensions.x / 2, -(this.titleBarHeight / 2), 0).addInPlace(this.origin);
192
+ titleBarTitle.position.copyFromFloats((this.dimensions.x / 2) - this.titleBarHeight, -(this.titleBarHeight / 2), rightHandScene ? Epsilon : -Epsilon).addInPlace(this.origin);
193
+ contentPlate.position.copyFromFloats(this.dimensions.x / 2, -(this.titleBarHeight + this.titleBarMargin + contentPlateHeight / 2), 0).addInPlace(this.origin);
194
+ backPlate.position.copyFromFloats(this.dimensions.x / 2, -(this.titleBarHeight + this.titleBarMargin + contentPlateHeight / 2), rightHandScene ? -Epsilon : Epsilon).addInPlace(this.origin);
195
+ // Update the title's AdvancedDynamicTexture scale to avoid visual stretching
196
+ this._titleTextComponent.host.scaleTo(HolographicSlate.DEFAULT_TEXT_RESOLUTION_Y * titleBarTitle.scaling.x / titleBarTitle.scaling.y, HolographicSlate.DEFAULT_TEXT_RESOLUTION_Y);
160
197
  var aspectRatio = this.dimensions.x / contentPlateHeight;
161
198
  this._contentViewport.width = this._contentScaleRatio;
162
199
  this._contentViewport.height = this._contentScaleRatio / aspectRatio;
163
200
  this._applyContentViewport();
201
+ if (this._gizmo) {
202
+ this._gizmo.updateBoundingBox();
203
+ }
164
204
  }
165
205
  };
166
206
  HolographicSlate.prototype._applyContentViewport = function () {
167
- if (this._contentPlate.material && this._contentPlate.material.albedoTexture) {
207
+ var _a;
208
+ if (((_a = this._contentPlate) === null || _a === void 0 ? void 0 : _a.material) && this._contentPlate.material.albedoTexture) {
168
209
  var tex = this._contentPlate.material.albedoTexture;
169
210
  tex.uScale = this._contentScaleRatio;
170
211
  tex.vScale = (this._contentScaleRatio / this._contentViewport.width) * this._contentViewport.height;
@@ -185,9 +226,8 @@ var HolographicSlate = /** @class */ (function (_super) {
185
226
  return;
186
227
  }
187
228
  // Update pivot point so it is at the center of geometry
188
- var center = this.dimensions.scale(0.5);
189
229
  // As origin is topleft corner in 2D, dimensions are calculated towards bottom right corner, thus y axis is downwards
190
- center.y *= -1;
230
+ var center = new Vector3(this.dimensions.x * 0.5, -this.dimensions.y * 0.5, Epsilon);
191
231
  center.addInPlace(this.origin);
192
232
  center.z = 0;
193
233
  var origin = new Vector3(0, 0, 0);
@@ -200,30 +240,47 @@ var HolographicSlate = /** @class */ (function (_super) {
200
240
  // Mesh association
201
241
  HolographicSlate.prototype._createNode = function (scene) {
202
242
  var _this = this;
203
- var node = new Mesh("slate" + this.name, scene);
204
- this._backPlate = CreateBox("backPlate" + this.name, { size: 1 }, scene);
205
- var faceUV = new Array(6).fill(new Vector4(0, 0, 1, 1));
243
+ var node = new Mesh("slate_" + this.name, scene);
244
+ this._titleBar = CreateBox("titleBar_" + this.name, { size: 1 }, scene);
245
+ this._titleBarTitle = CreatePlane("titleText_" + this.name, { size: 1 }, scene);
246
+ this._titleBarTitle.parent = node;
247
+ this._titleBarTitle.isPickable = false;
248
+ var adt = AdvancedDynamicTexture.CreateForMesh(this._titleBarTitle);
249
+ this._titleTextComponent = new TextBlock("titleText_" + this.name, this._titleText);
250
+ this._titleTextComponent.textWrapping = TextWrapping.Ellipsis;
251
+ this._titleTextComponent.textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
252
+ this._titleTextComponent.color = "white";
253
+ this._titleTextComponent.fontSize = HolographicSlate.DEFAULT_TEXT_RESOLUTION_Y / 2;
254
+ this._titleTextComponent.paddingLeft = HolographicSlate.DEFAULT_TEXT_RESOLUTION_Y / 4;
255
+ adt.addControl(this._titleTextComponent);
206
256
  if (scene.useRightHandedSystem) {
207
- faceUV[0].copyFromFloats(0, 1, 1, 0);
257
+ var faceUV = new Vector4(0, 0, 1, 1);
258
+ this._contentPlate = CreatePlane("contentPlate_" + this.name, { size: 1, sideOrientation: VertexData.BACKSIDE, frontUVs: faceUV }, scene);
259
+ this._backPlate = CreatePlane("backPlate_" + this.name, { size: 1, sideOrientation: VertexData.FRONTSIDE }, scene);
208
260
  }
209
- this._contentPlate = CreateBox("contentPlate" + this.name, { size: 1, faceUV: faceUV }, scene);
210
- this._backPlate.parent = node;
211
- this._backPlate.isNearGrabbable = true;
261
+ else {
262
+ var faceUV = new Vector4(0, 0, 1, 1);
263
+ this._contentPlate = CreatePlane("contentPlate_" + this.name, { size: 1, sideOrientation: VertexData.FRONTSIDE, frontUVs: faceUV }, scene);
264
+ this._backPlate = CreatePlane("backPlate_" + this.name, { size: 1, sideOrientation: VertexData.BACKSIDE }, scene);
265
+ }
266
+ this._titleBar.parent = node;
267
+ this._titleBar.isNearGrabbable = true;
212
268
  this._contentPlate.parent = node;
269
+ this._backPlate.parent = node;
213
270
  this._attachContentPlateBehavior();
214
271
  this._addControl(this._followButton);
215
272
  this._addControl(this._closeButton);
216
- var followButtonMesh = this._followButton.mesh;
217
- var closeButtonMesh = this._closeButton.mesh;
218
- followButtonMesh.parent = node;
219
- closeButtonMesh.parent = node;
273
+ var followButton = this._followButton;
274
+ var closeButton = this._closeButton;
275
+ followButton.node.parent = node;
276
+ closeButton.node.parent = node;
220
277
  this._positionElements();
221
278
  this._followButton.imageUrl = HolographicSlate.ASSETS_BASE_URL + HolographicSlate.FOLLOW_ICON_FILENAME;
222
279
  this._closeButton.imageUrl = HolographicSlate.ASSETS_BASE_URL + HolographicSlate.CLOSE_ICON_FILENAME;
223
280
  this._followButton.isBackplateVisible = false;
224
281
  this._closeButton.isBackplateVisible = false;
225
- this._followButton.onPointerClickObservable.add(function () {
226
- _this._defaultBehavior.followBehaviorEnabled = !_this._defaultBehavior.followBehaviorEnabled;
282
+ this._followButton.onToggleObservable.add(function (isToggled) {
283
+ _this._defaultBehavior.followBehaviorEnabled = isToggled;
227
284
  if (_this._defaultBehavior.followBehaviorEnabled) {
228
285
  _this._defaultBehavior.followBehavior.recenter();
229
286
  }
@@ -255,8 +312,8 @@ var HolographicSlate = /** @class */ (function (_super) {
255
312
  startViewport = _this._contentViewport.clone();
256
313
  worldMatrix = _this.node.computeWorldMatrix(true);
257
314
  origin.copyFrom(event.dragPlanePoint);
258
- worldDimensions.copyFrom(_this.dimensions);
259
- worldDimensions.y -= _this.backplateDimensions.y + _this.backPlateMargin;
315
+ worldDimensions.set(_this.dimensions.x, _this.dimensions.y, Epsilon);
316
+ worldDimensions.y -= _this.titleBarHeight + _this.titleBarMargin;
260
317
  Vector3.TransformNormalToRef(worldDimensions, worldMatrix, worldDimensions);
261
318
  upWorld.copyFromFloats(0, 1, 0);
262
319
  Vector3.TransformNormalToRef(upWorld, worldMatrix, upWorld);
@@ -280,20 +337,17 @@ var HolographicSlate = /** @class */ (function (_super) {
280
337
  };
281
338
  HolographicSlate.prototype._affectMaterial = function (mesh) {
282
339
  // TODO share materials
283
- this._backPlateMaterial = new FluentBackplateMaterial(this.name + " plateMaterial", mesh.getScene());
284
- this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
285
- // if (pickedPoint) {
286
- // this._backPlateMaterial. = pickedPoint;
287
- // this._backPlateMaterial.hoverColor.a = 1.0;
288
- // } else {
289
- // this._backPlateMaterial.hoverColor.a = 0;
290
- // }
291
- });
292
- this._contentMaterial = new FluentMaterial(this.name + "contentMaterial", mesh.getScene());
340
+ this._titleBarMaterial = new FluentBackplateMaterial("".concat(this.name, " plateMaterial"), mesh.getScene());
341
+ this._contentMaterial = new FluentMaterial("".concat(this.name, " contentMaterial"), mesh.getScene());
293
342
  this._contentMaterial.renderBorders = true;
294
- this._backPlate.material = this._backPlateMaterial;
343
+ this._backMaterial = new FluentBackplateMaterial("".concat(this.name, " backPlate"), mesh.getScene());
344
+ this._backMaterial.lineWidth = Epsilon;
345
+ this._backMaterial.radius = 0.005;
346
+ this._backMaterial.backFaceCulling = true;
347
+ this._titleBar.material = this._titleBarMaterial;
295
348
  this._contentPlate.material = this._contentMaterial;
296
- this._rebuildContent();
349
+ this._backPlate.material = this._backMaterial;
350
+ this._resetContent();
297
351
  this._applyContentViewport();
298
352
  };
299
353
  /** @hidden **/
@@ -303,17 +357,22 @@ var HolographicSlate = /** @class */ (function (_super) {
303
357
  this._gizmo = new SlateGizmo(this._host.utilityLayer);
304
358
  this._gizmo.attachedSlate = this;
305
359
  this._defaultBehavior = new DefaultBehavior();
306
- this._defaultBehavior.attach(this.node, [this._backPlate]);
360
+ this._defaultBehavior.attach(this.node, [this._titleBar]);
361
+ this._defaultBehavior.sixDofDragBehavior.onDragStartObservable.add(function () {
362
+ _this._followButton.isToggled = false;
363
+ });
307
364
  this._positionChangedObserver = this._defaultBehavior.sixDofDragBehavior.onPositionChangedObservable.add(function () {
308
365
  _this._gizmo.updateBoundingBox();
309
366
  });
310
367
  this._updatePivot();
311
- this.resetDefaultAspectAndPose();
368
+ this.resetDefaultAspectAndPose(false);
312
369
  };
313
370
  /**
314
371
  * Resets the aspect and pose of the slate so it is right in front of the active camera, facing towards it.
372
+ * @param resetAspect Should the slate's dimensions/aspect ratio be reset as well
315
373
  */
316
- HolographicSlate.prototype.resetDefaultAspectAndPose = function () {
374
+ HolographicSlate.prototype.resetDefaultAspectAndPose = function (resetAspect) {
375
+ if (resetAspect === void 0) { resetAspect = true; }
317
376
  if (!this._host || !this._host.utilityLayer || !this.node) {
318
377
  return;
319
378
  }
@@ -322,12 +381,14 @@ var HolographicSlate = /** @class */ (function (_super) {
322
381
  if (camera) {
323
382
  var worldMatrix = camera.getWorldMatrix();
324
383
  var backward = Vector3.TransformNormal(Vector3.Backward(scene.useRightHandedSystem), worldMatrix);
325
- this.dimensions.copyFrom(this.defaultDimensions);
326
384
  this.origin.setAll(0);
327
385
  this._gizmo.updateBoundingBox();
328
386
  var pivot = this.node.getAbsolutePivotPoint();
329
387
  this.node.position.copyFrom(camera.position).subtractInPlace(backward).subtractInPlace(pivot);
330
388
  this.node.rotationQuaternion = Quaternion.FromLookDirectionLH(backward, new Vector3(0, 1, 0));
389
+ if (resetAspect) {
390
+ this.dimensions = this.defaultDimensions;
391
+ }
331
392
  }
332
393
  };
333
394
  /**
@@ -335,10 +396,12 @@ var HolographicSlate = /** @class */ (function (_super) {
335
396
  */
336
397
  HolographicSlate.prototype.dispose = function () {
337
398
  _super.prototype.dispose.call(this);
338
- this._backPlateMaterial.dispose();
399
+ this._titleBarMaterial.dispose();
339
400
  this._contentMaterial.dispose();
340
- this._backPlate.dispose();
401
+ this._titleBar.dispose();
402
+ this._titleBarTitle.dispose();
341
403
  this._contentPlate.dispose();
404
+ this._backPlate.dispose();
342
405
  this._followButton.dispose();
343
406
  this._closeButton.dispose();
344
407
  this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
@@ -359,6 +422,7 @@ var HolographicSlate = /** @class */ (function (_super) {
359
422
  * File name for the close icon.
360
423
  */
361
424
  HolographicSlate.FOLLOW_ICON_FILENAME = "IconFollowMe.png";
425
+ HolographicSlate.DEFAULT_TEXT_RESOLUTION_Y = 102.4;
362
426
  return HolographicSlate;
363
427
  }(ContentDisplay3D));
364
428
  export { HolographicSlate };