UNPKG

molstar

Version:

A comprehensive macromolecular library.

44 lines (43 loc) 2.24 kB
/** * Copyright (c) 2026 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ import { BaseGeometry } from '../../../mol-geo/geometry/base.js'; import { Representation } from '../../representation.js'; import { ParamDefinition as PD } from '../../../mol-util/param-definition.js'; import { ComplexRepresentation } from '../complex-representation.js'; import { StructureRepresentationProvider, StructureRepresentationStateBuilder } from '../representation.js'; import { CoordinationPolyhedronMeshParams, CoordinationPolyhedronMeshVisual } from '../visual/coordination-polyhedron-mesh.js'; const PolyhedronVisuals = { 'coordination-polyhedron-mesh': (ctx, getParams) => ComplexRepresentation('Coordination Polyhedron mesh', ctx, getParams, CoordinationPolyhedronMeshVisual), }; export const PolyhedronParams = { ...CoordinationPolyhedronMeshParams, bumpFrequency: PD.Numeric(1, { min: 0, max: 10, step: 0.1 }, BaseGeometry.ShadingCategory), density: PD.Numeric(0.5, { min: 0, max: 1, step: 0.01 }, BaseGeometry.ShadingCategory), visuals: PD.MultiSelect(['coordination-polyhedron-mesh'], PD.objectToOptions(PolyhedronVisuals)), }; export function getPolyhedronParams(ctx, structure) { return PolyhedronParams; } export function PolyhedronRepresentation(ctx, getParams) { return Representation.createMulti('Polyhedron', ctx, getParams, StructureRepresentationStateBuilder, PolyhedronVisuals); } export const PolyhedronRepresentationProvider = StructureRepresentationProvider({ name: 'polyhedron', label: 'Polyhedron', description: 'Displays coordination polyhedra around atoms with enough bonds.', factory: PolyhedronRepresentation, getParams: getPolyhedronParams, defaultValues: PD.getDefaultValues(PolyhedronParams), defaultColorTheme: { name: 'element-symbol' }, defaultSizeTheme: { name: 'uniform' }, isApplicable: (structure) => structure.elementCount > 0, getData: (structure, props) => { return props.includeParent ? structure.asParent() : structure; }, mustRecreate: (oldProps, newProps) => { return oldProps.includeParent !== newProps.includeParent; } });