fix dashboard position in XR mode

This commit is contained in:
2026-04-16 18:48:00 +03:00
parent aa1fcb121f
commit 080e9e7d3e
+13 -3
View File
@@ -116,10 +116,18 @@ class DashBoard extends EventManager {
pointsText.position.set(0.86 * dashWidth/2, 0.47 * dashHeight, -0.001);
dash.add(pointsText);
engine.renderer.xr.addEventListener('sessionstart', this.orient)
this.orient = function(){
dash.quaternion.copy(engine.camera.quaternion)
dash.position.copy(engine.camera.position)
dash.translateZ(-dashDistance -(dashHeight/2)/Math.tan(engine.camera.fov/2 * Math.PI/180) * engine.camera.zoom);
let object = engine.camera, dk = 1;
if (engine.renderer.xr.isPresenting){
dk = 17;
}
// dash.quaternion.copy(object.quaternion)
dash.rotation.y = object.rotation.y;
dash.position.copy(object.position)
//dash.position.set(0,0,0);
dash.translateZ(-dashDistance * dk -(dashHeight/2)/Math.tan(engine.camera.fov/2 * Math.PI/180) * engine.camera.zoom);
}
this.orient();
@@ -142,6 +150,7 @@ class DashBoard extends EventManager {
this.updateText = async function(t, params = {}){
if (!textPlane) return;
await Utils.killWait(this.#textTimeout);
if (!!t) this.orient();
textPlane.visible = !!t;
engine.motionQueue.clear(text);
text.text = t;
@@ -231,6 +240,7 @@ class DashBoard extends EventManager {
//dashPlacement, rotate = false, plane = false
this.attach = (object, opts = {})=>{
this.orient();
this.cameraFix = engine.hero.cameraZ;
engine.hero.cameraZ = 6;
hud.visible = true;