Griffin M.
Griffin M.

Reputation: 196

Three.js drag to look around

For a project that I am doing, I want to do something like THREE.OrbitControls:

var controls = new THREE.OrbitControls(camera, renderer.domElement);

but not have the camera move.

I'm looking for some three.js plugin (like OrbitControls), or some code to do this.

Thanks!

Upvotes: 2

Views: 1938

Answers (1)

WestLangley
WestLangley

Reputation: 104843

If you want the camera at the center of your scene and rotate only, you can use OrbitControls and this pattern:

// camera
camera = new THREE.PerspectiveCamera( ... );
camera.position.set( 0, 0, 0.01 ); // OrbitControls target is the origin

// controls
controls = new THREE.OrbitControls( camera, renderer.domElement );
controls.addEventListener( 'change', render ); // use this only if there is no animation loop
controls.enableZoom = false;
controls.enablePan = false;

three.js r.84

Upvotes: 2

Related Questions