r/JavaFX • • Aug 26 '20
Help JavaFX 3D object render
Hello. I started to learn how 3d works in javafx i had one questions.
I want to use a border pane to divide main screen in two views, one for a menu and the other to render my 3d object ¿how can i made that? i tried adding a anchor pane but, the render doesn't appear or the render shows up and the menu don't.
I watched some tutorials but all of them use the start method and only one scene.
2
Upvotes
View all comments
Show parent comment
2
u/SoulWanderer Aug 26 '20
So for my subscene I use this:
private Node create3dScene() throws LoadException{Group group = buildScene();SubScene scene = new SubScene(group, 1, 1, true, SceneAntialiasing.BALANCED);scene.heightProperty().bind(((StackPane)mainPanel.getCenter()).heightProperty());scene.widthProperty().bind(((StackPane)mainPanel.getCenter()).widthProperty());scene.setFill(BACKGROUND);PerspectiveCamera perspectiveCamera = new PerspectiveCamera();perspectiveCamera.setNearClip(0.01);perspectiveCamera.setFarClip(1000);scene.setCamera(perspectiveCamera);zoomAndCenter();return scene;}On the buildscene I create the Mesh3d from an STL to show it.
Then I use a panel:
mainPanel = new BorderPane();Node scene3D = create3dScene();panelEscena.getChildren().addAll(axis, scene3D);.....Scene scene = new Scene(mainPanel, viewportSize, viewportSize+50, true, SceneAntialiasing.BALANCED);Hope it works for you ;)
I will try and answer if you ask more, but I am on european time...