worldPlane method

Plane worldPlane()

The mirror plane in world space, derived from the node's transform: through the node's origin, facing localNormal under the node's rotation and scale.

Implementation

Plane worldPlane() {
  final transform = node.globalTransform;
  final point = transform.getTranslation();
  // Normals transform by the inverse transpose so non-uniform scale keeps
  // the plane's facing correct; a singular transform falls back to the
  // raw rotation.
  final rotation = transform.getRotation();
  final inverted = Matrix3.copy(rotation);
  final normalMatrix = inverted.invert() != 0.0
      ? (inverted..transpose())
      : rotation;
  final normal = (normalMatrix * localNormal) as Vector3;
  if (normal.length2 < 1e-24) {
    return Plane.normalconstant(Vector3(0, 1, 0), -point.y);
  }
  normal.normalize();
  return Plane.normalconstant(normal, -normal.dot(point));
}