zenhanu
zenhanu

Reputation: 21

Enable/Disable Rotation, Pan, Zoom in Camera COntrols

Is there any way to disable/enable only the rotation, pan, zoom options in Camera Controls.

In that, the enabled option sets enabled or disables all controls. But I need to specify the options like zoom, pan or rotation.

Upvotes: 1

Views: 413

Answers (2)

Artyom Rybin
Artyom Rybin

Reputation: 1

You can set azimuthRotateSpeed, polarRotateSpeed, dollySpeed ​​and truckSpeed ​​to "0" to disable unnecessary controls

Upvotes: 0

MiguelG
MiguelG

Reputation: 466

I was about to post the same problem. Turns out that I found a workaround. You can try disabling the camera controls and temporarily instantiate an orbit control.

    const orbitControls = new OrbitControls(
      viewer.camera.get(),
      viewer.ui.viewerContainer
    );

///setting same mouse button configurations
    orbitControls.mouseButtons = {
      LEFT: THREE.MOUSE.ROTATE,
    };

also don't forget to capture the animation frame id so you can get rip of it later on

let animationLoopId;
function animate() {
  animationLoopId =
    requestAnimationFrame(animate);
  orbitControls.update();
  viewer.renderer
    .get()
    .render(scene, viewer.camera.get());
}
animate();

later on, you can dispose it and get back to work with camera controls: ...

cancelAnimationFrame(animationLoopId!);
orbitControls.dispose();
controls.enabled = true;

Hope this helps!

Upvotes: 0

Related Questions