modifiersOf function

List<Listed> modifiersOf(
  1. ModelProject project,
  2. int id
)

id's own modifier stack, top of the list first — the order ReorderModifier and SetModifierField index it in — with what each one is and whether the picture and the file both run it (ux-19). The kind is read out of the modifier's own toJson rather than switched on here, so a modifier kind added to flutter3d_mesh is listed by name the day it lands instead of the day somebody remembers this file: kind is what modifierFromJson already reads it back by, so it cannot drift.

Implementation

List<Listed> modifiersOf(ModelProject project, int id) {
  final List<ModifierSlot>? stack = project[id]?.modifiers;
  if (stack == null) return const <Listed>[];
  return <Listed>[
    for (var i = 0; i < stack.length; i++)
      if (stack[i].modifier.toJson() case final Map<String, Object?> fields)
        Listed(
          id: i,
          name: fields['kind'] as String? ?? 'modifier $i',
          kind: fields['kind'] as String?,
          about: <String, Object?>{
            'enabled': stack[i].enabled,
            'inExport': stack[i].inExport,
            'fields': fields,
          },
        ),
  ];
}