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