Raycaster issue

Maybe my little example will help?

View the source code. Since it was only in German up to now, I quickly translated it into English.

Both versions are there: http://threejs.hofk.de/

English version: http://threejs.hofk.de/raycaster/raycaster.html
raycasterDragDrop

The important functions


function onDocumentMouseDown(event) {
   
     mouseX = (event.clientX / window.innerWidth) * 2 - 1;
     mouseY = -(event.clientY / window.innerHeight) * 2 + 1;

    var vector = new THREE.Vector3(mouseX, mouseY, 1);
	
    vector.unproject(camera);    // .unproject:  Ray from camera from 2D screen (mouse coordinates) into 3D object space. 

    raycaster.set(camera.position, vector.sub(camera.position ).normalize() );

    var intersects = raycaster.intersectObjects(objects);

    if (intersects.length > 0) {        //  cutting objects available

       controls.enabled = false;

      // Selection - first cutting object
       selection = intersects[0].object;

      // Determining the Offset
      var intersects = raycaster.intersectObject(plane);
	  
      offset.copy(intersects[0].point).sub(plane.position);
	  
    }
	
}
  
function onDocumentMouseMove(event) {

    event.preventDefault();

    var mouseX = (event.clientX / window.innerWidth) * 2 - 1;
    var mouseY = -(event.clientY / window.innerHeight) * 2 + 1;

    var vector = new THREE.Vector3(mouseX, mouseY, 1);
	
    vector.unproject(camera);   // .unproject: Ray from camera from 2D screen (mouse coordinates) into 3D object space. 

    raycaster.set(camera.position, vector.sub(camera.position ).normalize() );	//Raycaster position

    if (selection) {
	
      // Position section with auxiliary plane
      var intersects = raycaster.intersectObject(plane);
	  
      //  Object displacement (each position according to intersection point with auxiliary plane)
       selection.position.copy(intersects[0].point.sub(offset));
	   
    } else {
	
      // new position auxiliary layer (if necessary)
      var intersects = raycaster.intersectObjects(objects);
	  
      if (intersects.length > 0) {
	  
         plane.position.copy(intersects[0].object.position);
         plane.lookAt(camera.position);
		 
      }
	  
    }
	
}