From d27302ea42e56b74c6cb9ca34eb561cb35e70a24 Mon Sep 17 00:00:00 2001 From: goynov Date: Sat, 11 Apr 2026 21:15:37 +0300 Subject: [PATCH] #39 --- src/lib/Dashboard.js | 10 ++++++---- src/lib/PointerControls.js | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/lib/Dashboard.js b/src/lib/Dashboard.js index db72c14..4b0c0ee 100644 --- a/src/lib/Dashboard.js +++ b/src/lib/Dashboard.js @@ -26,7 +26,7 @@ class DashBoard extends EventManager { dash.renderOrder = 1000; const k = 3.11; const dashWidth = engine.aspect * k, dashHeight = k; - const dashDistance = 1.77; + const dashDistance = 0.11; this.width = dashWidth; this.height = dashHeight; @@ -114,11 +114,13 @@ class DashBoard extends EventManager { pointsText.position.set(0.86 * dashWidth/2, 0.47 * dashHeight, -0.001); dash.add(pointsText); - //engine.addEventListener('beforeRender', ()=>{ + this.orient = function(){ dash.quaternion.copy(engine.camera.quaternion) dash.position.copy(engine.camera.position) - dash.translateZ(-dashDistance -0.75/Math.tan(engine.camera.fov/2 * Math.PI/180) * engine.camera.zoom); - //}) + dash.translateZ(-dashDistance -(dashHeight/2)/Math.tan(engine.camera.fov/2 * Math.PI/180) * engine.camera.zoom); + } + + this.orient(); this.pointer = new Mesh( new RingGeometry(dashHeight * 0.002, dashHeight * 0.005), diff --git a/src/lib/PointerControls.js b/src/lib/PointerControls.js index 56ca56f..11ff04a 100644 --- a/src/lib/PointerControls.js +++ b/src/lib/PointerControls.js @@ -209,6 +209,7 @@ function onMouseWheel( event ){ if (this.engine.camera.fov >= 45){ this.unlock(); } + this.engine.dashboard?.orient(); } } @@ -220,6 +221,9 @@ function onPointerlockChange() { this.isLocked = false; this.dispatchEvent( { type: 'unlock' } ); } + this.engine.camera.fov = 45; + this.engine.camera.updateProjectionMatrix(); + this.engine.dashboard?.orient(); //this.engine.cameraRig.rotation.y = this.isLocked ? 0 : Math.PI; }