From 080e9e7d3ec2dc8c2a0e5c7ccc84edb4ebd8abc6 Mon Sep 17 00:00:00 2001 From: goynov Date: Thu, 16 Apr 2026 18:48:00 +0300 Subject: [PATCH] fix dashboard position in XR mode --- src/lib/Dashboard.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/lib/Dashboard.js b/src/lib/Dashboard.js index 306ec42..0644cb8 100644 --- a/src/lib/Dashboard.js +++ b/src/lib/Dashboard.js @@ -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;