I’d like to know where some 2d stage coords are on a 3d plane. I know about the MouseEvent3D, but that does not really work for me I’m afraid.
So I figure: Let ‘s use Ray.getRayToTriangleIntersection twice.
var dest:Vector3D = _view.camera.unproject(x,y);
var cameraPosition:Vector3D = _view.camera.position;
dest.add(cameraPosition);
var r:Ray = new Ray();
//plane is 1000x1000 @ 0,0,0, yUp=true
var v0:Vector3D = new Vector3D(-500,0,-500);
var v1:Vector3D = new Vector3D(+500,0,-500);
var v2:Vector3D = new Vector3D(+500,0, +500);
var intersection:Vector3D = r.getRayToTriangleIntersection(cameraPosition, dest, v0,v1,v2);
if(!intersection){
v1 = new Vector3D(+500,0,-500);
intersection = r.getRayToTriangleIntersection(cameraPosition, ray, v0,v1,v2);
}
if(!intersection) {
trace( 'no intersection!');
return;
}
So this does not work.
I think the problem lies with the unproject function, which gives me values way up in the +/- 9.000.
Any better ways to do this?