瀏覽代碼

better use of StateSelection API

Alexander Rose 3 年之前
父節點
當前提交
d3da79f3dd
共有 1 個文件被更改,包括 2 次插入6 次删除
  1. 2 6
      src/mol-plugin/behavior/dynamic/representation.ts

+ 2 - 6
src/mol-plugin/behavior/dynamic/representation.ts

@@ -186,12 +186,8 @@ export const SelectLoci = PluginBehavior.create({
                         Structure.areEquivalent(structure, oldStructure) &&
                         Structure.areHierarchiesEqual(structure, oldStructure)) return;
 
-                    const children = this.ctx.state.data.select(StateSelection.children(ref));
-                    for (const child of children) {
-                        if (child.obj?.type === SO.Molecule.Structure.Representation3D.type) {
-                            this.applySelectMark(child.transform.ref, true);
-                        }
-                    }
+                    const reprs = this.ctx.state.data.select(StateSelection.children(ref).ofType(SO.Molecule.Structure.Representation3D));
+                    for (const repr of reprs) this.applySelectMark(repr.transform.ref, true);
                 }
             });
         }