UNPKG

molstar

Version:

A comprehensive macromolecular library.

30 lines (29 loc) 1.17 kB
"use strict"; /** * Copyright (c) 2018 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.addSphere = exports.getSphere = void 0; var linear_algebra_1 = require("../../../../mol-math/linear-algebra"); var mesh_builder_1 = require("../mesh-builder"); var sphere_1 = require("../../../primitive/sphere"); var sphereMap = new Map(); var tmpSphereMat = linear_algebra_1.Mat4.identity(); function setSphereMat(m, center, radius) { return linear_algebra_1.Mat4.scaleUniformly(m, linear_algebra_1.Mat4.fromTranslation(m, center), radius); } function getSphere(detail) { var sphere = sphereMap.get(detail); if (sphere === undefined) { sphere = (0, sphere_1.Sphere)(detail); sphereMap.set(detail, sphere); } return sphere; } exports.getSphere = getSphere; function addSphere(state, center, radius, detail) { mesh_builder_1.MeshBuilder.addPrimitive(state, setSphereMat(tmpSphereMat, center, radius), getSphere(detail)); } exports.addSphere = addSphere;