Alternatives to JavaFX 3D Graphics

I've been trying to use JavaFX meshes to display a folded bidimensional figure in a 3D space. It's been completely unworkable even when creating two meshes, one for the front side and one for the back. Without getting in the details, let's just say it simply won't display correctly. For the main graphics API included in the JDK and already at version 8, this has been equally surprising and frustrating. It seems JavaFX's meshes are only practical if you intend to create closed three dimensional figures.

On top of that, the surfaces look ugly and unrealistic, although, to be fair, I didn't spend much time delving with textures to try to get a better visual result.

Let this be a warning to those who intend to use JavaFX with a similar purpose in mind.

The good news is that one can use other Java 3D graphics libraries and integrate them with JavaFX for the rest of the application.

Thin Wrappers

Using a thin wrapper like JOGL, which is an OpenGL wrapper, or LWJGL, another thin OpenGL wrapper,  and integrating it with the JavaFX application using JavaFX's SwingNode is one possibility.

JOGL seems to be a dead project now and LWJGL's documentation is sparse and not very good. The spaghetti code to get the latter working is also scary to look at. Not to mention the need to understand the mathematics of 3D transformations. As someone who likes maths, I have no particular interest in spending time to understand the formulas, code them, unit test them and finally debug the inevitable error. If I want to let's say, rotate an object around an axis in a 3D space, I want a library method to that.

Game Engine

Another possibility is using a game engine such as jmonkeyengine that provides high level functions even if we are only interested in a small subset of it. It is under active development and the documentation is pretty good.

Java3D

If you feel a game engine is overkill for your purposes you still have the possibility of using Java 3D, which provides a lot of high level functionality.

Despite some claims to the contrary, Java3D is not dead. JavaFX is probably viewed as a replacement at Oracle and there are no new developments since version 1.5, but it continues to be actively developed by a third party. 

Version 1.5 is part of the JDK. If you want a newer version you'll need to add the jars to your project and it will likely continue to be a third party library in the future.

As I mentioned before, Java 3D is a high level wrapper, which I find more convenient than thin wrappers for most cases, and it runs atop DirectX or OpenGL.

Comments