我正在处理全景场景。我想用光标移动飞机。当我移动鼠标时,平面必须是鼠标坐标。我想采用平面 3D 坐标 (x,y,z) 特别是 z 坐标。我尝试下面的代码。但它不能正常工作。鼠标和飞机在屏幕上的坐标不同。我该怎么办?
public class RayTracer
{
public static function getIntersection(viewport:Viewport3D, camera:CameraObject3D, normal:Array):Number3D
{
var plane3D:Plane3D=new Plane3D();
plane3D.setNormalAndPoint(new Number3D(0, 1, 0), new Number3D(0, 0, 0));
var cameraPosition:Number3D=new Number3D(camera.x, camera.y, camera.z);
var ray:Number3D=camera.unproject(viewport.containerSprite.mouseX, viewport.containerSprite.mouseY);
ray=Number3D.add(ray, cameraPosition);
var intersect:Number3D=plane3D.getIntersectionLineNumbers(cameraPosition, ray);
return intersect;
}
}