scenePosition method

MVector2 scenePosition([
  1. Node? upTo
])

This node's position, composed with the transform of every TransformNode ancestor, stopping at (but not including) upTo.

The returned vector is a fresh copy, free for the caller to mutate.

Implementation

MVector2 scenePosition([Node? upTo]) {
  final absolute = MVector2.copy(position);
  var current = parent;

  while (current != null && !identical(current, upTo)) {
    if (current is TransformNode) {
      absolute.transform(current.localTransform);
    }

    current = current.parent;
  }

  return absolute;
}