I want to show 3D mesh after generating it in a Java FX thread but in the final view I can see both - this mesh and unexpected plane which is interrupting the proper shape/mesh.
How do I find the problem? Firstly, I've created a test Java FX application in which I wanted to show generated mesh. It worked correctly as you can see here:
and code for this something like this:
public class Main extends Application {
@Override
public void start(Stage arg0) throws Exception {
Group meshGroup = new Group();
TriangleMesh detectedMesh = new TriangleMesh();
detectedMesh.getTexCoords().addAll(0, 0);
// ... adding points and faces to the mesh from double[][] data
MeshView mv = new MeshView(detectedMesh);
// ... some MeshView settings
meshGroup.getChildren().addAll(mv);
StackPane root = new StackPane();
root.getChildren().add(meshGroup);
Scene scene = new Scene(root, 800, 600, true, SceneAntialiasing.BALANCED);
scene.setCamera(new PerspectiveCamera());
Stage primaryStage = new Stage();
primaryStage.setScene(scene);
primaryStage.show();
}
}
Next, I wanted to use this code in the proper app which shows this mesh in the new window after some calculations. This time, the problem occured as you can see here:
Code for this is almost the same but this time it's not an independent application but the window is created by another Java FX thread. It's important that in both cases I've used the same double[][] data.
public class ChartGenerator {
double[][] data;
public ChartGenerator(double[][] data) {
this.data = data;
}
public void show() {
Group meshGroup = new Group();
TriangleMesh detectedMesh = new TriangleMesh();
detectedMesh.getTexCoords().addAll(0, 0);
// ... adding points and faces to the mesh from double[][] data
MeshView mv = new MeshView(detectedMesh);
// ... some MeshView settings
meshGroup.getChildren().addAll(mv);
StackPane root = new StackPane();
root.getChildren().add(meshGroup);
Scene scene = new Scene(root, 800, 600, true, SceneAntialiasing.BALANCED);
scene.setCamera(new PerspectiveCamera());
Stage primaryStage = new Stage();
primaryStage.setScene(scene);
primaryStage.show();
}
}
I will be thankful for any ideas or suggestions.