from static method

Vec from(
  1. dynamic point
)

Implementation

static Vec from(dynamic point) {
  if (point is Vec) return point;
  if (point is List) {
    return Vec(
      point[0].toDouble(),
      point[1].toDouble(),
      point.length > 2 ? point[2].toDouble() : 0,
    );
  }
  if (point is Map) {
    return Vec(
      point["x"].toDouble(),
      point["y"].toDouble(),
      point.containsKey("z") ? point["z"].toDouble() : 0,
    );
  }
  throw ArgumentError("Cannot convert to Vec: $point");
}