Vec2.fromJson constructor
Fail-fast: requires numeric x and y.
Implementation
factory Vec2.fromJson(Map<String, dynamic> json) {
final dx = _asDouble(json['x']);
final dy = _asDouble(json['y']);
if (dx == null || dy == null) {
throw FormatException(
'Vec2 requires numeric x/y; got x=${json['x']} (${json['x']?.runtimeType}), '
'y=${json['y']} (${json['y']?.runtimeType})',
);
}
return Vec2(dx, dy);
}