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 r = smoothingResponse(clampDeltaSeconds(deltaSeconds));
_azimuth += (_azimuthGoal - _azimuth) * r;
_polar += (_polarGoal - _polar) * r;
_distance += (_distanceGoal - _distance) * r;
_target += (_targetGoal - _target) * r;
var eyeDistance = _distance;
final projection = node.getComponent<CameraComponent>()?.projection;
if (projection is OrthographicProjection) {
var state = _orthographic;
if (state == null || !identical(state.projection, projection)) {
state = (
projection: projection,
eyeDistance: _distance,
zoomedAt: _distance,
);
} else if (_distance != state.zoomedAt) {
// Scale by this frame's dolly only, so zoom set elsewhere survives.
projection.zoom *= state.zoomedAt / _distance;
state = (
projection: projection,
eyeDistance: state.eyeDistance,
zoomedAt: _distance,
);
}
_orthographic = state;
eyeDistance = state.eyeDistance;
} else {
_orthographic = null;
}
node.lookAtFrom(_eyeFor(_target, eyeDistance), _target);
}