Java Reference
In-Depth Information
Figure 10-12. The MeshCube program
Interacting with JavaFX 3D Scenes
The 3D shapes in the JavaFX 3D graphics API support the full range of JavaFX mouse and touch events. Your JavaFX
3D program can take full advantage of these events to implement interactive behaviors. In fact, we have implemented
mouse interactions in the EarthSphere, EarthCylinder, EarthBox, and MeshCube programs. In the EarthSphere we set
event handlers on the scene:
scene.setOnMousePressed((MouseEvent event) -> {
anchorX = event.getSceneX();
anchorY = event.getSceneY();
anchorAngleX = angleX.get();
anchorAngleY = angleY.get();
});
scene.setOnMouseDragged((MouseEvent event) -> {
angleY.set(anchorAngleY + anchorX - event.getSceneX());
});
 
Search WWH ::




Custom Search