molstar
Version:
A comprehensive macromolecular library.
49 lines (48 loc) • 2.73 kB
JavaScript
;
/**
* Copyright (c) 2026 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.PolyhedronRepresentationProvider = exports.PolyhedronParams = void 0;
exports.getPolyhedronParams = getPolyhedronParams;
exports.PolyhedronRepresentation = PolyhedronRepresentation;
const base_1 = require("../../../mol-geo/geometry/base.js");
const representation_1 = require("../../representation.js");
const param_definition_1 = require("../../../mol-util/param-definition.js");
const complex_representation_1 = require("../complex-representation.js");
const representation_2 = require("../representation.js");
const coordination_polyhedron_mesh_1 = require("../visual/coordination-polyhedron-mesh.js");
const PolyhedronVisuals = {
'coordination-polyhedron-mesh': (ctx, getParams) => (0, complex_representation_1.ComplexRepresentation)('Coordination Polyhedron mesh', ctx, getParams, coordination_polyhedron_mesh_1.CoordinationPolyhedronMeshVisual),
};
exports.PolyhedronParams = {
...coordination_polyhedron_mesh_1.CoordinationPolyhedronMeshParams,
bumpFrequency: param_definition_1.ParamDefinition.Numeric(1, { min: 0, max: 10, step: 0.1 }, base_1.BaseGeometry.ShadingCategory),
density: param_definition_1.ParamDefinition.Numeric(0.5, { min: 0, max: 1, step: 0.01 }, base_1.BaseGeometry.ShadingCategory),
visuals: param_definition_1.ParamDefinition.MultiSelect(['coordination-polyhedron-mesh'], param_definition_1.ParamDefinition.objectToOptions(PolyhedronVisuals)),
};
function getPolyhedronParams(ctx, structure) {
return exports.PolyhedronParams;
}
function PolyhedronRepresentation(ctx, getParams) {
return representation_1.Representation.createMulti('Polyhedron', ctx, getParams, representation_2.StructureRepresentationStateBuilder, PolyhedronVisuals);
}
exports.PolyhedronRepresentationProvider = (0, representation_2.StructureRepresentationProvider)({
name: 'polyhedron',
label: 'Polyhedron',
description: 'Displays coordination polyhedra around atoms with enough bonds.',
factory: PolyhedronRepresentation,
getParams: getPolyhedronParams,
defaultValues: param_definition_1.ParamDefinition.getDefaultValues(exports.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;
}
});