Skip to content
1 change: 1 addition & 0 deletions dist/preview release/what's new.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
- Optional camera gaze mode added to the pointer selection feature ([RaananW](https://github.com/RaananW))
- Exposing feature points when running on top of BabylonNative ([Alex-MSFT](https://github.com/Alex-MSFT))
- WebXR hit test can now define different entity type for the results ([#8687](https://github.com/BabylonJS/Babylon.js/issues/8687)) ([RaananW](https://github.com/RaananW))
- Expose the overlay to which the XR Enter/Exit buttons are added to ([#8754](https://github.com/BabylonJS/Babylon.js/issues/8754)) ([RaananW](https://github.com/RaananW))
- WebXR hand-tracking module is available, able to track hand-joints on selected devices including physics interactions ([RaananW](https://github.com/RaananW))

### Collisions
Expand Down
18 changes: 11 additions & 7 deletions src/XR/webXREnterExitUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ export class WebXREnterExitUIOptions {
export class WebXREnterExitUI implements IDisposable {
private _activeButton: Nullable<WebXREnterExitUIButton> = null;
private _buttons: Array<WebXREnterExitUIButton> = [];
private _overlay: HTMLDivElement;
/**
* The HTML Div Element to which buttons are added.
*/
public readonly overlay: HTMLDivElement;

/**
* Fired every time the active button is changed.
Expand All @@ -90,8 +93,9 @@ export class WebXREnterExitUI implements IDisposable {
/** version of the options passed to this UI */
public options: WebXREnterExitUIOptions
) {
this._overlay = document.createElement("div");
this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
this.overlay = document.createElement("div");
this.overlay.classList.add('xr-button-overlay');
this.overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";

// if served over HTTP, warn people.
// Hopefully the browsers will catch up
Expand Down Expand Up @@ -131,7 +135,7 @@ export class WebXREnterExitUI implements IDisposable {

var renderCanvas = scene.getEngine().getInputElement();
if (renderCanvas && renderCanvas.parentNode) {
renderCanvas.parentNode.appendChild(this._overlay);
renderCanvas.parentNode.appendChild(this.overlay);
scene.onDisposeObservable.addOnce(() => {
this.dispose();
});
Expand All @@ -158,7 +162,7 @@ export class WebXREnterExitUI implements IDisposable {
return Promise.all(supportedPromises).then((results) => {
results.forEach((supported, i) => {
if (supported) {
ui._overlay.appendChild(ui._buttons[i].element);
ui.overlay.appendChild(ui._buttons[i].element);
ui._buttons[i].element.onclick = async () => {
if (helper.state == WebXRState.IN_XR) {
await helper.exitXRAsync();
Expand Down Expand Up @@ -192,8 +196,8 @@ export class WebXREnterExitUI implements IDisposable {
*/
public dispose() {
var renderCanvas = this.scene.getEngine().getInputElement();
if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this._overlay)) {
renderCanvas.parentNode.removeChild(this._overlay);
if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this.overlay)) {
renderCanvas.parentNode.removeChild(this.overlay);
}
this.activeButtonChangedObservable.clear();
}
Expand Down