How to resize a JavaFX 3D SubScene?

java, javafx

Solution

bind it to the parent

SubScene subscene = new SubScene(root, 1024, 768, true, null);
subscene.setFill(Color.GREY);
subscene.setCamera(camera);
StackPane stackPane = new StackPane();
stackPane.getChildren().add(subscene);
subscene.heightProperty().bind(stackPane.heightProperty());
subscene.widthProperty().bind(stackPane.widthProperty());

Problem

This code will create a 3d scene that is 300x300 large. The viewport won't resize when I resize the containing window/stage. `Parent` doesn't have any `width` or `height` properties. How do I adjust the size of the `Parent` and/or `SubScene` to the changing window size?

Original source