0

I have a canvas in which I display objects. To click an object I must click to the left and above the object by an amount equal to the offset of the canvas, i.e. it is only right if the canvas is located to the top left portion of the window. I can't find any literature on that problem. Anyone has an idea? Here is the code for the event:

function onDocumentMouseUp(event){
  var mouseVector=new THREE.Vector3( 2*(event.clientX/canvasWidth)-1 , 1-2*(event.clientY/canvasHeight));
  var raycaster=projector.pickingRay(mouseVector.clone() , camera);
// hit testing
  var intersects=raycaster.intersectObjects(slots);
      if (intersects.length>0)     // do we have one or more hits
      if (0===intersects[0].object.material.color.g) {
          intersects[0].object.material.color  =X;   // change color
          intersects[0].object.material.opacity=1;
           Play();
      } 
    }

0 Answers0