parseKey static method
Parse a uniform key into (structName, memberName, arrayIndex).
Examples:
'VertexInfo.model'becomes('VertexInfo', 'model', null)'Lights.positions[0]'becomes('Lights', 'positions', 0)'albedoTexture'becomes('albedoTexture', null, null)
Implementation
static (String, String?, int?) parseKey(String key) {
final match = _keyMatches.putIfAbsent(key, () {
final match = _keyRegex.firstMatch(key);
if (match == null) {
throw StateError('Invalid uniform key: "$key"');
}
return match;
});
final struct = match.group(1)!;
final member = match.group(2);
final index = match.group(3);
return (struct, member, index != null ? int.parse(index) : null);
}