From 95c878e9799e1b5db4f4a51b6754276354afd33b Mon Sep 17 00:00:00 2001 From: goynov Date: Sun, 15 Mar 2026 15:54:02 +0200 Subject: [PATCH] #70, #71 --- src/lib/Hero.js | 21 ++++++++++++++++----- src/lib/PointerControls.js | 24 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/lib/Hero.js b/src/lib/Hero.js index 7da6249..66d5c03 100644 --- a/src/lib/Hero.js +++ b/src/lib/Hero.js @@ -95,13 +95,16 @@ class Hero{ this.updateCharacterControls(delta) if (this.engine.renderer.xr.isPresenting){ this.cameraMode = 'fixed' - this.cameraY = this.size.y * 1; + this.engine.cameraRig.position.y = -this.engine.camera.position.y; + this.engine.dashboard.object.position.y = this.engine.camera.position.y; + //this.cameraY = this.size.y * 1; //this.camera = this.engine.cameraWorld; // this.engine.activeObjects.position.x = -this.camera.position.x; // this.engine.activeObjects.position.z = -this.camera.position.z; }else{ this.cameraMode = 'rotate' - this.cameraY = this.size.y * 1.5; + this.engine.cameraRig.position.y = 0; + //this.cameraY = this.size.y * 1.5; // this.camera = this.engine.cameraWorld; // this.engine.camera.position.set(0,0,0); // this.engine.camera.rotation.set(0,0,0); @@ -109,7 +112,7 @@ class Hero{ } } - destroy(){ + dispose(){ delete this.engine.hero; this.engine.mixers.splice(this.engine.mixers.indexOf(this.mixer), 1); } @@ -187,13 +190,21 @@ class Hero{ this.cameraDelta += delta * ( pc.cameraLeft * -1 + pc.cameraRight * 1) this.walkDirection.setScalar(0); - if (pc.kb.KeyR && this.cameraY < 5){ + if (pc.cameraUp && this.cameraY < 5){ this.cameraY+=delta; } - if (pc.kb.KeyF && this.cameraY > 1){ + if (pc.cameraDown && this.cameraY > 1){ this.cameraY-=delta; } + if (pc.moveCloser){ + this.cameraZ+=delta; + } + + if (pc.moveAway){ + this.cameraZ-=delta; + } + if (pc.motion){ if (!pc.isLocked){ //this.directionVelocity = this.directionVelocity * 2.5 * Math.abs(input[0]) diff --git a/src/lib/PointerControls.js b/src/lib/PointerControls.js index 4fdd11a..ea37070 100644 --- a/src/lib/PointerControls.js +++ b/src/lib/PointerControls.js @@ -100,6 +100,18 @@ class PointerControls extends Controls { return this.kb['ArrowRight'] || this.kb['KeyD'] || this.engine.xrController1?.gamepad?.axes[2] > 0.5 || false } + get moveAway(){ + return this.kb.KeyT || + (this.engine.xrController2?.gamepad?.axes[3] < -0.5 && !this.engine.xrController1?.gamepad?.buttons[4]?.pressed) + || false + } + + get moveCloser(){ + return this.kb.KeyG || + (this.engine.xrController2?.gamepad?.axes[3] > 0.5 && !this.engine.xrController1?.gamepad?.buttons[4]?.pressed ) + || false + } + get rotateLeft(){ return this.moveLeft; } @@ -124,6 +136,18 @@ class PointerControls extends Controls { return this.kb['KeyE'] || this.engine.xrController2?.gamepad?.axes[2] < -0.5 || false } + get cameraUp(){ + return this.kb.KeyR || + (this.engine.xrController2?.gamepad?.axes[3] < -0.5 && this.engine.xrController1?.gamepad?.buttons[4]?.pressed) + || false + } + + get cameraDown(){ + return this.kb.KeyF || + (this.engine.xrController2?.gamepad?.axes[3] > 0.5 && this.engine.xrController1?.gamepad?.buttons[4]?.pressed) + || false + } + get moving(){ return this.moveForward || this.moveBackward || this.moveLeft || this.moveRight; }