import java.applet.Applet;import java.awt.*;import javax.swing.*;import com.sun.j3d.utils.geometry.*;import com.sun.j3d.utils.universe.SimpleUniverse;import javax.media.j3d.*;import javax.vecmath.*;public class Kuubike extends JApplet implements Runnable{ TransformGroup keere1; TransformGroup keere2; double nurk; public Kuubike() { Canvas3D c = new Canvas3D(SimpleUniverse.getPreferredConfiguration()); getContentPane().add(c, BorderLayout.CENTER); BranchGroup juur = new BranchGroup(); Transform3D keerd1=new Transform3D(); keere1=new TransformGroup(keerd1); keere2=new TransformGroup(keerd1); keere1.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); keere2.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); Cylinder sl=new Cylinder(0.5f, 1.5f); Appearance v=new Appearance(); Material m=new Material( new Color3f(Color.black), new Color3f(Color.blue), new Color3f(Color.blue), new Color3f(Color.black), 1 ); v.setMaterial(m); sl.setAppearance(v); juur.addChild(keere1); juur.addChild(keere2); keere1.addChild(new ColorCube(0.5)); keere2.addChild(sl); juur.compile(); SimpleUniverse u = new SimpleUniverse(c); u.getViewingPlatform().setNominalViewingTransform(); u.addBranchGraph(juur); new Thread(this).start(); } public void run(){ while(true){ try{Thread.sleep(50);}catch(Exception e){} nurk+=0.1; //double kaugus=-1+Math.sin(nurk/3); //double kaugus2=-1+Math.sin(nurk2/3); //Transform3D t=new Transform3D(); //t.rotY(nurk); //t.setTranslation(new Vector3d(0, 0, 0)); //t2.setTranslation(new Vector3d(0, 0, 0)); //keere1.setTransform(t); Transform3D t2=new Transform3D(); t2.rotX(nurk); keere1.setTransform(t2); keere2.setTransform(t2); } } public static void main(String[] args) { Frame f=new Frame("Vist Kuup?"); f.add(new Kuubike()); f.setSize(300, 300); f.setVisible(true); }}