title: how to combine fxml file with 3d Box and PerspectiveCamera
body: <p>As a newbie I'm trying to do some my own projects to practice Java, JavaFX and Raspberry coding. Ma latest goal which I set for myself is 3D visualization of force from tensometric beam. I managed to achieve simple chart and and simple visualization of actual pressure force (in circle).
  (<a href="https://imagizer.imageshack.com/img922/2663/spBwMs.gif" rel="nofollow noreferrer">https://imagizer.imageshack.com/img922/2663/spBwMs.gif</a>)
  Now I'd like to represent it as 3D bar. 
  I tried to understood some examples from Ensemble: jnlps://download.oracle.com/otndocs/products/javafx/8/samples/Ensemble/Ensemble.jnlp 
  and I managed to do something like that:
  (<a href="https://imagizer.imageshack.com/img921/2766/12te0a.gif" rel="nofollow noreferrer">https://imagizer.imageshack.com/img921/2766/12te0a.gif</a>)
  but I'd like to achieve something similar using FXML file. </p>
  
  <p>I tried to code it but no effect so far. I'd like you use some Hbox to place 2 boxes next to each other, but then I don't know where to place Camera properly. Actually 3D with javaFX is a little bit of black magic for me ;)</p>
  
  <p>Main.java:</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.scene.SceneAntialiasing;
  import javafx.stage.Stage;
  
  public class Main extends Application {
  
      @Override
      public void start(Stage primaryStage) throws Exception{
          Parent root = FXMLLoader.load(getClass().getResource("main.fxml"));
          primaryStage.setTitle("Hello World");
          primaryStage.setScene(new Scene(root,800,800, true, SceneAntialiasing.BALANCED));
          primaryStage.show();
      }
  
  
      public static void main(String[] args) {
          launch(args);
      }
  }
  </code></pre>
  
  <p>Controller.java:</p>
  
  <pre><code>
  import javafx.animation.KeyFrame;
  import javafx.animation.KeyValue;
  import javafx.animation.Timeline;
  import javafx.beans.InvalidationListener;
  import javafx.beans.Observable;
  import javafx.fxml.FXML;
  import javafx.scene.*;
  import javafx.scene.layout.AnchorPane;
  import javafx.scene.paint.Color;
  import javafx.scene.paint.PhongMaterial;
  import javafx.scene.shape.Box;
  import javafx.scene.transform.Rotate;
  import javafx.scene.transform.Translate;
  import javafx.util.Duration;
  
  
  public class Controller{
  
      @FXML
      private AnchorPane pane;
      @FXML
      private Box box;
      @FXML
      private PerspectiveCamera camera;
  
  
      final Rotate rx = new Rotate(0, Rotate.X_AXIS);
      final Rotate ry = new Rotate(0, Rotate.Y_AXIS);
      final Rotate rz = new Rotate(0, Rotate.Z_AXIS);
  
      private Timeline animation;
  
      @FXML
      void initialize() {
  
  
          box.setMaterial(new PhongMaterial(Color.ORANGE));
  /*      box.setDepth(100);
          box.setWidth(100);
          box.setHeight(100);*/
          rx.setAngle(90);
          ry.setAngle(25);
          box.getTransforms().addAll(rz, ry, rx);
  
          animation = new Timeline();
          animation.getKeyFrames().addAll(
                  new KeyFrame(Duration.ZERO,
  
                          new KeyValue(box.depthProperty(), 0d),
                          new KeyValue(box.translateYProperty(),400d)),
                  new KeyFrame(Duration.seconds(5),
  
                          new KeyValue(box.depthProperty(), 800d),
                          new KeyValue(box.translateYProperty(), 0d)));
  
          animation.setCycleCount(Timeline.INDEFINITE);
  
          camera.getTransforms().addAll (
                  new Rotate(-35, Rotate.X_AXIS),
                  new Translate(0, 0, 10)
          );
  
          box.sceneProperty().addListener(new InvalidationListener() {
              @Override
              public void invalidated(Observable observable) {
                  box.getScene().setCamera(camera);
                  box.sceneProperty().removeListener(this);
              }
          });
          animation.play();
      }
  
  }
  </code></pre>
  
  <p>main.fxml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import javafx.scene.PerspectiveCamera?&gt;
  &lt;?import javafx.scene.layout.AnchorPane?&gt;
  &lt;?import javafx.scene.shape.Box?&gt;
  
  &lt;AnchorPane fx:id="pane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="check.brakes.Controller"&gt;
     &lt;children&gt;
        &lt;Box fx:id="box" depth="100.0" height="100.0" layoutX="380.0" layoutY="673.0" width="100.0"&gt;
  
              &lt;/Box&gt;
        &lt;PerspectiveCamera fx:id="camera" farClip="70.0" fieldOfView="35.0" nearClip="0.5" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" /&gt;
     &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p>I expect the bars should look like from the example I provided.</p>
  
  <p><strong>Update</strong></p>
  
  <p>I did it, I'm sure it's not perfect at all, but somehow I have to start.</p>
  
  <p>BTW.</p>
  
  <p>Why is that, when i resize application window, camera angle is changing ?</p>