alignOnBorder method

void alignOnBorder(
  1. Vector3 direction, {
  2. double? buffer,
})

Implementation

void alignOnBorder(Vector3 direction, {double? buffer}) {
  buffer ??= DEFAULT_MOBJECT_TO_EDGE_BUFFER;

  var targetPoint =
      direction.sign() * Vector3(FRAME_X_RADIUS, FRAME_Y_RADIUS, 0);

  var pointToAlign = getCriticalPoint(direction);

  var shiftVal = targetPoint - pointToAlign - direction * buffer;
  shiftVal *= direction.sign().abs();

  shift(shiftVal);
}