tick method

bool tick(
  1. double now
)

Advances the springs to now (seconds). Returns whether anything is still moving.

Implementation

bool tick(double now) {
  final double dt = _now == null ? 0 : (now - _now!).clamp(0.0, 0.1);
  _now = now;
  for (var i = 0; i < _pending.length; i++) {
    if (_pending[i].$1 == null) {
      _pending[i] = (now + _latency, _pending[i].$2);
    }
  }
  while (_pending.isNotEmpty && _pending.first.$1! <= now) {
    _luma = _pending.removeAt(0).$2;
    _decide();
    _aimAt = now + _glassLag;
  }
  if (_aimAt != null && now >= _aimAt!) {
    _aimAt = null;
    _aim();
  }
  var moving = _pending.isNotEmpty || _aimAt != null;
  for (final GlassSpring s in <GlassSpring>[
    ..._glassValues,
    ..._pillValues,
  ]) {
    s.step(dt);
    moving |= !s.isSettled;
  }
  debugOnChange?.call(this, 'tick');
  return moving;
}