How to use 3dmol - 3 common examples

To help you get started, we’ve selected a few 3dmol examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Autodesk / molecule-3d-for-react / src / components / molecule_3d.jsx View on Github external
render3dMol() {
    if (!this.glviewer && Molecule3d.isModelDataEmpty(this.props.modelData)) {
      return;
    }

    const glviewer = this.glviewer || $3Dmol.createViewer(jQuery(this.container), {
      defaultcolors: $3Dmol.elementColors.rasmol,
    });

    const renderingSameModelData = moleculeUtils.modelDataEquivalent(
      this.oldModelData, this.props.modelData
    );
    if (!renderingSameModelData) {
      this.lastStylesByAtom = null;
      Molecule3d.render3dMolModel(glviewer, this.props.modelData);
    }

    const styleUpdates = Object.create(null); // style update strings to atom ids needed
    const stylesByAtom = Object.create(null); // all atom ids to style string
    this.props.modelData.atoms.forEach((atom, i) => {
      const selected = this.state.selectedAtomIds.indexOf(atom.serial) !== -1;
      const libStyle = libUtils.getLibStyle(
github Autodesk / molecule-3d-for-react / src / components / molecule_3d.jsx View on Github external
render3dMol() {
    if (!this.glviewer && Molecule3d.isModelDataEmpty(this.props.modelData)) {
      return;
    }

    const glviewer = this.glviewer || $3Dmol.createViewer(jQuery(this.container), {
      defaultcolors: $3Dmol.elementColors.rasmol,
    });

    const renderingSameModelData = moleculeUtils.modelDataEquivalent(
      this.oldModelData, this.props.modelData
    );
    if (!renderingSameModelData) {
      this.lastStylesByAtom = null;
      Molecule3d.render3dMolModel(glviewer, this.props.modelData);
    }

    const styleUpdates = Object.create(null); // style update strings to atom ids needed
    const stylesByAtom = Object.create(null); // all atom ids to style string
    this.props.modelData.atoms.forEach((atom, i) => {
      const selected = this.state.selectedAtomIds.indexOf(atom.serial) !== -1;
      const libStyle = libUtils.getLibStyle(
        atom, selected, this.props.atomLabelsShown, this.props.styles[i]
github Autodesk / molecule-3d-for-react / src / components / molecule_3d.jsx View on Github external
static render3dMolOrbital(glviewer, orbital) {
    if (orbital.cube_file) {
      const volumeData = new $3Dmol.VolumeData(orbital.cube_file, 'cube');
      glviewer.addIsosurface(volumeData, {
        isoval: orbital.iso_val,
        color: ORBITAL_COLOR_POSITIVE,
        opacity: orbital.opacity,
      });
      glviewer.addIsosurface(volumeData, {
        isoval: -orbital.iso_val,
        color: ORBITAL_COLOR_NEGATIVE,
        opacity: orbital.opacity,
      });
    }
  }

3dmol

JavaScript/TypeScript molecular visualization library

BSD-3-Clause
Latest version published 1 month ago

Package Health Score

87 / 100
Full package analysis

Similar packages