Controlling Geometric Objects

Let's create a sphere whose position in the 'y' direction is fixed to 0.0. In other words, the sphere is not capable of moving in the up/down direction.

1. Create an analytic sphere.

2. Select the sphere, open the property window and go to the Script tab.

3. Select JavaScript from the Command Language control and enter the following text into the text field:

    center=Self.GetCenter();
    center.y = 0;
    Self.SetCenter(center);

Now, try to move the sphere with the mouse. You can move it horizontally but not up or down!

Let's create a simple animation. Try the following script:

    center=Self.GetCenter();
    center.y = Time;
    Self.SetCenter(center);

On other words, the 'y' position of the sphere depends on the time. Play the animation to verify this.