onScaleUpdate method

void onScaleUpdate(
  1. ScaleUpdateDetails details
)

Implementation

void onScaleUpdate(ScaleUpdateDetails details) {
  if (_activeNode == null) return;

  final node = _activeNode!;

  // SCALE
  if (gestureConfig.enableScale) {
    _currentScale = (_initialScale * details.scale).clamp(0.2, 40.0);
  }

  // ROTATE – CHỈ TRỤC Y
  if (gestureConfig.enableRotation && _lastDragPosition != null) {
    final dx = details.focalPoint.dx - _lastDragPosition!.dx;
    _lastDragPosition = details.focalPoint;

    const sensitivity = 0.01;

    final deltaRotation = Quaternion.axisAngle(
      Vector3(0, 1, 0),
      dx * sensitivity,
    );

    // 👇 TÍCH LŨY rotation
    _currentRotation = deltaRotation * _currentRotation;
    _currentRotation.normalize();
  }

  node.transform = Matrix4.compose(
    node.position,
    _currentRotation,
    Vector3(
      _currentScale,
      _currentScale,
      _currentScale,
    ),
  );

  updateNode(node);
}