-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
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
TransformControls PointerLock support #16093
Conversation
/ping @arodic |
Hey thanks @Mugen87 I'll take a look at it. Just wondering @jbaicoianu, in what scenario would you use TransformControls and pointerlock at the same time since there is no cursor? Anyway, it should be ok to pick with some sort of visible crosshair in the middle of the screen. Without a visual aid, I think it would be very awkward to use. |
As a side note, I have custom email filter for "TransformControls" but I appreciate the pings @Mugen87 :) Also, I apologise for slow response sometimes. |
@arodic yes, in our case when pointerlock is enabled, our engine is already drawing a crosshair at the center, so it works intuitively. I don't think this is something the TransformControls needs to handle itself, since many people who use pointerlock controls have a crosshair of some sort, for other purposes - this change just lets TransformControls play nicely when the pointer is already locked via an external mechanism. This tweet has a video which shows off how we're using TransformControls in first person mode - works like a charm, feels very intuitive to be able to grab an object then walk off while holding it https://twitter.com/matrixscene/status/1111522564692566016?s=20 |
This looks good to me. I am going to add pointer lock to example and send you a PR into jbaicoianu:transformcontrols-pointerlock then we can merge it to dev as one PR. I'm not sure why the CI is throwing error. Some kind of timeout? |
Ugh... turns out Not sure what is the best approach to test pointerlock behavior with @jbaicoianu if you have a working example I'm in favor of merging this, but ideally, transform controls example should have pointerlock option. |
Since fixing #16160 is taking longer than expected, I suggest to merge this and I'll add PointerLock in the example later. Not sure why LGTM analysis is failing. @jbaicoianu perhaps you can amend your branch to trigger another CI pass to see if its just a fluke. |
…/three.js into transformcontrols-pointerlock
Not sure what happened with the LGTM analysis originally, but when I submitted this pull request I noticed there were a couple other pull requests that failed in the same way, so I suspect it may have just been a temporary issue with the service. I've pushed a minor change and it's rechecking, let's see if it works this time around. We're not using PointerLockControls in our engine, we've built our own implementation so I'm not as familiar with PointerLockControls' internals - all of the issues you pointed out sound familiar from when we evaluated it a few years back though. Sounds like some clean-up would be nice to have, but as you noted, it's always hard to change something when it's worked that way for so long. Maybe since these are examples anyway, it might make sense to implement it as a separate control, like PointerLock2Controls, or something more creatively named - maybe specifically FPSControls? Right now my only example of TransformControls and pointer lock working together is in my local dev copy, I don't have a publicly accessible link yet but I'm working on finalizing the code for a release soon. |
There is already FirstPersonControls... |
True, I tried using that but noticed it does not implement PointerLock, and also lacks change event, etc.
This brings up a larger issue with |
This PR has been tested and its OK to merge. I submitted the example on top of it from this branch |
Thanks! |
This pull request extends TransformControl's
getPointer
method to allow it to be used when pointer lock is enabled. Without this patch, the TransformControl will react to the mouse at the position it was when the pointer was locked, which leads to confusing behavior. The patch fixes this behavior by returning the center of the screen as the pointer location whenever the pointer is locked.