@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.
Files changed (178) hide show
  1. package/2D/adtInstrumentation.js +70 -90
  2. package/2D/adtInstrumentation.js.map +1 -1
  3. package/2D/advancedDynamicTexture.d.ts +14 -0
  4. package/2D/advancedDynamicTexture.js +574 -620
  5. package/2D/advancedDynamicTexture.js.map +1 -1
  6. package/2D/controls/button.js +76 -90
  7. package/2D/controls/button.js.map +1 -1
  8. package/2D/controls/checkbox.js +86 -106
  9. package/2D/controls/checkbox.js.map +1 -1
  10. package/2D/controls/colorpicker.js +395 -415
  11. package/2D/controls/colorpicker.js.map +1 -1
  12. package/2D/controls/container.js +187 -230
  13. package/2D/controls/container.js.map +1 -1
  14. package/2D/controls/control.js +1073 -1353
  15. package/2D/controls/control.js.map +1 -1
  16. package/2D/controls/displayGrid.js +152 -196
  17. package/2D/controls/displayGrid.js.map +1 -1
  18. package/2D/controls/ellipse.js +32 -40
  19. package/2D/controls/ellipse.js.map +1 -1
  20. package/2D/controls/focusableButton.js +30 -35
  21. package/2D/controls/focusableButton.js.map +1 -1
  22. package/2D/controls/grid.js +172 -212
  23. package/2D/controls/grid.js.map +1 -1
  24. package/2D/controls/image.js +489 -592
  25. package/2D/controls/image.js.map +1 -1
  26. package/2D/controls/inputPassword.js +9 -16
  27. package/2D/controls/inputPassword.js.map +1 -1
  28. package/2D/controls/inputText.js +380 -467
  29. package/2D/controls/inputText.js.map +1 -1
  30. package/2D/controls/inputTextArea.js +234 -273
  31. package/2D/controls/inputTextArea.js.map +1 -1
  32. package/2D/controls/line.js +147 -198
  33. package/2D/controls/line.js.map +1 -1
  34. package/2D/controls/multiLine.js +87 -113
  35. package/2D/controls/multiLine.js.map +1 -1
  36. package/2D/controls/radioButton.js +106 -127
  37. package/2D/controls/radioButton.js.map +1 -1
  38. package/2D/controls/rectangle.js +60 -72
  39. package/2D/controls/rectangle.js.map +1 -1
  40. package/2D/controls/scrollViewers/scrollViewer.js +439 -543
  41. package/2D/controls/scrollViewers/scrollViewer.js.map +1 -1
  42. package/2D/controls/scrollViewers/scrollViewerWindow.js +99 -118
  43. package/2D/controls/scrollViewers/scrollViewerWindow.js.map +1 -1
  44. package/2D/controls/selector.js +241 -329
  45. package/2D/controls/selector.js.map +1 -1
  46. package/2D/controls/sliders/baseSlider.js +182 -230
  47. package/2D/controls/sliders/baseSlider.js.map +1 -1
  48. package/2D/controls/sliders/imageBasedSlider.js +86 -109
  49. package/2D/controls/sliders/imageBasedSlider.js.map +1 -1
  50. package/2D/controls/sliders/imageScrollBar.js +148 -178
  51. package/2D/controls/sliders/imageScrollBar.js.map +1 -1
  52. package/2D/controls/sliders/scrollBar.js +64 -80
  53. package/2D/controls/sliders/scrollBar.js.map +1 -1
  54. package/2D/controls/sliders/slider.js +91 -115
  55. package/2D/controls/sliders/slider.js.map +1 -1
  56. package/2D/controls/stackPanel.js +114 -135
  57. package/2D/controls/stackPanel.js.map +1 -1
  58. package/2D/controls/statics.js +5 -5
  59. package/2D/controls/statics.js.map +1 -1
  60. package/2D/controls/textBlock.js +322 -384
  61. package/2D/controls/textBlock.js.map +1 -1
  62. package/2D/controls/textWrapper.js +27 -41
  63. package/2D/controls/textWrapper.js.map +1 -1
  64. package/2D/controls/toggleButton.js +105 -121
  65. package/2D/controls/toggleButton.js.map +1 -1
  66. package/2D/controls/virtualKeyboard.js +101 -123
  67. package/2D/controls/virtualKeyboard.js.map +1 -1
  68. package/2D/math2D.js +62 -70
  69. package/2D/math2D.js.map +1 -1
  70. package/2D/measure.js +30 -32
  71. package/2D/measure.js.map +1 -1
  72. package/2D/multiLinePoint.js +71 -89
  73. package/2D/multiLinePoint.js.map +1 -1
  74. package/2D/style.js +55 -73
  75. package/2D/style.js.map +1 -1
  76. package/2D/valueAndUnit.js +71 -104
  77. package/2D/valueAndUnit.js.map +1 -1
  78. package/2D/xmlLoader.js +70 -84
  79. package/2D/xmlLoader.js.map +1 -1
  80. package/3D/behaviors/defaultBehavior.js +40 -59
  81. package/3D/behaviors/defaultBehavior.js.map +1 -1
  82. package/3D/controls/abstractButton3D.js +8 -12
  83. package/3D/controls/abstractButton3D.js.map +1 -1
  84. package/3D/controls/button3D.js +30 -35
  85. package/3D/controls/button3D.js.map +1 -1
  86. package/3D/controls/container3D.js +57 -71
  87. package/3D/controls/container3D.js.map +1 -1
  88. package/3D/controls/contentDisplay3D.js +47 -60
  89. package/3D/controls/contentDisplay3D.js.map +1 -1
  90. package/3D/controls/control3D.js +123 -158
  91. package/3D/controls/control3D.js.map +1 -1
  92. package/3D/controls/cylinderPanel.js +28 -38
  93. package/3D/controls/cylinderPanel.js.map +1 -1
  94. package/3D/controls/handMenu.js +20 -29
  95. package/3D/controls/handMenu.js.map +1 -1
  96. package/3D/controls/holographicBackplate.js +52 -72
  97. package/3D/controls/holographicBackplate.js.map +1 -1
  98. package/3D/controls/holographicButton.js +160 -200
  99. package/3D/controls/holographicButton.js.map +1 -1
  100. package/3D/controls/holographicSlate.js +176 -206
  101. package/3D/controls/holographicSlate.js.map +1 -1
  102. package/3D/controls/meshButton3D.js +24 -30
  103. package/3D/controls/meshButton3D.js.map +1 -1
  104. package/3D/controls/nearMenu.js +57 -71
  105. package/3D/controls/nearMenu.js.map +1 -1
  106. package/3D/controls/planePanel.js +6 -13
  107. package/3D/controls/planePanel.js.map +1 -1
  108. package/3D/controls/scatterPanel.js +43 -54
  109. package/3D/controls/scatterPanel.js.map +1 -1
  110. package/3D/controls/slider3D.js +168 -222
  111. package/3D/controls/slider3D.js.map +1 -1
  112. package/3D/controls/spherePanel.js +29 -39
  113. package/3D/controls/spherePanel.js.map +1 -1
  114. package/3D/controls/stackPanel3D.js +36 -49
  115. package/3D/controls/stackPanel3D.js.map +1 -1
  116. package/3D/controls/touchButton3D.js +126 -154
  117. package/3D/controls/touchButton3D.js.map +1 -1
  118. package/3D/controls/touchHolographicButton.js +223 -272
  119. package/3D/controls/touchHolographicButton.js.map +1 -1
  120. package/3D/controls/touchHolographicMenu.js +55 -66
  121. package/3D/controls/touchHolographicMenu.js.map +1 -1
  122. package/3D/controls/touchMeshButton3D.js +24 -30
  123. package/3D/controls/touchMeshButton3D.js.map +1 -1
  124. package/3D/controls/volumeBasedPanel.js +85 -107
  125. package/3D/controls/volumeBasedPanel.js.map +1 -1
  126. package/3D/gizmos/gizmoHandle.js +68 -103
  127. package/3D/gizmos/gizmoHandle.js.map +1 -1
  128. package/3D/gizmos/slateGizmo.js +165 -182
  129. package/3D/gizmos/slateGizmo.js.map +1 -1
  130. package/3D/gui3DManager.js +76 -101
  131. package/3D/gui3DManager.js.map +1 -1
  132. package/3D/materials/fluent/fluentMaterial.js +110 -119
  133. package/3D/materials/fluent/fluentMaterial.js.map +1 -1
  134. package/3D/materials/fluent/shaders/fluent.fragment.js +20 -3
  135. package/3D/materials/fluent/shaders/fluent.fragment.js.map +1 -1
  136. package/3D/materials/fluent/shaders/fluent.vertex.js +11 -3
  137. package/3D/materials/fluent/shaders/fluent.vertex.js.map +1 -1
  138. package/3D/materials/fluentBackplate/fluentBackplateMaterial.js +168 -177
  139. package/3D/materials/fluentBackplate/fluentBackplateMaterial.js.map +1 -1
  140. package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.js +9 -3
  141. package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.js.map +1 -1
  142. package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.js +15 -3
  143. package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.js.map +1 -1
  144. package/3D/materials/fluentButton/fluentButtonMaterial.js +205 -213
  145. package/3D/materials/fluentButton/fluentButtonMaterial.js.map +1 -1
  146. package/3D/materials/fluentButton/shaders/fluentButton.fragment.js +6 -3
  147. package/3D/materials/fluentButton/shaders/fluentButton.fragment.js.map +1 -1
  148. package/3D/materials/fluentButton/shaders/fluentButton.vertex.js +6 -3
  149. package/3D/materials/fluentButton/shaders/fluentButton.vertex.js.map +1 -1
  150. package/3D/materials/handle/handleMaterial.js +56 -69
  151. package/3D/materials/handle/handleMaterial.js.map +1 -1
  152. package/3D/materials/handle/shaders/handle.fragment.js +3 -3
  153. package/3D/materials/handle/shaders/handle.fragment.js.map +1 -1
  154. package/3D/materials/handle/shaders/handle.vertex.js +3 -3
  155. package/3D/materials/handle/shaders/handle.vertex.js.map +1 -1
  156. package/3D/materials/mrdl/mrdlBackplateMaterial.js +158 -166
  157. package/3D/materials/mrdl/mrdlBackplateMaterial.js.map +1 -1
  158. package/3D/materials/mrdl/mrdlSliderBarMaterial.js +322 -330
  159. package/3D/materials/mrdl/mrdlSliderBarMaterial.js.map +1 -1
  160. package/3D/materials/mrdl/mrdlSliderThumbMaterial.js +322 -330
  161. package/3D/materials/mrdl/mrdlSliderThumbMaterial.js.map +1 -1
  162. package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.js +9 -3
  163. package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.js.map +1 -1
  164. package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.js +6 -3
  165. package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.js.map +1 -1
  166. package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.js +24 -3
  167. package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.js.map +1 -1
  168. package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.js +12 -3
  169. package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.js.map +1 -1
  170. package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.js +24 -3
  171. package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.js.map +1 -1
  172. package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.js +12 -3
  173. package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.js.map +1 -1
  174. package/3D/vector3WithInfo.js +6 -12
  175. package/3D/vector3WithInfo.js.map +1 -1
  176. package/legacy/legacy.js +1 -1
  177. package/legacy/legacy.js.map +1 -1
  178. package/package.json +3 -6
@@ -1,4 +1,3 @@
1
- import { __extends } from "tslib";
2
1
  import { ContentDisplay3D } from "./contentDisplay3D.js";
3
2
  import { TouchHolographicButton } from "./touchHolographicButton.js";
4
3
  import { AdvancedDynamicTexture } from "../../2D/advancedDynamicTexture.js";
@@ -22,164 +21,142 @@ import { VertexData } from "@babylonjs/core/Meshes/mesh.vertexData.js";
22
21
  * Class used to create a holographic slate
23
22
  * @since 5.0.0
24
23
  */
25
- var HolographicSlate = /** @class */ (function (_super) {
26
- __extends(HolographicSlate, _super);
24
+ export class HolographicSlate extends ContentDisplay3D {
27
25
  /**
28
26
  * Creates a new slate
29
27
  * @param name defines the control name
30
28
  */
31
- function HolographicSlate(name) {
32
- var _this = _super.call(this, name) || this;
29
+ constructor(name) {
30
+ super(name);
33
31
  /**
34
32
  * Margin between title bar and contentplate
35
33
  */
36
- _this.titleBarMargin = 0.005;
34
+ this.titleBarMargin = 0.005;
37
35
  /**
38
36
  * Origin in local coordinates (top left corner)
39
37
  */
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;
38
+ this.origin = new Vector3(0, 0, 0);
39
+ this._dimensions = new Vector2(21.875, 12.5);
40
+ this._titleBarHeight = 0.625;
41
+ this._titleText = "";
42
+ this._contentScaleRatio = 1;
45
43
  /**
46
44
  * Minimum dimensions of the slate
47
45
  */
48
- _this.minDimensions = new Vector2(15.625, 6.25);
46
+ this.minDimensions = new Vector2(15.625, 6.25);
49
47
  /**
50
48
  * Default dimensions of the slate
51
49
  */
52
- _this.defaultDimensions = _this._dimensions.clone();
53
- _this._followButton = new TouchHolographicButton("followButton" + _this.name);
54
- _this._followButton.isToggleButton = true;
55
- _this._closeButton = new TouchHolographicButton("closeButton" + _this.name);
56
- _this._contentViewport = new Viewport(0, 0, 1, 1);
57
- _this._contentDragBehavior = new PointerDragBehavior({
50
+ this.defaultDimensions = this._dimensions.clone();
51
+ this._followButton = new TouchHolographicButton("followButton" + this.name);
52
+ this._followButton.isToggleButton = true;
53
+ this._closeButton = new TouchHolographicButton("closeButton" + this.name);
54
+ this._contentViewport = new Viewport(0, 0, 1, 1);
55
+ this._contentDragBehavior = new PointerDragBehavior({
58
56
  dragPlaneNormal: new Vector3(0, 0, -1),
59
57
  });
60
- return _this;
61
58
  }
62
- Object.defineProperty(HolographicSlate.prototype, "defaultBehavior", {
63
- /**
64
- * Regroups all mesh behaviors for the slate
65
- */
66
- get: function () {
67
- return this._defaultBehavior;
68
- },
69
- enumerable: false,
70
- configurable: true
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
- }
59
+ /**
60
+ * Regroups all mesh behaviors for the slate
61
+ */
62
+ get defaultBehavior() {
63
+ return this._defaultBehavior;
64
+ }
65
+ /**
66
+ * 2D dimensions of the slate
67
+ */
68
+ get dimensions() {
69
+ return this._dimensions;
70
+ }
71
+ set dimensions(value) {
72
+ //clamp, respecting ratios
73
+ let scale = 1.0;
74
+ if (value.x < this.minDimensions.x || value.y < this.minDimensions.y) {
75
+ const newRatio = value.x / value.y;
76
+ const minRatio = this.minDimensions.x / this.minDimensions.y;
77
+ if (minRatio > newRatio) {
78
+ // We just need to make sure the x-val is greater than the min
79
+ scale = this.minDimensions.x / value.x;
93
80
  }
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
- });
114
- Object.defineProperty(HolographicSlate.prototype, "renderingGroupId", {
115
- get: function () {
116
- return this._titleBar.renderingGroupId;
117
- },
118
- /**
119
- * Rendering ground id of all the meshes
120
- */
121
- set: function (id) {
122
- this._titleBar.renderingGroupId = id;
123
- this._titleBarTitle.renderingGroupId = id;
124
- this._contentPlate.renderingGroupId = id;
125
- this._backPlate.renderingGroupId = id;
126
- },
127
- enumerable: false,
128
- configurable: true
129
- });
130
- Object.defineProperty(HolographicSlate.prototype, "title", {
131
- get: function () {
132
- return this._titleText;
133
- },
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;
81
+ else {
82
+ // We just need to make sure the y-val is greater than the min
83
+ scale = this.minDimensions.y / value.y;
141
84
  }
142
- },
143
- enumerable: false,
144
- configurable: true
145
- });
85
+ }
86
+ this._dimensions.copyFrom(value).scaleInPlace(scale);
87
+ this._updatePivot();
88
+ this._positionElements();
89
+ }
90
+ /**
91
+ * Height of the title bar component
92
+ */
93
+ get titleBarHeight() {
94
+ return this._titleBarHeight;
95
+ }
96
+ set titleBarHeight(value) {
97
+ this._titleBarHeight = value;
98
+ }
99
+ /**
100
+ * Rendering ground id of all the meshes
101
+ */
102
+ set renderingGroupId(id) {
103
+ this._titleBar.renderingGroupId = id;
104
+ this._titleBarTitle.renderingGroupId = id;
105
+ this._contentPlate.renderingGroupId = id;
106
+ this._backPlate.renderingGroupId = id;
107
+ }
108
+ get renderingGroupId() {
109
+ return this._titleBar.renderingGroupId;
110
+ }
111
+ /**
112
+ * The title text displayed at the top of the slate
113
+ */
114
+ set title(title) {
115
+ this._titleText = title;
116
+ if (this._titleTextComponent) {
117
+ this._titleTextComponent.text = title;
118
+ }
119
+ }
120
+ get title() {
121
+ return this._titleText;
122
+ }
146
123
  /**
147
124
  * Apply the facade texture (created from the content property).
148
125
  * This function can be overloaded by child classes
149
126
  * @param facadeTexture defines the AdvancedDynamicTexture to use
150
127
  */
151
- HolographicSlate.prototype._applyFacade = function (facadeTexture) {
128
+ _applyFacade(facadeTexture) {
152
129
  this._contentMaterial.albedoTexture = facadeTexture;
153
130
  this._resetContentPositionAndZoom();
154
131
  this._applyContentViewport();
155
132
  facadeTexture.attachToMesh(this._contentPlate, true);
156
- };
157
- HolographicSlate.prototype._addControl = function (control) {
133
+ }
134
+ _addControl(control) {
158
135
  control._host = this._host;
159
136
  if (this._host.utilityLayer) {
160
137
  control._prepareNode(this._host.utilityLayer.utilityLayerScene);
161
138
  }
162
- };
163
- HolographicSlate.prototype._getTypeName = function () {
139
+ }
140
+ _getTypeName() {
164
141
  return "HolographicSlate";
165
- };
142
+ }
166
143
  /**
167
144
  * @hidden
168
145
  */
169
- HolographicSlate.prototype._positionElements = function () {
170
- var followButton = this._followButton;
171
- var closeButton = this._closeButton;
172
- var titleBar = this._titleBar;
173
- var titleBarTitle = this._titleBarTitle;
174
- var contentPlate = this._contentPlate;
175
- var backPlate = this._backPlate;
146
+ _positionElements() {
147
+ const followButton = this._followButton;
148
+ const closeButton = this._closeButton;
149
+ const titleBar = this._titleBar;
150
+ const titleBarTitle = this._titleBarTitle;
151
+ const contentPlate = this._contentPlate;
152
+ const backPlate = this._backPlate;
176
153
  if (followButton && closeButton && titleBar) {
177
154
  closeButton.scaling.setAll(this.titleBarHeight);
178
155
  followButton.scaling.setAll(this.titleBarHeight);
179
156
  closeButton.position.copyFromFloats(this.dimensions.x - this.titleBarHeight / 2, -this.titleBarHeight / 2, 0).addInPlace(this.origin);
180
157
  followButton.position.copyFromFloats(this.dimensions.x - (3 * this.titleBarHeight) / 2, -this.titleBarHeight / 2, 0).addInPlace(this.origin);
181
- var contentPlateHeight = this.dimensions.y - this.titleBarHeight - this.titleBarMargin;
182
- var rightHandScene = contentPlate.getScene().useRightHandedSystem;
158
+ const contentPlateHeight = this.dimensions.y - this.titleBarHeight - this.titleBarMargin;
159
+ const rightHandScene = contentPlate.getScene().useRightHandedSystem;
183
160
  titleBar.scaling.set(this.dimensions.x, this.titleBarHeight, Epsilon);
184
161
  titleBarTitle.scaling.set(this.dimensions.x - 2 * this.titleBarHeight, this.titleBarHeight, Epsilon);
185
162
  contentPlate.scaling.copyFromFloats(this.dimensions.x, contentPlateHeight, Epsilon);
@@ -194,7 +171,7 @@ var HolographicSlate = /** @class */ (function (_super) {
194
171
  .addInPlace(this.origin);
195
172
  // Update the title's AdvancedDynamicTexture scale to avoid visual stretching
196
173
  this._titleTextComponent.host.scaleTo((HolographicSlate._DEFAULT_TEXT_RESOLUTION_Y * titleBarTitle.scaling.x) / titleBarTitle.scaling.y, HolographicSlate._DEFAULT_TEXT_RESOLUTION_Y);
197
- var aspectRatio = this.dimensions.x / contentPlateHeight;
174
+ const aspectRatio = this.dimensions.x / contentPlateHeight;
198
175
  this._contentViewport.width = this._contentScaleRatio;
199
176
  this._contentViewport.height = this._contentScaleRatio / aspectRatio;
200
177
  this._applyContentViewport();
@@ -202,50 +179,48 @@ var HolographicSlate = /** @class */ (function (_super) {
202
179
  this._gizmo.updateBoundingBox();
203
180
  }
204
181
  }
205
- };
206
- HolographicSlate.prototype._applyContentViewport = function () {
207
- var _a;
208
- if (((_a = this._contentPlate) === null || _a === void 0 ? void 0 : _a.material) && this._contentPlate.material.albedoTexture) {
209
- var tex = this._contentPlate.material.albedoTexture;
182
+ }
183
+ _applyContentViewport() {
184
+ if (this._contentPlate?.material && this._contentPlate.material.albedoTexture) {
185
+ const tex = this._contentPlate.material.albedoTexture;
210
186
  tex.uScale = this._contentScaleRatio;
211
187
  tex.vScale = (this._contentScaleRatio / this._contentViewport.width) * this._contentViewport.height;
212
188
  tex.uOffset = this._contentViewport.x;
213
189
  tex.vOffset = this._contentViewport.y;
214
190
  }
215
- };
216
- HolographicSlate.prototype._resetContentPositionAndZoom = function () {
191
+ }
192
+ _resetContentPositionAndZoom() {
217
193
  this._contentViewport.x = 0;
218
194
  this._contentViewport.y = 1 - this._contentViewport.height / this._contentViewport.width;
219
195
  this._contentScaleRatio = 1;
220
- };
196
+ }
221
197
  /**
222
198
  * @hidden
223
199
  */
224
- HolographicSlate.prototype._updatePivot = function () {
200
+ _updatePivot() {
225
201
  if (!this.mesh) {
226
202
  return;
227
203
  }
228
204
  // Update pivot point so it is at the center of geometry
229
205
  // As origin is topleft corner in 2D, dimensions are calculated towards bottom right corner, thus y axis is downwards
230
- var center = new Vector3(this.dimensions.x * 0.5, -this.dimensions.y * 0.5, Epsilon);
206
+ const center = new Vector3(this.dimensions.x * 0.5, -this.dimensions.y * 0.5, Epsilon);
231
207
  center.addInPlace(this.origin);
232
208
  center.z = 0;
233
- var origin = new Vector3(0, 0, 0);
209
+ const origin = new Vector3(0, 0, 0);
234
210
  Vector3.TransformCoordinatesToRef(origin, this.mesh.computeWorldMatrix(true), origin);
235
211
  this.mesh.setPivotPoint(center);
236
- var origin2 = new Vector3(0, 0, 0);
212
+ const origin2 = new Vector3(0, 0, 0);
237
213
  Vector3.TransformCoordinatesToRef(origin2, this.mesh.computeWorldMatrix(true), origin2);
238
214
  this.mesh.position.addInPlace(origin).subtractInPlace(origin2);
239
- };
215
+ }
240
216
  // Mesh association
241
- HolographicSlate.prototype._createNode = function (scene) {
242
- var _this = this;
243
- var node = new Mesh("slate_" + this.name, scene);
217
+ _createNode(scene) {
218
+ const node = new Mesh("slate_" + this.name, scene);
244
219
  this._titleBar = CreateBox("titleBar_" + this.name, { size: 1 }, scene);
245
220
  this._titleBarTitle = CreatePlane("titleText_" + this.name, { size: 1 }, scene);
246
221
  this._titleBarTitle.parent = node;
247
222
  this._titleBarTitle.isPickable = false;
248
- var adt = AdvancedDynamicTexture.CreateForMesh(this._titleBarTitle);
223
+ const adt = AdvancedDynamicTexture.CreateForMesh(this._titleBarTitle);
249
224
  this._titleTextComponent = new TextBlock("titleText_" + this.name, this._titleText);
250
225
  this._titleTextComponent.textWrapping = TextWrapping.Ellipsis;
251
226
  this._titleTextComponent.textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
@@ -254,12 +229,12 @@ var HolographicSlate = /** @class */ (function (_super) {
254
229
  this._titleTextComponent.paddingLeft = HolographicSlate._DEFAULT_TEXT_RESOLUTION_Y / 4;
255
230
  adt.addControl(this._titleTextComponent);
256
231
  if (scene.useRightHandedSystem) {
257
- var faceUV = new Vector4(0, 0, 1, 1);
232
+ const faceUV = new Vector4(0, 0, 1, 1);
258
233
  this._contentPlate = CreatePlane("contentPlate_" + this.name, { size: 1, sideOrientation: VertexData.BACKSIDE, frontUVs: faceUV }, scene);
259
234
  this._backPlate = CreatePlane("backPlate_" + this.name, { size: 1, sideOrientation: VertexData.FRONTSIDE }, scene);
260
235
  }
261
236
  else {
262
- var faceUV = new Vector4(0, 0, 1, 1);
237
+ const faceUV = new Vector4(0, 0, 1, 1);
263
238
  this._contentPlate = CreatePlane("contentPlate_" + this.name, { size: 1, sideOrientation: VertexData.FRONTSIDE, frontUVs: faceUV }, scene);
264
239
  this._backPlate = CreatePlane("backPlate_" + this.name, { size: 1, sideOrientation: VertexData.BACKSIDE }, scene);
265
240
  }
@@ -270,8 +245,8 @@ var HolographicSlate = /** @class */ (function (_super) {
270
245
  this._attachContentPlateBehavior();
271
246
  this._addControl(this._followButton);
272
247
  this._addControl(this._closeButton);
273
- var followButton = this._followButton;
274
- var closeButton = this._closeButton;
248
+ const followButton = this._followButton;
249
+ const closeButton = this._closeButton;
275
250
  followButton.node.parent = node;
276
251
  closeButton.node.parent = node;
277
252
  this._positionElements();
@@ -279,41 +254,40 @@ var HolographicSlate = /** @class */ (function (_super) {
279
254
  this._closeButton.imageUrl = HolographicSlate.ASSETS_BASE_URL + HolographicSlate.CLOSE_ICON_FILENAME;
280
255
  this._followButton.isBackplateVisible = false;
281
256
  this._closeButton.isBackplateVisible = false;
282
- this._followButton.onToggleObservable.add(function (isToggled) {
283
- _this._defaultBehavior.followBehaviorEnabled = isToggled;
284
- if (_this._defaultBehavior.followBehaviorEnabled) {
285
- _this._defaultBehavior.followBehavior.recenter();
257
+ this._followButton.onToggleObservable.add((isToggled) => {
258
+ this._defaultBehavior.followBehaviorEnabled = isToggled;
259
+ if (this._defaultBehavior.followBehaviorEnabled) {
260
+ this._defaultBehavior.followBehavior.recenter();
286
261
  }
287
262
  });
288
- this._closeButton.onPointerClickObservable.add(function () {
289
- _this.dispose();
263
+ this._closeButton.onPointerClickObservable.add(() => {
264
+ this.dispose();
290
265
  });
291
266
  node.rotationQuaternion = Quaternion.Identity();
292
267
  node.isVisible = false;
293
268
  return node;
294
- };
295
- HolographicSlate.prototype._attachContentPlateBehavior = function () {
296
- var _this = this;
269
+ }
270
+ _attachContentPlateBehavior() {
297
271
  this._contentDragBehavior.attach(this._contentPlate);
298
272
  this._contentDragBehavior.moveAttached = false;
299
273
  this._contentDragBehavior.useObjectOrientationForDragging = true;
300
274
  this._contentDragBehavior.updateDragPlane = false;
301
- var origin = new Vector3();
302
- var worldDimensions = new Vector3();
303
- var upWorld = new Vector3();
304
- var rightWorld = new Vector3();
305
- var projectedOffset = new Vector2();
306
- var startViewport;
307
- var worldMatrix;
308
- this._contentDragBehavior.onDragStartObservable.add(function (event) {
309
- if (!_this.node) {
275
+ const origin = new Vector3();
276
+ const worldDimensions = new Vector3();
277
+ const upWorld = new Vector3();
278
+ const rightWorld = new Vector3();
279
+ const projectedOffset = new Vector2();
280
+ let startViewport;
281
+ let worldMatrix;
282
+ this._contentDragBehavior.onDragStartObservable.add((event) => {
283
+ if (!this.node) {
310
284
  return;
311
285
  }
312
- startViewport = _this._contentViewport.clone();
313
- worldMatrix = _this.node.computeWorldMatrix(true);
286
+ startViewport = this._contentViewport.clone();
287
+ worldMatrix = this.node.computeWorldMatrix(true);
314
288
  origin.copyFrom(event.dragPlanePoint);
315
- worldDimensions.set(_this.dimensions.x, _this.dimensions.y, Epsilon);
316
- worldDimensions.y -= _this.titleBarHeight + _this.titleBarMargin;
289
+ worldDimensions.set(this.dimensions.x, this.dimensions.y, Epsilon);
290
+ worldDimensions.y -= this.titleBarHeight + this.titleBarMargin;
317
291
  Vector3.TransformNormalToRef(worldDimensions, worldMatrix, worldDimensions);
318
292
  upWorld.copyFromFloats(0, 1, 0);
319
293
  Vector3.TransformNormalToRef(upWorld, worldMatrix, upWorld);
@@ -324,23 +298,23 @@ var HolographicSlate = /** @class */ (function (_super) {
324
298
  rightWorld.normalize();
325
299
  rightWorld.scaleInPlace(1 / Vector3.Dot(rightWorld, worldDimensions));
326
300
  });
327
- var offset = new Vector3();
328
- this._contentDragBehavior.onDragObservable.add(function (event) {
301
+ const offset = new Vector3();
302
+ this._contentDragBehavior.onDragObservable.add((event) => {
329
303
  offset.copyFrom(event.dragPlanePoint);
330
304
  offset.subtractInPlace(origin);
331
305
  projectedOffset.copyFromFloats(Vector3.Dot(offset, rightWorld), Vector3.Dot(offset, upWorld));
332
306
  // By default, content takes full width available and height is cropped to keep aspect ratio
333
- _this._contentViewport.x = Scalar.Clamp(startViewport.x - offset.x, 0, 1 - _this._contentViewport.width * _this._contentScaleRatio);
334
- _this._contentViewport.y = Scalar.Clamp(startViewport.y - offset.y, 0, 1 - _this._contentViewport.height * _this._contentScaleRatio);
335
- _this._applyContentViewport();
307
+ this._contentViewport.x = Scalar.Clamp(startViewport.x - offset.x, 0, 1 - this._contentViewport.width * this._contentScaleRatio);
308
+ this._contentViewport.y = Scalar.Clamp(startViewport.y - offset.y, 0, 1 - this._contentViewport.height * this._contentScaleRatio);
309
+ this._applyContentViewport();
336
310
  });
337
- };
338
- HolographicSlate.prototype._affectMaterial = function (mesh) {
311
+ }
312
+ _affectMaterial(mesh) {
339
313
  // TODO share materials
340
- this._titleBarMaterial = new FluentBackplateMaterial("".concat(this.name, " plateMaterial"), mesh.getScene());
341
- this._contentMaterial = new FluentMaterial("".concat(this.name, " contentMaterial"), mesh.getScene());
314
+ this._titleBarMaterial = new FluentBackplateMaterial(`${this.name} plateMaterial`, mesh.getScene());
315
+ this._contentMaterial = new FluentMaterial(`${this.name} contentMaterial`, mesh.getScene());
342
316
  this._contentMaterial.renderBorders = true;
343
- this._backMaterial = new FluentBackplateMaterial("".concat(this.name, " backPlate"), mesh.getScene());
317
+ this._backMaterial = new FluentBackplateMaterial(`${this.name} backPlate`, mesh.getScene());
344
318
  this._backMaterial.lineWidth = Epsilon;
345
319
  this._backMaterial.radius = 0.005;
346
320
  this._backMaterial.backFaceCulling = true;
@@ -349,56 +323,54 @@ var HolographicSlate = /** @class */ (function (_super) {
349
323
  this._backPlate.material = this._backMaterial;
350
324
  this._resetContent();
351
325
  this._applyContentViewport();
352
- };
326
+ }
353
327
  /**
354
328
  * @param scene
355
329
  * @hidden*
356
330
  */
357
- HolographicSlate.prototype._prepareNode = function (scene) {
358
- var _this = this;
359
- _super.prototype._prepareNode.call(this, scene);
331
+ _prepareNode(scene) {
332
+ super._prepareNode(scene);
360
333
  this._gizmo = new SlateGizmo(this._host.utilityLayer);
361
334
  this._gizmo.attachedSlate = this;
362
335
  this._defaultBehavior = new DefaultBehavior();
363
336
  this._defaultBehavior.attach(this.node, [this._titleBar]);
364
- this._defaultBehavior.sixDofDragBehavior.onDragStartObservable.add(function () {
365
- _this._followButton.isToggled = false;
337
+ this._defaultBehavior.sixDofDragBehavior.onDragStartObservable.add(() => {
338
+ this._followButton.isToggled = false;
366
339
  });
367
- this._positionChangedObserver = this._defaultBehavior.sixDofDragBehavior.onPositionChangedObservable.add(function () {
368
- _this._gizmo.updateBoundingBox();
340
+ this._positionChangedObserver = this._defaultBehavior.sixDofDragBehavior.onPositionChangedObservable.add(() => {
341
+ this._gizmo.updateBoundingBox();
369
342
  });
370
343
  this._updatePivot();
371
344
  this.resetDefaultAspectAndPose(false);
372
- };
345
+ }
373
346
  /**
374
347
  * Resets the aspect and pose of the slate so it is right in front of the active camera, facing towards it.
375
348
  * @param resetAspect Should the slate's dimensions/aspect ratio be reset as well
376
349
  */
377
- HolographicSlate.prototype.resetDefaultAspectAndPose = function (resetAspect) {
378
- if (resetAspect === void 0) { resetAspect = true; }
350
+ resetDefaultAspectAndPose(resetAspect = true) {
379
351
  if (!this._host || !this._host.utilityLayer || !this.node) {
380
352
  return;
381
353
  }
382
- var scene = this._host.utilityLayer.utilityLayerScene;
383
- var camera = scene.activeCamera;
354
+ const scene = this._host.utilityLayer.utilityLayerScene;
355
+ const camera = scene.activeCamera;
384
356
  if (camera) {
385
- var worldMatrix = camera.getWorldMatrix();
386
- var backward = Vector3.TransformNormal(Vector3.Backward(scene.useRightHandedSystem), worldMatrix);
357
+ const worldMatrix = camera.getWorldMatrix();
358
+ const backward = Vector3.TransformNormal(Vector3.Backward(scene.useRightHandedSystem), worldMatrix);
387
359
  this.origin.setAll(0);
388
360
  this._gizmo.updateBoundingBox();
389
- var pivot = this.node.getAbsolutePivotPoint();
361
+ const pivot = this.node.getAbsolutePivotPoint();
390
362
  this.node.position.copyFrom(camera.position).subtractInPlace(backward).subtractInPlace(pivot);
391
363
  this.node.rotationQuaternion = Quaternion.FromLookDirectionLH(backward, new Vector3(0, 1, 0));
392
364
  if (resetAspect) {
393
365
  this.dimensions = this.defaultDimensions;
394
366
  }
395
367
  }
396
- };
368
+ }
397
369
  /**
398
370
  * Releases all associated resources
399
371
  */
400
- HolographicSlate.prototype.dispose = function () {
401
- _super.prototype.dispose.call(this);
372
+ dispose() {
373
+ super.dispose();
402
374
  this._titleBarMaterial.dispose();
403
375
  this._contentMaterial.dispose();
404
376
  this._titleBar.dispose();
@@ -412,21 +384,19 @@ var HolographicSlate = /** @class */ (function (_super) {
412
384
  this._defaultBehavior.detach();
413
385
  this._gizmo.dispose();
414
386
  this._contentDragBehavior.detach();
415
- };
416
- /**
417
- * Base Url for the assets.
418
- */
419
- HolographicSlate.ASSETS_BASE_URL = "https://assets.babylonjs.com/meshes/MRTK/";
420
- /**
421
- * File name for the close icon.
422
- */
423
- HolographicSlate.CLOSE_ICON_FILENAME = "IconClose.png";
424
- /**
425
- * File name for the close icon.
426
- */
427
- HolographicSlate.FOLLOW_ICON_FILENAME = "IconFollowMe.png";
428
- HolographicSlate._DEFAULT_TEXT_RESOLUTION_Y = 102.4;
429
- return HolographicSlate;
430
- }(ContentDisplay3D));
431
- export { HolographicSlate };
387
+ }
388
+ }
389
+ /**
390
+ * Base Url for the assets.
391
+ */
392
+ HolographicSlate.ASSETS_BASE_URL = "https://assets.babylonjs.com/meshes/MRTK/";
393
+ /**
394
+ * File name for the close icon.
395
+ */
396
+ HolographicSlate.CLOSE_ICON_FILENAME = "IconClose.png";
397
+ /**
398
+ * File name for the close icon.
399
+ */
400
+ HolographicSlate.FOLLOW_ICON_FILENAME = "IconFollowMe.png";
401
+ HolographicSlate._DEFAULT_TEXT_RESOLUTION_Y = 102.4;
432
402
  //# sourceMappingURL=holographicSlate.js.map