Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Dead-simple mouse-driven camera for Processing
Java HTML CSS Other
Pull request Compare This branch is 59 commits behind master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.settings
commons-math-1.2
examples/HelloPeasy
resources
src/peasy
web
.classpath
.gitignore
.project
.pydevproject
README.textile

README.textile

PeasyCam provides a dead-simple mouse-driven camera for Processing. It is
created and maintained by Jonathan Feinberg. It is
free for all uses, per the Apache 2.0 license.

To download the distribution, and to see a demo, go to
the PeasyCam home page.

Example

PeasyCam camera;

void setup() {
    // PeasyCam constructor:
    // PeasyCam(PApplet parent,
    //          double lookAtX, double lookAtY, double lookAtZ, 
    //          double distance);
    camera = new PeasyCam(this, 0, 0, 0, 50);
}

That’s it. Now a mouse left-drag will rotate the camera around the subject, a
right drag will zoom in and out, and a middle-drag will pan. A double-click
restores the camera to its original position.

The PeasyCam is positioned on a sphere whose radius is the given distance from
the look-at point. Rotations are around axes that pass through the looked-at
point.

Constructors

PeasyCam(PApplet parent, double lookAtX, double lookAtY, double lookAtZ, double distance);
PeasyCam(PApplet parent, double distance); // look at 0,0,0

Methods

camera.setMouseControlled(boolean isMouseControlled);
camera.lookAt(double x, double y, double z);
camera.rotateX(double angle);  // rotate around the x-axis passing through the subject
camera.rotateY(double angle);  // rotate around the y-axis passing through the subject
camera.rotateZ(double angle);  // rotate around the z-axis passing through the subject
camera.setDistance(double d);  // distance from looked-at point
camera.pan(double dx, double dy);     // move the looked-at point relative to current orientation

camera.reset();
camera.reset(long animationTimeInMillis);  // reset camera to its starting settings

CameraState state = camera.getState(); // get a serializable settings object for current state
camera.setState(CameraState state);
camera.setState(CameraState state, long animationTimeInMillis); // set the camera to the given saved state

PeasyCam is impervious to gimbal lock, and has no known “singularities” or
discontinuities in its behavior. It relies on the excellent
Apache Commons Math
geometry package for its rotations.

Something went wrong with that request. Please try again.