@babylonjs/gui 5.0.0-beta.8 → 5.0.0-rc.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/advancedDynamicTexture.d.ts +11 -0
- package/2D/advancedDynamicTexture.js +95 -48
- package/2D/advancedDynamicTexture.js.map +1 -1
- package/2D/controls/container.d.ts +1 -1
- package/2D/controls/container.js.map +1 -1
- package/2D/controls/control.d.ts +7 -7
- package/2D/controls/control.js +12 -12
- package/2D/controls/control.js.map +1 -1
- package/2D/controls/inputText.d.ts +2 -0
- package/2D/controls/inputText.js +2 -1
- package/2D/controls/inputText.js.map +1 -1
- package/2D/controls/sliders/baseSlider.js +1 -1
- package/2D/controls/sliders/baseSlider.js.map +1 -1
- package/2D/controls/textBlock.d.ts +1 -0
- package/2D/controls/textBlock.js +17 -7
- package/2D/controls/textBlock.js.map +1 -1
- package/2D/xmlLoader.js +8 -1
- package/2D/xmlLoader.js.map +1 -1
- package/3D/controls/contentDisplay3D.js +1 -1
- package/3D/controls/contentDisplay3D.js.map +1 -1
- package/3D/controls/holographicSlate.d.ts +45 -35
- package/3D/controls/holographicSlate.js +172 -113
- package/3D/controls/holographicSlate.js.map +1 -1
- package/3D/controls/slider3D.d.ts +1 -0
- package/3D/controls/slider3D.js +6 -6
- package/3D/controls/slider3D.js.map +1 -1
- package/3D/controls/touchButton3D.d.ts +12 -1
- package/3D/controls/touchButton3D.js +43 -4
- package/3D/controls/touchButton3D.js.map +1 -1
- package/3D/controls/touchHolographicButton.d.ts +5 -0
- package/3D/controls/touchHolographicButton.js +17 -4
- package/3D/controls/touchHolographicButton.js.map +1 -1
- package/3D/gizmos/slateGizmo.d.ts +2 -4
- package/3D/gizmos/slateGizmo.js +24 -18
- package/3D/gizmos/slateGizmo.js.map +1 -1
- package/3D/gui3DManager.js.map +1 -1
- package/package.json +2 -2
|
@@ -27,6 +27,7 @@ export declare class AdvancedDynamicTexture extends DynamicTexture {
|
|
|
27
27
|
private _resizeObserver;
|
|
28
28
|
private _preKeyboardObserver;
|
|
29
29
|
private _pointerMoveObserver;
|
|
30
|
+
private _sceneRenderObserver;
|
|
30
31
|
private _pointerObserver;
|
|
31
32
|
private _canvasPointerOutObserver;
|
|
32
33
|
private _canvasBlurObserver;
|
|
@@ -199,6 +200,13 @@ export declare class AdvancedDynamicTexture extends DynamicTexture {
|
|
|
199
200
|
*/
|
|
200
201
|
get clipboardData(): string;
|
|
201
202
|
set clipboardData(value: string);
|
|
203
|
+
/**
|
|
204
|
+
* If set to true, every scene render will trigger a pointer event for the GUI
|
|
205
|
+
* if it is linked to a mesh or has controls linked to a mesh. This will allow
|
|
206
|
+
* you to catch the pointer moving around the GUI due to camera or mesh movements,
|
|
207
|
+
* but it has a performance cost.
|
|
208
|
+
*/
|
|
209
|
+
checkPointerEveryFrame: boolean;
|
|
202
210
|
/**
|
|
203
211
|
* Creates a new AdvancedDynamicTexture
|
|
204
212
|
* @param name defines the name of the texture
|
|
@@ -301,6 +309,7 @@ export declare class AdvancedDynamicTexture extends DynamicTexture {
|
|
|
301
309
|
}, control: Control): void;
|
|
302
310
|
/** @hidden */
|
|
303
311
|
_cleanControlAfterRemoval(control: Control): void;
|
|
312
|
+
private _translateToPicking;
|
|
304
313
|
/** Attach to all scene events required to support pointer events */
|
|
305
314
|
attach(): void;
|
|
306
315
|
/** @hidden */
|
|
@@ -329,6 +338,7 @@ export declare class AdvancedDynamicTexture extends DynamicTexture {
|
|
|
329
338
|
*/
|
|
330
339
|
moveFocusToControl(control: IFocusableControl): void;
|
|
331
340
|
private _manageFocus;
|
|
341
|
+
private _attachPickingToSceneRender;
|
|
332
342
|
private _attachToOnPointerOut;
|
|
333
343
|
private _attachToOnBlur;
|
|
334
344
|
/**
|
|
@@ -410,3 +420,4 @@ export declare class AdvancedDynamicTexture extends DynamicTexture {
|
|
|
410
420
|
*/
|
|
411
421
|
scaleTo(width: number, height: number): void;
|
|
412
422
|
}
|
|
423
|
+
export { IFocusableControl };
|
|
@@ -103,6 +103,13 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
|
103
103
|
* Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
|
|
104
104
|
*/
|
|
105
105
|
_this.applyYInversionOnUpdate = true;
|
|
106
|
+
/**
|
|
107
|
+
* If set to true, every scene render will trigger a pointer event for the GUI
|
|
108
|
+
* if it is linked to a mesh or has controls linked to a mesh. This will allow
|
|
109
|
+
* you to catch the pointer moving around the GUI due to camera or mesh movements,
|
|
110
|
+
* but it has a performance cost.
|
|
111
|
+
*/
|
|
112
|
+
_this.checkPointerEveryFrame = false;
|
|
106
113
|
_this._useInvalidateRectOptimization = true;
|
|
107
114
|
// Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
|
|
108
115
|
_this._invalidatedRectangle = null;
|
|
@@ -576,6 +583,9 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
|
576
583
|
if (this._pointerMoveObserver) {
|
|
577
584
|
scene.onPrePointerObservable.remove(this._pointerMoveObserver);
|
|
578
585
|
}
|
|
586
|
+
if (this._sceneRenderObserver) {
|
|
587
|
+
scene.onBeforeRenderObservable.remove(this._sceneRenderObserver);
|
|
588
|
+
}
|
|
579
589
|
if (this._pointerObserver) {
|
|
580
590
|
scene.onPointerObservable.remove(this._pointerObserver);
|
|
581
591
|
}
|
|
@@ -813,6 +823,61 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
|
813
823
|
this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
|
|
814
824
|
this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
|
|
815
825
|
};
|
|
826
|
+
AdvancedDynamicTexture.prototype._translateToPicking = function (scene, tempViewport, pi) {
|
|
827
|
+
var camera = scene.cameraToUseForPointers || scene.activeCamera;
|
|
828
|
+
var engine = scene.getEngine();
|
|
829
|
+
var originalCameraToUseForPointers = scene.cameraToUseForPointers;
|
|
830
|
+
if (!camera) {
|
|
831
|
+
tempViewport.x = 0;
|
|
832
|
+
tempViewport.y = 0;
|
|
833
|
+
tempViewport.width = engine.getRenderWidth();
|
|
834
|
+
tempViewport.height = engine.getRenderHeight();
|
|
835
|
+
}
|
|
836
|
+
else {
|
|
837
|
+
if (camera.rigCameras.length) {
|
|
838
|
+
// rig camera - we need to find the camera to use for this event
|
|
839
|
+
var rigViewport_1 = new Viewport(0, 0, 1, 1);
|
|
840
|
+
camera.rigCameras.forEach(function (rigCamera) {
|
|
841
|
+
// generate the viewport of this camera
|
|
842
|
+
rigCamera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), rigViewport_1);
|
|
843
|
+
var x = scene.pointerX / engine.getHardwareScalingLevel() - rigViewport_1.x;
|
|
844
|
+
var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - rigViewport_1.y - rigViewport_1.height);
|
|
845
|
+
// check if the pointer is in the camera's viewport
|
|
846
|
+
if (x < 0 || y < 0 || x > rigViewport_1.width || y > rigViewport_1.height) {
|
|
847
|
+
// out of viewport - don't use this camera
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
// set the camera to use for pointers until this pointer loop is over
|
|
851
|
+
scene.cameraToUseForPointers = rigCamera;
|
|
852
|
+
// set the viewport
|
|
853
|
+
tempViewport.x = rigViewport_1.x;
|
|
854
|
+
tempViewport.y = rigViewport_1.y;
|
|
855
|
+
tempViewport.width = rigViewport_1.width;
|
|
856
|
+
tempViewport.height = rigViewport_1.height;
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
else {
|
|
860
|
+
camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
|
|
864
|
+
var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
|
|
865
|
+
this._shouldBlockPointer = false;
|
|
866
|
+
// Do picking modifies _shouldBlockPointer
|
|
867
|
+
if (pi) {
|
|
868
|
+
var pointerId = pi.event.pointerId || this._defaultMousePointerId;
|
|
869
|
+
this._doPicking(x, y, pi, pi.type, pointerId, pi.event.button, pi.event.deltaX, pi.event.deltaY);
|
|
870
|
+
// Avoid overwriting a true skipOnPointerObservable to false
|
|
871
|
+
if (this._shouldBlockPointer) {
|
|
872
|
+
pi.skipOnPointerObservable = this._shouldBlockPointer;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
else {
|
|
876
|
+
this._doPicking(x, y, null, PointerEventTypes.POINTERMOVE, this._defaultMousePointerId, 0);
|
|
877
|
+
}
|
|
878
|
+
// if overridden by a rig camera - reset back to the original value
|
|
879
|
+
scene.cameraToUseForPointers = originalCameraToUseForPointers;
|
|
880
|
+
};
|
|
816
881
|
/** Attach to all scene events required to support pointer events */
|
|
817
882
|
AdvancedDynamicTexture.prototype.attach = function () {
|
|
818
883
|
var _this = this;
|
|
@@ -834,55 +899,9 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
|
834
899
|
if (pi.type === PointerEventTypes.POINTERMOVE && pi.event.pointerId) {
|
|
835
900
|
_this._defaultMousePointerId = pi.event.pointerId; // This is required to make sure we have the correct pointer ID for wheel
|
|
836
901
|
}
|
|
837
|
-
|
|
838
|
-
var engine = scene.getEngine();
|
|
839
|
-
var originalCameraToUseForPointers = scene.cameraToUseForPointers;
|
|
840
|
-
if (!camera) {
|
|
841
|
-
tempViewport.x = 0;
|
|
842
|
-
tempViewport.y = 0;
|
|
843
|
-
tempViewport.width = engine.getRenderWidth();
|
|
844
|
-
tempViewport.height = engine.getRenderHeight();
|
|
845
|
-
}
|
|
846
|
-
else {
|
|
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
|
-
}
|
|
872
|
-
}
|
|
873
|
-
var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
|
|
874
|
-
var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
|
|
875
|
-
_this._shouldBlockPointer = false;
|
|
876
|
-
// Do picking modifies _shouldBlockPointer
|
|
877
|
-
var pointerId = pi.event.pointerId || _this._defaultMousePointerId;
|
|
878
|
-
_this._doPicking(x, y, pi, pi.type, pointerId, pi.event.button, pi.event.deltaX, pi.event.deltaY);
|
|
879
|
-
// Avoid overwriting a true skipOnPointerObservable to false
|
|
880
|
-
if (_this._shouldBlockPointer) {
|
|
881
|
-
pi.skipOnPointerObservable = _this._shouldBlockPointer;
|
|
882
|
-
}
|
|
883
|
-
// if overridden by a rig camera - reset back to the original value
|
|
884
|
-
scene.cameraToUseForPointers = originalCameraToUseForPointers;
|
|
902
|
+
_this._translateToPicking(scene, tempViewport, pi);
|
|
885
903
|
});
|
|
904
|
+
this._attachPickingToSceneRender(scene, function () { return _this._translateToPicking(scene, tempViewport, null); }, false);
|
|
886
905
|
this._attachToOnPointerOut(scene);
|
|
887
906
|
this._attachToOnBlur(scene);
|
|
888
907
|
};
|
|
@@ -968,6 +987,23 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
|
968
987
|
}
|
|
969
988
|
});
|
|
970
989
|
mesh.enablePointerMoveEvents = supportPointerMove;
|
|
990
|
+
this._attachPickingToSceneRender(scene, function () {
|
|
991
|
+
var pointerId = _this._defaultMousePointerId;
|
|
992
|
+
var pick = scene === null || scene === void 0 ? void 0 : scene.pick(scene.pointerX, scene.pointerY);
|
|
993
|
+
if (pick && pick.hit && pick.pickedMesh === mesh) {
|
|
994
|
+
var uv = pick.getTextureCoordinates();
|
|
995
|
+
if (uv) {
|
|
996
|
+
var size = _this.getSize();
|
|
997
|
+
_this._doPicking(uv.x * size.width, (_this.applyYInversionOnUpdate ? 1.0 - uv.y : uv.y) * size.height, null, PointerEventTypes.POINTERMOVE, pointerId, 0);
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
else {
|
|
1001
|
+
if (_this._lastControlOver[pointerId]) {
|
|
1002
|
+
_this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], null, true);
|
|
1003
|
+
}
|
|
1004
|
+
delete _this._lastControlOver[pointerId];
|
|
1005
|
+
}
|
|
1006
|
+
}, true);
|
|
971
1007
|
this._attachToOnPointerOut(scene);
|
|
972
1008
|
this._attachToOnBlur(scene);
|
|
973
1009
|
};
|
|
@@ -996,6 +1032,17 @@ var AdvancedDynamicTexture = /** @class */ (function (_super) {
|
|
|
996
1032
|
}
|
|
997
1033
|
}
|
|
998
1034
|
};
|
|
1035
|
+
AdvancedDynamicTexture.prototype._attachPickingToSceneRender = function (scene, pickFunction, forcePicking) {
|
|
1036
|
+
var _this = this;
|
|
1037
|
+
this._sceneRenderObserver = scene.onBeforeRenderObservable.add(function () {
|
|
1038
|
+
if (!_this.checkPointerEveryFrame) {
|
|
1039
|
+
return;
|
|
1040
|
+
}
|
|
1041
|
+
if (_this._linkedControls.length > 0 || forcePicking) {
|
|
1042
|
+
pickFunction();
|
|
1043
|
+
}
|
|
1044
|
+
});
|
|
1045
|
+
};
|
|
999
1046
|
AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
|
|
1000
1047
|
var _this = this;
|
|
1001
1048
|
this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
|