andy ram
andy ram

Reputation: 213

Touch controls using pointer lock controls in three.js

I tried using Pointer lock controls for normal First Person keyboard setup, now i wanted to know if i can include touch settings in pointer lock controls file for moving forward on touch and to look around using swipe. Is it possible to do this using pointer lock controls ?

Upvotes: 2

Views: 958

Answers (1)

FeaturedSpace
FeaturedSpace

Reputation: 499

Yes, however I would suggest using Hammer.js and editing your onswipe event to move the opposite x and y values to create the correct effect.

Try this code:

hammertime.on("pan", function(event) {
  rotateCamera(-event.movementX, -event.movementY);
});

Remember, if you use thsi code you will have to create a specific rotateCamera function, however, that shouldn't be hard if you examine your FirstPersonControls file and some other peoples code. Just be resourceful an make sure you've Googled it in about 5 different ways before you ask!

:)

Upvotes: 1

Related Questions