Skip to content

Commit

Permalink
Go back to the old pan and zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Feinberg committed Feb 22, 2009
1 parent c3dfad1 commit cde71b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ PeasyCam.jar
distribution
bin
examples/*/applet
reference
36 changes: 4 additions & 32 deletions src/peasy/PeasyCam.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ private static enum Constraint
private PeasyMouseListener mouseListener = null;

private final DampedAction rotateX, rotateY, rotateZ;
private final DampedAction panX, panY;
private final DampedAction zoom;

private double distance;
private Vector3D center;
Expand Down Expand Up @@ -104,29 +102,6 @@ protected void behave(final double velocity)
}
};

panX = new DampedAction(this, .25) {
@Override
protected void behave(final double velocity)
{
center = center.add(rotation.applyTo(new Vector3D(velocity, 0, 0)));
}
};

panY = new DampedAction(this, .25) {
@Override
protected void behave(final double velocity)
{
center = center.add(rotation.applyTo(new Vector3D(0, velocity, 0)));
}
};

zoom = new DampedAction(this, .25) {
@Override
protected void behave(final double velocity)
{
setDistance(PeasyCam.this.distance + velocity);
}
};
}

public void setMouseControlled(final boolean isMouseControlled)
Expand Down Expand Up @@ -216,15 +191,14 @@ else if (b == PConstants.RIGHT)

private void mouseZoom(final double delta)
{
final double zoomScale = distance * .002;
zoom.impulse(delta * zoomScale);
setDistance(distance + delta * Math.sqrt(distance * .2));
}

private void mousePan(final double dxMouse, final double dyMouse)
{
final double panScale = distance * .0005;
panX.impulse(dragConstraint == Constraint.Y ? 0 : -dxMouse * panScale);
panY.impulse(dragConstraint == Constraint.X ? 0 : -dyMouse * panScale);
final double panScale = Math.sqrt(distance * .005);
pan(dragConstraint == Constraint.Y ? 0 : -dxMouse * panScale,
dragConstraint == Constraint.X ? 0 : -dyMouse * panScale);
}

private void mouseRotate(final double dx, final double dy)
Expand Down Expand Up @@ -409,8 +383,6 @@ public void setState(final CameraState state, final long animationTimeMillis)
rotateX.stop();
rotateY.stop();
rotateZ.stop();
panX.stop();
panY.stop();
if (animationTimeMillis > 0)
{
startInterpolation(new Interp(state.rotation, state.center, state.distance,
Expand Down

0 comments on commit cde71b7

Please sign in to comment.