Skip to content

Commit

Permalink
reuse existing spin object for subsequent spin(true) calls
Browse files Browse the repository at this point in the history
This makes sure spinning does not get faster when calling spin(true)
multiple times.
  • Loading branch information
biasmv committed Mar 14, 2015
1 parent 9afbd5a commit d4ad81f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/gfx/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,13 @@ utils.derive(Spin, Animation, {
mat3.mul(rotation, axisRot, rotation);
cam.setRotation(rotation);
};
})()
})(),
setSpeed : function(speed) {
this._speed = speed;
},
setAxis : function(axis) {
this._axis = axis;
}
});


Expand Down
9 changes: 7 additions & 2 deletions src/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,13 @@ Viewer.prototype = {
speed = Math.PI/8;
}
axis = axis || [0, 1, 0];
this._spin = anim.spin(axis, speed);
this._animControl.add(this._spin);
if (this._spin === null) {
this._spin = anim.spin(axis, speed);
this._animControl.add(this._spin);
} else {
this._spin.setSpeed(speed);
this._spin.setAxis(axis);
}
this.requestRedraw();
return true;
},
Expand Down

0 comments on commit d4ad81f

Please sign in to comment.