Javatpoint Logo
Javatpoint Logo

3D Object Properties

JavaFX allows us to set the various properties of 3D objects. There are the special classes defined for each property in JavaFX. In this part of the tutorial, we will discuss the types of the properties which can be applied to the 3D objects for the better appearance.

Cull Face

Culling can be simply defined as the process of removing the part of the 3D objects which are not visible in the view area. In JavaFX, 3D shapes contain the property of the type CullFace. This property can be set to an appropriate value by using the following instance method which is to be called on the 3D shape class object. .

setCullFace(CullFace value)

there are three type of strokes defined in the CullFace class that are:

  1. None: Culling is not performed
  2. Front : all the front facing polygons get culled
  3. Back : all the back facing polygons get culled


In the following example, we have created three spheres and set three of the cull faces for each one of them.

JavaFX 3D Object Properties

3D Object Material

JavaFX provides different kinds of material which can be applied to the surface of a 3D shape. The class Material of the package javafx.scene.paint provides all the classes to deal with the material of a 3D shape. The class PhongMaterial is the subclass of the class Material. We just need to instantiate this class to create the desired material.

This class provides various types of materials as the properties of this class which can be set to a certain value by using the setter methods. However, the material can be applied to a shape by using the following method.


The properties of the class javafx.scene.paint.PhongMaterial along with their setter methods are described in the following table.

Property Description Setter Methods
bumpMap This property is of the type Image. This represents the Bump Map of the material. setBumpMap(Image URL)
diffuseColor This is a color type property. This represents the diffuse color of the material. setDiffuseColor(Color color)
diffuseMap This is an Image type property. This represents the DiffuseMap of the material. setDiffuseMap(Image URL)
selfIlluminationMap This is an Image type property. This represents the selfillumination map of the material setSelfIlluminationMap(Image URL)
specularColor This is a color type property. This represents the specular color of the material. setSpecularColor(Color value)
specularPower This is a double type property. This represents the specular power of the Material. setSpecularPower(Double value)


JavaFX 3D Object Properties

Drawing Modes

JavaFX provides various Drawing modes to draw the 3D shapes. This property is of the type DrawMode. The following types of DrawMode are defined in the class.

  1. Fill : this mode draws and fill the 3D shape. It is represented by DrawMode.Fill
  2. Line : this mode draws the 3D shape using Lines only. It is represented by DrawMode.Line

Use the following setter method to set a drawmode for the 3D shape.


In the following example, we have created two boxes, one is by using DrawMode Fill while the other is by using DrawMode Line.

JavaFX 3D Object Properties

JavaFX Camera

In JavaFX, the camera is treated as an object which can be moved around a 3D layout and change the view of the Scene accordingly. The class javafx.scene.Camera represents camera. However, it is different from a 2D space where we don't need to move camera around the screen.

In JavaFX, camera coordinate system, the X-coordinate points to the right, the Y-coordinate points to the down, and the Z-coordinate points away from the viewer or into the screen.

For creating camera and adding it to the scene, we must use the following lines of code.

// creating the instance of javafx.scene.Camera

//setting the camera to 50 in the right X direction


//setting the camera to 20 into the screen

//Adding the camera to the scene

JavaFX Subscene

A subscene node can be defined as a container which can hold the some node of the scene for which the camera angle needs to be specified. It is used for scene separation. We can use the subscene node if we need to set the different camera for a part of the scene. Subscene can be used in one of the following cases.

  1. If we need a static camera(overlay) for the UI controls we are using in our scene.
  2. Y-up for the 3D objects and Y-down for the 2D UI.
  3. Underlay for background

Use the following syntax to instantiate a subscene.

Next TopicJavaFX Box

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA