import java.awt.*; import javax.swing.*; import com.sun.j3d.utils.geometry.ColorCube; import com.sun.j3d.utils.universe.SimpleUniverse; import javax.media.j3d.*; import javax.vecmath.*; public class Kuup2a extends JApplet implements Runnable{ TransformGroup keere1; double nurk; public Kuup2a() { Canvas3D c = new Canvas3D(SimpleUniverse.getPreferredConfiguration()); getContentPane().add(c, BorderLayout.CENTER); BranchGroup juur = new BranchGroup(); Transform3D keerd1=new Transform3D(); keere1=new TransformGroup(keerd1); keere1.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); juur.addChild(keere1); keere1.addChild(new ColorCube(0.5)); 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.2; double kaugus=-1+Math.sin(nurk/3); Transform3D t=new Transform3D(); t.rotY(nurk); t.setTranslation(new Vector3d(0, 0, kaugus)); keere1.setTransform(t); } } public static void main(String[] args) { Frame f=new Frame("Keerlev kuup"); f.add(new Kuup2a()); f.setSize(300, 300); f.setVisible(true); } }