import com.cult3d.*;
import com.cult3d.world.*;
import com.cult3d.math.*;

public class Zoom implements Cult3DScript
{
	// the object
	private CultObject box = new CultObject("Box01");
	// the Camera
	private CultObject cam = new CultObject("Camera01");

	// Closest distance to zoom to
	private float MIN_DIST = 20f;
	
	public Zoom()
	{
	}

	public void worldStep(String s)
	{
		Vector3 pos  = box.getPosition(Node.WORLD);
		Vector3 cpos = cam.getPosition(Node.WORLD);

		// Calculate the distance between object and camera
		Vector3 dist = new Vector3();
		dist.sub(pos, cpos);
		
		// If less then MIN_DIST move camera back.
		float z = dist.getZ();
		if(z > -MIN_DIST) {
			cpos.setZ(pos.getZ() + MIN_DIST);
			cam.setPosition(Node.WORLD, cpos);
		}
    }

	public void cult3dDestroy()
	{
	}
}