Java3D StdDraw3D Animated Sphere

/*
* Animated Sphere in Java3D using StdDraw3D
* Developed for JustJava3d.wordpress.com
*/
public class Main {

    public static void main(String[] args) {

        //Create a value for the Y-Axis of the sphere
        double posY = 0;

        //While loop for the animation
        while(true) {
            //Clear the screen for everything to be redrawn
            StdDraw3D.clear();

            //Set the scale of the window
            StdDraw3D.setScale(-1, 1);

            //Increment the value of the Y-Axis every frame
            posY += 0.001;

            //Draw a sphere in the centre of the window
            StdDraw3D.sphere(0, posY, 0, 1);

            //Render the 3D view in 0ms
            StdDraw3D.show(1);
        }

    }

}
Advertisements