Java3D Specific Hints

10. Play by Java3D's rules

The most obvious thing to affect the performance of Java3D is the scene graph you create

Read the documentation

The most obvious thing to affect the performance of Java3D is the scene graph you create. Java 3D recommends a number of basic things you can do to your scene graph in the interests of efficiency. These are all pretty obvious if you've read the documentation, but as a refresher remember to:

  1. enable only the minimum number of capabilities required for each node in the scene - see SceneGraphObject.setCapability()

  2. compile any static branches of the scene - see BranchGroup.compile()

  3. set minimal bounding volumes for the Nodes in the scene - see Node.setBounds()

The first two won't make a massive difference to the performance of your code [3] but they're good programming practices to follow. Tight specification of bounds is more important, and can really improve picking and collision detection. Think a little more carefully when it comes to the bounds on Behaviour nodes. Java3D tries to encourage you to minimise behaviour bounds, but in tip #12 and tip #15 we'll look at why this isn't necessarily good advice.