如何在 flex papervision3d 上获取鼠标 z 坐标?
我正在研究全景场景。我想用光标移动飞机。当我移动鼠标时,平面必须是鼠标坐标。我想获取平面 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;
}
}
I am working on panoramic scene . And I want to move a plane with cursor. When I move mouse, plane must be mouse coordinates. And I want to take plane 3D coordinates (x,y,z) expecially z-coordinate. I try below code. But it doesnt work correctly. Mouse and plane are not be same coordinates on screen. How I can do?
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;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,即使在 PV3d 中也没有鼠标的 Z 坐标。
As far as I know there is no Z coordinate of the Mouse even in PV3d.
不,我会尝试。我正在尝试使用 Mouse3d 对象并运行以下代码:
}
但 mouse3D 坐标始终为 (0,0,0)。我不知道为什么。
No i will try. I am trying to Mouse3d object and run below code:
}
But mouse3D coordinates always (0,0,0). I dont know why.