Skip to content
Snippets Groups Projects
Commit 458aad01 authored by dsehnal's avatar dsehnal
Browse files

Volume.PickingGranuality custom property

parent 9e313246
No related branches found
No related tags found
No related merge requests found
...@@ -38,7 +38,7 @@ function print(volume: Volume) { ...@@ -38,7 +38,7 @@ function print(volume: Volume) {
} }
async function doMesh(volume: Volume, filename: string) { 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 }); console.log({ vc: mesh.vertexCount, tc: mesh.triangleCount });
// Export the mesh in OBJ format. // Export the mesh in OBJ format.
......
...@@ -219,4 +219,14 @@ export namespace Volume { ...@@ -219,4 +219,14 @@ export namespace Volume {
return Sphere3D.expand(bs, bs, Mat4.getMaxScaleOnAxis(transform) * 10); 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
...@@ -32,8 +32,7 @@ import { BaseGeometry } from '../../mol-geo/geometry/base'; ...@@ -32,8 +32,7 @@ import { BaseGeometry } from '../../mol-geo/geometry/base';
import { ValueCell } from '../../mol-util/value-cell'; import { ValueCell } from '../../mol-util/value-cell';
export const VolumeIsosurfaceParams = { export const VolumeIsosurfaceParams = {
isoValue: Volume.IsoValueParam, isoValue: Volume.IsoValueParam
pickingGranularity: PD.Select<'voxels' | 'surfaces'>('voxels', [['voxels', 'Voxels'], ['surfaces', 'Surfaces']]),
}; };
export type VolumeIsosurfaceParams = typeof VolumeIsosurfaceParams export type VolumeIsosurfaceParams = typeof VolumeIsosurfaceParams
export type VolumeIsosurfaceProps = PD.Values<VolumeIsosurfaceParams> export type VolumeIsosurfaceProps = PD.Values<VolumeIsosurfaceParams>
...@@ -67,8 +66,9 @@ function getLoci(volume: Volume, props: VolumeIsosurfaceProps) { ...@@ -67,8 +66,9 @@ function getLoci(volume: Volume, props: VolumeIsosurfaceProps) {
function getIsosurfaceLoci(pickingId: PickingId, volume: Volume, props: VolumeIsosurfaceProps, id: number) { function getIsosurfaceLoci(pickingId: PickingId, volume: Volume, props: VolumeIsosurfaceProps, id: number) {
const { objectId, groupId } = pickingId; const { objectId, groupId } = pickingId;
if (id === objectId) { if (id === objectId) {
if (props.pickingGranularity === 'surfaces') { if (Volume.PickingGranuality.get(volume) === 'surface') {
return Volume.Isosurface.Loci(volume, props.isoValue); return Volume.Isosurface.Loci(volume, props.isoValue);
} else { } else {
return Volume.Cell.Loci(volume, Interval.ofSingleton(groupId as Volume.CellIndex)); return Volume.Cell.Loci(volume, Interval.ofSingleton(groupId as Volume.CellIndex));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment