impostorRight function

Vector3 impostorRight(
  1. Vector3 d
)

The right-hand axis of a card, or a baked view, facing along d: level with the ground, except looking straight up or down, where level has no direction and -Z stands in for up.

Implementation

Vector3 impostorRight(Vector3 d) {
  final up = d.y.abs() > 0.999 ? Vector3(0, 0, -1) : Vector3(0, 1, 0);
  return up.cross(d)..normalize();
}