Enable the depth buffer on the scene : SceneBuilder « JavaFX « Java

Enable the depth buffer on the scene


import javafx.application.Application;
import javafx.scene.GroupBuilder;
import javafx.scene.Parent;
import javafx.scene.PerspectiveCameraBuilder;
import javafx.scene.Scene;
import javafx.scene.SceneBuilder;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.RectangleBuilder;
import javafx.stage.Stage;

public class Main extends Application {
    public static void main(String[] args) {

    public void start(Stage stage) {
        stage.setTitle("Depth Buffer");

    private Scene makeScene() {
        return SceneBuilder.create()

    private Parent createRoot() {
      Rectangle node1 = RectangleBuilder.create()

      Rectangle node2 = RectangleBuilder.create()

      Rectangle node3 = RectangleBuilder.create()

        return GroupBuilder.create()
            .children(node1, node2, node3)


Related examples in the same category

1.Using SceneBuilder to create UI
2.The Depth Buffer