22.11 Three-Dimensional Shapes

Throughout this chapter, we’ve demonstrated many two-dimensional graphics capabilities. In Java SE 8, JavaFX added several three-dimensional shapes and corresponding capabilities. The three-dimensional shapes are subclasses of Shape3D from the package javafx.scene.shape. In this section, you’ll use Scene Builder to create a Box, a Cylinder and a Sphere and specify several of their properties. Then, in the app’s controller, you’ll create so-called materials that apply color and images to the 3D shapes.

FXML for the Box, Cylinder and Sphere

Figure 22.16 shows the completed FXML that we created with Scene Builder:

  • Lines 16–21 define the Box object.

  • Lines 22–27 define the Cylinder object.

  • Lines 28–29 define ...

Get Java How to Program, Early Objects, 11th Edition 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.