update method
Called once per frame while the component is mounted, enabled, and
loaded. deltaSeconds is the elapsed time since the previous tick.
A traversal visits each component at most once. Removing this component
or an earlier sibling is safe. A component inserted before the current
traversal position starts on the next frame. Reordering component or
child lists during traversal is unsupported.
Implementation
@override
void update(double deltaSeconds) {
final base =
followTarget?.globalTransform.getTranslation() ?? Vector3.zero();
final lookAt = base + Vector3(0.0, lookHeight, 0.0);
final desired = _desiredPosition(lookAt);
if (!_initialized) {
_position.setFrom(desired);
_target.setFrom(lookAt);
_initialized = true;
} else {
final r = smoothingResponse(clampDeltaSeconds(deltaSeconds));
_position.addScaled(desired - _position, r);
_target.addScaled(lookAt - _target, r);
}
node.lookAtFrom(_position, _target);
}