mirror of
https://github.com/molstar/molstar.git
synced 2026-06-04 13:30:24 +08:00
Orders GUI elements so that subgroups after their group
This commit is contained in:
@@ -539,26 +539,38 @@ async function applyKinemageInfoToState(plugin: PluginContext, kinInfo: Kinemage
|
||||
// Iterate over all of the groupDict entries and create a state object for each group.
|
||||
// Name each after the group dictionary key.
|
||||
for (const [groupKey, groupInfo] of Object.entries(kinData.groupDict)) {
|
||||
const groupName = groupKey;
|
||||
|
||||
// capture desired visibility and set it as the transform state at creation time
|
||||
const visible = !(groupInfo as any).off;
|
||||
update
|
||||
.toRoot()
|
||||
.apply(KinemageGroupProvider, { name: groupName, groupData: groupKey, data: kinData }, { state: { isHidden: !visible } });
|
||||
.apply(KinemageGroupProvider, { name: groupKey, groupData: groupKey, data: kinData }, { state: { isHidden: !visible } });
|
||||
|
||||
// Iterate over all of the subgroupDict entries under this group and create a state object for each subgroup.
|
||||
// Name each after the subgroup dictionary key, which is in the format "GroupName:SubgroupName" to preserve tree structure.
|
||||
for (const [subgroupKey, subgroupInfo] of Object.entries(kinData.subgroupDict)) {
|
||||
// Skip subgroups that don't belong to this group (based on the naming convention of "GroupName:SubgroupName")
|
||||
if (!subgroupKey.startsWith(groupKey + ':')) continue;
|
||||
|
||||
// capture desired visibility and set it as the transform state at creation time
|
||||
const visible = !(subgroupInfo as any).off;
|
||||
update
|
||||
.toRoot()
|
||||
.apply(KinemageSubgroupProvider, { name: subgroupKey, subgroupData: subgroupKey, data: kinData }, { state: { isHidden: !visible } });
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate over all of the subgroupDict entries and create a state object for each subgroup.
|
||||
// Name each after the subgroup dictionary key, which is in the format "GroupName:SubgroupName" to preserve tree structure.
|
||||
// Iterate over all subgroupDict entries that don't have a parent group and create state objects for them as well,
|
||||
// so they show up in the State Tree.
|
||||
for (const [subgroupKey, subgroupInfo] of Object.entries(kinData.subgroupDict)) {
|
||||
const subgroupName = subgroupKey;
|
||||
|
||||
// capture desired visibility and set it as the transform state at creation time
|
||||
const visible = !(subgroupInfo as any).off;
|
||||
update
|
||||
.toRoot()
|
||||
.apply(KinemageSubgroupProvider, { name: subgroupName, subgroupData: subgroupKey, data: kinData }, { state: { isHidden: !visible } });
|
||||
}
|
||||
// Skip subgroups that belong to a group (characters before the ":" indicate the parent group)
|
||||
if (subgroupKey[0] === ':' || subgroupKey.indexOf(':') === -1) continue;
|
||||
|
||||
// capture desired visibility and set it as the transform state at creation time
|
||||
const visible = !(subgroupInfo as any).off;
|
||||
update
|
||||
.toRoot()
|
||||
.apply(KinemageSubgroupProvider, { name: subgroupKey, subgroupData: subgroupKey, data: kinData }, { state: { isHidden: !visible } });
|
||||
}
|
||||
|
||||
// Iterate over all of the masterDict entries and create a state object for each master.
|
||||
// Name each after the master dictionary key.
|
||||
|
||||
Reference in New Issue
Block a user