public static Group convertTo3D(Node node, int depth) {
Group root = new Group();
root.setTranslateX(node.getLayoutX());
root.setTranslateY(node.getLayoutY());
root.setTranslateZ(-20);
System.out.println("Layer " + depth + " - Node Type: " + node.getClass());
Box box = new Box(node.getBoundsInParent().getWidth(), node.getBoundsInParent().getHeight(), 0.1);
box.setTranslateX(node.getLayoutX());
box.setTranslateY(node.getLayoutY());
SnapshotParameters snapshotParameters = new SnapshotParameters();
snapshotParameters.setFill(Color.TRANSPARENT);
box.setMaterial(new PhongMaterial(Color.WHITE, node.snapshot(snapshotParameters, new WritableImage((int) node.getBoundsInParent().getWidth(), (int) node.getBoundsInParent().getHeight())), null, null, null));
root.getChildren().add(box);
if (node instanceof Parent) {
for (Node child : ((Parent) node).getChildrenUnmodifiable()) {
root.getChildren().add(convertTo3D(child, depth + 1));
}
}
return root;
}