refactor pointerControls, move away from hero to gameEngine

This commit is contained in:
2026-02-21 20:42:29 +02:00
parent 8954770ff7
commit 151e1ff82f
4 changed files with 22 additions and 26 deletions
+8 -2
View File
@@ -2,7 +2,7 @@ import { Vector3 } from 'three';
import { PointerLockControls } from 'three/examples/jsm/Addons.js';
class PointerControls {
constructor(camera, hero, domElement) {
constructor(camera, domElement) {
this.kb = {};
this.dom = domElement;
@@ -14,7 +14,6 @@ class PointerControls {
this.rvelo = 0;
this.camera = camera;
this.hero = hero;
this.click = false;
this.controls = new PointerLockControls(camera, domElement);
@@ -117,6 +116,13 @@ class PointerControls {
return this.moving && this.kb.ShiftLeft;
}
get input() {
return [
this.moveLeft * 1 + this.moveRight * -1,
this.moveForward * 1 + this.moveBackward * -1
]
}
async lock(unadjustedMovement = false){
await this.dom.requestPointerLock( {
unadjustedMovement