I have been using OrbitControls to rotate the camera around the object, and it has worked well. However, I now need to dynamically enable and disable rotation around the Z-axis using mouse events or programmatically. After spending some time playing with camera.up adjustments, I realized that achieving this with OrbitControls is quite challenging. As a result, I started looking into ArcballControls since it provides Z-axis rotation out of the box. However, I encountered the opposite issue: I am now struggling to disable the mentioned rotation. I attempted to conditionally disable the camera.up update as shown below:
//update camera up vector
if (
(this._state == STATE.ROTATE ||
this._state == STATE.ZROTATE ||
this._state == STATE.ANIMATION_ROTATE) &&
!this._disableZAxis
) {
this.camera.up
.copy(this._upState)
.applyQuaternion(this.camera.quaternion);
}
However, this approach resulted in a weird behavior when using diagonal mouse-move rotation. OrbitControls handle this situation better by limiting vertical mouse rotation to 180 degrees. I would like to replicate this behavior in ArcballControls when Z-axis rotation is disabled, however, I am still quite new in this area and I am not sure how to do it. Should I adjust rotationAxis calculation or it is purely rotationMatrix manipulation? How can it be done?
Thank you in advance!