Java3D Specific Hints

11. Collapse chains of transforms

Dangers of having too many transforms in a scene

Every position and orientation of every object in a scene is specified with one or more TransformGroups, so inevitably they are going to be one of the most common nodes you use.

Java3D has to multiply together all the transforms from that leaf back to the root of the scene.

Where you can, combine a sequence of transformations together into a single TransformGroup.

Java3D does this automatically (compile a branch), but only for transformations which can't be read or written to.

Dear old TransformGroup, what a trusty friend it is. But sometimes your friends can lead you into bad ways. Mother always said not to take sweets from strangers, but she never mentioned the dangers of having too many transforms in a scene. Every position and orientation of every object in a scene is specified with one or more TransformGroups, so inevitably they are going to be one of the most common nodes you use. Trouble is to render a bit of geometry at one of the leaves in your scene Java3D has to multiply together all the transforms from that leaf back to the root of the scene. If you have long chains of transforms that can start to cost a bit. Perhaps Mother doesn't know best after all.

Where you can, it pays to combine a sequence of transformations together and so collapse a long chain down to a single TransformGroup. Java3D does this automatically when you compile a branch of your scene graph, but only for transformations which can't be read or written to. If you need to update the positions of objects it's far better to concentrate all those updates into one, or a small number, of transform nodes.