catch the lockControls error when no user interaction

This commit is contained in:
2026-02-09 08:09:30 +02:00
parent 1e33773e97
commit 55de3124fe
2 changed files with 17 additions and 3 deletions
+11
View File
@@ -4,6 +4,7 @@ import { PointerLockControls } from 'three/examples/jsm/Addons.js';
class PointerControls {
constructor(camera, hero, domElement) {
this.kb = {};
this.dom = domElement;
this.canJump = false;
this.velocity = new Vector3();
@@ -115,6 +116,16 @@ class PointerControls {
get running(){
return this.moving && this.kb.ShiftLeft;
}
async lock(unadjustedMovement = false){
await this.dom.requestPointerLock( {
unadjustedMovement
} );
}
unlock(){
this.dom.ownerDocument.exitPointerLock();
}
}
export { PointerControls };