theo
theo

Reputation: 75

Three.js : Pan/move camera using mouse movement (without clicking)?

I want to be able to pan the pan the camera around my scene using the mouse. So far I've used TrackballControls to create this effect by click and dragging.

function init(){
  camera = new THREE.PerspectiveCamera(45,window.innerWidth / window.innerHeight, 1, 1000);
  camera.position.z = 500;

  controls = new THREE.TrackballControls(camera);
  controls.addEventListener('change', render);
}

function animate(){
  requestAnimationFrame(animate);
  controls.update();
}

Is there a way to be able to do this without having to click? Similar to this site ...

I have made a codepen with my site so far.

Thanks :)

Upvotes: 0

Views: 3186

Answers (1)

theo
theo

Reputation: 75

Nevermind, I worked it out :)

If anyone's trying to do the same thing I made the following modifications to the TrackballControls.js file.

Upvotes: 1

Related Questions