I am trying to set the orbit controls target here in three.js. for example in https://threejs.org/editor/ when you add any cube or shape, the camera always rotates around the center of the model unless you pan the camera and it will still rotate around (0,0,0). Now the behavior I am trying to get from orbit controls is that on the mouse click, I should be able to set the target for the orbit controls. for this, I am using raycaster and then getting the object position/center on a mouse-down event and then setting the target for orbit controls there and it works fine when click and move happened as it sets the target exactly in front of the camera. But the problem comes when target is set somewhere else, user is zooming in the model(i have implemented zoom to cursor)/panning the model, and then without clicking on new object on another side, user click on empty space and did mouse move, immediately, I see the jump of controls and camera to the previous target.
I want to set the target of orbit controls exactly at the mouse cursor even though if it is empty space. How can I get that thing?
I tried getting mouse pointer in 2D and then Unproject it from the camera to get 3D coordinates, but that is setting the orbit target just near the camera's near plane. I am not able to get what value should I pass to the orbit target if user hits an empty part of the model.