I don’t really understand what you are suggesting:
You say I should use e.ray.intersectPlane instead of ray.intersectPlane?
What would I need to change in my code-example?
Any chance you can provide the relative unit you’re using to define “too far”? Why does the plane need to be that far? Also if you see the distance from camera to sphere and from sphere to plane as a ratio in the context you’re trying to find the direction of the ray, I could imagine problems being introduced where the plane is far away and the sphere too close to the camera, at some stage you’re going to start firing ambiguous rays depending on the unit sizes you’re using…
The camera position is somewhat irrelevant in the equation, it’s the position of the sphere relative to the cameras frustum eg… the projected screen space mouse position while hovering the sphere that would give the correct projection in this case maybe
It seems like ray.intersectPlane doesn’t hit from the line where the planeMesh fades out.
(The planeMesh isn’t used for the intersection calculation, but they have the same limit)
The plane itself doesn’t need to be far away for that to happen. Since the camera (rotation) is controllable, the plane can be angled such that there a points on the plane that are very far away.
How is the camera position irrelevant? When projecting the point onto the plane, the point should stay under the mouse cursor. (the projection should go from the camera through the unprojected point onto the plane)
Yes this sounds like you’re on the right track of thinking, however, the code you provided previous does not mention any unprotected mouse position, it’s currently deriving the direction from the camera position to the sphere…
const cameraPosition = camera.position;
const direction = sphereMesh.position.clone().sub(cameraPosition).normalize();
const ray = new THREE.Ray(cameraPosition, direction);
ray.intersectPlane(plane, sphereMesh.position)
I think here instead of camera position you’d rather use the mouse position projected from the camera…
Since DragControls sets the sphere position to the mouse position before the drag event is called, sphereMesh.position is the unprojected mouse position before projecting.