Getting Started with JavaFX 3D Graphics

Previous
Next

Beta Draft: 2013-09-17

4 Subscene

This chapter gives information about the use of Subscenes in JavaFX.

The SubScene node is a container for content in a scene graph. It is a special Node for scene separation. It can be used to render part of the scene with a different camera. You can use a SubScene node if you want to have Y-up for 3D objects and Y-down for 2D UI objects in your layout.

Some of the possible SubScene use cases are:

  • overlay for UI controls (needs a static camera)

  • Underlay for background (static or updated less frequently)

  • “Heads-up” display

  • Y-up for your 3D objects and Y-down for your 2D UI.

Creating a SubScene

Example 4-1 shows the two constructors for creating a new instance of a SubScene node in your application.

Example 4-1 SubScene Constructors

// Creates a SubScene for a specific root Node with a specific size.
SubScene(Parent root, double width, double height, boolean depthBuffer, 
         boolean antiAliasing)

// Constructs a SubScene consisting of a root, with a dimension of width and 
// height, specifies whether a depth buffer is created for this scene and 
// specifies whether scene anti-aliasing is requested.
SubScene(Parent root, double width, double height)

Once you have created a SubScene, you can modify it by using the available methods to specify or obtain the height, root node, width, background fill of the SubScene, the type of camera used to render the SubScene, or whether the SubScene is anti-aliased. See the JavaFX 8 API documentation for more information.

Previous
Next