3D Features Planned for Version 8
Introduction
This page contains the list of 3D features schedule for JavaFX 8.0
We have been thinking about the possible 3D features for JavaFX 8 for a while. We are now ready to present the plan to the community for review. This information has also been presented at this year's JavaOne 3D Made Easy with JavaFX technical session.
Three umbrella JIRA issues were created to capture most of the work: Movable Camera , 3D Geometry, and 3D Attributes
Here this a link to FX Experience blog on JavaFX 3D Early Access
A list simple examples
- A blue sphere and a red box with mouse control: SphereAndBox.java
- A rectangular mesh: SimpleMeshView.java
Proposed API
Proposed Features
Movable cameras and SubScene
- Camera is now a Node
- Camera can be added to a scene graph
- Camera's position and aim (or orientation) is set using standard Node transform properties and methods
- For backward compatibility, fixed camera need not be added to the scene
- Added new properties for near & far clipping plane
- SubScene is a special Node for scene separation
- It can be used to render part of the Scene with different camera
- Possible use cases are:
- Overlay for UI controls (needs a static camera)
- Underlay for background (static or updated less frequently)
- "Heads-up" display
Camera Class Hierarchy
- javafx.scene.Node
- javafx.scene.Camera (abstract)
- javafx.scene.ParallelCamera
- javafx.scene.PerspectiveCamera
- javafx.scene.SubScene
- javafx.scene.Camera (abstract)
Code segment
Specifying a fixed Camera (existing 2.2 API)
Specifying a movable Camera
3D primitives
- Added two type of 3D shapes, extending from an abstract Shape3D base class:
- User-defined shapes (MeshView)
- Predefined shapes
User-defined shapes
- User defined mesh (geometry) of a shape by specifying a set of points, texture coordinates, and faces (triangles that describe the topology)
- User defined smoothing group to specify group of faces that are part of the same curved surface
- A mesh is sharable among mutiple user-defined shapes
Predefined shapes
- Three commonly used predefined 3D shapes are introduced: Box, Cylinder and Sphere
Shape3D Class Hierarchy
- javafx.scene.Node
- javafx.scene.shape.Shape3D (abstract)
- javafx.scene.shape.MeshView
- javafx.scene.shape.Box
- javafx.scene.shape.Cylinder
- javafx.scene.shape.Sphere
- javafx.scene.shape.Shape3D (abstract)
Mesh Class Hierarchy
- java.lang.Object
- javafx.scene.shape.Mesh (abstract)
- javafx.scene.shape.TriangleMesh
- javafx.scene.shape.Mesh (abstract)
Code Segment
Defining a MeshView
Using Predefined Shapes
3D attributes
- Added lights and 3D materials to add realism for 3D shapes.
- Material specifies the appearance of a 3D shape
- Light interacts with the geometry of a Shape3D and its material to provide the rendering result
- A Shape3D can be rendered as a filled shape or as a wireframe
- A Shape3D has a face culling property (front, back or none)
Light
- Light is defined as a node in the scene graph
- A scene contains a set of active lights
- A default light is provided when the set of active light is empty
- Each light contains a set of affected nodes
- If a Parent is in the set, all its children are affected
- Default is the root node of the Scene
- Added 2 type of light sources:
- AmbientLight and PointLight
- May add more in the future
Material
- Material contains a set of rendering properties
- PhongMaterial is a concrete subclass of Material
- It has the following properties:
- Ambient color
- Diffuse color, diffuse map
- Specular color, specular map
- Specular power
- Bump map
- Self-illumination map
- It has the following properties:
- Sharable among multiple Shape3D nodes
Light Class Hierarchy
- javafx.scene.Node
- javafx.scene.LightBase (abstract)
- javafx.scene.AmbientLight
- javafx.scene.PointLight
- javafx.scene.LightBase (abstract)
Material Class Hierarchy
- java.lang.Object
- javafx.scene.paint.Material (abstract)
- javafx.scene.paint.PhongMaterial
- javafx.scene.paint.Material (abstract)
Code Segment
Defining Lights
Defining Materials
3D picking
- 3D ray picking already used for 2D primitives with PerspectiveCamera
- Existing limitation when used with depth buffer will be fixed (JIRA: RT-13740)
- We will add support for picking 3D geometry (JIRA: RT-24646)
Proposed API to support 3D picking: Picking3dAPI
Methods added to Node
- A LOD helper method that returns the area of the Node projected onto the physical screen in pixel units.
- A set of 3D transform methods
Loader support
- Many 3D file formats exist, such as:
- Obj, Maya, 3D Studio Max, Collada, KRML
- We will not provide a loader as part of the JavaFX runtime
- We will make sample code available for one or two popular formats



15 Comments
comments.show.hideOct 17, 2012
21912
It is extremely important to support officially at least one file format. I believe Java3D did not get widespread adoption because of this point. Do not underestimate the importance of supporting a file format. Without it there is no workflow from 3D modeling software to JavaFX 3D.
Instead of obj, maya, 3ds or blender file formats, JavaFX should support the FBX format. This is supported by almost every modeling software. It is also the format supported by the Unity game engine, which means there are enourmous number of available models to purchase or download for free (and most of these are modeled specifically to add to a real time engine/game engine), and also millions of modelers who are already using the workflow of model -> FBX -> 3D engine.
Please reconsider the lack of a file format loader, it would be a catastrophic error not to include and officially support one.
Feb 20, 2013
zmirc
I really really agree with you. This is a killer feature. It must be available. It would bring so many benefits to have this feature.
Oracle team, please consider this if you want JavaFX to be a huge success!
Oct 21, 2012
Narayan
This 3D Features is really important for me and all JavaFX Devs. I'm glad to hear about this features updates. I've been making some 3D Maker Software for JavaFX like "Scene Builder". I think JavaFX must be made highly optimized for rendering the 3D objects . I found many glitch while making this software like performance, the memory usage etc. Anyway hope in future JavaFX team will improve for the optimization and high graphics acceleration.
I'm looking forward for the supported formats which can be imported in javafx for 3D Development.
Thanks
Dec 30, 2012
Patrick Martin
In my opinion, what you propose is very difficult and is reinventing the wheel. I think that the effort would be better spent embracing WebGL support within the WebKit based WebView. JavaFX already embraces the official HTML5 standards and this seems to be a natural step in its evolution.
I would think that enabling the WebGL hooks already existing in the WebKit would also be much easier to accomplish. It's quite easy to facilitate data bindings between the WebEngine and some html content. WebGL would bring powerful frameworks like Three.js into JavaFX.
I have tried to get by with Three.js rendering to a canvas, but the capabilities are very limited and the performance is about 60 times slower than a WebGL renderer.
Rendering to HTML5 also has the benefit of easily saving JavaFX created assets as standalone html pages and I think that this follows the existing paradigm of embracing existing and emerging web standards in JavaFX.
Feb 20, 2013
Arnaud Couturier
Agreed, long and difficult path ahead.
It'll only be useful to the most simplistic cases, and won't leverage 20 years of OpenGL/DirectX advances and experience.
You will quickly run into limitations by wrapping OpenGL/DirectX into yet another scenegraph API. Expose low level API first please. Lots of third-party scenegraphs exist already for those who need more simplicity. You could even sponsor one of them as “semi-official”, like Adobe did with Away3D.
I have an app that uses JOGL, but I can’t port it to JavaFX if it doesn’t support OpenGL, which is a real pity since JavaFX has lots of strong points (CSS GUI skinning!)
Why not work with the JOGL team to expose OpenGL to JavaFX officially ?
Jan 28, 2013
ciruman
Since 14th Nov, last year, there is no more information about 3D. Is there any information about the progress? In Java 8, there is no 3D change, and the 28th Feb there is a developer preview. Are those 3D features postposed?
Thanks.
PD.- I also think that providing WebGL for the webview will be powerful (http://madebyevan.com/webgl-water/).
Jan 28, 2013
Chien Yang
The implementation of 3D API for FX 8 is actively being developed and should be available in a FX 8 EA build soon.
Jan 31, 2013
SproketBoy
Thanks, how can we be notified of this? I'll watch this page. :)
Feb 01, 2013
Chien Yang
I believe the OpenJFX alias (openjfx-dev@openjdk.java.net) might be a good place to monitor the 3D API progress. We will be sending a formal 3D API approval request to the OpenJFX alias shortly.
Feb 20, 2013
KonradZuse
I see how we can define images using "materials" but can we define each side of a rectangle, or another 3D Object(That has sides)? What about splitting a sphere in half and having 2 different images or affects on each? Before using a box, I had made a cube using a rectangle builder for 6 sides, and having 6 images to create a "dice." There seems to be a lot of new features I don't know about, so I apologize if it's specified above to which I didn't grasp it :).
Feb 20, 2013
waynedyoung
Here's a Java 8 Lambda version of the rotation logic.
Feb 22, 2013
KonradZuse
Yeah I found that out last night with NEtbeansLamba8. I thought it was super cool.. I'm new to Event Handling in JavaFX, so normally you would do event, then mouse? I know in swing you could do a few things like implement the mouseMotionListener, or call each and override, which seems to be what this lambda is getting rid of :). super cool!
Feb 21, 2013
ciruman
There is something wrong, in the TriangleMesh there is no setPositions, but there is setPoints.
Thanks for the example, is there any example with triangle mesh? I make sence to add a link to the example from fxexperience: http://fxexperience.com/2013/02/javafx-3d-early-access-available/.
Feb 22, 2013
Chien Yang
Thanks for pointing this out. I have updated the code segment. The setPositions was the name used in our prototype. This name is now changed to setPoints during our API review.
Here is a simple mesh generation program: https://wikis.oracle.com/display/OpenJDK/SimpleMeshView.java
Feb 28, 2013
KonradZuse
Why exactly is there no set x, y, z for Box?