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