Pick a 3D Node in JavaFX from screen coordinates

1.2k views Asked by At

Is there a way to pick a 3D node on the JFX scene with screen coordinates ?

Knowing that I am not using the Mouse, but use a Custom Touch Handler (Not the JFX Touch events).

What I've tried:

  1. Emulate a MouseEvent from the Touch Handler and fire the event. The PickResult got from the event is always null.
  2. Use the common way: Ray/Node collision by calling the (deprecated) method: Node.impl_pickNode(pickray, result), so I tried to get the PickRay:
    1. By calling: Camera.computePickRay(double x, double y, PickRay pickRay), but the method is not public...
    2. Build it, but I need to convert the screen coordinates in 3D coordinates, but don't know how to do it with the JFX API.

Thanks for any input !

1

There are 1 answers

0
Birdasaur On

Jose Pereda recently contributed a RayCasting example to the free open source F(X)yz library:

https://github.com/FXyz/FXyzLib/blob/master/src/org/fxyz/tests/RayTest.java

It is still in flux but it might give you everything you need. This is similar to this question where he and @jdub1581 try to explain javafx-8-3d-scene-intersection-point