I'm trying to achieve a functionality to load the 3D model on the current mouse coordinates. I'm using jQuery drag and drop functionality to load the 3D model. I can load the model into the canvas, but it is not snapping to the mouse coordinates.
I've used the below code to convert the 2D mouse coordinates to 3D coordinates but it's not providing the exact position.
function 2DTo3DSpace(event) {
var planeZ = new THREE.Plane(new THREE.Vector3(1500, 1500, 1500), 0);
var mv = new THREE.Vector3((event.clientX / window.innerWidth) * 2 - 1, -(event.clientY / window.innerHeight) * 2 + 1, 0.5);
var raycaster = projector.pickingRay(mv, camera);
var pos = raycaster.ray.intersectPlane(planeZ);
return pos;
}