I think, you’ll first need to describe what you would consider a “proper” behaviour, before someone will tell you that you’ll need to adjust your expectations
Honestly: are you talking about a 3rd-person view, or a 1st person view? And please describe as exactly as possible what a “camera flip” exactly means.
If you’re going to allow the camera to do loops like that, you might want to not use OrbitControls, and instead attach the camera directly to the target object.
You can try setting the “up” vector of the camera to it’s actual up instead of 0,1,0… and possibly get it to do a loop without flipping.
so like…
at init camera.up = new THEE.Vector3();
then in your game loop…
By proper I was referring to the camera not flipping 180 degrees past certain points, effectively to prevent reorientation once the up vector becomes flipped
The solution that worked for me is to get the cross product between forward and right vectors, and constantly update what is the new up vector
const forward = new THREE.Vector3(0, 0, -1).applyQuaternion(groupRef.current.quaternion);
const right = new THREE.Vector3(1, 0, 0).applyQuaternion(groupRef.current.quaternion);
upVector.current.crossVectors(right, forward).normalize();
camera.up.copy(upVector.current);