@babylonjs/gui 5.0.0-alpha.9 → 5.0.0-beta.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 (276) hide show
  1. package/2D/adtInstrumentation.js +1 -1
  2. package/2D/advancedDynamicTexture.d.ts +165 -125
  3. package/2D/advancedDynamicTexture.js +342 -181
  4. package/2D/advancedDynamicTexture.js.map +1 -1
  5. package/2D/controls/button.d.ts +8 -0
  6. package/2D/controls/button.js +33 -10
  7. package/2D/controls/button.js.map +1 -1
  8. package/2D/controls/checkbox.d.ts +2 -1
  9. package/2D/controls/checkbox.js +10 -8
  10. package/2D/controls/checkbox.js.map +1 -1
  11. package/2D/controls/colorpicker.d.ts +4 -3
  12. package/2D/controls/colorpicker.js +40 -23
  13. package/2D/controls/colorpicker.js.map +1 -1
  14. package/2D/controls/container.d.ts +16 -5
  15. package/2D/controls/container.js +91 -13
  16. package/2D/controls/container.js.map +1 -1
  17. package/2D/controls/control.d.ts +103 -44
  18. package/2D/controls/control.js +278 -129
  19. package/2D/controls/control.js.map +1 -1
  20. package/2D/controls/displayGrid.d.ts +2 -1
  21. package/2D/controls/displayGrid.js +6 -6
  22. package/2D/controls/displayGrid.js.map +1 -1
  23. package/2D/controls/ellipse.d.ts +5 -3
  24. package/2D/controls/ellipse.js +9 -5
  25. package/2D/controls/ellipse.js.map +1 -1
  26. package/2D/controls/focusableButton.d.ts +1 -0
  27. package/2D/controls/focusableButton.js +9 -6
  28. package/2D/controls/focusableButton.js.map +1 -1
  29. package/2D/controls/grid.d.ts +13 -2
  30. package/2D/controls/grid.js +108 -24
  31. package/2D/controls/grid.js.map +1 -1
  32. package/2D/controls/image.d.ts +5 -4
  33. package/2D/controls/image.js +52 -31
  34. package/2D/controls/image.js.map +1 -1
  35. package/2D/controls/index.js +29 -29
  36. package/2D/controls/inputPassword.js +4 -4
  37. package/2D/controls/inputPassword.js.map +1 -1
  38. package/2D/controls/inputText.d.ts +2 -1
  39. package/2D/controls/inputText.js +40 -14
  40. package/2D/controls/inputText.js.map +1 -1
  41. package/2D/controls/line.d.ts +3 -2
  42. package/2D/controls/line.js +8 -8
  43. package/2D/controls/line.js.map +1 -1
  44. package/2D/controls/multiLine.d.ts +4 -3
  45. package/2D/controls/multiLine.js +6 -6
  46. package/2D/controls/multiLine.js.map +1 -1
  47. package/2D/controls/radioButton.d.ts +2 -1
  48. package/2D/controls/radioButton.js +10 -7
  49. package/2D/controls/radioButton.js.map +1 -1
  50. package/2D/controls/rectangle.d.ts +8 -3
  51. package/2D/controls/rectangle.js +21 -5
  52. package/2D/controls/rectangle.js.map +1 -1
  53. package/2D/controls/scrollViewers/scrollViewer.d.ts +3 -2
  54. package/2D/controls/scrollViewers/scrollViewer.js +9 -9
  55. package/2D/controls/scrollViewers/scrollViewer.js.map +1 -1
  56. package/2D/controls/scrollViewers/scrollViewerWindow.d.ts +4 -3
  57. package/2D/controls/scrollViewers/scrollViewerWindow.js +4 -4
  58. package/2D/controls/scrollViewers/scrollViewerWindow.js.map +1 -1
  59. package/2D/controls/selector.js +8 -8
  60. package/2D/controls/selector.js.map +1 -1
  61. package/2D/controls/sliders/baseSlider.d.ts +1 -1
  62. package/2D/controls/sliders/baseSlider.js +12 -10
  63. package/2D/controls/sliders/baseSlider.js.map +1 -1
  64. package/2D/controls/sliders/imageBasedSlider.d.ts +10 -1
  65. package/2D/controls/sliders/imageBasedSlider.js +29 -5
  66. package/2D/controls/sliders/imageBasedSlider.js.map +1 -1
  67. package/2D/controls/sliders/imageScrollBar.d.ts +2 -1
  68. package/2D/controls/sliders/imageScrollBar.js +3 -3
  69. package/2D/controls/sliders/imageScrollBar.js.map +1 -1
  70. package/2D/controls/sliders/scrollBar.d.ts +2 -1
  71. package/2D/controls/sliders/scrollBar.js +3 -3
  72. package/2D/controls/sliders/scrollBar.js.map +1 -1
  73. package/2D/controls/sliders/slider.d.ts +2 -1
  74. package/2D/controls/sliders/slider.js +4 -4
  75. package/2D/controls/sliders/slider.js.map +1 -1
  76. package/2D/controls/stackPanel.d.ts +10 -3
  77. package/2D/controls/stackPanel.js +35 -13
  78. package/2D/controls/stackPanel.js.map +1 -1
  79. package/2D/controls/statics.js +3 -3
  80. package/2D/controls/statics.js.map +1 -1
  81. package/2D/controls/textBlock.d.ts +16 -9
  82. package/2D/controls/textBlock.js +75 -34
  83. package/2D/controls/textBlock.js.map +1 -1
  84. package/2D/controls/textWrapper.js +2 -2
  85. package/2D/controls/textWrapper.js.map +1 -1
  86. package/2D/controls/toggleButton.d.ts +1 -13
  87. package/2D/controls/toggleButton.js +29 -38
  88. package/2D/controls/toggleButton.js.map +1 -1
  89. package/2D/controls/virtualKeyboard.js +5 -5
  90. package/2D/controls/virtualKeyboard.js.map +1 -1
  91. package/2D/index.d.ts +1 -1
  92. package/2D/index.js +9 -9
  93. package/2D/index.js.map +1 -1
  94. package/2D/math2D.d.ts +5 -0
  95. package/2D/math2D.js +14 -2
  96. package/2D/math2D.js.map +1 -1
  97. package/2D/measure.js +1 -1
  98. package/2D/measure.js.map +1 -1
  99. package/2D/multiLinePoint.js +3 -3
  100. package/2D/style.js +2 -2
  101. package/2D/valueAndUnit.d.ts +21 -6
  102. package/2D/valueAndUnit.js +57 -13
  103. package/2D/valueAndUnit.js.map +1 -1
  104. package/2D/xmlLoader.d.ts +17 -3
  105. package/2D/xmlLoader.js +54 -15
  106. package/2D/xmlLoader.js.map +1 -1
  107. package/3D/behaviors/defaultBehavior.d.ts +73 -0
  108. package/3D/behaviors/defaultBehavior.js +122 -0
  109. package/3D/behaviors/defaultBehavior.js.map +1 -0
  110. package/3D/controls/abstractButton3D.d.ts +2 -2
  111. package/3D/controls/abstractButton3D.js +3 -3
  112. package/3D/controls/abstractButton3D.js.map +1 -1
  113. package/3D/controls/button3D.d.ts +0 -24
  114. package/3D/controls/button3D.js +15 -84
  115. package/3D/controls/button3D.js.map +1 -1
  116. package/3D/controls/container3D.js +2 -2
  117. package/3D/controls/contentDisplay3D.d.ts +30 -0
  118. package/3D/controls/contentDisplay3D.js +79 -0
  119. package/3D/controls/contentDisplay3D.js.map +1 -0
  120. package/3D/controls/control3D.d.ts +10 -7
  121. package/3D/controls/control3D.js +27 -19
  122. package/3D/controls/control3D.js.map +1 -1
  123. package/3D/controls/cylinderPanel.js +5 -5
  124. package/3D/controls/handMenu.d.ts +28 -0
  125. package/3D/controls/handMenu.js +48 -0
  126. package/3D/controls/handMenu.js.map +1 -0
  127. package/3D/controls/holographicBackplate.d.ts +48 -0
  128. package/3D/controls/holographicBackplate.js +121 -0
  129. package/3D/controls/holographicBackplate.js.map +1 -0
  130. package/3D/controls/holographicButton.d.ts +1 -1
  131. package/3D/controls/holographicButton.js +35 -31
  132. package/3D/controls/holographicButton.js.map +1 -1
  133. package/3D/controls/holographicSlate.d.ts +118 -0
  134. package/3D/controls/holographicSlate.js +365 -0
  135. package/3D/controls/holographicSlate.js.map +1 -0
  136. package/3D/controls/index.d.ts +7 -0
  137. package/3D/controls/index.js +22 -15
  138. package/3D/controls/index.js.map +1 -1
  139. package/3D/controls/meshButton3D.js +2 -2
  140. package/3D/controls/meshButton3D.js.map +1 -1
  141. package/3D/controls/nearMenu.d.ts +45 -0
  142. package/3D/controls/nearMenu.js +111 -0
  143. package/3D/controls/nearMenu.js.map +1 -0
  144. package/3D/controls/planePanel.js +3 -3
  145. package/3D/controls/scatterPanel.js +4 -4
  146. package/3D/controls/slider3D.d.ts +80 -0
  147. package/3D/controls/slider3D.js +268 -0
  148. package/3D/controls/slider3D.js.map +1 -0
  149. package/3D/controls/spherePanel.js +5 -5
  150. package/3D/controls/stackPanel3D.js +3 -3
  151. package/3D/controls/touchButton3D.d.ts +9 -21
  152. package/3D/controls/touchButton3D.js +52 -224
  153. package/3D/controls/touchButton3D.js.map +1 -1
  154. package/3D/controls/touchHolographicButton.d.ts +20 -3
  155. package/3D/controls/touchHolographicButton.js +137 -67
  156. package/3D/controls/touchHolographicButton.js.map +1 -1
  157. package/3D/controls/touchHolographicMenu.d.ts +61 -0
  158. package/3D/controls/touchHolographicMenu.js +149 -0
  159. package/3D/controls/touchHolographicMenu.js.map +1 -0
  160. package/3D/controls/touchMeshButton3D.d.ts +3 -6
  161. package/3D/controls/touchMeshButton3D.js +6 -14
  162. package/3D/controls/touchMeshButton3D.js.map +1 -1
  163. package/3D/controls/touchToggleButton3D.d.ts +35 -0
  164. package/3D/controls/touchToggleButton3D.js +60 -0
  165. package/3D/controls/touchToggleButton3D.js.map +1 -0
  166. package/3D/controls/volumeBasedPanel.d.ts +1 -1
  167. package/3D/controls/volumeBasedPanel.js +5 -5
  168. package/3D/controls/volumeBasedPanel.js.map +1 -1
  169. package/3D/gizmos/gizmoHandle.d.ts +108 -0
  170. package/3D/gizmos/gizmoHandle.js +210 -0
  171. package/3D/gizmos/gizmoHandle.js.map +1 -0
  172. package/3D/gizmos/index.d.ts +2 -0
  173. package/3D/gizmos/index.js +3 -0
  174. package/3D/gizmos/index.js.map +1 -0
  175. package/3D/gizmos/slateGizmo.d.ts +59 -0
  176. package/3D/gizmos/slateGizmo.js +364 -0
  177. package/3D/gizmos/slateGizmo.js.map +1 -0
  178. package/3D/gui3DManager.d.ts +15 -2
  179. package/3D/gui3DManager.js +62 -41
  180. package/3D/gui3DManager.js.map +1 -1
  181. package/3D/index.d.ts +3 -2
  182. package/3D/index.js +5 -4
  183. package/3D/index.js.map +1 -1
  184. package/3D/materials/fluent/fluentMaterial.d.ts +90 -0
  185. package/3D/materials/fluent/fluentMaterial.js +282 -0
  186. package/3D/materials/fluent/fluentMaterial.js.map +1 -0
  187. package/3D/materials/fluent/index.d.ts +1 -0
  188. package/3D/materials/fluent/index.js +2 -0
  189. package/3D/materials/fluent/index.js.map +1 -0
  190. package/3D/materials/{shaders → fluent/shaders}/fluent.fragment.d.ts +0 -0
  191. package/3D/materials/fluent/shaders/fluent.fragment.js +7 -0
  192. package/3D/materials/fluent/shaders/fluent.fragment.js.map +1 -0
  193. package/3D/materials/{shaders → fluent/shaders}/fluent.vertex.d.ts +0 -0
  194. package/3D/materials/{shaders → fluent/shaders}/fluent.vertex.js +2 -2
  195. package/3D/materials/fluent/shaders/fluent.vertex.js.map +1 -0
  196. package/3D/materials/fluentBackplate/fluentBackplateMaterial.d.ts +154 -0
  197. package/3D/materials/fluentBackplate/fluentBackplateMaterial.js +435 -0
  198. package/3D/materials/fluentBackplate/fluentBackplateMaterial.js.map +1 -0
  199. package/3D/materials/fluentBackplate/index.d.ts +1 -0
  200. package/3D/materials/fluentBackplate/index.js +2 -0
  201. package/3D/materials/fluentBackplate/index.js.map +1 -0
  202. package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.d.ts +5 -0
  203. package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.js +7 -0
  204. package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.js.map +1 -0
  205. package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.d.ts +5 -0
  206. package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.js +7 -0
  207. package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.js.map +1 -0
  208. package/3D/materials/fluentButton/fluentButtonMaterial.d.ts +189 -0
  209. package/3D/materials/fluentButton/fluentButtonMaterial.js +538 -0
  210. package/3D/materials/fluentButton/fluentButtonMaterial.js.map +1 -0
  211. package/3D/materials/fluentButton/index.d.ts +1 -0
  212. package/3D/materials/fluentButton/index.js +2 -0
  213. package/3D/materials/fluentButton/index.js.map +1 -0
  214. package/3D/materials/fluentButton/shaders/fluentButton.fragment.d.ts +5 -0
  215. package/3D/materials/fluentButton/shaders/fluentButton.fragment.js +7 -0
  216. package/3D/materials/fluentButton/shaders/fluentButton.fragment.js.map +1 -0
  217. package/3D/materials/fluentButton/shaders/fluentButton.vertex.d.ts +5 -0
  218. package/3D/materials/fluentButton/shaders/fluentButton.vertex.js +7 -0
  219. package/3D/materials/fluentButton/shaders/fluentButton.vertex.js.map +1 -0
  220. package/3D/materials/fluentMaterial.d.ts +2 -88
  221. package/3D/materials/fluentMaterial.js +2 -277
  222. package/3D/materials/fluentMaterial.js.map +1 -1
  223. package/3D/materials/handle/handleMaterial.d.ts +68 -0
  224. package/3D/materials/handle/handleMaterial.js +127 -0
  225. package/3D/materials/handle/handleMaterial.js.map +1 -0
  226. package/3D/materials/handle/index.d.ts +1 -0
  227. package/3D/materials/handle/index.js +2 -0
  228. package/3D/materials/handle/index.js.map +1 -0
  229. package/3D/materials/handle/shaders/handle.fragment.d.ts +5 -0
  230. package/3D/materials/handle/shaders/handle.fragment.js +7 -0
  231. package/3D/materials/handle/shaders/handle.fragment.js.map +1 -0
  232. package/3D/materials/handle/shaders/handle.vertex.d.ts +5 -0
  233. package/3D/materials/handle/shaders/handle.vertex.js +7 -0
  234. package/3D/materials/handle/shaders/handle.vertex.js.map +1 -0
  235. package/3D/materials/index.d.ts +5 -1
  236. package/3D/materials/index.js +5 -1
  237. package/3D/materials/index.js.map +1 -1
  238. package/3D/materials/mrdl/index.d.ts +3 -0
  239. package/3D/materials/mrdl/index.js +4 -0
  240. package/3D/materials/mrdl/index.js.map +1 -0
  241. package/3D/materials/mrdl/mrdlBackplateMaterial.d.ts +147 -0
  242. package/3D/materials/mrdl/mrdlBackplateMaterial.js +410 -0
  243. package/3D/materials/mrdl/mrdlBackplateMaterial.js.map +1 -0
  244. package/3D/materials/mrdl/mrdlSliderBarMaterial.d.ts +333 -0
  245. package/3D/materials/mrdl/mrdlSliderBarMaterial.js +787 -0
  246. package/3D/materials/mrdl/mrdlSliderBarMaterial.js.map +1 -0
  247. package/3D/materials/mrdl/mrdlSliderThumbMaterial.d.ts +333 -0
  248. package/3D/materials/mrdl/mrdlSliderThumbMaterial.js +787 -0
  249. package/3D/materials/mrdl/mrdlSliderThumbMaterial.js.map +1 -0
  250. package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.d.ts +5 -0
  251. package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.js +7 -0
  252. package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.js.map +1 -0
  253. package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.d.ts +5 -0
  254. package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.js +7 -0
  255. package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.js.map +1 -0
  256. package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.d.ts +5 -0
  257. package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.js +7 -0
  258. package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.js.map +1 -0
  259. package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.d.ts +5 -0
  260. package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.js +7 -0
  261. package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.js.map +1 -0
  262. package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.d.ts +5 -0
  263. package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.js +7 -0
  264. package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.js.map +1 -0
  265. package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.d.ts +5 -0
  266. package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.js +7 -0
  267. package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.js.map +1 -0
  268. package/3D/vector3WithInfo.js +1 -1
  269. package/index.d.ts +2 -2
  270. package/index.js +2 -2
  271. package/index.js.map +1 -1
  272. package/legacy/legacy.js +2 -2
  273. package/package.json +117 -9
  274. package/3D/materials/shaders/fluent.fragment.js +0 -7
  275. package/3D/materials/shaders/fluent.fragment.js.map +0 -1
  276. package/3D/materials/shaders/fluent.vertex.js.map +0 -1
@@ -1,43 +1,44 @@
1
1
  import { __extends } from "tslib";
2
- import { Observable } from "@babylonjs/core/Misc/observable";
3
- import { Vector2, Vector3 } from "@babylonjs/core/Maths/math.vector";
4
- import { Tools } from "@babylonjs/core/Misc/tools";
5
- import { PointerEventTypes } from '@babylonjs/core/Events/pointerEvents';
6
- import { ClipboardEventTypes, ClipboardInfo } from "@babylonjs/core/Events/clipboardEvents";
7
- import { KeyboardEventTypes } from "@babylonjs/core/Events/keyboardEvents";
8
- import { StandardMaterial } from "@babylonjs/core/Materials/standardMaterial";
9
- import { Texture } from "@babylonjs/core/Materials/Textures/texture";
10
- import { DynamicTexture } from "@babylonjs/core/Materials/Textures/dynamicTexture";
11
- import { Layer } from "@babylonjs/core/Layers/layer";
12
- import { Container } from "./controls/container";
13
- import { Control } from "./controls/control";
14
- import { Style } from "./style";
15
- import { Measure } from "./measure";
16
- import { Constants } from '@babylonjs/core/Engines/constants';
17
- import { Viewport } from '@babylonjs/core/Maths/math.viewport';
18
- import { Color3 } from '@babylonjs/core/Maths/math.color';
19
- import { WebRequest } from "@babylonjs/core/Misc/webRequest";
2
+ import { Observable } from "@babylonjs/core/Misc/observable.js";
3
+ import { Vector2, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
4
+ import { Tools } from "@babylonjs/core/Misc/tools.js";
5
+ import { PointerEventTypes } from "@babylonjs/core/Events/pointerEvents.js";
6
+ import { ClipboardEventTypes, ClipboardInfo } from "@babylonjs/core/Events/clipboardEvents.js";
7
+ import { KeyboardEventTypes } from "@babylonjs/core/Events/keyboardEvents.js";
8
+ import { StandardMaterial } from "@babylonjs/core/Materials/standardMaterial.js";
9
+ import { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
10
+ import { DynamicTexture } from "@babylonjs/core/Materials/Textures/dynamicTexture.js";
11
+ import { Layer } from "@babylonjs/core/Layers/layer.js";
12
+ import { Container } from "./controls/container.js";
13
+ import { Control } from "./controls/control.js";
14
+ import { Style } from "./style.js";
15
+ import { Measure } from "./measure.js";
16
+ import { Constants } from "@babylonjs/core/Engines/constants.js";
17
+ import { Viewport } from "@babylonjs/core/Maths/math.viewport.js";
18
+ import { Color3 } from "@babylonjs/core/Maths/math.color.js";
19
+ import { WebRequest } from "@babylonjs/core/Misc/webRequest.js";
20
20
  /**
21
- * Class used to create texture to support 2D GUI elements
22
- * @see https://doc.babylonjs.com/how_to/gui
23
- */
21
+ * Class used to create texture to support 2D GUI elements
22
+ * @see https://doc.babylonjs.com/how_to/gui
23
+ */
24
24
  var AdvancedDynamicTexture = /** @class */ (function (_super) {
25
25
  __extends(AdvancedDynamicTexture, _super);
26
26
  /**
27
- * Creates a new AdvancedDynamicTexture
28
- * @param name defines the name of the texture
29
- * @param width defines the width of the texture
30
- * @param height defines the height of the texture
31
- * @param scene defines the hosting scene
32
- * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
33
- * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
34
- * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
35
- */
27
+ * Creates a new AdvancedDynamicTexture
28
+ * @param name defines the name of the texture
29
+ * @param width defines the width of the texture
30
+ * @param height defines the height of the texture
31
+ * @param scene defines the hosting scene
32
+ * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
33
+ * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
34
+ * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
35
+ */
36
36
  function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode, invertY) {
37
37
  if (width === void 0) { width = 0; }
38
38
  if (height === void 0) { height = 0; }
39
39
  if (generateMipMaps === void 0) { generateMipMaps = false; }
40
40
  if (samplingMode === void 0) { samplingMode = Texture.NEAREST_SAMPLINGMODE; }
41
+ if (invertY === void 0) { invertY = true; }
41
42
  var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, Constants.TEXTUREFORMAT_RGBA, invertY) || this;
42
43
  _this._isDirty = false;
43
44
  /** @hidden */
@@ -65,37 +66,37 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
65
66
  /** @hidden */
66
67
  _this._numRenderCalls = 0;
67
68
  /**
68
- * Define type to string to ensure compatibility across browsers
69
- * Safari doesn't support DataTransfer constructor
70
- */
69
+ * Define type to string to ensure compatibility across browsers
70
+ * Safari doesn't support DataTransfer constructor
71
+ */
71
72
  _this._clipboardData = "";
72
73
  /**
73
- * Observable event triggered each time an clipboard event is received from the rendering canvas
74
- */
74
+ * Observable event triggered each time an clipboard event is received from the rendering canvas
75
+ */
75
76
  _this.onClipboardObservable = new Observable();
76
77
  /**
77
- * Observable event triggered each time a pointer down is intercepted by a control
78
- */
78
+ * Observable event triggered each time a pointer down is intercepted by a control
79
+ */
79
80
  _this.onControlPickedObservable = new Observable();
80
81
  /**
81
- * Observable event triggered before layout is evaluated
82
- */
82
+ * Observable event triggered before layout is evaluated
83
+ */
83
84
  _this.onBeginLayoutObservable = new Observable();
84
85
  /**
85
- * Observable event triggered after the layout was evaluated
86
- */
86
+ * Observable event triggered after the layout was evaluated
87
+ */
87
88
  _this.onEndLayoutObservable = new Observable();
88
89
  /**
89
- * Observable event triggered before the texture is rendered
90
- */
90
+ * Observable event triggered before the texture is rendered
91
+ */
91
92
  _this.onBeginRenderObservable = new Observable();
92
93
  /**
93
- * Observable event triggered after the texture was rendered
94
- */
94
+ * Observable event triggered after the texture was rendered
95
+ */
95
96
  _this.onEndRenderObservable = new Observable();
96
97
  /**
97
- * Gets or sets a boolean defining if alpha is stored as premultiplied
98
- */
98
+ * Gets or sets a boolean defining if alpha is stored as premultiplied
99
+ */
99
100
  _this.premulAlpha = false;
100
101
  /**
101
102
  * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
@@ -130,6 +131,7 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
130
131
  if (!scene || !_this._texture) {
131
132
  return _this;
132
133
  }
134
+ _this.applyYInversionOnUpdate = invertY;
133
135
  _this._rootElement = scene.getEngine().getInputElement();
134
136
  _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
135
137
  _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
@@ -168,9 +170,9 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
168
170
  });
169
171
  Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
170
172
  /**
171
- * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
172
- * Useful when you want more antialiasing
173
- */
173
+ * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
174
+ * Useful when you want more antialiasing
175
+ */
174
176
  get: function () {
175
177
  return this._renderScale;
176
178
  },
@@ -201,10 +203,10 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
201
203
  });
202
204
  Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
203
205
  /**
204
- * Gets or sets the ideal width used to design controls.
205
- * The GUI will then rescale everything accordingly
206
- * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
207
- */
206
+ * Gets or sets the ideal width used to design controls.
207
+ * The GUI will then rescale everything accordingly
208
+ * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
209
+ */
208
210
  get: function () {
209
211
  return this._idealWidth;
210
212
  },
@@ -221,10 +223,10 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
221
223
  });
222
224
  Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
223
225
  /**
224
- * Gets or sets the ideal height used to design controls.
225
- * The GUI will then rescale everything accordingly
226
- * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
227
- */
226
+ * Gets or sets the ideal height used to design controls.
227
+ * The GUI will then rescale everything accordingly
228
+ * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
229
+ */
228
230
  get: function () {
229
231
  return this._idealHeight;
230
232
  },
@@ -241,9 +243,9 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
241
243
  });
242
244
  Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
243
245
  /**
244
- * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
245
- * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
246
- */
246
+ * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
247
+ * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
248
+ */
247
249
  get: function () {
248
250
  return this._useSmallestIdeal;
249
251
  },
@@ -260,9 +262,9 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
260
262
  });
261
263
  Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
262
264
  /**
263
- * Gets or sets a boolean indicating if adaptive scaling must be used
264
- * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
265
- */
265
+ * Gets or sets a boolean indicating if adaptive scaling must be used
266
+ * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
267
+ */
266
268
  get: function () {
267
269
  return this._renderAtIdealSize;
268
270
  },
@@ -279,24 +281,26 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
279
281
  Object.defineProperty(AdvancedDynamicTexture.prototype, "idealRatio", {
280
282
  /**
281
283
  * Gets the ratio used when in "ideal mode"
282
- * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
284
+ * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
283
285
  * */
284
286
  get: function () {
285
287
  var rwidth = 0;
286
288
  var rheight = 0;
287
289
  if (this._idealWidth) {
288
- rwidth = (this.getSize().width) / this._idealWidth;
290
+ rwidth = this.getSize().width / this._idealWidth;
289
291
  }
290
292
  if (this._idealHeight) {
291
- rheight = (this.getSize().height) / this._idealHeight;
293
+ rheight = this.getSize().height / this._idealHeight;
292
294
  }
293
295
  if (this._useSmallestIdeal && this._idealWidth && this._idealHeight) {
294
296
  return window.innerWidth < window.innerHeight ? rwidth : rheight;
295
297
  }
296
- if (this._idealWidth) { // horizontal
298
+ if (this._idealWidth) {
299
+ // horizontal
297
300
  return rwidth;
298
301
  }
299
- if (this._idealHeight) { // vertical
302
+ if (this._idealHeight) {
303
+ // vertical
300
304
  return rheight;
301
305
  }
302
306
  return 1;
@@ -306,8 +310,8 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
306
310
  });
307
311
  Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
308
312
  /**
309
- * Gets the underlying layer used to render the texture when in fullscreen mode
310
- */
313
+ * Gets the underlying layer used to render the texture when in fullscreen mode
314
+ */
311
315
  get: function () {
312
316
  return this._layerToDispose;
313
317
  },
@@ -316,8 +320,8 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
316
320
  });
317
321
  Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
318
322
  /**
319
- * Gets the root container control
320
- */
323
+ * Gets the root container control
324
+ */
321
325
  get: function () {
322
326
  return this._rootContainer;
323
327
  },
@@ -325,26 +329,45 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
325
329
  configurable: true
326
330
  });
327
331
  /**
328
- * Returns an array containing the root container.
329
- * This is mostly used to let the Inspector introspects the ADT
330
- * @returns an array containing the rootContainer
331
- */
332
+ * Returns an array containing the root container.
333
+ * This is mostly used to let the Inspector introspects the ADT
334
+ * @returns an array containing the rootContainer
335
+ */
332
336
  AdvancedDynamicTexture.prototype.getChildren = function () {
333
337
  return [this._rootContainer];
334
338
  };
335
339
  /**
336
- * Will return all controls that are inside this texture
337
- * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
338
- * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
339
- * @return all child controls
340
- */
340
+ * Will return all controls that are inside this texture
341
+ * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
342
+ * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
343
+ * @return all child controls
344
+ */
341
345
  AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
342
346
  return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
343
347
  };
348
+ /**
349
+ * Will return all controls with the given type name
350
+ * @param typeName defines the type name to search for
351
+ * @returns an array of all controls found
352
+ */
353
+ AdvancedDynamicTexture.prototype.getControlsByType = function (typeName) {
354
+ return this._rootContainer.getDescendants(false, function (control) { return control.typeName === typeName; });
355
+ };
356
+ /**
357
+ * Will return the first control with the given name
358
+ * @param name defines the name to search for
359
+ * @return the first control found or null
360
+ */
361
+ AdvancedDynamicTexture.prototype.getControlByName = function (name) {
362
+ return this._getControlByKey("name", name);
363
+ };
364
+ AdvancedDynamicTexture.prototype._getControlByKey = function (key, value) {
365
+ return this._rootContainer.getDescendants().find(function (control) { return control[key] === value; }) || null;
366
+ };
344
367
  Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
345
368
  /**
346
- * Gets or sets the current focused control
347
- */
369
+ * Gets or sets the current focused control
370
+ */
348
371
  get: function () {
349
372
  return this._focusedControl;
350
373
  },
@@ -365,13 +388,13 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
365
388
  });
366
389
  Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
367
390
  /**
368
- * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
369
- */
391
+ * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
392
+ */
370
393
  get: function () {
371
394
  if (!this.layer) {
372
395
  return true;
373
396
  }
374
- return (!this.layer.isBackground);
397
+ return !this.layer.isBackground;
375
398
  },
376
399
  set: function (value) {
377
400
  if (!this.layer) {
@@ -387,8 +410,8 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
387
410
  });
388
411
  Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
389
412
  /**
390
- * Gets or set information about clipboardData
391
- */
413
+ * Gets or set information about clipboardData
414
+ */
392
415
  get: function () {
393
416
  return this._clipboardData;
394
417
  },
@@ -399,17 +422,17 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
399
422
  configurable: true
400
423
  });
401
424
  /**
402
- * Get the current class name of the texture useful for serialization or dynamic coding.
403
- * @returns "AdvancedDynamicTexture"
404
- */
425
+ * Get the current class name of the texture useful for serialization or dynamic coding.
426
+ * @returns "AdvancedDynamicTexture"
427
+ */
405
428
  AdvancedDynamicTexture.prototype.getClassName = function () {
406
429
  return "AdvancedDynamicTexture";
407
430
  };
408
431
  /**
409
- * Function used to execute a function on all controls
410
- * @param func defines the function to execute
411
- * @param container defines the container where controls belong. If null the root container will be used
412
- */
432
+ * Function used to execute a function on all controls
433
+ * @param func defines the function to execute
434
+ * @param container defines the container where controls belong. If null the root container will be used
435
+ */
413
436
  AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
414
437
  if (!container) {
415
438
  container = this._rootContainer;
@@ -462,40 +485,83 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
462
485
  }
463
486
  };
464
487
  /**
465
- * Marks the texture as dirty forcing a complete update
466
- */
488
+ * Marks the texture as dirty forcing a complete update
489
+ */
467
490
  AdvancedDynamicTexture.prototype.markAsDirty = function () {
468
491
  this._isDirty = true;
469
492
  };
470
493
  /**
471
- * Helper function used to create a new style
472
- * @returns a new style
473
- * @see https://doc.babylonjs.com/how_to/gui#styles
474
- */
494
+ * Helper function used to create a new style
495
+ * @returns a new style
496
+ * @see https://doc.babylonjs.com/how_to/gui#styles
497
+ */
475
498
  AdvancedDynamicTexture.prototype.createStyle = function () {
476
499
  return new Style(this);
477
500
  };
478
501
  /**
479
- * Adds a new control to the root container
480
- * @param control defines the control to add
481
- * @returns the current texture
482
- */
502
+ * Adds a new control to the root container
503
+ * @param control defines the control to add
504
+ * @returns the current texture
505
+ */
483
506
  AdvancedDynamicTexture.prototype.addControl = function (control) {
484
507
  this._rootContainer.addControl(control);
485
508
  return this;
486
509
  };
487
510
  /**
488
- * Removes a control from the root container
489
- * @param control defines the control to remove
490
- * @returns the current texture
491
- */
511
+ * Removes a control from the root container
512
+ * @param control defines the control to remove
513
+ * @returns the current texture
514
+ */
492
515
  AdvancedDynamicTexture.prototype.removeControl = function (control) {
493
516
  this._rootContainer.removeControl(control);
494
517
  return this;
495
518
  };
496
519
  /**
497
- * Release all resources
498
- */
520
+ * Moves overlapped controls towards a position where it is not overlapping anymore.
521
+ * Please note that this method alters linkOffsetXInPixels and linkOffsetYInPixels.
522
+ * @param overlapGroup the overlap group which will be processed or undefined to process all overlap groups
523
+ * @param deltaStep the step size (speed) to reach the target non overlapping position (default 0.1)
524
+ * @param repelFactor how much is the control repelled by other controls
525
+ */
526
+ AdvancedDynamicTexture.prototype.moveToNonOverlappedPosition = function (overlapGroup, deltaStep, repelFactor) {
527
+ if (deltaStep === void 0) { deltaStep = 1; }
528
+ if (repelFactor === void 0) { repelFactor = 1; }
529
+ var controlsForGroup;
530
+ if (Array.isArray(overlapGroup)) {
531
+ controlsForGroup = overlapGroup;
532
+ }
533
+ else {
534
+ var descendants = this.getDescendants(true);
535
+ // get only the controls with an overlapGroup property set
536
+ // if the overlapGroup parameter is set, filter the controls and get only the controls belonging to that overlapGroup
537
+ controlsForGroup = overlapGroup === undefined ? descendants.filter(function (c) { return c.overlapGroup !== undefined; }) : descendants.filter(function (c) { return c.overlapGroup === overlapGroup; });
538
+ }
539
+ controlsForGroup.forEach(function (control1) {
540
+ var _a;
541
+ var velocity = Vector2.Zero();
542
+ var center = new Vector2(control1.centerX, control1.centerY);
543
+ controlsForGroup.forEach(function (control2) {
544
+ if (control1 !== control2 && AdvancedDynamicTexture._Overlaps(control1, control2)) {
545
+ // if the two controls overlaps get a direction vector from one control's center to another control's center
546
+ var diff = center.subtract(new Vector2(control2.centerX, control2.centerY));
547
+ var diffLength = diff.length();
548
+ if (diffLength > 0) {
549
+ // calculate the velocity
550
+ velocity = velocity.add(diff.normalize().scale(repelFactor / diffLength));
551
+ }
552
+ }
553
+ });
554
+ if (velocity.length() > 0) {
555
+ // move the control along the direction vector away from the overlapping control
556
+ velocity = velocity.normalize().scale(deltaStep * ((_a = control1.overlapDeltaMultiplier) !== null && _a !== void 0 ? _a : 1));
557
+ control1.linkOffsetXInPixels += velocity.x;
558
+ control1.linkOffsetYInPixels += velocity.y;
559
+ }
560
+ });
561
+ };
562
+ /**
563
+ * Release all resources
564
+ */
499
565
  AdvancedDynamicTexture.prototype.dispose = function () {
500
566
  var scene = this.getScene();
501
567
  if (!scene) {
@@ -565,40 +631,40 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
565
631
  this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
566
632
  };
567
633
  /** @hidden */
568
- AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
569
- var engine = scene.getEngine();
570
- return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
634
+ AdvancedDynamicTexture.prototype._getGlobalViewport = function () {
635
+ var size = this.getSize();
636
+ var globalViewPort = this._fullscreenViewport.toGlobal(size.width, size.height);
637
+ var targetX = Math.round(globalViewPort.width * (1 / this.rootContainer.scaleX));
638
+ var targetY = Math.round(globalViewPort.height * (1 / this.rootContainer.scaleY));
639
+ globalViewPort.x += (globalViewPort.width - targetX) / 2;
640
+ globalViewPort.y += (globalViewPort.height - targetY) / 2;
641
+ globalViewPort.width = targetX;
642
+ globalViewPort.height = targetY;
643
+ return globalViewPort;
571
644
  };
572
645
  /**
573
- * Get screen coordinates for a vector3
574
- * @param position defines the position to project
575
- * @param worldMatrix defines the world matrix to use
576
- * @returns the projected position
577
- */
646
+ * Get screen coordinates for a vector3
647
+ * @param position defines the position to project
648
+ * @param worldMatrix defines the world matrix to use
649
+ * @returns the projected position
650
+ */
578
651
  AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
579
- var scene = this.getScene();
580
- if (!scene) {
581
- return Vector2.Zero();
582
- }
583
- var globalViewport = this._getGlobalViewport(scene);
584
- var projectedPosition = Vector3.Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
585
- projectedPosition.scaleInPlace(this.renderScale);
586
- return new Vector2(projectedPosition.x, projectedPosition.y);
652
+ var result = this.getProjectedPositionWithZ(position, worldMatrix);
653
+ return new Vector2(result.x, result.y);
587
654
  };
588
655
  /**
589
- * Get screen coordinates for a vector3
590
- * @param position defines the position to project
591
- * @param worldMatrix defines the world matrix to use
592
- * @returns the projected position with Z
593
- */
656
+ * Get screen coordinates for a vector3
657
+ * @param position defines the position to project
658
+ * @param worldMatrix defines the world matrix to use
659
+ * @returns the projected position with Z
660
+ */
594
661
  AdvancedDynamicTexture.prototype.getProjectedPositionWithZ = function (position, worldMatrix) {
595
662
  var scene = this.getScene();
596
663
  if (!scene) {
597
664
  return Vector3.Zero();
598
665
  }
599
- var globalViewport = this._getGlobalViewport(scene);
666
+ var globalViewport = this._getGlobalViewport();
600
667
  var projectedPosition = Vector3.Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
601
- projectedPosition.scaleInPlace(this.renderScale);
602
668
  return new Vector3(projectedPosition.x, projectedPosition.y, projectedPosition.z);
603
669
  };
604
670
  AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
@@ -612,7 +678,7 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
612
678
  if (!scene) {
613
679
  return;
614
680
  }
615
- var globalViewport = this._getGlobalViewport(scene);
681
+ var globalViewport = this._getGlobalViewport();
616
682
  var _loop_1 = function (control) {
617
683
  if (!control.isVisible) {
618
684
  return "continue";
@@ -631,11 +697,8 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
631
697
  return "continue";
632
698
  }
633
699
  control.notRenderable = false;
634
- // Account for RenderScale.
635
- projectedPosition.scaleInPlace(this_1.renderScale);
636
700
  control._moveToProjectedPosition(projectedPosition);
637
701
  };
638
- var this_1 = this;
639
702
  for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
640
703
  var control = _a[_i];
641
704
  _loop_1(control);
@@ -646,7 +709,7 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
646
709
  }
647
710
  this._isDirty = false;
648
711
  this._render();
649
- this.update(this.applyYInversionOnUpdate, this.premulAlpha);
712
+ this.update(this.applyYInversionOnUpdate, this.premulAlpha, AdvancedDynamicTexture.AllowGPUOptimizations);
650
713
  };
651
714
  AdvancedDynamicTexture.prototype._render = function () {
652
715
  var textureSize = this.getSize();
@@ -704,6 +767,9 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
704
767
  var textureSize = this.getSize();
705
768
  if (this._isFullscreen) {
706
769
  var camera = scene.cameraToUseForPointers || scene.activeCamera;
770
+ if (!camera) {
771
+ return;
772
+ }
707
773
  var viewport = camera.viewport;
708
774
  x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
709
775
  y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
@@ -714,7 +780,9 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
714
780
  }
715
781
  this._cursorChanged = false;
716
782
  if (!this._rootContainer._processPicking(x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY)) {
717
- this._changeCursor("");
783
+ if (!scene.doNotHandleCursors) {
784
+ this._changeCursor("");
785
+ }
718
786
  if (type === PointerEventTypes.POINTERMOVE) {
719
787
  if (this._lastControlOver[pointerId]) {
720
788
  this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId], pi);
@@ -722,7 +790,7 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
722
790
  }
723
791
  }
724
792
  }
725
- if (!this._cursorChanged) {
793
+ if (!this._cursorChanged && !scene.doNotHandleCursors) {
726
794
  this._changeCursor("");
727
795
  }
728
796
  this._manageFocus();
@@ -753,16 +821,13 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
753
821
  }
754
822
  var tempViewport = new Viewport(0, 0, 0, 0);
755
823
  this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
756
- if (scene.isPointerCaptured((pi.event).pointerId)) {
824
+ if (scene.isPointerCaptured(pi.event.pointerId)) {
757
825
  return;
758
826
  }
759
- if (pi.type !== PointerEventTypes.POINTERMOVE
760
- && pi.type !== PointerEventTypes.POINTERUP
761
- && pi.type !== PointerEventTypes.POINTERDOWN
762
- && pi.type !== PointerEventTypes.POINTERWHEEL) {
763
- return;
764
- }
765
- if (!scene) {
827
+ if (pi.type !== PointerEventTypes.POINTERMOVE &&
828
+ pi.type !== PointerEventTypes.POINTERUP &&
829
+ pi.type !== PointerEventTypes.POINTERDOWN &&
830
+ pi.type !== PointerEventTypes.POINTERWHEEL) {
766
831
  return;
767
832
  }
768
833
  if (pi.type === PointerEventTypes.POINTERMOVE && pi.event.pointerId) {
@@ -770,6 +835,7 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
770
835
  }
771
836
  var camera = scene.cameraToUseForPointers || scene.activeCamera;
772
837
  var engine = scene.getEngine();
838
+ var originalCameraToUseForPointers = scene.cameraToUseForPointers;
773
839
  if (!camera) {
774
840
  tempViewport.x = 0;
775
841
  tempViewport.y = 0;
@@ -777,7 +843,31 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
777
843
  tempViewport.height = engine.getRenderHeight();
778
844
  }
779
845
  else {
780
- camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
846
+ if (camera.rigCameras.length) {
847
+ // rig camera - we need to find the camera to use for this event
848
+ var rigViewport_1 = new Viewport(0, 0, 1, 1);
849
+ camera.rigCameras.forEach(function (rigCamera) {
850
+ // generate the viewport of this camera
851
+ rigCamera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), rigViewport_1);
852
+ var x = scene.pointerX / engine.getHardwareScalingLevel() - rigViewport_1.x;
853
+ var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - rigViewport_1.y - rigViewport_1.height);
854
+ // check if the pointer is in the camera's viewport
855
+ if (x < 0 || y < 0 || x > rigViewport_1.width || y > rigViewport_1.height) {
856
+ // out of viewport - don't use this camera
857
+ return;
858
+ }
859
+ // set the camera to use for pointers until this pointer loop is over
860
+ scene.cameraToUseForPointers = rigCamera;
861
+ // set the viewport
862
+ tempViewport.x = rigViewport_1.x;
863
+ tempViewport.y = rigViewport_1.y;
864
+ tempViewport.width = rigViewport_1.width;
865
+ tempViewport.height = rigViewport_1.height;
866
+ });
867
+ }
868
+ else {
869
+ camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
870
+ }
781
871
  }
782
872
  var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
783
873
  var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
@@ -789,13 +879,15 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
789
879
  if (_this._shouldBlockPointer) {
790
880
  pi.skipOnPointerObservable = _this._shouldBlockPointer;
791
881
  }
882
+ // if overridden by a rig camera - reset back to the original value
883
+ scene.cameraToUseForPointers = originalCameraToUseForPointers;
792
884
  });
793
885
  this._attachToOnPointerOut(scene);
794
886
  this._attachToOnBlur(scene);
795
887
  };
796
888
  /**
797
- * Register the clipboard Events onto the canvas
798
- */
889
+ * Register the clipboard Events onto the canvas
890
+ */
799
891
  AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
800
892
  self.addEventListener("copy", this.onClipboardCopy, false);
801
893
  self.addEventListener("cut", this.onClipboardCut, false);
@@ -810,10 +902,10 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
810
902
  self.removeEventListener("paste", this.onClipboardPaste);
811
903
  };
812
904
  /**
813
- * Connect the texture to a hosting mesh to enable interactions
814
- * @param mesh defines the mesh to attach to
815
- * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
816
- */
905
+ * Connect the texture to a hosting mesh to enable interactions
906
+ * @param mesh defines the mesh to attach to
907
+ * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
908
+ */
817
909
  AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
818
910
  var _this = this;
819
911
  if (supportPointerMove === void 0) { supportPointerMove = true; }
@@ -822,17 +914,21 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
822
914
  return;
823
915
  }
824
916
  this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
825
- if (pi.type !== PointerEventTypes.POINTERMOVE
826
- && pi.type !== PointerEventTypes.POINTERUP
827
- && pi.type !== PointerEventTypes.POINTERDOWN) {
917
+ if (pi.type !== PointerEventTypes.POINTERMOVE &&
918
+ pi.type !== PointerEventTypes.POINTERUP &&
919
+ pi.type !== PointerEventTypes.POINTERDOWN &&
920
+ pi.type !== PointerEventTypes.POINTERWHEEL) {
828
921
  return;
829
922
  }
923
+ if (pi.type === PointerEventTypes.POINTERMOVE && pi.event.pointerId) {
924
+ _this._defaultMousePointerId = pi.event.pointerId; // This is required to make sure we have the correct pointer ID for wheel
925
+ }
830
926
  var pointerId = pi.event.pointerId || _this._defaultMousePointerId;
831
927
  if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
832
928
  var uv = pi.pickInfo.getTextureCoordinates();
833
929
  if (uv) {
834
930
  var size = _this.getSize();
835
- _this._doPicking(uv.x * size.width, (_this.applyYInversionOnUpdate ? (1.0 - uv.y) : uv.y) * size.height, pi, pi.type, pointerId, pi.event.button);
931
+ _this._doPicking(uv.x * size.width, (_this.applyYInversionOnUpdate ? 1.0 - uv.y : uv.y) * size.height, pi, pi.type, pointerId, pi.event.button, pi.event.deltaX, pi.event.deltaY);
836
932
  }
837
933
  }
838
934
  else if (pi.type === PointerEventTypes.POINTERUP) {
@@ -875,9 +971,9 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
875
971
  this._attachToOnBlur(scene);
876
972
  };
877
973
  /**
878
- * Move the focus to a specific control
879
- * @param control defines the control which will receive the focus
880
- */
974
+ * Move the focus to a specific control
975
+ * @param control defines the control which will receive the focus
976
+ */
881
977
  AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
882
978
  this.focusedControl = control;
883
979
  this._lastPickedControl = control;
@@ -919,6 +1015,7 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
919
1015
  var key = _a[0], value = _a[1];
920
1016
  value._onCanvasBlur();
921
1017
  });
1018
+ _this.focusedControl = null;
922
1019
  _this._lastControlDown = {};
923
1020
  });
924
1021
  };
@@ -927,8 +1024,11 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
927
1024
  * @returns an object with the JSON serialized data
928
1025
  */
929
1026
  AdvancedDynamicTexture.prototype.serializeContent = function () {
1027
+ var size = this.getSize();
930
1028
  var serializationObject = {
931
- root: {}
1029
+ root: {},
1030
+ width: size.width,
1031
+ height: size.height,
932
1032
  };
933
1033
  this._rootContainer.serialize(serializationObject.root);
934
1034
  return serializationObject;
@@ -936,16 +1036,25 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
936
1036
  /**
937
1037
  * Recreate the content of the ADT from a JSON object
938
1038
  * @param serializedObject define the JSON serialized object to restore from
1039
+ * @param scaleToSize defines whether to scale to texture to the saved size
939
1040
  */
940
- AdvancedDynamicTexture.prototype.parseContent = function (serializedObject) {
1041
+ AdvancedDynamicTexture.prototype.parseContent = function (serializedObject, scaleToSize) {
941
1042
  this._rootContainer = Control.Parse(serializedObject.root, this);
1043
+ if (scaleToSize) {
1044
+ var width = serializedObject.width;
1045
+ var height = serializedObject.height;
1046
+ if (typeof width === "number" && typeof height === "number" && width >= 0 && height >= 0) {
1047
+ this.scaleTo(width, height);
1048
+ }
1049
+ }
942
1050
  };
943
1051
  /**
944
1052
  * Recreate the content of the ADT from a snippet saved by the GUI editor
945
1053
  * @param snippetId defines the snippet to load
1054
+ * @param scaleToSize defines whether to scale to texture to the saved size
946
1055
  * @returns a promise that will resolve on success
947
1056
  */
948
- AdvancedDynamicTexture.prototype.parseFromSnippetAsync = function (snippetId) {
1057
+ AdvancedDynamicTexture.prototype.parseFromSnippetAsync = function (snippetId, scaleToSize) {
949
1058
  var _this = this;
950
1059
  if (snippetId === "_BLANK") {
951
1060
  return Promise.resolve();
@@ -957,7 +1066,7 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
957
1066
  if (request.status == 200) {
958
1067
  var snippet = JSON.parse(JSON.parse(request.responseText).jsonPayload);
959
1068
  var serializationObject = JSON.parse(snippet.gui);
960
- _this.parseContent(serializationObject);
1069
+ _this.parseContent(serializationObject, scaleToSize);
961
1070
  _this.snippetId = snippetId;
962
1071
  resolve();
963
1072
  }
@@ -970,7 +1079,49 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
970
1079
  request.send();
971
1080
  });
972
1081
  };
1082
+ /**
1083
+ * Recreate the content of the ADT from a url json
1084
+ * @param url defines the url to load
1085
+ * @param scaleToSize defines whether to scale to texture to the saved size
1086
+ * @returns a promise that will resolve on success
1087
+ */
1088
+ AdvancedDynamicTexture.prototype.parseFromURLAsync = function (url, scaleToSize) {
1089
+ var _this = this;
1090
+ if (url === "") {
1091
+ return Promise.resolve();
1092
+ }
1093
+ return new Promise(function (resolve, reject) {
1094
+ var request = new WebRequest();
1095
+ request.addEventListener("readystatechange", function () {
1096
+ if (request.readyState == 4) {
1097
+ if (request.status == 200) {
1098
+ var gui = request.responseText;
1099
+ var serializationObject = JSON.parse(gui);
1100
+ _this.parseContent(serializationObject, scaleToSize);
1101
+ resolve();
1102
+ }
1103
+ else {
1104
+ reject("Unable to load");
1105
+ }
1106
+ }
1107
+ });
1108
+ request.open("GET", url);
1109
+ request.send();
1110
+ });
1111
+ };
973
1112
  // Statics
1113
+ /**
1114
+ * Compares two rectangle based controls for pixel overlap
1115
+ * @param control1 The first control to compare
1116
+ * @param control2 The second control to compare
1117
+ * @returns true if overlaps, otherwise false
1118
+ */
1119
+ AdvancedDynamicTexture._Overlaps = function (control1, control2) {
1120
+ return !(control1.centerX > control2.centerX + control2.widthInPixels ||
1121
+ control1.centerX + control1.widthInPixels < control2.centerX ||
1122
+ control1.centerY + control1.heightInPixels < control2.centerY ||
1123
+ control1.centerY > control2.centerY + control2.heightInPixels);
1124
+ };
974
1125
  /**
975
1126
  * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
976
1127
  * @param mesh defines the mesh which will receive the texture
@@ -1022,33 +1173,43 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
1022
1173
  return result;
1023
1174
  };
1024
1175
  /**
1025
- * Creates a new AdvancedDynamicTexture in fullscreen mode.
1026
- * In this mode the texture will rely on a layer for its rendering.
1027
- * This allows it to be treated like any other layer.
1028
- * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
1029
- * LayerMask is set through advancedTexture.layer.layerMask
1030
- * @param name defines name for the texture
1031
- * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
1032
- * @param scene defines the hsoting scene
1033
- * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
1034
- * @returns a new AdvancedDynamicTexture
1035
- */
1036
- AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
1176
+ * Creates a new AdvancedDynamicTexture in fullscreen mode.
1177
+ * In this mode the texture will rely on a layer for its rendering.
1178
+ * This allows it to be treated like any other layer.
1179
+ * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
1180
+ * LayerMask is set through advancedTexture.layer.layerMask
1181
+ * @param name defines name for the texture
1182
+ * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
1183
+ * @param scene defines the hosting scene
1184
+ * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
1185
+ * @param adaptiveScaling defines whether to automatically scale root to match hardwarescaling (false by default)
1186
+ * @returns a new AdvancedDynamicTexture
1187
+ */
1188
+ AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling, adaptiveScaling) {
1037
1189
  if (foreground === void 0) { foreground = true; }
1038
1190
  if (scene === void 0) { scene = null; }
1039
1191
  if (sampling === void 0) { sampling = Texture.BILINEAR_SAMPLINGMODE; }
1192
+ if (adaptiveScaling === void 0) { adaptiveScaling = false; }
1040
1193
  var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
1041
1194
  // Display
1042
- var layer = new Layer(name + "_layer", null, scene, !foreground);
1195
+ var resultScene = result.getScene();
1196
+ var layer = new Layer(name + "_layer", null, resultScene, !foreground);
1043
1197
  layer.texture = result;
1044
1198
  result._layerToDispose = layer;
1045
1199
  result._isFullscreen = true;
1200
+ if (adaptiveScaling && resultScene) {
1201
+ var newScale = 1 / resultScene.getEngine().getHardwareScalingLevel();
1202
+ result._rootContainer.scaleX = newScale;
1203
+ result._rootContainer.scaleY = newScale;
1204
+ }
1046
1205
  // Attach
1047
1206
  result.attach();
1048
1207
  return result;
1049
1208
  };
1050
1209
  /** Define the Uurl to load snippets */
1051
1210
  AdvancedDynamicTexture.SnippetUrl = "https://snippet.babylonjs.com";
1211
+ /** Indicates if some optimizations can be performed in GUI GPU management (the downside is additional memory/GPU texture memory used) */
1212
+ AdvancedDynamicTexture.AllowGPUOptimizations = true;
1052
1213
  return AdvancedDynamicTexture;
1053
1214
  }(DynamicTexture));
1054
1215
  export { AdvancedDynamicTexture };