diff --git a/src/cli/structure-info/volume.ts b/src/cli/structure-info/volume.ts index c8ebd5aeee8c658099c0108dada139ab86df0f02..23bf618afea516c5b252966060b0a7082f04d646 100644 --- a/src/cli/structure-info/volume.ts +++ b/src/cli/structure-info/volume.ts @@ -38,7 +38,7 @@ function print(volume: Volume) { } async function doMesh(volume: Volume, filename: string) { - const mesh = await Task.create('', runtime => createVolumeIsosurfaceMesh({ runtime }, volume, Theme.createEmpty(), { isoValue: Volume.IsoValue.absolute(1.5), pickingGranularity: 'voxels' })).run(); + const mesh = await Task.create('', runtime => createVolumeIsosurfaceMesh({ runtime }, volume, Theme.createEmpty(), { isoValue: Volume.IsoValue.absolute(1.5) })).run(); console.log({ vc: mesh.vertexCount, tc: mesh.triangleCount }); // Export the mesh in OBJ format. diff --git a/src/mol-model/volume/volume.ts b/src/mol-model/volume/volume.ts index 1bf87a936741013df04c4b65cf823a6490c57170..521ab451d5287d5f81e6040c46414f31c82c4abc 100644 --- a/src/mol-model/volume/volume.ts +++ b/src/mol-model/volume/volume.ts @@ -219,4 +219,14 @@ export namespace Volume { return Sphere3D.expand(bs, bs, Mat4.getMaxScaleOnAxis(transform) * 10); } } + + export type PickingGranuality = 'surface' | 'voxel'; + export const PickingGranuality = { + set(volume: Volume, granuality: PickingGranuality) { + volume._propertyData['__picking_granuality__'] = granuality; + }, + get(volume: Volume): PickingGranuality { + return volume._propertyData['__picking_granuality__'] ?? 'voxel'; + } + }; } \ No newline at end of file diff --git a/src/mol-repr/volume/isosurface.ts b/src/mol-repr/volume/isosurface.ts index 9ad3da6efe26683bc7500a5678e99b5ab708a3bd..6d3ab3b21ff7ceea8ae3a254ea7ac80c86cc1304 100644 --- a/src/mol-repr/volume/isosurface.ts +++ b/src/mol-repr/volume/isosurface.ts @@ -32,8 +32,7 @@ import { BaseGeometry } from '../../mol-geo/geometry/base'; import { ValueCell } from '../../mol-util/value-cell'; export const VolumeIsosurfaceParams = { - isoValue: Volume.IsoValueParam, - pickingGranularity: PD.Select<'voxels' | 'surfaces'>('voxels', [['voxels', 'Voxels'], ['surfaces', 'Surfaces']]), + isoValue: Volume.IsoValueParam }; export type VolumeIsosurfaceParams = typeof VolumeIsosurfaceParams export type VolumeIsosurfaceProps = PD.Values<VolumeIsosurfaceParams> @@ -67,8 +66,9 @@ function getLoci(volume: Volume, props: VolumeIsosurfaceProps) { function getIsosurfaceLoci(pickingId: PickingId, volume: Volume, props: VolumeIsosurfaceProps, id: number) { const { objectId, groupId } = pickingId; + if (id === objectId) { - if (props.pickingGranularity === 'surfaces') { + if (Volume.PickingGranuality.get(volume) === 'surface') { return Volume.Isosurface.Loci(volume, props.isoValue); } else { return Volume.Cell.Loci(volume, Interval.ofSingleton(groupId as Volume.CellIndex));