Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requestPointerLock() documentation should note that it must be called from the user's callback #5191

Closed
jgordon510 opened this issue Apr 17, 2021 · 4 comments · Fixed by #5592

Comments

@jgordon510
Copy link

  • [X ] Documentation

Details about the bug:

The page at https://p5js.org/reference/#/p5/requestPointerLock notes that "not all browsers support this feature." It should also note, however, that the feature requires being called in a user callback (a click or something) in most browsers. Chrome definitely requires it, similar to audiocontext.

@outofambit
Copy link
Contributor

Hi @jgordon510, thanks for filing this! I hadn't heard this before but it could certainly be true since i think that API is still evolving.

However, I tried the example at https://p5js.org/reference/#/p5/requestPointerLock in Chrome (version 90.0.4430.72) and it worked fine. 😕 Does that example work for you in Chrome? (You should see the little sphere mesh rotate around when you move your mouse.

Thanks!

@jgordon510
Copy link
Author

jgordon510 commented Apr 18, 2021 via email

@limzykenneth
Copy link
Member

I can see this behaviour in Firefox as well. A note about needing user interaction in order to request pointer lock is probably needed in the documentation here and the example be edited to something like.

let cam;
function setup() {
  createCanvas(100, 100, WEBGL);
  cam = createCamera();
}

function draw() {
  background(255);
  cam.pan(-movedX * 0.001);
  cam.tilt(movedY * 0.001);
  sphere(25);
}

function mouseClicked(){
  requestPointerLock();
}

@stalgiag
Copy link
Contributor

Yes, agree. I believe that this requirement wasn't in place when this example was made.

reejuBhattacharya added a commit to reejuBhattacharya/p5.js that referenced this issue Feb 6, 2022
reejuBhattacharya added a commit to reejuBhattacharya/p5.js that referenced this issue Feb 16, 2022
This reverts commit b8c5da3.

reverts commit from another pull request
limzykenneth added a commit that referenced this issue Feb 18, 2022
fixes issue #5191 along with minor grammatical edits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants