Skip to content
Snippets Groups Projects
Commit 208b8597 authored by David Sehnal's avatar David Sehnal
Browse files

mol-canvas: move spin() to update()

parent f9828bc0
No related branches found
No related tags found
No related merge requests found
......@@ -209,6 +209,8 @@ namespace TrackballControls {
/** Update the object's position, direction and up vectors */
function update() {
if (p.spin) spin();
Vec3.sub(_eye, object.position, target)
rotateCamera()
......@@ -300,7 +302,6 @@ namespace TrackballControls {
function spin() {
_spinSpeed[0] = (p.spinSpeed || 0) / 1000;
if (!_isInteracting) Vec2.add(_moveCurr, _movePrev, _spinSpeed);
if (p.spin) requestAnimationFrame(spin);
}
// force an update at start
......@@ -313,9 +314,7 @@ namespace TrackballControls {
get props() { return p as Readonly<TrackballControlsProps> },
setProps: (props: Partial<TrackballControlsProps>) => {
const wasSpinning = p.spin
Object.assign(p, props)
if (p.spin && !wasSpinning) requestAnimationFrame(spin)
},
update,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment