@babylonjs/gui 5.0.0-alpha.8 → 5.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/2D/adtInstrumentation.js +1 -1
- package/2D/advancedDynamicTexture.d.ts +165 -125
- package/2D/advancedDynamicTexture.js +342 -181
- package/2D/advancedDynamicTexture.js.map +1 -1
- package/2D/controls/button.d.ts +8 -0
- package/2D/controls/button.js +33 -10
- package/2D/controls/button.js.map +1 -1
- package/2D/controls/checkbox.d.ts +2 -1
- package/2D/controls/checkbox.js +10 -8
- package/2D/controls/checkbox.js.map +1 -1
- package/2D/controls/colorpicker.d.ts +4 -3
- package/2D/controls/colorpicker.js +40 -23
- package/2D/controls/colorpicker.js.map +1 -1
- package/2D/controls/container.d.ts +16 -5
- package/2D/controls/container.js +91 -13
- package/2D/controls/container.js.map +1 -1
- package/2D/controls/control.d.ts +103 -44
- package/2D/controls/control.js +278 -129
- package/2D/controls/control.js.map +1 -1
- package/2D/controls/displayGrid.d.ts +2 -1
- package/2D/controls/displayGrid.js +6 -6
- package/2D/controls/displayGrid.js.map +1 -1
- package/2D/controls/ellipse.d.ts +5 -3
- package/2D/controls/ellipse.js +9 -5
- package/2D/controls/ellipse.js.map +1 -1
- package/2D/controls/focusableButton.d.ts +1 -0
- package/2D/controls/focusableButton.js +9 -6
- package/2D/controls/focusableButton.js.map +1 -1
- package/2D/controls/grid.d.ts +13 -2
- package/2D/controls/grid.js +108 -24
- package/2D/controls/grid.js.map +1 -1
- package/2D/controls/image.d.ts +5 -4
- package/2D/controls/image.js +52 -31
- package/2D/controls/image.js.map +1 -1
- package/2D/controls/index.js +29 -29
- package/2D/controls/inputPassword.js +4 -4
- package/2D/controls/inputPassword.js.map +1 -1
- package/2D/controls/inputText.d.ts +2 -1
- package/2D/controls/inputText.js +40 -14
- package/2D/controls/inputText.js.map +1 -1
- package/2D/controls/line.d.ts +3 -2
- package/2D/controls/line.js +8 -8
- package/2D/controls/line.js.map +1 -1
- package/2D/controls/multiLine.d.ts +4 -3
- package/2D/controls/multiLine.js +6 -6
- package/2D/controls/multiLine.js.map +1 -1
- package/2D/controls/radioButton.d.ts +2 -1
- package/2D/controls/radioButton.js +10 -7
- package/2D/controls/radioButton.js.map +1 -1
- package/2D/controls/rectangle.d.ts +8 -3
- package/2D/controls/rectangle.js +21 -5
- package/2D/controls/rectangle.js.map +1 -1
- package/2D/controls/scrollViewers/scrollViewer.d.ts +3 -2
- package/2D/controls/scrollViewers/scrollViewer.js +9 -9
- package/2D/controls/scrollViewers/scrollViewer.js.map +1 -1
- package/2D/controls/scrollViewers/scrollViewerWindow.d.ts +4 -3
- package/2D/controls/scrollViewers/scrollViewerWindow.js +4 -4
- package/2D/controls/scrollViewers/scrollViewerWindow.js.map +1 -1
- package/2D/controls/selector.js +8 -8
- package/2D/controls/selector.js.map +1 -1
- package/2D/controls/sliders/baseSlider.d.ts +1 -1
- package/2D/controls/sliders/baseSlider.js +12 -10
- package/2D/controls/sliders/baseSlider.js.map +1 -1
- package/2D/controls/sliders/imageBasedSlider.d.ts +10 -1
- package/2D/controls/sliders/imageBasedSlider.js +29 -5
- package/2D/controls/sliders/imageBasedSlider.js.map +1 -1
- package/2D/controls/sliders/imageScrollBar.d.ts +2 -1
- package/2D/controls/sliders/imageScrollBar.js +3 -3
- package/2D/controls/sliders/imageScrollBar.js.map +1 -1
- package/2D/controls/sliders/scrollBar.d.ts +2 -1
- package/2D/controls/sliders/scrollBar.js +3 -3
- package/2D/controls/sliders/scrollBar.js.map +1 -1
- package/2D/controls/sliders/slider.d.ts +2 -1
- package/2D/controls/sliders/slider.js +4 -4
- package/2D/controls/sliders/slider.js.map +1 -1
- package/2D/controls/stackPanel.d.ts +10 -3
- package/2D/controls/stackPanel.js +35 -13
- package/2D/controls/stackPanel.js.map +1 -1
- package/2D/controls/statics.js +3 -3
- package/2D/controls/statics.js.map +1 -1
- package/2D/controls/textBlock.d.ts +16 -9
- package/2D/controls/textBlock.js +75 -34
- package/2D/controls/textBlock.js.map +1 -1
- package/2D/controls/textWrapper.js +2 -2
- package/2D/controls/textWrapper.js.map +1 -1
- package/2D/controls/toggleButton.d.ts +1 -13
- package/2D/controls/toggleButton.js +29 -38
- package/2D/controls/toggleButton.js.map +1 -1
- package/2D/controls/virtualKeyboard.js +5 -5
- package/2D/controls/virtualKeyboard.js.map +1 -1
- package/2D/index.d.ts +1 -1
- package/2D/index.js +9 -9
- package/2D/index.js.map +1 -1
- package/2D/math2D.d.ts +5 -0
- package/2D/math2D.js +14 -2
- package/2D/math2D.js.map +1 -1
- package/2D/measure.js +1 -1
- package/2D/measure.js.map +1 -1
- package/2D/multiLinePoint.js +3 -3
- package/2D/style.js +2 -2
- package/2D/valueAndUnit.d.ts +21 -6
- package/2D/valueAndUnit.js +57 -13
- package/2D/valueAndUnit.js.map +1 -1
- package/2D/xmlLoader.d.ts +17 -3
- package/2D/xmlLoader.js +54 -15
- package/2D/xmlLoader.js.map +1 -1
- package/3D/behaviors/defaultBehavior.d.ts +73 -0
- package/3D/behaviors/defaultBehavior.js +122 -0
- package/3D/behaviors/defaultBehavior.js.map +1 -0
- package/3D/controls/abstractButton3D.d.ts +2 -2
- package/3D/controls/abstractButton3D.js +3 -3
- package/3D/controls/abstractButton3D.js.map +1 -1
- package/3D/controls/button3D.d.ts +0 -24
- package/3D/controls/button3D.js +15 -84
- package/3D/controls/button3D.js.map +1 -1
- package/3D/controls/container3D.js +2 -2
- package/3D/controls/contentDisplay3D.d.ts +30 -0
- package/3D/controls/contentDisplay3D.js +79 -0
- package/3D/controls/contentDisplay3D.js.map +1 -0
- package/3D/controls/control3D.d.ts +10 -7
- package/3D/controls/control3D.js +27 -19
- package/3D/controls/control3D.js.map +1 -1
- package/3D/controls/cylinderPanel.js +5 -5
- package/3D/controls/handMenu.d.ts +28 -0
- package/3D/controls/handMenu.js +48 -0
- package/3D/controls/handMenu.js.map +1 -0
- package/3D/controls/holographicBackplate.d.ts +48 -0
- package/3D/controls/holographicBackplate.js +121 -0
- package/3D/controls/holographicBackplate.js.map +1 -0
- package/3D/controls/holographicButton.d.ts +1 -1
- package/3D/controls/holographicButton.js +35 -31
- package/3D/controls/holographicButton.js.map +1 -1
- package/3D/controls/holographicSlate.d.ts +118 -0
- package/3D/controls/holographicSlate.js +365 -0
- package/3D/controls/holographicSlate.js.map +1 -0
- package/3D/controls/index.d.ts +7 -0
- package/3D/controls/index.js +22 -15
- package/3D/controls/index.js.map +1 -1
- package/3D/controls/meshButton3D.js +2 -2
- package/3D/controls/meshButton3D.js.map +1 -1
- package/3D/controls/nearMenu.d.ts +45 -0
- package/3D/controls/nearMenu.js +111 -0
- package/3D/controls/nearMenu.js.map +1 -0
- package/3D/controls/planePanel.js +3 -3
- package/3D/controls/scatterPanel.js +4 -4
- package/3D/controls/slider3D.d.ts +80 -0
- package/3D/controls/slider3D.js +268 -0
- package/3D/controls/slider3D.js.map +1 -0
- package/3D/controls/spherePanel.js +5 -5
- package/3D/controls/stackPanel3D.js +3 -3
- package/3D/controls/touchButton3D.d.ts +9 -21
- package/3D/controls/touchButton3D.js +52 -224
- package/3D/controls/touchButton3D.js.map +1 -1
- package/3D/controls/touchHolographicButton.d.ts +20 -3
- package/3D/controls/touchHolographicButton.js +137 -67
- package/3D/controls/touchHolographicButton.js.map +1 -1
- package/3D/controls/touchHolographicMenu.d.ts +61 -0
- package/3D/controls/touchHolographicMenu.js +149 -0
- package/3D/controls/touchHolographicMenu.js.map +1 -0
- package/3D/controls/touchMeshButton3D.d.ts +3 -6
- package/3D/controls/touchMeshButton3D.js +6 -14
- package/3D/controls/touchMeshButton3D.js.map +1 -1
- package/3D/controls/touchToggleButton3D.d.ts +35 -0
- package/3D/controls/touchToggleButton3D.js +60 -0
- package/3D/controls/touchToggleButton3D.js.map +1 -0
- package/3D/controls/volumeBasedPanel.d.ts +1 -1
- package/3D/controls/volumeBasedPanel.js +5 -5
- package/3D/controls/volumeBasedPanel.js.map +1 -1
- package/3D/gizmos/gizmoHandle.d.ts +108 -0
- package/3D/gizmos/gizmoHandle.js +210 -0
- package/3D/gizmos/gizmoHandle.js.map +1 -0
- package/3D/gizmos/index.d.ts +2 -0
- package/3D/gizmos/index.js +3 -0
- package/3D/gizmos/index.js.map +1 -0
- package/3D/gizmos/slateGizmo.d.ts +59 -0
- package/3D/gizmos/slateGizmo.js +364 -0
- package/3D/gizmos/slateGizmo.js.map +1 -0
- package/3D/gui3DManager.d.ts +15 -2
- package/3D/gui3DManager.js +62 -41
- package/3D/gui3DManager.js.map +1 -1
- package/3D/index.d.ts +3 -2
- package/3D/index.js +5 -4
- package/3D/index.js.map +1 -1
- package/3D/materials/fluent/fluentMaterial.d.ts +90 -0
- package/3D/materials/fluent/fluentMaterial.js +282 -0
- package/3D/materials/fluent/fluentMaterial.js.map +1 -0
- package/3D/materials/fluent/index.d.ts +1 -0
- package/3D/materials/fluent/index.js +2 -0
- package/3D/materials/fluent/index.js.map +1 -0
- package/3D/materials/{shaders → fluent/shaders}/fluent.fragment.d.ts +0 -0
- package/3D/materials/fluent/shaders/fluent.fragment.js +7 -0
- package/3D/materials/fluent/shaders/fluent.fragment.js.map +1 -0
- package/3D/materials/{shaders → fluent/shaders}/fluent.vertex.d.ts +0 -0
- package/3D/materials/{shaders → fluent/shaders}/fluent.vertex.js +2 -2
- package/3D/materials/fluent/shaders/fluent.vertex.js.map +1 -0
- package/3D/materials/fluentBackplate/fluentBackplateMaterial.d.ts +154 -0
- package/3D/materials/fluentBackplate/fluentBackplateMaterial.js +435 -0
- package/3D/materials/fluentBackplate/fluentBackplateMaterial.js.map +1 -0
- package/3D/materials/fluentBackplate/index.d.ts +1 -0
- package/3D/materials/fluentBackplate/index.js +2 -0
- package/3D/materials/fluentBackplate/index.js.map +1 -0
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.d.ts +5 -0
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.js +7 -0
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.js.map +1 -0
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.d.ts +5 -0
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.js +7 -0
- package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.js.map +1 -0
- package/3D/materials/fluentButton/fluentButtonMaterial.d.ts +189 -0
- package/3D/materials/fluentButton/fluentButtonMaterial.js +538 -0
- package/3D/materials/fluentButton/fluentButtonMaterial.js.map +1 -0
- package/3D/materials/fluentButton/index.d.ts +1 -0
- package/3D/materials/fluentButton/index.js +2 -0
- package/3D/materials/fluentButton/index.js.map +1 -0
- package/3D/materials/fluentButton/shaders/fluentButton.fragment.d.ts +5 -0
- package/3D/materials/fluentButton/shaders/fluentButton.fragment.js +7 -0
- package/3D/materials/fluentButton/shaders/fluentButton.fragment.js.map +1 -0
- package/3D/materials/fluentButton/shaders/fluentButton.vertex.d.ts +5 -0
- package/3D/materials/fluentButton/shaders/fluentButton.vertex.js +7 -0
- package/3D/materials/fluentButton/shaders/fluentButton.vertex.js.map +1 -0
- package/3D/materials/fluentMaterial.d.ts +2 -88
- package/3D/materials/fluentMaterial.js +2 -277
- package/3D/materials/fluentMaterial.js.map +1 -1
- package/3D/materials/handle/handleMaterial.d.ts +68 -0
- package/3D/materials/handle/handleMaterial.js +127 -0
- package/3D/materials/handle/handleMaterial.js.map +1 -0
- package/3D/materials/handle/index.d.ts +1 -0
- package/3D/materials/handle/index.js +2 -0
- package/3D/materials/handle/index.js.map +1 -0
- package/3D/materials/handle/shaders/handle.fragment.d.ts +5 -0
- package/3D/materials/handle/shaders/handle.fragment.js +7 -0
- package/3D/materials/handle/shaders/handle.fragment.js.map +1 -0
- package/3D/materials/handle/shaders/handle.vertex.d.ts +5 -0
- package/3D/materials/handle/shaders/handle.vertex.js +7 -0
- package/3D/materials/handle/shaders/handle.vertex.js.map +1 -0
- package/3D/materials/index.d.ts +5 -1
- package/3D/materials/index.js +5 -1
- package/3D/materials/index.js.map +1 -1
- package/3D/materials/mrdl/index.d.ts +3 -0
- package/3D/materials/mrdl/index.js +4 -0
- package/3D/materials/mrdl/index.js.map +1 -0
- package/3D/materials/mrdl/mrdlBackplateMaterial.d.ts +147 -0
- package/3D/materials/mrdl/mrdlBackplateMaterial.js +410 -0
- package/3D/materials/mrdl/mrdlBackplateMaterial.js.map +1 -0
- package/3D/materials/mrdl/mrdlSliderBarMaterial.d.ts +333 -0
- package/3D/materials/mrdl/mrdlSliderBarMaterial.js +787 -0
- package/3D/materials/mrdl/mrdlSliderBarMaterial.js.map +1 -0
- package/3D/materials/mrdl/mrdlSliderThumbMaterial.d.ts +333 -0
- package/3D/materials/mrdl/mrdlSliderThumbMaterial.js +787 -0
- package/3D/materials/mrdl/mrdlSliderThumbMaterial.js.map +1 -0
- package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.d.ts +5 -0
- package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.js +7 -0
- package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.js.map +1 -0
- package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.d.ts +5 -0
- package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.js +7 -0
- package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.js.map +1 -0
- package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.d.ts +5 -0
- package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.js +7 -0
- package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.js.map +1 -0
- package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.d.ts +5 -0
- package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.js +7 -0
- package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.js.map +1 -0
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.d.ts +5 -0
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.js +7 -0
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.js.map +1 -0
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.d.ts +5 -0
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.js +7 -0
- package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.js.map +1 -0
- package/3D/vector3WithInfo.js +1 -1
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/index.js.map +1 -1
- package/legacy/legacy.js +2 -2
- package/package.json +117 -9
- package/3D/materials/shaders/fluent.fragment.js +0 -7
- package/3D/materials/shaders/fluent.fragment.js.map +0 -1
- 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
|
|
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
|
|
17
|
-
import { Viewport } from
|
|
18
|
-
import { Color3 } from
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
69
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
82
|
-
|
|
82
|
+
* Observable event triggered before layout is evaluated
|
|
83
|
+
*/
|
|
83
84
|
_this.onBeginLayoutObservable = new Observable();
|
|
84
85
|
/**
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
* Observable event triggered after the layout was evaluated
|
|
87
|
+
*/
|
|
87
88
|
_this.onEndLayoutObservable = new Observable();
|
|
88
89
|
/**
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
* Observable event triggered before the texture is rendered
|
|
91
|
+
*/
|
|
91
92
|
_this.onBeginRenderObservable = new Observable();
|
|
92
93
|
/**
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
* Observable event triggered after the texture was rendered
|
|
95
|
+
*/
|
|
95
96
|
_this.onEndRenderObservable = new Observable();
|
|
96
97
|
/**
|
|
97
|
-
|
|
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
|
-
|
|
172
|
-
|
|
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
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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
|
-
|
|
245
|
-
|
|
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
|
-
|
|
264
|
-
|
|
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
|
-
|
|
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 =
|
|
290
|
+
rwidth = this.getSize().width / this._idealWidth;
|
|
289
291
|
}
|
|
290
292
|
if (this._idealHeight) {
|
|
291
|
-
rheight =
|
|
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) {
|
|
298
|
+
if (this._idealWidth) {
|
|
299
|
+
// horizontal
|
|
297
300
|
return rwidth;
|
|
298
301
|
}
|
|
299
|
-
if (this._idealHeight) {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
329
|
-
|
|
330
|
-
|
|
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
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
403
|
-
|
|
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
|
-
|
|
410
|
-
|
|
411
|
-
|
|
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
|
-
|
|
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
|
-
|
|
472
|
-
|
|
473
|
-
|
|
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
|
-
|
|
480
|
-
|
|
481
|
-
|
|
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
|
-
|
|
489
|
-
|
|
490
|
-
|
|
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
|
-
|
|
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 (
|
|
569
|
-
var
|
|
570
|
-
|
|
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
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
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
|
|
580
|
-
|
|
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
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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(
|
|
824
|
+
if (scene.isPointerCaptured(pi.event.pointerId)) {
|
|
757
825
|
return;
|
|
758
826
|
}
|
|
759
|
-
if (pi.type !== PointerEventTypes.POINTERMOVE
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
814
|
-
|
|
815
|
-
|
|
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
|
-
|
|
827
|
-
|
|
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 ?
|
|
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
|
-
|
|
879
|
-
|
|
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
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
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
|
|
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 };
|