catch the lockControls error when no user interaction
This commit is contained in:
@@ -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 };
|
||||
Reference in New Issue
Block a user