title: Overlaping Shapes - wrong overlapping shapes behaviour
body: <p>In short - I have 2 rotating rectangles. While rotating (by Y axis) they should overlap one over another - unfortunetlny one of ractangles is "always in front" despite of 180 degree turn. How to fix that behaviour? It looks like it is relevant to order in whitch rectangles hass been added to group. The one that was added as last is always in front.</p>
  
  <p>scene:</p>
  
  <pre><code>    package drawing.scene;
  
  import javafx.application.Application;
  import javafx.geometry.Point3D;
  import javafx.scene.Camera;
  import javafx.scene.Group;
  import javafx.scene.PerspectiveCamera;
  import javafx.scene.Scene;
  import javafx.scene.transform.Rotate;
  import javafx.stage.Stage;
  import drawing.objects.Clock;
  import drawing.objects.Cube;
  
  public class MyScene extends Application {
  
      private int sceneEdgeSize = 800;
      private int clolcSize = 400;
  
      @Override
      public void start(Stage primaryStage) throws Exception {
          Group g = new Group();
          g.setTranslateX((sceneEdgeSize - clolcSize) / 2f);
          g.setTranslateY((sceneEdgeSize - clolcSize) / 2f);
  
          final Cube c = new Cube(clolcSize);
          g.getChildren().add(c);
          Thread t = new Thread(new Runnable() {
  
              @Override
              public void run() {
                  Rotate r = rotate(0, Rotate.Y_AXIS);
                  c.getTransforms().add(r);
                  double angle = 0.0;
                  while (true) {
  
                      r.setAngle(angle += 2);
                      try {
                          Thread.sleep(25);
                      } catch (InterruptedException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                      }
                  }
              }
          });
          t.setDaemon(true);
          primaryStage.setScene(new Scene(g, sceneEdgeSize, sceneEdgeSize));
          PerspectiveCamera camera = new PerspectiveCamera();
          primaryStage.getScene().setCamera(camera);
          primaryStage.show();
          t.start();
  
      }
  
      public static void main(String[] args) {
          launch(args);
      }
  
      public Rotate rotate(double angle, Point3D axis) {
          return new Rotate(angle, clolcSize / 2f, clolcSize / 2f, 0, axis);
      }
  
  }
  </code></pre>
  
  <p>cube class:</p>
  
  <pre><code>package drawing.objects;
  
  import javafx.collections.ObservableList;
  import javafx.scene.Group;
  import javafx.scene.Node;
  import javafx.scene.paint.Color;
  import javafx.scene.shape.Rectangle;
  import javafx.scene.shape.RectangleBuilder;
  import javafx.scene.transform.Rotate;
  
  public class Cube extends Group {
  
      private double edgeLength = 0;
  
      public Cube(double edgeLength) {
          super();
          this.edgeLength = edgeLength;
          create();
      }
  
      private void create() {
          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);
  
          this.getTransforms().addAll(rx, ry, rz);
  
          ObservableList&lt;Node&gt; children = this.getChildren();
          //@formatter:off
  
          Rectangle rect;
  
          rect = RectangleBuilder // face
                  .create()
                  .width(edgeLength-20)
                  .height(edgeLength-20)
                  .translateZ(edgeLength * 0.5)
  //                  .translateY(edgeLength * 0.5)
                  //  .translateX(-edgeLength * 0.5)
                  .fill(Color.LIGHTGREEN)
                  .build()
                  ;
          children.add(rect);
          rect = RectangleBuilder // face
                  .create()
                  .width(edgeLength-20)
                  .height(edgeLength-20)
                  .translateZ(-edgeLength * 0.5)
  //              .translateY(-edgeLength * 0.5)
              //  .translateX(-edgeLength * 0.5)
                  .fill(Color.DARKGREEN)
                  .build()
                  ;
          children.add(rect);
  
  
          //@formatter:on
      }
  }
  </code></pre>