vec3<C extends Component> static method
A Vector3 property. Add an RgbColor constraint for linear RGB
colors carried as vectors (byte-compatible with existing documents).
Implementation
static ComponentField<C> vec3<C extends Component>(
String name, {
required Vector3 Function() defaultValue,
Vector3 Function(C component)? get,
void Function(C component, Vector3 value)? set,
String? doc,
String? group,
List<PropertyConstraint<Object>> constraints = const [],
List<String> formerNames = const [],
bool transient = false,
}) => ComponentField(
ComponentPropertyDef(
name,
ComponentPropertyKind.vec3,
defaultValue: Vec3Value(defaultValue()),
doc: doc,
group: group,
constraints: constraints,
formerNames: formerNames,
transient: transient,
),
read: get == null ? null : (c, _) => Vec3Value(get(c).clone()),
write: set == null
? null
: (c, v, _) {
if (v is! Vec3Value) return;
final vector = v.value.clone();
if (constraints.any((constraint) => constraint is Normalized) &&
vector.length2 > 0) {
vector.normalize();
}
set(c, vector);
},
);