Justin
Justin

Reputation: 1939

OrbitControls - Can I enable/disable zooming dynamically?

I'm running Three.js r69 with the bundled OrbitControls.js. I have a simple scene with a couple of objects that are selectable. I'd like to be able to disable zooming while an object is selected and re-enable it once I've cleared the selection.

I'm working on a temporary solution, but it involves editing the OrbitControls.js code. This could make it really annoying to upgrade to a new version of Three.js, especially if OrbitControls is ever changed.

Is there currently a way to enable/disable certain features (like zooming, panning, or orbiting) on the fly, independently of each other?

Upvotes: 18

Views: 23015

Answers (2)

meirm
meirm

Reputation: 1379

Is simple:

const controls = new THREE.OrbitControls( camera );
    
// to disable zoom
controls.enableZoom = false;
        
// to disable rotation
controls.enableRotate = false;
    
// to disable pan
controls.enablePan = false;

Upvotes: 49

Bob Woodley
Bob Woodley

Reputation: 1284

If you're editing the source you must have seen noZoom and noPan.

And this post shows how to constrain rotation.

Do these not meet your need?

Upvotes: 1

Related Questions