Skip to content

Commit

Permalink
check for requestPointerLock unadjustedMovement support (#250)
Browse files Browse the repository at this point in the history
Co-authored-by: Brian Thomas Smith <brian@smith.berlin>
  • Loading branch information
KaelWD and bsmth authored Jul 17, 2024
1 parent 8dd8e89 commit d955ab6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pointer-lock/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,18 @@ canvasDraw();

canvas.addEventListener("click", async () => {
if(!document.pointerLockElement) {
await canvas.requestPointerLock({
unadjustedMovement: true,
});
try {
await canvas.requestPointerLock({
unadjustedMovement: true,
});
} catch (error) {
if (error.name === "NotSupportedError") {
// Some platforms may not support unadjusted movement.
await canvas.requestPointerLock();
} else {
throw error;
}
}
}
});

Expand Down

0 comments on commit d955ab6

Please sign in to comment.