diff --git a/src/mol-canvas3d/controls/trackball.ts b/src/mol-canvas3d/controls/trackball.ts index cb122268df5473392f58ad84ab0f45f9efa6fab0..fc9b7fce064e166176c71e9a3aa2a0d4b6d1d6fc 100644 --- a/src/mol-canvas3d/controls/trackball.ts +++ b/src/mol-canvas3d/controls/trackball.ts @@ -371,11 +371,11 @@ namespace TrackballControls { const moveDir = Vec3(); const moveEye = Vec3(); - function moveCamera() { + function moveCamera(deltaT: number) { Vec3.sub(moveEye, camera.position, camera.target); Vec3.setMagnitude(moveEye, moveEye, camera.state.minNear); - const moveSpeed = p.moveSpeed * (keyState.boostMove === 1 ? p.boostMoveFactor : 1); + const moveSpeed = deltaT * (60 / 1000) * p.moveSpeed * (keyState.boostMove === 1 ? p.boostMoveFactor : 1); if (keyState.moveForward === 1) { Vec3.normalize(moveDir, moveEye); @@ -483,9 +483,11 @@ namespace TrackballControls { /** Update the object's position, direction and up vectors */ function update(t: number) { if (lastUpdated === t) return; + + const deltaT = t - lastUpdated; if (lastUpdated > 0) { - if (p.animate.name === 'spin') spin(t - lastUpdated); - else if (p.animate.name === 'rock') rock(t - lastUpdated); + if (p.animate.name === 'spin') spin(deltaT); + else if (p.animate.name === 'rock') rock(deltaT); } Vec3.sub(_eye, camera.position, camera.target); @@ -501,7 +503,9 @@ namespace TrackballControls { Vec3.add(camera.position, camera.target, _eye); checkDistances(); - moveCamera(); + if (lastUpdated > 0 && deltaT < 1000) { + moveCamera(deltaT); + } Vec3.sub(_eye, camera.position, camera.target); checkDistances();