import com.sun.j3d.utils.behaviors.vp.OrbitBehavior; //导入依赖的package包/类
private void init( )
{
canvasComponent.setPreferredSize( new Dimension( 400 , 400 ) );
canvasComponent.setSize( new Dimension( 400 , 400 ) );
universe = new SimpleUniverse( this.canvas );
frame = new JFrame( );
frame.getContentPane( ).setLayout( new BorderLayout( ) );
frame.getContentPane( ).add( BorderLayout.CENTER , canvas );
vp = universe.getViewingPlatform( );
camera = new Camera3D( vp );
camera.setLocation( new Point3d( 0 , 2 , 0 ) , true );
camera.lookAt( new Point3d( 0 , 0 , 0 ) , true );
sceneRoot = new BranchGroup( );
sceneRoot.setCapability( BranchGroup.ALLOW_CHILDREN_EXTEND );
sceneRoot.setCapability( BranchGroup.ALLOW_CHILDREN_READ );
sceneRoot.setCapability( BranchGroup.ALLOW_CHILDREN_WRITE );
axes = new XyzAxes2( .05f , 1f );
sceneRoot.addChild( axes );
ambientLight = new AmbientLight( new Color3f( .3f , .3f , .3f ) );
worldBounds = new BoundingSphere( new Point3d( ) , 10000.0 );
ambientLight.setInfluencingBounds( worldBounds );
ambientLight.setCapability( Light.ALLOW_STATE_WRITE );
sceneRoot.addChild( ambientLight );
sceneTrans = new TransformGroup( );
sceneTrans.setCapability( TransformGroup.ALLOW_TRANSFORM_WRITE );
sceneTrans.addChild( sceneRoot );
worldRoot = new BranchGroup( );
worldRoot.addChild( sceneTrans );
orbiter = new OrbitBehavior( universe.getCanvas( ) );
orbiter.setSchedulingBounds( worldBounds );
vp.setViewPlatformBehavior( orbiter );
universe.addBranchGraph( worldRoot );
frame.pack( );
}