In my attempt to configure the orbit controls target in three.js, I encounter a challenge. For instance, when using , the camera consistently revolves around the center of the model unless the camera is panned. The desired behavior from the orbit controls is to set the target upon a mouse click. To achieve this, I utilize raycasting to capture the object position or center during a mouse-down event, consequently setting the orbit controls' target to that position. This method works well during click and move actions as the target aligns precisely in front of the camera. However, an issue arises when the target is established in one location, the user zooms or pans the model, and then, without clicking on a new object, clicks on an empty space, resulting in a sudden shift of controls and camera back to the previous target.
My objective is to position the orbit controls' target directly at the mouse cursor, even when it is over empty space. How can I achieve this?
I have attempted to obtain the 2D mouse pointer and unproject it from the camera to obtain 3D coordinates. Unfortunately, this places the orbit target close to the camera's near plane. I am struggling to determine the appropriate value to pass to the orbit target when the user clicks on an empty part of the model.