Is it possible to switch between controls?

I’m creating a scene that starts with Orbit Controls but after a click event I want the scene to switch to First-Person shooter controls. Is this possible?

Try this: Call orbitControls.dispose() in your click handler which removes all internal event listeners of OrbitControls. After that, you can create an instance of your FPS control class. In this way, both controls should not interfere.

2 Likes

Excellent - thanks!

Does calling dispose() on the orbitControls have any effect on the orbitControls.update() method?

Wait, I have a better advice: Just set OrbitControls.enabled to false. In this way, the logic in the internal event listeners is not executed, too. Besides, you can easily check if orbitControls.enabled is true and only then perform the update.

2 Likes

I tried setting OrbitControls.enabled to false but there must be something I’m missing because even with them set to false the camera rotation is paralyzed on the First-Person Shooter perspective. I created a fiddle with the issue.

The scene starts with orbit controls.
The “Move Camera” button moves the camera to the first-person shooter position.
The “Switch to First-Person Shooter” button triggers the controls.enabled = false.

https://jsfiddle.net/darcypaterson/vqbjse8c/15/

Try to use this pattern for now:

if ( controls.enabled ) controls.update();

It’s maybe a bit unfortunate that the controls are still updating even if .enabled is set to false :thinking:

1 Like