>>432 のつづき

public BranchGroup createSceneGraph() {
BranchGroup objRoot = new BranchGroup();

/* この例では、ColorCubeクラスを使ってます */
objRoot.addChild(new ColorCube(0.4));
objRoot.compile();

return objRoot;
}

public Sample3D() {
getContentPane().setLayout(new BorderLayout());

GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();

Canvas3D canvas = new Canvas3D(config);
getContentPane().add("Center", canvas);

BranchGroup scene = createSceneGraph();
SimpleUniverse universe = new SimpleUniverse(canvas);

universe.getViewingPlatform().setNominalViewingTransform();
universe.addBranchGraph(scene);
}