Is there a worked example of setting up a HolographicSlate so it is initially in front of the user after the user enters an immersive session? I can create one, but it always appears far away, no mater what I do to set the position.
The Playground examples https://playground.babylonjs.com/#SYD2M2#10 https://playground.babylonjs.com/#43YQHC#2 don’t set up for XR.
Hi Doug, thanks for the clear question. The slate gets its initial pose from the active camera when manager.addControl(slate) runs. If that happens before XR starts, it uses the non-XR camera.
The simplest option is to add the slate after the session enters XR:
xr.baseExperience.onStateChangedObservable.add((state) => {
if (state !== BABYLON.WebXRState.IN_XR) {
return;
}
const slate = new BABYLON.GUI.HolographicSlate("slate");
slate.title = "My slate";
manager.addControl(slate);
slate.content = content;
});
This lets the slate place itself in front of the XR camera. Please make sure this runs only once if the user can enter XR more than once. I did not test the linked playgrounds, but this matches the current HolographicSlate setup code.