This discussion is archived
6 Replies Latest reply: Jan 3, 2013 5:49 PM by 805536 RSS

JavaFX 3D support

PatrickMartin Newbie
Currently Being Moderated
I see in the JavaFX roadmap that 3D capabilities and enhanced HTML5 support are being seriously considered. My fear is that Oracle will invest heavily in rolling their own framework.

JavaFX is based upon a theater paradigmn which translates pretty well into the scene/view/camera paradigm prevalent in most 3D frameworks. However, JavaFX is also unique in the sense that it embraces HTML5 technologies both externally via the ability to pull webcontent into the application then interact with it internally via executeScript routines. The applications are skinnable via CSS (something I am growing to appreciate).

Developing a new 3D framework feels like a mistake and a waste of limited resources. In my opinion, the most bang for the Oracle development buck would come from integrating WebView fully into WebGL as it would bring fairly mature frameworks with an immense amount of preexisting content such as Three.js into JavaFX. Embrace and extend. Many existing WebGL appls could also be seamlessly integrated into the JavaFX experience.

I understand that SVGRenderers and Canvas renders can be used in frameworks like Three.js. I've been there, tried to do that. However, they are mostly useless for any task beyond rotating a hello world cube on a screen. Textures and many other features are not supported and performance is about 60 times slower based on FPS ratings I see in the small subset of applications which can be retooled to use alternate renderers.

JavaFX should flow with the web standards and emerging ones such as WebGL. Embrace and adopt them so that their capabilities become ours. If Oracle wants to create new 3D capabalities unique to JavaFX, fine. Cover your bet and embrace the existing capabilities emerging within the browser.

Java is awesome in so many respects, but I've never seen it come anywhere close to competing in the 3d space with the content you can create with WebGL, and it's quickly making its way to the mobile devices. It's already supported in Apple devices in things like iAd. The ability is there, though Apple has not yet chosen to enable it.

My fear is that by the time JavaFX catches up in this area, it'll be too late.

Hopefully this comes across as constructively as it was intended.

- Pat
  • 1. Re: JavaFX 3D support
    KonradZuse Explorer
    Currently Being Moderated
    you make some good points; however you are forgetting that FX is new, especially 2.0 that we use. Give it some time and FX will most likely take over. The same could be applied to Open GL. I've never heard of Web GL, but why code in FX when thereis Open GL? Same issue.
  • 2. Re: JavaFX 3D support
    PatrickMartin Newbie
    Currently Being Moderated
    You are very optimistic!

    I don't see FX or any technology which isn't supported natively within the browser taking over across the board. This is why these technologies have to be embraced and strategies adopted which offer everything that you can do in the browser, plus additional capabilities you get with adopting FX. WebGL is on the cusp of being available everywhere; but not quite there yet.

    I wouldn't hold my breath on FX supplanting HTML5. I don't see that happening.

    WebGL is based on OpenGL ES 2.0. So you're really talking about a standard which has been evolving since the SGI Open Inventor days going back at least 20 years.

    Content like this is everywhere:

    http://helloracer.com/webgl/

    Oracle and the Java teams are amazing, but the bar has been raised dramatically in this space, and I'd rather see JavaFX stay focused on delivering a solid UI experience rather than spread themselves too thin by trying to tackle a custom 3D framework. Better to embrace an existing one.

    - Pat
  • 3. Re: JavaFX 3D support
    gimbal2 Guru
    Currently Being Moderated
    Patrick Martin wrote:
    You are very optimistic!
    There is a whole thread about this you know, its not like you are the first one to get up in the morning and wonder about this stuff.

    JavaOne 2012: JavaFX on iOS, Android and Windows 8 Metro???
    I wouldn't hold my breath on FX supplanting HTML5. I don't see that happening.
    Not really difficult to reason since Oracle itself has expressed this.
    and I'd rather see JavaFX stay focused on delivering a solid UI experience rather than spread themselves too thin by trying to tackle a custom 3D framework.
    On THAT we -fully- agree. There are plenty of good third party 3D solutions like LWJGL or JogAmp for low level stuff, LibGDX for middle level and something like JMonkeyEngine for high level abstraction.
  • 4. Re: JavaFX 3D support
    KonradZuse Explorer
    Currently Being Moderated
    FX and HTML are RIA's. FX NEEDS 3D. WebGL is okay and all, but it's just for the web? How big is it? Supported? In Java Currently there is JOGL(rare support last updated in 2008) and LWJGL which has more support. Problem is these are open source projects that might die soon. There is no set help for either also. Very limited tuts, and help all on the web. Why should we have to rely on 3rd party when Oracle can do it themselves? FX already has an Open GL Wrapper, all we need to do is implement it. Scene Builder already supports 3D objects, and rotation. 3D objects already exist in FX as well.. FX is the future, why rely on a 3rd party that might die?

    Also see this...

    https://wikis.oracle.com/display/OpenJDK/3D+Features

    Edited by: KonradZuse on Jan 3, 2013 10:38 AM
  • 5. Re: JavaFX 3D support
    gimbal2 Guru
    Currently Being Moderated
    KonradZuse wrote:
    FX and HTML are RIA's. FX NEEDS 3D. WebGL is okay and all, but it's just for the web? How big is it? Supported? In Java Currently there is JOGL(rare support last updated in 2008) and LWJGL which has more support. Problem is these are open source projects that might die soon.
    Open Source projects that start as Open Source projects don't die so easily. Closed source projects that then become open source have a far short shelf life. Just check out java.net, its full of ghosts of abandoned babies.
    There is no set help for either also.
    Plenty of books. Not on the APIs themselves but that's because they are only thin wrappers; you need to learn OpenGL, not JOGL or LWJGL.
    Very limited tuts, and help all on the web.
    Plenty of tuts, if you search in the correct context (OpenGL, OpenAL).
    Why should we have to rely on 3rd party when Oracle can do it themselves?
    Why not? It has worked perfectly fine for the past 15 years. Java Enterprise wouldn't be what it is today without the efforts of Apache, JBoss, IBM, ... Heck the JDK itself contains third party additions.
    why rely on a 3rd party that might die?
    JavaFX 1 died. Java3D died. JMF died. JAI died. J2ME is on life support. Heck: Sun died! And that's not third party stuff.

    If there is one certainty, it is that in software dev you deal only with uncertainty. We have learned to adapt and cope with that, so its not a problem. If JavaFX 2 comes to pass we'll just flock to the next best thing. If Java as a platform comes to pass (I hope not), we'll just pick up another brand of hammers, saws and screwdrivers.
  • 6. Re: JavaFX 3D support
    805536 Journeyer
    Currently Being Moderated
    >
    Java is awesome in so many respects, but I've never seen it come anywhere close to competing in the 3d space with the content you can create with WebGL, and it's quickly making its way to the mobile devices.
    >
    No reason you can't duplicate the same results already. JOGL is the Java port of OpenGL. As far as I can tell, WebGL is nothing more than a JavaScript port of the same.

    >
    Developing a new 3D framework feels like a mistake and a waste of limited resources. In my opinion, the most bang for the Oracle development buck would come from integrating WebView fully into WebGL as it would bring fairly mature frameworks with an immense amount of preexisting content such as Three.js into JavaFX. Embrace and extend. Many existing WebGL appls could also be seamlessly integrated into the JavaFX experience.
    >
    If you want to use OpenGL with Java, use JOGL, the Java port of OpenGL. If you really want to use the new WebGL standard, then why even bother with Java at all, you may as well use JavaScript, the language WebGL was created for in the first place. I hear that this is what Runescape is planning to do.

    The entire point of using JavaFX instead of OpenGL is the fact that it is high level. So instead of:
    //Draw the same shape twice, but with different positions.
    //Pass the appropriate arrays into OpenGL.
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(3, GL_FLOAT, 0, vertices);
    
    glEnableClientState(GL_NORMAL_ARRAY);
    glNormalPointer(GL_DOUBLE, 0, normals);
    
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glTexCoordPointer(2, GL_DOUBLE, 0, textureCoordinates);
    
    //Draw the shape the first time.
    glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, indices);
    
    //Apply a translation matrix.
    glTranslate3f(32, 0, 0);
    
    //Draw the shape a second time.
    glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, indices);
    
    //Deactivate vertex arrays after drawing
    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_NORMAL_ARRAY);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    You might do [url https://wikis.oracle.com/display/OpenJDK/3D+Features]something like this as is described here :
     
    // Create a mesh
    TriangleMesh mesh = new TriangleMesh();
    mesh.setPositions(positions);
    mesh.setTexCoords(texCoords);
    mesh.setFaces(faces);
     
    // Create a couple mesh views with the same shape, but different positions.
    MeshView mv = new MeshView(mesh);
    MeshView mv2 = new MeshView(mesh);
    mv2.setTranslateX(32);
    Less flexible, but in a much more convenient object model.