mrdoob/three.js — Issue #954: About the intersect
Author: avicha
Created: 2011-12-22 16:59:53+00:00
State: open

This is a question about the intersect between a plane and a ray.As the code below:
// I make a plane size 2200*1800 and rotate it as a floor.
var planebottom=new THREE.PlaneGeometry( 2200, 1800, 10, 10 );

var material=new THREE.MeshPhongMaterial( { map:ceilingTexture} );

mesh = new THREE.Mesh( planebottom, material);

mesh.position.y = - 100;

mesh.rotation.x = - 90 * Math.PI / 180;

scene.add( mesh );

And now I want to click the plane and move my position to another position which I click on the plane,so I create a ray from my position to another position that I click,the ray will intersect the plane at a target point.But the question is that sometimes it really worked and I found the point,but sometime it intersect nothing and I can't get the point.like:

var intersects=ray.intersectScene(scene);
// If intersect
if(intersects.length>0){
targetPosition=new THREE.Vector3().add(camera.position,vector.multiplyScalar(intersects[ 0 ].distance));
}

Who can tell me what's wrong with the intersects between the plane and the ray??Help!