UNPKG

molstar

Version:

A comprehensive macromolecular library.

43 lines (42 loc) 2.38 kB
/** * Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Ludovic Autin <ludovic.autin@gmail.com> */ import { __assign } from "tslib"; import { ShapeRepresentation } from '../../mol-repr/shape/representation'; import { Shape } from '../../mol-model/shape'; import { ColorNames } from '../../mol-util/color/names'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { Mesh } from '../../mol-geo/geometry/mesh/mesh'; import { MeshBuilder } from '../../mol-geo/geometry/mesh/mesh-builder'; // import { Polyhedron, DefaultPolyhedronProps } from '../../mol-geo/primitive/polyhedron'; // import { Icosahedron } from '../../mol-geo/primitive/icosahedron'; import { Sphere } from '../../mol-geo/primitive/sphere'; import { Mat4, Vec3 } from '../../mol-math/linear-algebra'; import { Representation } from '../../mol-repr/representation'; var MembraneSphereParams = __assign(__assign({}, Mesh.Params), { cellColor: PD.Color(ColorNames.orange), cellScale: PD.Numeric(2, { min: 0.1, max: 5, step: 0.1 }), radius: PD.Numeric(2, { min: 0.1, max: 5, step: 0.1 }), center: PD.Vec3(Vec3.create(0, 0, 0)), quality: __assign(__assign({}, Mesh.Params.quality), { isEssential: false }) }); var MembraneSphereVisuals = { 'mesh': function (ctx, getParams) { return ShapeRepresentation(getMBShape, Mesh.Utils); }, }; export var MBParams = __assign({}, MembraneSphereParams); function getMBMesh(data, props, mesh) { var state = MeshBuilder.createState(256, 128, mesh); var radius = props.radius; var asphere = Sphere(3); var trans = Mat4.identity(); Mat4.fromScaling(trans, Vec3.create(radius, radius, radius)); state.currentGroup = 1; MeshBuilder.addPrimitive(state, trans, asphere); var m = MeshBuilder.getMesh(state); return m; } function getMBShape(ctx, data, props, shape) { var geo = getMBMesh(data, props, shape && shape.geometry); var label = 'mb'; return Shape.create(label, data, geo, function () { return props.cellColor; }, function () { return 1; }, function () { return label; }); } export function MBRepresentation(ctx, getParams) { return Representation.createMulti('MB', ctx, getParams, Representation.StateBuilder, MembraneSphereVisuals); }