Ver Fonte

limit ball+stick repr to atomic units

Alexander Rose há 6 anos atrás
pai
commit
521205bf87

+ 2 - 2
src/mol-geo/representation/structure/ball-and-stick.ts

@@ -8,7 +8,7 @@ import { StructureRepresentation } from '.';
 import { ElementSphereVisual, DefaultElementSphereProps } from './visual/element-sphere';
 import { IntraUnitLinkVisual, DefaultIntraUnitLinkProps } from './visual/intra-unit-link-cylinder';
 import { PickingId } from '../../util/picking';
-import { Structure } from 'mol-model/structure';
+import { Structure, Unit } from 'mol-model/structure';
 import { Task } from 'mol-task';
 import { Loci, isEmptyLoci } from 'mol-model/loci';
 import { MarkerAction } from '../../util/marker-data';
@@ -20,6 +20,7 @@ export const DefaultBallAndStickProps = {
     ...DefaultIntraUnitLinkProps,
 
     sizeTheme: { name: 'uniform', value: 0.25 } as SizeTheme,
+    unitKinds: [ Unit.Kind.Atomic ] as Unit.Kind[]
 }
 export type BallAndStickProps = Partial<typeof DefaultBallAndStickProps>
 
@@ -29,7 +30,6 @@ export function BallAndStickRepresentation(): StructureRepresentation<BallAndSti
 
     return {
         get renderObjects() {
-            // return linkRepr.renderObjects
             return [ ...elmementRepr.renderObjects, ...linkRepr.renderObjects ]
         },
         get props() {

+ 5 - 2
src/mol-geo/representation/structure/visual/element-sphere.ts

@@ -29,6 +29,7 @@ export const DefaultElementSphereProps = {
     ...DefaultStructureProps,
     sizeTheme: { name: 'physical', factor: 1 } as SizeTheme,
     detail: 0,
+    unitKinds: [ Unit.Kind.Atomic, Unit.Kind.Spheres ] as Unit.Kind[]
 }
 export type ElementSphereProps = Partial<typeof DefaultElementSphereProps>
 
@@ -47,13 +48,15 @@ export function ElementSphereVisual(): UnitsVisual<ElementSphereProps> {
             renderObjects.length = 0 // clear
             currentGroup = group
 
-            const { detail, colorTheme, sizeTheme } = { ...DefaultElementSphereProps, ...props }
+            const { detail, colorTheme, sizeTheme, unitKinds } = { ...DefaultElementSphereProps, ...props }
             const instanceCount = group.units.length
             const elementCount = group.elements.length
             const unit = group.units[0]
 
             const radius = getElementRadius(unit, sizeTheme)
-            mesh = await createElementSphereMesh(ctx, unit, radius, detail, mesh)
+            mesh = unitKinds.includes(unit.kind)
+                ? await createElementSphereMesh(ctx, unit, radius, detail, mesh)
+                : Mesh.createEmpty(mesh)
 
             if (ctx.shouldUpdate) await ctx.update('Computing spacefill transforms');
             const transforms = createTransforms(group)