Skip to content

Commit

Permalink
Fixed rotation
Browse files Browse the repository at this point in the history
Removed slingshot effect when dragging over long distance but have
stopped moving. Made it possible to stop the rotation by holding
position for a second.
  • Loading branch information
kellyegan committed Oct 27, 2014
1 parent 6bd29e4 commit cfb616a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions ArcBall.pde
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,24 @@ public class ArcBall implements PConstants{
public void dragEnd() {
dragging = false;
}



/**
* Update currentRotation with data from dragging
*/
public void update(){
if( dragging ) {
currentRotation = quaternion.mult(deltaRotation, startRotation);

if(frameCount % 3 == 0) {
startRotation.set(currentRotation);
deltaRotation.setToIdentity();
startPoint.set(endPoint);
}
} else {
currentRotation = quaternion.mult(deltaRotation, currentRotation);
deltaRotation = deltaRotation.power(0.9f);
deltaRotation = deltaRotation.power(0.999f);
}

applyRotation(currentRotation);

applyRotation(currentRotation);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion sketch3d.pde
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ void mousePressed() {
}

void mouseDragged() {
arcBall.dragging(mouseX, mouseY);
//arcBall.dragging(mouseX, mouseY);
}

void mouseReleased() {
Expand Down

0 comments on commit cfb616a

Please sign in to comment.