molstar
Version:
A comprehensive macromolecular library.
47 lines (46 loc) • 2.93 kB
JavaScript
/**
* 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>
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.MBRepresentation = exports.MBParams = void 0;
var tslib_1 = require("tslib");
var representation_1 = require("../../mol-repr/shape/representation");
var shape_1 = require("../../mol-model/shape");
var names_1 = require("../../mol-util/color/names");
var param_definition_1 = require("../../mol-util/param-definition");
var mesh_1 = require("../../mol-geo/geometry/mesh/mesh");
var mesh_builder_1 = require("../../mol-geo/geometry/mesh/mesh-builder");
// import { Polyhedron, DefaultPolyhedronProps } from '../../mol-geo/primitive/polyhedron';
// import { Icosahedron } from '../../mol-geo/primitive/icosahedron';
var sphere_1 = require("../../mol-geo/primitive/sphere");
var linear_algebra_1 = require("../../mol-math/linear-algebra");
var representation_2 = require("../../mol-repr/representation");
var MembraneSphereParams = tslib_1.__assign(tslib_1.__assign({}, mesh_1.Mesh.Params), { cellColor: param_definition_1.ParamDefinition.Color(names_1.ColorNames.orange), cellScale: param_definition_1.ParamDefinition.Numeric(2, { min: 0.1, max: 5, step: 0.1 }), radius: param_definition_1.ParamDefinition.Numeric(2, { min: 0.1, max: 5, step: 0.1 }), center: param_definition_1.ParamDefinition.Vec3(linear_algebra_1.Vec3.create(0, 0, 0)), quality: tslib_1.__assign(tslib_1.__assign({}, mesh_1.Mesh.Params.quality), { isEssential: false }) });
var MembraneSphereVisuals = {
'mesh': function (ctx, getParams) { return (0, representation_1.ShapeRepresentation)(getMBShape, mesh_1.Mesh.Utils); },
};
exports.MBParams = tslib_1.__assign({}, MembraneSphereParams);
function getMBMesh(data, props, mesh) {
var state = mesh_builder_1.MeshBuilder.createState(256, 128, mesh);
var radius = props.radius;
var asphere = (0, sphere_1.Sphere)(3);
var trans = linear_algebra_1.Mat4.identity();
linear_algebra_1.Mat4.fromScaling(trans, linear_algebra_1.Vec3.create(radius, radius, radius));
state.currentGroup = 1;
mesh_builder_1.MeshBuilder.addPrimitive(state, trans, asphere);
var m = mesh_builder_1.MeshBuilder.getMesh(state);
return m;
}
function getMBShape(ctx, data, props, shape) {
var geo = getMBMesh(data, props, shape && shape.geometry);
var label = 'mb';
return shape_1.Shape.create(label, data, geo, function () { return props.cellColor; }, function () { return 1; }, function () { return label; });
}
function MBRepresentation(ctx, getParams) {
return representation_2.Representation.createMulti('MB', ctx, getParams, representation_2.Representation.StateBuilder, MembraneSphereVisuals);
}
exports.MBRepresentation = MBRepresentation;
;