Hi,
I’ve put together a version of PointerLockControls.js that works on mobile and touchscreen devices.
A few years ago, I came across an implementation that adapted PointerLockControls for touchscreens witch I was using. Since then, PointerLockControls has been completely rewritten (for the best) but that older touchscreen version is no longer compatible.
I wanted to keep the benefits of the updated pointerLockControls while making my projects available on mobile devices, so I adapted the new version for touchscreens
Because touchscreens don’t have a mouse pointer, this isn’t a true pointer lock implementation. Instead, it recreates the same experience and allows users to move around in first-person mode using touch input.
If you’d like to test it, replace pointerLockControls.js in jsm/controls/ with this version.
EDIT :
It tests for touchscreen and the pointerSpeed property affects the speed at which touch can rotate the camera.
It’s still a work in progress. For now it is FORCED to act as a mobile device, which means it behaves like a touchscreen device even when running on a desktop computer.
One thing I’m still trying to figure out is the most appropriate way to detect touch devices. Touchscreen devices aren’t limited to iOS and Android, so ideally the solution would work across any platform with touchscreen capabilities.
If you want to use standard Pointer Lock controls on desktop and touchscreen controls on mobile, you can set the bool on line 8 to false:
I’d also like to add support for the pointerSpeed property so it affects touchscreen controls as well.
Let me know what you think. ![]()