Can this situation be bypassed?
The quick answer is "Yes, but not with the standard version of OrbitControls.js".
Let's delve into my detailed explanation...
I recently delved into the source code of OrbitControls.js (r87) with the intention of adding a feature that would allow for an optional second point as the camera target.
However, upon examining the code, I've concluded that incorporating this feature into the public version might not be ideal. Several aspects of OrbitControls, such as limiting viewing angles, minimum and maximum rotation, and dolly distance, rely on the assumption that the camera and orbit center are the same. Introducing a secondary camera target would necessitate significant modifications to accommodate both options, potentially complicating the codebase unnecessarily for a specialized function.
Therefore, the solution:
Given your focus on technical functionality over limitations like viewing angles or rotations, my suggestion would be to duplicate OrbitControls.js in your project, rename it to OrbitControls_customised.js, and make the necessary alterations:
Introduce two new parameters after this.target titled this.cameraTarget and this.coupleCenters
// "target" sets the location of focus, where the object orbits around
this.target = new THREE.Vector3();
// "cameraTarget" defines where the camera is looking (initially same as target)
this.cameraTarget = new THREE.Vector3();
// Indicates if the camera should align with the orbit center
this.coupleCenters = true;
In the section where the camera looks at the center...
scope.object.lookAt( scope.target );
...adjust it to update the camera only when coupleCenters is true...
if( scope.coupleCenters ){
scope.cameraTarget = scope.target;
}
scope.object.lookAt( scope.cameraTarget );
With these adjustments, you can implement an onMouseDown event utilizing RayCasting to identify a point on your object, set controls.decoupleCenters to false, and establish controls.target as the intersecting point. Similarly, use an onMouseUp event to reset controls.target to controls.cameraTarget to restore normal behavior.
I trust this provides clarity on your query and points you towards a potential solution.