Namespace: $3Dmol

$3Dmol

All of the functionality of $3Dmol.js is contained within the $3Dmol global namespace

Classes

GLModel
GLShape
GLShape
GLViewer
Label
VolumeData

Namespaces

GLDraw

Members

<static> builtinColorSchemes

Properties:
Name Type Description
built

in color schemes The user can pass all of these values directly as the colorscheme and they will use the respective colorscheme

<static> elementColors

Preset element coloring - from individual element colors to entire mappings (e.g. '$3Dmol.elementColors.Jmol' colors atoms with Jmol stylings)

<static> Parsers

$3Dmol.Parsers stores functions for parsing molecular data. They all take a string of molecular data and options. The default behavior is to only read the first model in the case of multimodel files, and all parsers return a list of atom list(s)

$3Dmol.Parsers. corresponds to the parsers for files with extension ext

<static> ssColors

Preset secondary structure color scheme

<static> SurfaceType :number

$3Dmol surface types

Type:
  • number
Properties:
Name Type Default Description
VDW number 1
MS number 2
SAS number 3
SES number 4

<static> syncSurface :boolean

Render surface synchronously if true

Type:
  • boolean

<static> viewers

Contains a dictionary of embedded viewers created from HTML elements with a the viewer_3Dmoljs css class indexed by their id (or numerically if they do not have an id).

Methods

<static> createViewer(element, config) → {$3Dmol.GLViewer}

Create and initialize an appropriate viewer at supplied HTML element using specification in config

Parameters:
Name Type Description
element Object | string

Either HTML element or string identifier

config ViewerSpec

Viewer specification

Returns:

GLViewer, null if unable to instantiate WebGL

Type
$3Dmol.GLViewer
Example
$3Dmol.download("pdb:4UAA",viewer,{},function(){
               viewer.setBackgroundColor(0xffffffff);
               var colorAsSnake = function(atom) {
                 return atom.resi % 2 ? 'white': 'green'
               };

               viewer.setStyle( {}, { cartoon: {colorfunc: colorAsSnake }});

               viewer.render();
           });                     
                    

<static> download(query, viewer, options, callback) → {$3Dmol.GLModel}

Load a PDB/PubChem structure into existing viewer. Automatically calls 'zoomTo' and 'render' on viewer after loading model

Parameters:
Name Type Description
query string

String specifying pdb or pubchem id; must be prefaced with "pdb: " or "cid: ", respectively

viewer $3Dmol.GLViewer

Add new model to existing viewer

options Object

Specify additional options format: file format to download, if multiple are available, default format is pdb pdbUri: URI to retrieve PDB files, default URI is http://www.rcsb.org/pdb/files/

callback function

Function to call with model as argument after data is loaded.

Returns:

GLModel

Type
$3Dmol.GLModel
Example
viewer.setBackgroundColor(0xffffffff);
      $3Dmol.download('pdb:2nbd',viewer,{onemol: true,multimodel: true},function(m) {
       m.setStyle({'cartoon':{colorscheme:{prop:'ss',map:$3Dmol.ssColors.Jmol}}});
      viewer.zoomTo();
      viewer.render(callback);
   });

<static> getbin(uri, callback)

Download binary data (e.g. a gzipped file) into an array buffer and provide arraybuffer to callback.

Parameters:
Name Type Description
uri string

location of data

callback function

Function to call with arraybuffer as argument.

<static> getColorFromStyle(atom, style) → {$3Dmol.Color}

Return proper color for atom given style

Parameters:
Name Type Description
atom AtomSpec
style AtomStyle
Returns:
Type
$3Dmol.Color

<static> getExtent(atomlist) → {Array}

computes the bounding box around the provided atoms

Parameters:
Name Type Description
atomlist Array.<AtomSpec>
Returns:
Type
Array

<static> mergeGeos(geometry, mesh) → {undefined}

Parameters:
Name Type Description
geometry $3Dmol.Geometry
mesh $3Dmol.Mesh
Returns:
Type
undefined

<static> specStringToObject((String)) → {Object}

Parse a string that represents a style or atom selection and convert it into an object. The goal is to make it easier to write out these specifications without resorting to json. Objects cannot be defined recursively. ; - delineates fields of the object : - if the field has a value other than an empty object, it comes after a colon , - delineates key/value pairs of a value object If the value object consists of ONLY keys (no = present) the keys are converted to a list. Otherwise a object of key/value pairs is created with any missing values set to null = OR ~ - separates key/value pairs of a value object, if not provided value is null twiddle is supported since = has special meaning in URLs

Parameters:
Name Type Description
(String)

str

Returns:
Type
Object