update method

  1. @override
void update(
  1. double deltaSeconds
)
override

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) {
  if (!_initialized) onMount();
  if (deltaSeconds <= 0.0 || !isAttached) return;

  _time += deltaSeconds;

  // 1. Calculate vertical bob offset
  final bobOffset =
      math.sin(_time * hoverFrequency * 2 * math.pi) * hoverAmplitude;
  final newPos = _initialPosition + vm.Vector3(0, bobOffset, 0);

  // 2. Calculate tilt and continuous spin
  final tiltRad =
      (wobbleDegrees * math.pi / 180.0) *
      math.sin(_time * wobbleFrequency * 2 * math.pi);
  final spinRad = _time * spinSpeed;

  final spinRot = vm.Quaternion.axisAngle(vm.Vector3(0, 1, 0), spinRad);
  final tiltRot = vm.Quaternion.axisAngle(vm.Vector3(1, 0, 0), tiltRad);
  final newRot = _initialRotation * spinRot * tiltRot;

  node.localTransform = vm.Matrix4.compose(newPos, newRot, node.scale);
}