BranchGroup scene = new BranchGroup();
/* Create a TransformGroup node. Enable its TRANSFORM_WRITE
capability so it can be affected at run time */
TransformGroup tg = new TransformGroup();
tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
scene.addChild(tg); // add to the scene
// connect a coloured cube to the TransformGroup
tg.addChild( new ColorCube(0.4) );
/* Create a rotation behaviour (a rotation interpolator) which will
make the cube spin around its y-axis, taking 4 secs to do one
rotation. */
Transform3D yAxis = new Transform3D();
Alpha rotationAlpha = new Alpha(-1, 4000); // 4 secs
RotationInterpolator rotator =
new RotationInterpolator(rotationAlpha, tg,
yAxis, 0.0f, (float) Math.PI*2.0f);
rotator.setSchedulingBounds(
new BoundingSphere( new Point3d(0,0,0), 100.0) );
scene.addChild(rotator); // add to the scene
// optimize the scene graph
scene.compile();
return scene;