@babylonjs/gui 5.0.0-rc.7 → 5.0.0-rc.9

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 (203) hide show
  1. package/2D/adtInstrumentation.d.ts +52 -52
  2. package/2D/adtInstrumentation.js +126 -126
  3. package/2D/advancedDynamicTexture.d.ts +448 -448
  4. package/2D/advancedDynamicTexture.js +1318 -1318
  5. package/2D/controls/button.d.ts +135 -135
  6. package/2D/controls/button.js +276 -276
  7. package/2D/controls/checkbox.d.ts +59 -59
  8. package/2D/controls/checkbox.js +188 -188
  9. package/2D/controls/colorpicker.d.ts +103 -103
  10. package/2D/controls/colorpicker.js +1417 -1417
  11. package/2D/controls/container.d.ts +175 -175
  12. package/2D/controls/container.js +570 -570
  13. package/2D/controls/control.d.ts +866 -866
  14. package/2D/controls/control.js +2433 -2433
  15. package/2D/controls/displayGrid.d.ts +53 -53
  16. package/2D/controls/displayGrid.js +245 -245
  17. package/2D/controls/ellipse.d.ts +21 -21
  18. package/2D/controls/ellipse.js +85 -85
  19. package/2D/controls/focusableButton.d.ts +59 -59
  20. package/2D/controls/focusableButton.js +99 -99
  21. package/2D/controls/focusableControl.d.ts +34 -34
  22. package/2D/controls/focusableControl.js +1 -1
  23. package/2D/controls/grid.d.ts +139 -139
  24. package/2D/controls/grid.js +529 -529
  25. package/2D/controls/image.d.ts +204 -204
  26. package/2D/controls/image.js +887 -887
  27. package/2D/controls/index.d.ts +29 -29
  28. package/2D/controls/index.js +29 -29
  29. package/2D/controls/inputPassword.d.ts +8 -8
  30. package/2D/controls/inputPassword.js +25 -25
  31. package/2D/controls/inputText.d.ts +201 -201
  32. package/2D/controls/inputText.js +1119 -1119
  33. package/2D/controls/line.d.ts +66 -66
  34. package/2D/controls/line.js +271 -271
  35. package/2D/controls/multiLine.d.ts +75 -75
  36. package/2D/controls/multiLine.js +262 -262
  37. package/2D/controls/radioButton.d.ts +49 -49
  38. package/2D/controls/radioButton.js +205 -205
  39. package/2D/controls/rectangle.d.ts +29 -29
  40. package/2D/controls/rectangle.js +150 -150
  41. package/2D/controls/scrollViewers/scrollViewer.d.ts +182 -182
  42. package/2D/controls/scrollViewers/scrollViewer.js +677 -677
  43. package/2D/controls/scrollViewers/scrollViewerWindow.d.ts +57 -57
  44. package/2D/controls/scrollViewers/scrollViewerWindow.js +278 -278
  45. package/2D/controls/selector.d.ts +263 -263
  46. package/2D/controls/selector.js +692 -692
  47. package/2D/controls/sliders/baseSlider.d.ts +82 -82
  48. package/2D/controls/sliders/baseSlider.js +347 -347
  49. package/2D/controls/sliders/imageBasedSlider.d.ts +49 -49
  50. package/2D/controls/sliders/imageBasedSlider.js +192 -192
  51. package/2D/controls/sliders/imageScrollBar.d.ts +65 -65
  52. package/2D/controls/sliders/imageScrollBar.js +263 -263
  53. package/2D/controls/sliders/scrollBar.d.ts +38 -38
  54. package/2D/controls/sliders/scrollBar.js +143 -143
  55. package/2D/controls/sliders/slider.d.ts +35 -35
  56. package/2D/controls/sliders/slider.js +271 -271
  57. package/2D/controls/stackPanel.d.ts +64 -64
  58. package/2D/controls/stackPanel.js +246 -246
  59. package/2D/controls/statics.d.ts +6 -6
  60. package/2D/controls/statics.js +49 -49
  61. package/2D/controls/textBlock.d.ts +175 -175
  62. package/2D/controls/textBlock.js +603 -603
  63. package/2D/controls/textWrapper.d.ts +13 -13
  64. package/2D/controls/textWrapper.js +101 -101
  65. package/2D/controls/toggleButton.d.ts +117 -117
  66. package/2D/controls/toggleButton.js +268 -268
  67. package/2D/controls/virtualKeyboard.d.ts +96 -96
  68. package/2D/controls/virtualKeyboard.js +256 -256
  69. package/2D/index.d.ts +9 -9
  70. package/2D/index.js +9 -9
  71. package/2D/math2D.d.ts +117 -117
  72. package/2D/math2D.js +221 -221
  73. package/2D/measure.d.ts +77 -77
  74. package/2D/measure.js +139 -139
  75. package/2D/multiLinePoint.d.ts +47 -47
  76. package/2D/multiLinePoint.js +127 -127
  77. package/2D/style.d.ts +46 -46
  78. package/2D/style.js +97 -97
  79. package/2D/valueAndUnit.d.ts +89 -89
  80. package/2D/valueAndUnit.js +226 -226
  81. package/2D/xmlLoader.d.ts +60 -60
  82. package/2D/xmlLoader.js +348 -348
  83. package/3D/behaviors/defaultBehavior.d.ts +73 -73
  84. package/3D/behaviors/defaultBehavior.js +121 -121
  85. package/3D/controls/abstractButton3D.d.ts +15 -15
  86. package/3D/controls/abstractButton3D.js +25 -25
  87. package/3D/controls/button3D.d.ts +30 -30
  88. package/3D/controls/button3D.js +93 -93
  89. package/3D/controls/container3D.d.ts +72 -72
  90. package/3D/controls/container3D.js +139 -139
  91. package/3D/controls/contentDisplay3D.d.ts +30 -30
  92. package/3D/controls/contentDisplay3D.js +79 -79
  93. package/3D/controls/control3D.d.ts +201 -201
  94. package/3D/controls/control3D.js +445 -445
  95. package/3D/controls/cylinderPanel.d.ts +17 -17
  96. package/3D/controls/cylinderPanel.js +66 -66
  97. package/3D/controls/handMenu.d.ts +28 -28
  98. package/3D/controls/handMenu.js +47 -47
  99. package/3D/controls/holographicBackplate.d.ts +49 -49
  100. package/3D/controls/holographicBackplate.js +120 -120
  101. package/3D/controls/holographicButton.d.ts +84 -84
  102. package/3D/controls/holographicButton.js +339 -339
  103. package/3D/controls/holographicSlate.d.ts +131 -131
  104. package/3D/controls/holographicSlate.js +431 -431
  105. package/3D/controls/index.d.ts +21 -21
  106. package/3D/controls/index.js +21 -21
  107. package/3D/controls/meshButton3D.d.ts +21 -21
  108. package/3D/controls/meshButton3D.js +62 -62
  109. package/3D/controls/nearMenu.d.ts +44 -44
  110. package/3D/controls/nearMenu.js +114 -114
  111. package/3D/controls/planePanel.d.ts +9 -9
  112. package/3D/controls/planePanel.js +36 -36
  113. package/3D/controls/scatterPanel.d.ts +18 -18
  114. package/3D/controls/scatterPanel.js +108 -108
  115. package/3D/controls/slider3D.d.ts +81 -81
  116. package/3D/controls/slider3D.js +268 -268
  117. package/3D/controls/spherePanel.d.ts +17 -17
  118. package/3D/controls/spherePanel.js +67 -67
  119. package/3D/controls/stackPanel3D.d.ts +22 -22
  120. package/3D/controls/stackPanel3D.js +107 -107
  121. package/3D/controls/touchButton3D.d.ts +80 -80
  122. package/3D/controls/touchButton3D.js +233 -233
  123. package/3D/controls/touchHolographicButton.d.ts +110 -110
  124. package/3D/controls/touchHolographicButton.js +445 -445
  125. package/3D/controls/touchHolographicMenu.d.ts +61 -61
  126. package/3D/controls/touchHolographicMenu.js +149 -149
  127. package/3D/controls/touchMeshButton3D.d.ts +21 -21
  128. package/3D/controls/touchMeshButton3D.js +62 -62
  129. package/3D/controls/volumeBasedPanel.d.ts +53 -53
  130. package/3D/controls/volumeBasedPanel.js +174 -174
  131. package/3D/gizmos/gizmoHandle.d.ts +108 -108
  132. package/3D/gizmos/gizmoHandle.js +209 -209
  133. package/3D/gizmos/index.d.ts +2 -2
  134. package/3D/gizmos/index.js +2 -2
  135. package/3D/gizmos/slateGizmo.d.ts +57 -57
  136. package/3D/gizmos/slateGizmo.js +369 -369
  137. package/3D/gui3DManager.d.ts +94 -94
  138. package/3D/gui3DManager.js +257 -257
  139. package/3D/index.d.ts +5 -5
  140. package/3D/index.js +5 -5
  141. package/3D/materials/fluent/fluentMaterial.d.ts +90 -90
  142. package/3D/materials/fluent/fluentMaterial.js +292 -292
  143. package/3D/materials/fluent/index.d.ts +1 -1
  144. package/3D/materials/fluent/index.js +1 -1
  145. package/3D/materials/fluent/shaders/fluent.fragment.d.ts +5 -5
  146. package/3D/materials/fluent/shaders/fluent.fragment.js +8 -8
  147. package/3D/materials/fluent/shaders/fluent.vertex.d.ts +5 -5
  148. package/3D/materials/fluent/shaders/fluent.vertex.js +8 -8
  149. package/3D/materials/fluentBackplate/fluentBackplateMaterial.d.ts +154 -154
  150. package/3D/materials/fluentBackplate/fluentBackplateMaterial.js +469 -469
  151. package/3D/materials/fluentBackplate/index.d.ts +1 -1
  152. package/3D/materials/fluentBackplate/index.js +1 -1
  153. package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.d.ts +5 -5
  154. package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.js +8 -8
  155. package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.d.ts +5 -5
  156. package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.js +8 -8
  157. package/3D/materials/fluentButton/fluentButtonMaterial.d.ts +189 -189
  158. package/3D/materials/fluentButton/fluentButtonMaterial.js +539 -539
  159. package/3D/materials/fluentButton/index.d.ts +1 -1
  160. package/3D/materials/fluentButton/index.js +1 -1
  161. package/3D/materials/fluentButton/shaders/fluentButton.fragment.d.ts +5 -5
  162. package/3D/materials/fluentButton/shaders/fluentButton.fragment.js +8 -8
  163. package/3D/materials/fluentButton/shaders/fluentButton.vertex.d.ts +5 -5
  164. package/3D/materials/fluentButton/shaders/fluentButton.vertex.js +8 -8
  165. package/3D/materials/fluentMaterial.d.ts +4 -4
  166. package/3D/materials/fluentMaterial.js +4 -4
  167. package/3D/materials/handle/handleMaterial.d.ts +68 -68
  168. package/3D/materials/handle/handleMaterial.js +126 -126
  169. package/3D/materials/handle/index.d.ts +1 -1
  170. package/3D/materials/handle/index.js +1 -1
  171. package/3D/materials/handle/shaders/handle.fragment.d.ts +5 -5
  172. package/3D/materials/handle/shaders/handle.fragment.js +8 -8
  173. package/3D/materials/handle/shaders/handle.vertex.d.ts +5 -5
  174. package/3D/materials/handle/shaders/handle.vertex.js +8 -8
  175. package/3D/materials/index.d.ts +5 -5
  176. package/3D/materials/index.js +5 -5
  177. package/3D/materials/mrdl/index.d.ts +3 -3
  178. package/3D/materials/mrdl/index.js +3 -3
  179. package/3D/materials/mrdl/mrdlBackplateMaterial.d.ts +147 -147
  180. package/3D/materials/mrdl/mrdlBackplateMaterial.js +436 -436
  181. package/3D/materials/mrdl/mrdlSliderBarMaterial.d.ts +333 -333
  182. package/3D/materials/mrdl/mrdlSliderBarMaterial.js +851 -851
  183. package/3D/materials/mrdl/mrdlSliderThumbMaterial.d.ts +333 -333
  184. package/3D/materials/mrdl/mrdlSliderThumbMaterial.js +851 -851
  185. package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.d.ts +5 -5
  186. package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.js +8 -8
  187. package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.d.ts +5 -5
  188. package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.js +8 -8
  189. package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.d.ts +5 -5
  190. package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.js +8 -8
  191. package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.d.ts +5 -5
  192. package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.js +8 -8
  193. package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.d.ts +5 -5
  194. package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.js +8 -8
  195. package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.d.ts +5 -5
  196. package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.js +8 -8
  197. package/3D/vector3WithInfo.d.ts +16 -16
  198. package/3D/vector3WithInfo.js +23 -23
  199. package/index.d.ts +2 -2
  200. package/index.js +2 -2
  201. package/legacy/legacy.d.ts +1 -1
  202. package/legacy/legacy.js +13 -13
  203. package/package.json +2 -2
@@ -1,446 +1,446 @@
1
- import { __extends } from "tslib";
2
- import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
3
- import { StandardMaterial } from "@babylonjs/core/Materials/standardMaterial.js";
4
- import { TransformNode } from "@babylonjs/core/Meshes/transformNode.js";
5
- import { Mesh } from "@babylonjs/core/Meshes/mesh.js";
6
- import { CreatePlane } from "@babylonjs/core/Meshes/Builders/planeBuilder.js";
7
- import { CreateBox } from "@babylonjs/core/Meshes/Builders/boxBuilder.js";
8
- import { FadeInOutBehavior } from "@babylonjs/core/Behaviors/Meshes/fadeInOutBehavior.js";
9
- import { FluentMaterial } from "../materials/fluent/fluentMaterial.js";
10
- import { FluentButtonMaterial } from "../materials/fluentButton/fluentButtonMaterial.js";
11
- import { StackPanel } from "../../2D/controls/stackPanel.js";
12
- import { Image } from "../../2D/controls/image.js";
13
- import { TextBlock } from "../../2D/controls/textBlock.js";
14
- import { AdvancedDynamicTexture } from "../../2D/advancedDynamicTexture.js";
15
- import { Color3 } from "@babylonjs/core/Maths/math.color.js";
16
- import { TouchButton3D } from "./touchButton3D.js";
17
- import { SceneLoader } from "@babylonjs/core/Loading/sceneLoader.js";
18
- import { DomManagement } from "@babylonjs/core/Misc/domManagement.js";
19
- import { Scalar } from "@babylonjs/core/Maths/math.scalar.js";
20
- /**
21
- * Class used to create a holographic button in 3D
22
- * @since 5.0.0
23
- */
24
- var TouchHolographicButton = /** @class */ (function (_super) {
25
- __extends(TouchHolographicButton, _super);
26
- /**
27
- * Creates a new button
28
- * @param name defines the control name
29
- * @param shareMaterials
30
- */
31
- function TouchHolographicButton(name, shareMaterials) {
32
- if (shareMaterials === void 0) { shareMaterials = true; }
33
- var _this = _super.call(this, name) || this;
34
- _this._shareMaterials = true;
35
- _this._isBackplateVisible = true;
36
- _this._frontPlateDepth = 0.5;
37
- _this._backPlateDepth = 0.04;
38
- _this._backplateColor = new Color3(0.08, 0.15, 0.55);
39
- _this._backplateToggledColor = new Color3(0.25, 0.4, 0.95);
40
- _this._shareMaterials = shareMaterials;
41
- _this.pointerEnterAnimation = function () {
42
- _this._frontMaterial.leftBlobEnable = true;
43
- _this._frontMaterial.rightBlobEnable = true;
44
- };
45
- _this.pointerOutAnimation = function () {
46
- _this._frontMaterial.leftBlobEnable = false;
47
- _this._frontMaterial.rightBlobEnable = false;
48
- };
49
- _this.pointerDownAnimation = function () {
50
- if (_this._frontPlate && !_this.isActiveNearInteraction) {
51
- _this._frontPlate.scaling.z = _this._frontPlateDepth * 0.2;
52
- _this._frontPlate.position = Vector3.Forward(_this._frontPlate._scene.useRightHandedSystem).scale((_this._frontPlateDepth - 0.2 * _this._frontPlateDepth) / 2);
53
- _this._textPlate.position = Vector3.Forward(_this._textPlate._scene.useRightHandedSystem).scale(-(_this._backPlateDepth + 0.2 * _this._frontPlateDepth) / 2);
54
- }
55
- };
56
- _this.pointerUpAnimation = function () {
57
- if (_this._frontPlate) {
58
- _this._frontPlate.scaling.z = _this._frontPlateDepth;
59
- _this._frontPlate.position = Vector3.Forward(_this._frontPlate._scene.useRightHandedSystem).scale((_this._frontPlateDepth - _this._frontPlateDepth) / 2);
60
- _this._textPlate.position = Vector3.Forward(_this._textPlate._scene.useRightHandedSystem).scale(-(_this._backPlateDepth + _this._frontPlateDepth) / 2);
61
- }
62
- };
63
- _this.onPointerMoveObservable.add(function (position) {
64
- if (_this._frontPlate && _this.isActiveNearInteraction) {
65
- var scale = Vector3.Zero();
66
- if (_this._backPlate.getWorldMatrix().decompose(scale, undefined, undefined)) {
67
- var interactionHeight = _this._getInteractionHeight(position, _this._backPlate.getAbsolutePosition()) / scale.z;
68
- interactionHeight = Scalar.Clamp(interactionHeight - _this._backPlateDepth / 2, 0.2 * _this._frontPlateDepth, _this._frontPlateDepth);
69
- _this._frontPlate.scaling.z = interactionHeight;
70
- _this._frontPlate.position = Vector3.Forward(_this._frontPlate._scene.useRightHandedSystem).scale((_this._frontPlateDepth - interactionHeight) / 2);
71
- _this._textPlate.position = Vector3.Forward(_this._textPlate._scene.useRightHandedSystem).scale(-(_this._backPlateDepth + interactionHeight) / 2);
72
- }
73
- }
74
- });
75
- _this._pointerHoverObserver = _this.onPointerMoveObservable.add(function (hoverPosition) {
76
- _this._frontMaterial.globalLeftIndexTipPosition = hoverPosition;
77
- });
78
- return _this;
79
- }
80
- TouchHolographicButton.prototype._disposeTooltip = function () {
81
- this._tooltipFade = null;
82
- if (this._tooltipTextBlock) {
83
- this._tooltipTextBlock.dispose();
84
- }
85
- if (this._tooltipTexture) {
86
- this._tooltipTexture.dispose();
87
- }
88
- if (this._tooltipMesh) {
89
- this._tooltipMesh.dispose();
90
- }
91
- this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
92
- this.onPointerOutObservable.remove(this._tooltipOutObserver);
93
- };
94
- Object.defineProperty(TouchHolographicButton.prototype, "renderingGroupId", {
95
- get: function () {
96
- return this._backPlate.renderingGroupId;
97
- },
98
- /**
99
- * Rendering ground id of all the mesh in the button
100
- */
101
- set: function (id) {
102
- this._backPlate.renderingGroupId = id;
103
- this._textPlate.renderingGroupId = id;
104
- this._frontPlate.renderingGroupId = id;
105
- if (this._tooltipMesh) {
106
- this._tooltipMesh.renderingGroupId = id;
107
- }
108
- },
109
- enumerable: false,
110
- configurable: true
111
- });
112
- Object.defineProperty(TouchHolographicButton.prototype, "mesh", {
113
- /**
114
- * Gets the mesh used to render this control
115
- */
116
- get: function () {
117
- return this._backPlate;
118
- },
119
- enumerable: false,
120
- configurable: true
121
- });
122
- Object.defineProperty(TouchHolographicButton.prototype, "tooltipText", {
123
- get: function () {
124
- if (this._tooltipTextBlock) {
125
- return this._tooltipTextBlock.text;
126
- }
127
- return null;
128
- },
129
- /**
130
- * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
131
- */
132
- set: function (text) {
133
- var _this = this;
134
- if (!text) {
135
- this._disposeTooltip();
136
- return;
137
- }
138
- if (!this._tooltipFade) {
139
- var rightHandedScene = this._backPlate._scene.useRightHandedSystem;
140
- // Create tooltip with mesh and text
141
- this._tooltipMesh = CreatePlane("", { size: 1 }, this._backPlate._scene);
142
- var tooltipBackground = CreatePlane("", { size: 1, sideOrientation: Mesh.DOUBLESIDE }, this._backPlate._scene);
143
- var mat = new StandardMaterial("", this._backPlate._scene);
144
- mat.diffuseColor = Color3.FromHexString("#212121");
145
- tooltipBackground.material = mat;
146
- tooltipBackground.isPickable = false;
147
- this._tooltipMesh.addChild(tooltipBackground);
148
- tooltipBackground.position = Vector3.Forward(rightHandedScene).scale(0.05);
149
- this._tooltipMesh.scaling.y = 1 / 3;
150
- this._tooltipMesh.position = Vector3.Up().scale(0.7).add(Vector3.Forward(rightHandedScene).scale(-0.15));
151
- this._tooltipMesh.isPickable = false;
152
- this._tooltipMesh.parent = this._backPlate;
153
- // Create text texture for the tooltip
154
- this._tooltipTexture = AdvancedDynamicTexture.CreateForMesh(this._tooltipMesh);
155
- this._tooltipTextBlock = new TextBlock();
156
- this._tooltipTextBlock.scaleY = 3;
157
- this._tooltipTextBlock.color = "white";
158
- this._tooltipTextBlock.fontSize = 130;
159
- this._tooltipTexture.addControl(this._tooltipTextBlock);
160
- // Add hover action to tooltip
161
- this._tooltipFade = new FadeInOutBehavior();
162
- this._tooltipFade.delay = 500;
163
- this._tooltipMesh.addBehavior(this._tooltipFade);
164
- this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
165
- if (_this._tooltipFade) {
166
- _this._tooltipFade.fadeIn(true);
167
- }
168
- });
169
- this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
170
- if (_this._tooltipFade) {
171
- _this._tooltipFade.fadeIn(false);
172
- }
173
- });
174
- }
175
- if (this._tooltipTextBlock) {
176
- this._tooltipTextBlock.text = text;
177
- }
178
- },
179
- enumerable: false,
180
- configurable: true
181
- });
182
- Object.defineProperty(TouchHolographicButton.prototype, "text", {
183
- /**
184
- * Gets or sets text for the button
185
- */
186
- get: function () {
187
- return this._text;
188
- },
189
- set: function (value) {
190
- if (this._text === value) {
191
- return;
192
- }
193
- this._text = value;
194
- this._rebuildContent();
195
- },
196
- enumerable: false,
197
- configurable: true
198
- });
199
- Object.defineProperty(TouchHolographicButton.prototype, "imageUrl", {
200
- /**
201
- * Gets or sets the image url for the button
202
- */
203
- get: function () {
204
- return this._imageUrl;
205
- },
206
- set: function (value) {
207
- if (this._imageUrl === value) {
208
- return;
209
- }
210
- this._imageUrl = value;
211
- this._rebuildContent();
212
- },
213
- enumerable: false,
214
- configurable: true
215
- });
216
- Object.defineProperty(TouchHolographicButton.prototype, "backMaterial", {
217
- /**
218
- * Gets the back material used by this button
219
- */
220
- get: function () {
221
- return this._backMaterial;
222
- },
223
- enumerable: false,
224
- configurable: true
225
- });
226
- Object.defineProperty(TouchHolographicButton.prototype, "frontMaterial", {
227
- /**
228
- * Gets the front material used by this button
229
- */
230
- get: function () {
231
- return this._frontMaterial;
232
- },
233
- enumerable: false,
234
- configurable: true
235
- });
236
- Object.defineProperty(TouchHolographicButton.prototype, "plateMaterial", {
237
- /**
238
- * Gets the plate material used by this button
239
- */
240
- get: function () {
241
- return this._plateMaterial;
242
- },
243
- enumerable: false,
244
- configurable: true
245
- });
246
- Object.defineProperty(TouchHolographicButton.prototype, "shareMaterials", {
247
- /**
248
- * Gets a boolean indicating if this button shares its material with other HolographicButtons
249
- */
250
- get: function () {
251
- return this._shareMaterials;
252
- },
253
- enumerable: false,
254
- configurable: true
255
- });
256
- Object.defineProperty(TouchHolographicButton.prototype, "isBackplateVisible", {
257
- /**
258
- * Sets whether the backplate is visible or hidden. Hiding the backplate is not recommended without some sort of replacement
259
- */
260
- set: function (isVisible) {
261
- if (this.mesh && !!this._backMaterial) {
262
- if (isVisible && !this._isBackplateVisible) {
263
- this._backPlate.visibility = 1;
264
- }
265
- else if (!isVisible && this._isBackplateVisible) {
266
- this._backPlate.visibility = 0;
267
- }
268
- }
269
- this._isBackplateVisible = isVisible;
270
- },
271
- enumerable: false,
272
- configurable: true
273
- });
274
- TouchHolographicButton.prototype._getTypeName = function () {
275
- return "TouchHolographicButton";
276
- };
277
- TouchHolographicButton.prototype._rebuildContent = function () {
278
- this._disposeFacadeTexture();
279
- var panel = new StackPanel();
280
- panel.isVertical = true;
281
- if (DomManagement.IsDocumentAvailable() && !!document.createElement) {
282
- if (this._imageUrl) {
283
- var image = new Image();
284
- image.source = this._imageUrl;
285
- image.paddingTop = "40px";
286
- image.height = "180px";
287
- image.width = "100px";
288
- image.paddingBottom = "40px";
289
- panel.addControl(image);
290
- }
291
- }
292
- if (this._text) {
293
- var text = new TextBlock();
294
- text.text = this._text;
295
- text.color = "white";
296
- text.height = "30px";
297
- text.fontSize = 24;
298
- panel.addControl(text);
299
- }
300
- this.content = panel;
301
- };
302
- // Mesh association
303
- TouchHolographicButton.prototype._createNode = function (scene) {
304
- var _this = this;
305
- var _a;
306
- this.name = (_a = this.name) !== null && _a !== void 0 ? _a : "TouchHolographicButton";
307
- var collisionMesh = CreateBox("".concat(this.name, "_collisionMesh"), {
308
- width: 1.0,
309
- height: 1.0,
310
- depth: this._frontPlateDepth,
311
- }, scene);
312
- collisionMesh.isPickable = true;
313
- collisionMesh.isNearPickable = true;
314
- collisionMesh.visibility = 0;
315
- collisionMesh.position = Vector3.Forward(scene.useRightHandedSystem).scale(-this._frontPlateDepth / 2);
316
- SceneLoader.ImportMeshAsync(undefined, TouchHolographicButton.MODEL_BASE_URL, TouchHolographicButton.MODEL_FILENAME, scene).then(function (result) {
317
- var alphaMesh = CreateBox("${this.name}_alphaMesh", {
318
- width: 1.0,
319
- height: 1.0,
320
- depth: 1.0,
321
- }, scene);
322
- alphaMesh.isPickable = false;
323
- alphaMesh.material = new StandardMaterial("${this.name}_alphaMesh_material", scene);
324
- alphaMesh.material.alpha = 0.15;
325
- var importedFrontPlate = result.meshes[1];
326
- importedFrontPlate.name = "".concat(_this.name, "_frontPlate");
327
- importedFrontPlate.isPickable = false;
328
- importedFrontPlate.scaling.z = _this._frontPlateDepth;
329
- alphaMesh.parent = importedFrontPlate;
330
- importedFrontPlate.parent = collisionMesh;
331
- if (_this._frontMaterial) {
332
- importedFrontPlate.material = _this._frontMaterial;
333
- }
334
- _this._frontPlate = importedFrontPlate;
335
- });
336
- this._backPlate = CreateBox("".concat(this.name, "_backPlate"), {
337
- width: 1.0,
338
- height: 1.0,
339
- depth: this._backPlateDepth,
340
- }, scene);
341
- this._backPlate.position = Vector3.Forward(scene.useRightHandedSystem).scale(this._backPlateDepth / 2);
342
- this._backPlate.isPickable = false;
343
- this._textPlate = _super.prototype._createNode.call(this, scene);
344
- this._textPlate.name = "".concat(this.name, "_textPlate");
345
- this._textPlate.isPickable = false;
346
- this._textPlate.position = Vector3.Forward(scene.useRightHandedSystem).scale(-this._frontPlateDepth / 2);
347
- this._backPlate.addChild(collisionMesh);
348
- this._backPlate.addChild(this._textPlate);
349
- var tn = new TransformNode("{this.name}_root", scene);
350
- this._backPlate.setParent(tn);
351
- this.collisionMesh = collisionMesh;
352
- this.collidableFrontDirection = this._backPlate.forward.negate(); // Mesh is facing the wrong way
353
- return tn;
354
- };
355
- TouchHolographicButton.prototype._applyFacade = function (facadeTexture) {
356
- this._plateMaterial.emissiveTexture = facadeTexture;
357
- this._plateMaterial.opacityTexture = facadeTexture;
358
- this._plateMaterial.diffuseColor = new Color3(0.4, 0.4, 0.4);
359
- };
360
- TouchHolographicButton.prototype._createBackMaterial = function (mesh) {
361
- this._backMaterial = new FluentMaterial(this.name + "backPlateMaterial", mesh.getScene());
362
- this._backMaterial.albedoColor = this._backplateColor;
363
- this._backMaterial.renderBorders = true;
364
- this._backMaterial.renderHoverLight = false;
365
- };
366
- TouchHolographicButton.prototype._createFrontMaterial = function (mesh) {
367
- this._frontMaterial = new FluentButtonMaterial(this.name + "Front Material", mesh.getScene());
368
- };
369
- TouchHolographicButton.prototype._createPlateMaterial = function (mesh) {
370
- this._plateMaterial = new StandardMaterial(this.name + "Plate Material", mesh.getScene());
371
- this._plateMaterial.specularColor = Color3.Black();
372
- };
373
- TouchHolographicButton.prototype._onToggle = function (newState) {
374
- if (this._backMaterial) {
375
- if (newState) {
376
- this._backMaterial.albedoColor = this._backplateToggledColor;
377
- }
378
- else {
379
- this._backMaterial.albedoColor = this._backplateColor;
380
- }
381
- }
382
- _super.prototype._onToggle.call(this, newState);
383
- };
384
- TouchHolographicButton.prototype._affectMaterial = function (mesh) {
385
- if (this._shareMaterials) {
386
- // Back
387
- if (!this._host._touchSharedMaterials["backFluentMaterial"]) {
388
- this._createBackMaterial(mesh);
389
- this._host._touchSharedMaterials["backFluentMaterial"] = this._backMaterial;
390
- }
391
- else {
392
- this._backMaterial = this._host._touchSharedMaterials["backFluentMaterial"];
393
- }
394
- // Front
395
- if (!this._host._touchSharedMaterials["frontFluentMaterial"]) {
396
- this._createFrontMaterial(mesh);
397
- this._host._touchSharedMaterials["frontFluentMaterial"] = this._frontMaterial;
398
- }
399
- else {
400
- this._frontMaterial = this._host._touchSharedMaterials["frontFluentMaterial"];
401
- }
402
- }
403
- else {
404
- this._createBackMaterial(mesh);
405
- this._createFrontMaterial(mesh);
406
- }
407
- this._createPlateMaterial(mesh);
408
- this._backPlate.material = this._backMaterial;
409
- this._textPlate.material = this._plateMaterial;
410
- if (!this._isBackplateVisible) {
411
- this._backPlate.visibility = 0;
412
- }
413
- if (this._frontPlate) {
414
- this._frontPlate.material = this._frontMaterial;
415
- }
416
- this._rebuildContent();
417
- };
418
- /**
419
- * Releases all associated resources
420
- */
421
- TouchHolographicButton.prototype.dispose = function () {
422
- _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
423
- this._disposeTooltip();
424
- this.onPointerMoveObservable.remove(this._pointerHoverObserver);
425
- if (!this.shareMaterials) {
426
- this._backMaterial.dispose();
427
- this._frontMaterial.dispose();
428
- this._plateMaterial.dispose();
429
- if (this._pickedPointObserver) {
430
- this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
431
- this._pickedPointObserver = null;
432
- }
433
- }
434
- };
435
- /**
436
- * Base Url for the button model.
437
- */
438
- TouchHolographicButton.MODEL_BASE_URL = "https://assets.babylonjs.com/meshes/MRTK/";
439
- /**
440
- * File name for the button model.
441
- */
442
- TouchHolographicButton.MODEL_FILENAME = "mrtk-fluent-button.glb";
443
- return TouchHolographicButton;
444
- }(TouchButton3D));
445
- export { TouchHolographicButton };
1
+ import { __extends } from "tslib";
2
+ import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
3
+ import { StandardMaterial } from "@babylonjs/core/Materials/standardMaterial.js";
4
+ import { TransformNode } from "@babylonjs/core/Meshes/transformNode.js";
5
+ import { Mesh } from "@babylonjs/core/Meshes/mesh.js";
6
+ import { CreatePlane } from "@babylonjs/core/Meshes/Builders/planeBuilder.js";
7
+ import { CreateBox } from "@babylonjs/core/Meshes/Builders/boxBuilder.js";
8
+ import { FadeInOutBehavior } from "@babylonjs/core/Behaviors/Meshes/fadeInOutBehavior.js";
9
+ import { FluentMaterial } from "../materials/fluent/fluentMaterial";
10
+ import { FluentButtonMaterial } from "../materials/fluentButton/fluentButtonMaterial";
11
+ import { StackPanel } from "../../2D/controls/stackPanel";
12
+ import { Image } from "../../2D/controls/image";
13
+ import { TextBlock } from "../../2D/controls/textBlock";
14
+ import { AdvancedDynamicTexture } from "../../2D/advancedDynamicTexture";
15
+ import { Color3 } from "@babylonjs/core/Maths/math.color.js";
16
+ import { TouchButton3D } from "./touchButton3D";
17
+ import { SceneLoader } from "@babylonjs/core/Loading/sceneLoader.js";
18
+ import { DomManagement } from "@babylonjs/core/Misc/domManagement.js";
19
+ import { Scalar } from "@babylonjs/core/Maths/math.scalar.js";
20
+ /**
21
+ * Class used to create a holographic button in 3D
22
+ * @since 5.0.0
23
+ */
24
+ var TouchHolographicButton = /** @class */ (function (_super) {
25
+ __extends(TouchHolographicButton, _super);
26
+ /**
27
+ * Creates a new button
28
+ * @param name defines the control name
29
+ * @param shareMaterials
30
+ */
31
+ function TouchHolographicButton(name, shareMaterials) {
32
+ if (shareMaterials === void 0) { shareMaterials = true; }
33
+ var _this = _super.call(this, name) || this;
34
+ _this._shareMaterials = true;
35
+ _this._isBackplateVisible = true;
36
+ _this._frontPlateDepth = 0.5;
37
+ _this._backPlateDepth = 0.04;
38
+ _this._backplateColor = new Color3(0.08, 0.15, 0.55);
39
+ _this._backplateToggledColor = new Color3(0.25, 0.4, 0.95);
40
+ _this._shareMaterials = shareMaterials;
41
+ _this.pointerEnterAnimation = function () {
42
+ _this._frontMaterial.leftBlobEnable = true;
43
+ _this._frontMaterial.rightBlobEnable = true;
44
+ };
45
+ _this.pointerOutAnimation = function () {
46
+ _this._frontMaterial.leftBlobEnable = false;
47
+ _this._frontMaterial.rightBlobEnable = false;
48
+ };
49
+ _this.pointerDownAnimation = function () {
50
+ if (_this._frontPlate && !_this.isActiveNearInteraction) {
51
+ _this._frontPlate.scaling.z = _this._frontPlateDepth * 0.2;
52
+ _this._frontPlate.position = Vector3.Forward(_this._frontPlate._scene.useRightHandedSystem).scale((_this._frontPlateDepth - 0.2 * _this._frontPlateDepth) / 2);
53
+ _this._textPlate.position = Vector3.Forward(_this._textPlate._scene.useRightHandedSystem).scale(-(_this._backPlateDepth + 0.2 * _this._frontPlateDepth) / 2);
54
+ }
55
+ };
56
+ _this.pointerUpAnimation = function () {
57
+ if (_this._frontPlate) {
58
+ _this._frontPlate.scaling.z = _this._frontPlateDepth;
59
+ _this._frontPlate.position = Vector3.Forward(_this._frontPlate._scene.useRightHandedSystem).scale((_this._frontPlateDepth - _this._frontPlateDepth) / 2);
60
+ _this._textPlate.position = Vector3.Forward(_this._textPlate._scene.useRightHandedSystem).scale(-(_this._backPlateDepth + _this._frontPlateDepth) / 2);
61
+ }
62
+ };
63
+ _this.onPointerMoveObservable.add(function (position) {
64
+ if (_this._frontPlate && _this.isActiveNearInteraction) {
65
+ var scale = Vector3.Zero();
66
+ if (_this._backPlate.getWorldMatrix().decompose(scale, undefined, undefined)) {
67
+ var interactionHeight = _this._getInteractionHeight(position, _this._backPlate.getAbsolutePosition()) / scale.z;
68
+ interactionHeight = Scalar.Clamp(interactionHeight - _this._backPlateDepth / 2, 0.2 * _this._frontPlateDepth, _this._frontPlateDepth);
69
+ _this._frontPlate.scaling.z = interactionHeight;
70
+ _this._frontPlate.position = Vector3.Forward(_this._frontPlate._scene.useRightHandedSystem).scale((_this._frontPlateDepth - interactionHeight) / 2);
71
+ _this._textPlate.position = Vector3.Forward(_this._textPlate._scene.useRightHandedSystem).scale(-(_this._backPlateDepth + interactionHeight) / 2);
72
+ }
73
+ }
74
+ });
75
+ _this._pointerHoverObserver = _this.onPointerMoveObservable.add(function (hoverPosition) {
76
+ _this._frontMaterial.globalLeftIndexTipPosition = hoverPosition;
77
+ });
78
+ return _this;
79
+ }
80
+ TouchHolographicButton.prototype._disposeTooltip = function () {
81
+ this._tooltipFade = null;
82
+ if (this._tooltipTextBlock) {
83
+ this._tooltipTextBlock.dispose();
84
+ }
85
+ if (this._tooltipTexture) {
86
+ this._tooltipTexture.dispose();
87
+ }
88
+ if (this._tooltipMesh) {
89
+ this._tooltipMesh.dispose();
90
+ }
91
+ this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
92
+ this.onPointerOutObservable.remove(this._tooltipOutObserver);
93
+ };
94
+ Object.defineProperty(TouchHolographicButton.prototype, "renderingGroupId", {
95
+ get: function () {
96
+ return this._backPlate.renderingGroupId;
97
+ },
98
+ /**
99
+ * Rendering ground id of all the mesh in the button
100
+ */
101
+ set: function (id) {
102
+ this._backPlate.renderingGroupId = id;
103
+ this._textPlate.renderingGroupId = id;
104
+ this._frontPlate.renderingGroupId = id;
105
+ if (this._tooltipMesh) {
106
+ this._tooltipMesh.renderingGroupId = id;
107
+ }
108
+ },
109
+ enumerable: false,
110
+ configurable: true
111
+ });
112
+ Object.defineProperty(TouchHolographicButton.prototype, "mesh", {
113
+ /**
114
+ * Gets the mesh used to render this control
115
+ */
116
+ get: function () {
117
+ return this._backPlate;
118
+ },
119
+ enumerable: false,
120
+ configurable: true
121
+ });
122
+ Object.defineProperty(TouchHolographicButton.prototype, "tooltipText", {
123
+ get: function () {
124
+ if (this._tooltipTextBlock) {
125
+ return this._tooltipTextBlock.text;
126
+ }
127
+ return null;
128
+ },
129
+ /**
130
+ * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
131
+ */
132
+ set: function (text) {
133
+ var _this = this;
134
+ if (!text) {
135
+ this._disposeTooltip();
136
+ return;
137
+ }
138
+ if (!this._tooltipFade) {
139
+ var rightHandedScene = this._backPlate._scene.useRightHandedSystem;
140
+ // Create tooltip with mesh and text
141
+ this._tooltipMesh = CreatePlane("", { size: 1 }, this._backPlate._scene);
142
+ var tooltipBackground = CreatePlane("", { size: 1, sideOrientation: Mesh.DOUBLESIDE }, this._backPlate._scene);
143
+ var mat = new StandardMaterial("", this._backPlate._scene);
144
+ mat.diffuseColor = Color3.FromHexString("#212121");
145
+ tooltipBackground.material = mat;
146
+ tooltipBackground.isPickable = false;
147
+ this._tooltipMesh.addChild(tooltipBackground);
148
+ tooltipBackground.position = Vector3.Forward(rightHandedScene).scale(0.05);
149
+ this._tooltipMesh.scaling.y = 1 / 3;
150
+ this._tooltipMesh.position = Vector3.Up().scale(0.7).add(Vector3.Forward(rightHandedScene).scale(-0.15));
151
+ this._tooltipMesh.isPickable = false;
152
+ this._tooltipMesh.parent = this._backPlate;
153
+ // Create text texture for the tooltip
154
+ this._tooltipTexture = AdvancedDynamicTexture.CreateForMesh(this._tooltipMesh);
155
+ this._tooltipTextBlock = new TextBlock();
156
+ this._tooltipTextBlock.scaleY = 3;
157
+ this._tooltipTextBlock.color = "white";
158
+ this._tooltipTextBlock.fontSize = 130;
159
+ this._tooltipTexture.addControl(this._tooltipTextBlock);
160
+ // Add hover action to tooltip
161
+ this._tooltipFade = new FadeInOutBehavior();
162
+ this._tooltipFade.delay = 500;
163
+ this._tooltipMesh.addBehavior(this._tooltipFade);
164
+ this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
165
+ if (_this._tooltipFade) {
166
+ _this._tooltipFade.fadeIn(true);
167
+ }
168
+ });
169
+ this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
170
+ if (_this._tooltipFade) {
171
+ _this._tooltipFade.fadeIn(false);
172
+ }
173
+ });
174
+ }
175
+ if (this._tooltipTextBlock) {
176
+ this._tooltipTextBlock.text = text;
177
+ }
178
+ },
179
+ enumerable: false,
180
+ configurable: true
181
+ });
182
+ Object.defineProperty(TouchHolographicButton.prototype, "text", {
183
+ /**
184
+ * Gets or sets text for the button
185
+ */
186
+ get: function () {
187
+ return this._text;
188
+ },
189
+ set: function (value) {
190
+ if (this._text === value) {
191
+ return;
192
+ }
193
+ this._text = value;
194
+ this._rebuildContent();
195
+ },
196
+ enumerable: false,
197
+ configurable: true
198
+ });
199
+ Object.defineProperty(TouchHolographicButton.prototype, "imageUrl", {
200
+ /**
201
+ * Gets or sets the image url for the button
202
+ */
203
+ get: function () {
204
+ return this._imageUrl;
205
+ },
206
+ set: function (value) {
207
+ if (this._imageUrl === value) {
208
+ return;
209
+ }
210
+ this._imageUrl = value;
211
+ this._rebuildContent();
212
+ },
213
+ enumerable: false,
214
+ configurable: true
215
+ });
216
+ Object.defineProperty(TouchHolographicButton.prototype, "backMaterial", {
217
+ /**
218
+ * Gets the back material used by this button
219
+ */
220
+ get: function () {
221
+ return this._backMaterial;
222
+ },
223
+ enumerable: false,
224
+ configurable: true
225
+ });
226
+ Object.defineProperty(TouchHolographicButton.prototype, "frontMaterial", {
227
+ /**
228
+ * Gets the front material used by this button
229
+ */
230
+ get: function () {
231
+ return this._frontMaterial;
232
+ },
233
+ enumerable: false,
234
+ configurable: true
235
+ });
236
+ Object.defineProperty(TouchHolographicButton.prototype, "plateMaterial", {
237
+ /**
238
+ * Gets the plate material used by this button
239
+ */
240
+ get: function () {
241
+ return this._plateMaterial;
242
+ },
243
+ enumerable: false,
244
+ configurable: true
245
+ });
246
+ Object.defineProperty(TouchHolographicButton.prototype, "shareMaterials", {
247
+ /**
248
+ * Gets a boolean indicating if this button shares its material with other HolographicButtons
249
+ */
250
+ get: function () {
251
+ return this._shareMaterials;
252
+ },
253
+ enumerable: false,
254
+ configurable: true
255
+ });
256
+ Object.defineProperty(TouchHolographicButton.prototype, "isBackplateVisible", {
257
+ /**
258
+ * Sets whether the backplate is visible or hidden. Hiding the backplate is not recommended without some sort of replacement
259
+ */
260
+ set: function (isVisible) {
261
+ if (this.mesh && !!this._backMaterial) {
262
+ if (isVisible && !this._isBackplateVisible) {
263
+ this._backPlate.visibility = 1;
264
+ }
265
+ else if (!isVisible && this._isBackplateVisible) {
266
+ this._backPlate.visibility = 0;
267
+ }
268
+ }
269
+ this._isBackplateVisible = isVisible;
270
+ },
271
+ enumerable: false,
272
+ configurable: true
273
+ });
274
+ TouchHolographicButton.prototype._getTypeName = function () {
275
+ return "TouchHolographicButton";
276
+ };
277
+ TouchHolographicButton.prototype._rebuildContent = function () {
278
+ this._disposeFacadeTexture();
279
+ var panel = new StackPanel();
280
+ panel.isVertical = true;
281
+ if (DomManagement.IsDocumentAvailable() && !!document.createElement) {
282
+ if (this._imageUrl) {
283
+ var image = new Image();
284
+ image.source = this._imageUrl;
285
+ image.paddingTop = "40px";
286
+ image.height = "180px";
287
+ image.width = "100px";
288
+ image.paddingBottom = "40px";
289
+ panel.addControl(image);
290
+ }
291
+ }
292
+ if (this._text) {
293
+ var text = new TextBlock();
294
+ text.text = this._text;
295
+ text.color = "white";
296
+ text.height = "30px";
297
+ text.fontSize = 24;
298
+ panel.addControl(text);
299
+ }
300
+ this.content = panel;
301
+ };
302
+ // Mesh association
303
+ TouchHolographicButton.prototype._createNode = function (scene) {
304
+ var _this = this;
305
+ var _a;
306
+ this.name = (_a = this.name) !== null && _a !== void 0 ? _a : "TouchHolographicButton";
307
+ var collisionMesh = CreateBox("".concat(this.name, "_collisionMesh"), {
308
+ width: 1.0,
309
+ height: 1.0,
310
+ depth: this._frontPlateDepth,
311
+ }, scene);
312
+ collisionMesh.isPickable = true;
313
+ collisionMesh.isNearPickable = true;
314
+ collisionMesh.visibility = 0;
315
+ collisionMesh.position = Vector3.Forward(scene.useRightHandedSystem).scale(-this._frontPlateDepth / 2);
316
+ SceneLoader.ImportMeshAsync(undefined, TouchHolographicButton.MODEL_BASE_URL, TouchHolographicButton.MODEL_FILENAME, scene).then(function (result) {
317
+ var alphaMesh = CreateBox("${this.name}_alphaMesh", {
318
+ width: 1.0,
319
+ height: 1.0,
320
+ depth: 1.0,
321
+ }, scene);
322
+ alphaMesh.isPickable = false;
323
+ alphaMesh.material = new StandardMaterial("${this.name}_alphaMesh_material", scene);
324
+ alphaMesh.material.alpha = 0.15;
325
+ var importedFrontPlate = result.meshes[1];
326
+ importedFrontPlate.name = "".concat(_this.name, "_frontPlate");
327
+ importedFrontPlate.isPickable = false;
328
+ importedFrontPlate.scaling.z = _this._frontPlateDepth;
329
+ alphaMesh.parent = importedFrontPlate;
330
+ importedFrontPlate.parent = collisionMesh;
331
+ if (_this._frontMaterial) {
332
+ importedFrontPlate.material = _this._frontMaterial;
333
+ }
334
+ _this._frontPlate = importedFrontPlate;
335
+ });
336
+ this._backPlate = CreateBox("".concat(this.name, "_backPlate"), {
337
+ width: 1.0,
338
+ height: 1.0,
339
+ depth: this._backPlateDepth,
340
+ }, scene);
341
+ this._backPlate.position = Vector3.Forward(scene.useRightHandedSystem).scale(this._backPlateDepth / 2);
342
+ this._backPlate.isPickable = false;
343
+ this._textPlate = _super.prototype._createNode.call(this, scene);
344
+ this._textPlate.name = "".concat(this.name, "_textPlate");
345
+ this._textPlate.isPickable = false;
346
+ this._textPlate.position = Vector3.Forward(scene.useRightHandedSystem).scale(-this._frontPlateDepth / 2);
347
+ this._backPlate.addChild(collisionMesh);
348
+ this._backPlate.addChild(this._textPlate);
349
+ var tn = new TransformNode("{this.name}_root", scene);
350
+ this._backPlate.setParent(tn);
351
+ this.collisionMesh = collisionMesh;
352
+ this.collidableFrontDirection = this._backPlate.forward.negate(); // Mesh is facing the wrong way
353
+ return tn;
354
+ };
355
+ TouchHolographicButton.prototype._applyFacade = function (facadeTexture) {
356
+ this._plateMaterial.emissiveTexture = facadeTexture;
357
+ this._plateMaterial.opacityTexture = facadeTexture;
358
+ this._plateMaterial.diffuseColor = new Color3(0.4, 0.4, 0.4);
359
+ };
360
+ TouchHolographicButton.prototype._createBackMaterial = function (mesh) {
361
+ this._backMaterial = new FluentMaterial(this.name + "backPlateMaterial", mesh.getScene());
362
+ this._backMaterial.albedoColor = this._backplateColor;
363
+ this._backMaterial.renderBorders = true;
364
+ this._backMaterial.renderHoverLight = false;
365
+ };
366
+ TouchHolographicButton.prototype._createFrontMaterial = function (mesh) {
367
+ this._frontMaterial = new FluentButtonMaterial(this.name + "Front Material", mesh.getScene());
368
+ };
369
+ TouchHolographicButton.prototype._createPlateMaterial = function (mesh) {
370
+ this._plateMaterial = new StandardMaterial(this.name + "Plate Material", mesh.getScene());
371
+ this._plateMaterial.specularColor = Color3.Black();
372
+ };
373
+ TouchHolographicButton.prototype._onToggle = function (newState) {
374
+ if (this._backMaterial) {
375
+ if (newState) {
376
+ this._backMaterial.albedoColor = this._backplateToggledColor;
377
+ }
378
+ else {
379
+ this._backMaterial.albedoColor = this._backplateColor;
380
+ }
381
+ }
382
+ _super.prototype._onToggle.call(this, newState);
383
+ };
384
+ TouchHolographicButton.prototype._affectMaterial = function (mesh) {
385
+ if (this._shareMaterials) {
386
+ // Back
387
+ if (!this._host._touchSharedMaterials["backFluentMaterial"]) {
388
+ this._createBackMaterial(mesh);
389
+ this._host._touchSharedMaterials["backFluentMaterial"] = this._backMaterial;
390
+ }
391
+ else {
392
+ this._backMaterial = this._host._touchSharedMaterials["backFluentMaterial"];
393
+ }
394
+ // Front
395
+ if (!this._host._touchSharedMaterials["frontFluentMaterial"]) {
396
+ this._createFrontMaterial(mesh);
397
+ this._host._touchSharedMaterials["frontFluentMaterial"] = this._frontMaterial;
398
+ }
399
+ else {
400
+ this._frontMaterial = this._host._touchSharedMaterials["frontFluentMaterial"];
401
+ }
402
+ }
403
+ else {
404
+ this._createBackMaterial(mesh);
405
+ this._createFrontMaterial(mesh);
406
+ }
407
+ this._createPlateMaterial(mesh);
408
+ this._backPlate.material = this._backMaterial;
409
+ this._textPlate.material = this._plateMaterial;
410
+ if (!this._isBackplateVisible) {
411
+ this._backPlate.visibility = 0;
412
+ }
413
+ if (this._frontPlate) {
414
+ this._frontPlate.material = this._frontMaterial;
415
+ }
416
+ this._rebuildContent();
417
+ };
418
+ /**
419
+ * Releases all associated resources
420
+ */
421
+ TouchHolographicButton.prototype.dispose = function () {
422
+ _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
423
+ this._disposeTooltip();
424
+ this.onPointerMoveObservable.remove(this._pointerHoverObserver);
425
+ if (!this.shareMaterials) {
426
+ this._backMaterial.dispose();
427
+ this._frontMaterial.dispose();
428
+ this._plateMaterial.dispose();
429
+ if (this._pickedPointObserver) {
430
+ this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
431
+ this._pickedPointObserver = null;
432
+ }
433
+ }
434
+ };
435
+ /**
436
+ * Base Url for the button model.
437
+ */
438
+ TouchHolographicButton.MODEL_BASE_URL = "https://assets.babylonjs.com/meshes/MRTK/";
439
+ /**
440
+ * File name for the button model.
441
+ */
442
+ TouchHolographicButton.MODEL_FILENAME = "mrtk-fluent-button.glb";
443
+ return TouchHolographicButton;
444
+ }(TouchButton3D));
445
+ export { TouchHolographicButton };
446
446
  //# sourceMappingURL=touchHolographicButton.js.map