JavaFX 3D Graphics: Mouse click position on 3D obj

2020-03-31 06:11发布

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.)?

1条回答
太酷不给撩
2楼-- · 2020-03-31 07:02

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());
    });
}
查看更多
登录 后发表回答