pan(dragConstraint == Constraint.PITCH ? 0 : -dxMouse * panScale,
dragConstraint == Constraint.YAW ? 0 : -dyMouse * panScale);
}
private void mouseRotate(final double dx, final double dy) {
final Vector3D u = LOOK.scalarMultiply(100 + .6 * startDistance).negate();
final int xSign = dx > 0 ? -1 : 1;
final int ySign = dy < 0 ? -1 : 1;
final double eccentricity = Math.abs((p.height / 2d) - p.mouseY)
/ (p.height / 2d);
final double rho = Math.abs((p.width / 2d) - p.mouseX) / (p.width / 2d);
if (dragConstraint == null || dragConstraint == Constraint.YAW
|| dragConstraint == Constraint.SUPPRESS_ROLL) {
final double adx = Math.abs(dx) * (1 - eccentricity);
final Vector3D vx = u.add(new Vector3D(adx, 0, 0));
rotateY.impulse(Vector3D.angle(u, vx) * xSign);
}
if (dragConstraint == null || dragConstraint == Constraint.PITCH
|| dragConstraint == Constraint.SUPPRESS_ROLL) {
final double ady = Math.abs(dy) * (1 - rho);
final Vector3D vy = u.add(new Vector3D(0, ady, 0));
rotateX.impulse(Vector3D.angle(u, vy) * ySign);
}
if (dragConstraint == null || dragConstraint == Constraint.ROLL) {
{
final double adz = Math.abs(dy) * rho;
final Vector3D vz = u.add(new Vector3D(0, adz, 0));
rotateZ.impulse(Vector3D.angle(u, vz) * -ySign
* (p.mouseX < p.width / 2 ? -1 : 1));
}
{
final double adz = Math.abs(dx) * eccentricity;
final Vector3D vz = u.add(new Vector3D(0, adz, 0));
rotateZ.impulse(Vector3D.angle(u, vz) * xSign
* (p.mouseY > p.height / 2 ? -1 : 1));
}
}
}