0

So I am looking for a way to rotate around an object in Threejs but without holding the mouse button. I've got an example website here: http://www.dilladimension.com/ which uses Threejs. Been looking through forums and on the Threejs documentation but I can't figure out how to rotate around an object without holding down the mouse.

Any help is greatly appreciated!

gman
  • 100,619
  • 31
  • 269
  • 393
Bayron2304
  • 117
  • 2
  • 13

1 Answers1

0

If you are trying to get that kind of mouse interaction as shown here, you can :

//Listen to mouse mouve events
function onDocumentMouseMove( event ) {
    mouseX = ( event.clientX - windowHalfX );
    mouseY = ( event.clientY - windowHalfY );
}


//Update your camera position
function render() {
    camera.position.x += ( mouseX - camera.position.x ) * .05;
    camera.position.y += ( - mouseY - camera.position.y ) * .05;
    camera.lookAt( scene.position );
    renderer.render( scene, camera );
}

Hope this helps.

ThisIsSparta
  • 1,307
  • 13
  • 22
  • This looks good, very close but not yet there. The movement is spot on I just want to know if there is a way to go full 360 around an object? I am a bit of a noob with Javascript so bare with me! – Bayron2304 Oct 12 '16 at 10:31
  • @Bayron2304, [this](http://stackoverflow.com/questions/8426822/rotate-camera-in-three-js-with-mouse) might help then (you need to adapt the code and remove the part checking if a mouse button is clicked) – ThisIsSparta Oct 12 '16 at 10:50
  • Thanks, I'll take a look! – Bayron2304 Oct 12 '16 at 11:01