Adding Camera to the Scene

To present a 3D scene to a user we need to specify where this user is located in the virtual 3D space of an application. The corresponding API class is called javafx.scene.Camera. Let's see how to create a simple Scene with PerspectiveCamera and a 3D element:

Refer to the following code snippet:

// chapter12/Basic3dDemo.javapublic void start(Stage stage) {    // creating a 3D cylinder        Cylinder cylinder = new Cylinder(40, 120);    cylinder.setRotationAxis(new Point3D(50, 50, 0));    cylinder.setRotate(45);    cylinder.setTranslateX(150);    cylinder.setTranslateY(150);    cylinder.setTranslateZ(600);    // setting up camera PerspectiveCamera ...

Get Mastering JavaFX 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.