title: How can I add 3D surface to the AnchorPane
body: <p>How Can I add 3D surface to the <code>view.fxml</code>, there is not "thing" on the Scene Builder panel like surface. 
  My scene builder hierarchy looks like :</p>
  
  <p><a href="https://i.stack.imgur.com/Lu90k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lu90k.png" alt="Hierarchy"></a></p>
  
  <p>And ss of app - like we can see got something on the left top corner, the surface should be on the middle. 
  <a href="https://i.stack.imgur.com/k0Ygc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k0Ygc.png" alt="enter image description here"></a></p>
  
  <p>I would like to add first just some samples of 3D surface : 
  My controller code : </p>
  
  <pre><code>    package sample.packet3D;
  
  import org.fxyz.cameras.CameraTransformer;
  
  import javafx.beans.InvalidationListener;
  import javafx.beans.Observable;
  import javafx.fxml.FXML;
  import javafx.scene.Group;
  import javafx.scene.PerspectiveCamera;
  import javafx.scene.PointLight;
  import javafx.scene.layout.AnchorPane;
  
  
  public class Window3DController {
  
      @FXML
      private AnchorPane anchorPane;
      @FXML
      private Group group;
  
      private Window3DBuilder window3dBuilder;
      private PerspectiveCamera perspectiveCamera;
  
  
  
      @FXML
      public void initialize() {
          perspectiveCamera = new PerspectiveCamera(true);
  
          window3dBuilder = new Window3DBuilder( group, perspectiveCamera );
          window3dBuilder.createScene();
  
  
  
          group.sceneProperty().addListener(new InvalidationListener() {
  
              @Override
              public void invalidated(Observable observable) {
                  group.getScene().setCamera(perspectiveCamera);
                  group.sceneProperty().removeListener(this);
              }
          });
      }
  }
  </code></pre>
  
  <p>Logic class :</p>
  
  <pre><code>   package sample.packet3D;
  
  
  import org.fxyz.cameras.CameraTransformer;
  import org.fxyz.shapes.primitives.SurfacePlotMesh;
  
  import javafx.geometry.Point3D;
  import javafx.scene.Group;
  import javafx.scene.PerspectiveCamera;
  import javafx.scene.PointLight;
  import javafx.scene.SceneAntialiasing;
  import javafx.scene.SubScene;
  import javafx.scene.layout.AnchorPane;
  import javafx.scene.paint.Color;
  import javafx.scene.shape.CullFace;
  import javafx.scene.shape.TriangleMesh;
  import javafx.scene.transform.Rotate;
  
  public class Window3DBuilder {
  
      private Group group;
      private SurfacePlotMesh surface;
      private PerspectiveCamera perspectiveCamera;
      private CameraTransformer cameraTransformer;
      private PointLight light;
  
      public Window3DBuilder( Group group, PerspectiveCamera perspectiveCamera ) {
          this.group = group;
          this.perspectiveCamera = perspectiveCamera;
          cameraTransformer = new CameraTransformer();
      }
  
      public void createScene() {
  
          createSurface();
          createLight(); 
          group.getChildren().addAll(surface);
  
          cameraTransformer.setTranslate(0, 0, 0);
          cameraTransformer.getChildren().addAll(perspectiveCamera);
  
          perspectiveCamera.setNearClip(0.1);
          perspectiveCamera.setFarClip(100000.0);
          perspectiveCamera.setTranslateX((group.getBoundsInLocal().getMaxX() + group.getBoundsInLocal().getMinX()) / 2d);
          perspectiveCamera.setTranslateY((group.getBoundsInLocal().getMaxY() + group.getBoundsInLocal().getMinY()) / 2d);
          double max = Math.max(group.getBoundsInLocal().getWidth(), group.getBoundsInLocal().getHeight());
          perspectiveCamera.setTranslateZ(-2 * max);
  
      }
  
      public void createLight() {
          light = new PointLight(Color.WHITE);
          cameraTransformer.getChildren().add(light);
          light.setTranslateX(perspectiveCamera.getTranslateX());
          light.setTranslateY(perspectiveCamera.getTranslateY());
          light.setTranslateZ(perspectiveCamera.getTranslateZ());
      }
  
      private void createSurface() {
          surface = new SurfacePlotMesh(
                  p-&gt; Math.sin(p.magnitude() + 1e-10) / (p.magnitude() + 1e-10),
                  20, 20, 100, 100, 4);
          surface.setCullFace(CullFace.NONE);
          surface.setTextureModeVertices3D(1530, p -&gt; p.magnitude());
          surface.getTransforms().addAll(new Rotate(200, Rotate.X_AXIS), new Rotate(-20, Rotate.Y_AXIS));
      }
  
  
  
  }
  </code></pre>
  
  <p>And view :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import javafx.scene.effect.*?&gt;
  &lt;?import javafx.scene.canvas.*?&gt;
  &lt;?import javafx.scene.*?&gt;
  &lt;?import javafx.scene.shape.*?&gt;
  &lt;?import javafx.scene.control.*?&gt;
  &lt;?import java.lang.*?&gt;
  &lt;?import javafx.scene.layout.*?&gt;
  
  &lt;AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.packet3D.Window3DController"&gt;
     &lt;children&gt;
        &lt;Group fx:id="group"&gt;
           &lt;effect&gt;
              &lt;Lighting&gt;
                 &lt;bumpInput&gt;
                    &lt;Shadow /&gt;
                 &lt;/bumpInput&gt;
                 &lt;light&gt;
                    &lt;Light.Distant /&gt;
                 &lt;/light&gt;
              &lt;/Lighting&gt;
           &lt;/effect&gt;
        &lt;/Group&gt;
        &lt;PerspectiveCamera fx:id="perspectiveCamera" visible="false" /&gt;
     &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p>What Am I doing wrong ? Could someone help me ?
  Also this is one of the window, to which I am entering by pressing the button.</p>
  
  <pre><code>@FXML
      public void moveTo3DScene(ActionEvent event) throws IOException {
          Stage stage3D = (Stage) ((Node) event.getSource()).getScene().getWindow();
          Parent parent3D = FXMLLoader.load(getClass().getResource("packet3D/Window3DSceneView.fxml"));
          stage3D.setTitle("Animation 3D");
          stage3D.setScene(new Scene(parent3D, 1200, 800));
          stage3D.show();
  
      }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/BO2xA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BO2xA.png" alt="enter image description here"></a></p>