JavaFX 3D 图形:鼠标在 3D 对象上的单击位置 [英] JavaFX 3D Graphics: Mouse click position on 3D object

查看:37
本文介绍了JavaFX 3D 图形:鼠标在 3D 对象上的单击位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚玩了Oracle JavaFX Sample 3D图形应用我想知道是否可以 计算当前鼠标相对位置到 3d 平台.我想要一些信息,例如如果鼠标悬停在 3d 对象上.有没有可能以任何方式(也许使用给定的相机翻译等)?

I just played around with the Oracle JavaFX Sample 3D Graphics app I am wondering if it is possible to calculate the current mouse position relative to the 3d platform. I would like some info e.g. if the mouse hovers a 3d object. Is that possible in any way (Maybe with the given camera translations etc.)?

推荐答案

您可以使用来自任何 MouseEvent 的 PickResult 类,这只是基本用法..

You can use the PickResult class from any MouseEvent, this is just the basic usage ..

...{
    shape3D.setOnMouseEntered(e->{
        PickResult pr = e.getPickResult();
        System.out.println(pr.getIntersectedPoint());
    });
}

这篇关于JavaFX 3D 图形:鼠标在 3D 对象上的单击位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆