Constructor
new CrystVis(element, width, height, rendererOptions)
An object providing a full interface to a renderer for crystallographic models
| Name | Type | Default | Description | 
|---|---|---|---|
element | string | CSS-style identifier for the HTML element to put the renderer in  | |
width | int | 0 | Window width  | 
height | int | 0 | Window height. If both this and width are set to 0, the window fits its context and automatically resizes with it  | 
rendererOptions | Object | Options for the renderer  | 
- Source
 
Members
displayed :ModelView
Displayed atoms
- ModelView
 
- Source
 
highlightSelected :bool
Whether the selected atoms should be highlighted with auras
- bool
 
- Source
 
(readonly) model :Model
Currently loaded model
- Model
 
- Source
 
(readonly) modelList :Array
List of loaded models
- Array
 
- Source
 
(readonly) modelName :String
Name of the currently loaded model
- String
 
- Source
 
selected :ModelView
Selected atoms
- ModelView
 
- Source
 
theme :object
Theme
- object
 
- Source
 
Methods
addNotification()
Add a notification to the list of notifications to be displayed
- Source
 
addNotifications()
Adds all notifications to the drawing
- Source
 
addPrimitive(p)
Add a primitive shape to the drawing
| Name | Type | Description | 
|---|---|---|
p | THREE. | Primitive to add  | 
- Source
 
centerCamera(center, shift)
Center the camera on a given point
| Name | Type | Description | 
|---|---|---|
center | Array.<float> | Point in model space that the orbiting camera should be centred on and look at  | 
shift | Array.<float> | Shift (in units of width/height of the canvas) with which the center of the camera should be rendered with respect to the center of the canvas  | 
- Source
 
clearNotifications()
Removes notifications from the drawing
- Source
 
deleteModel(name)
Erase a model from the recorded ones
| Name | Type | Description | 
|---|---|---|
name | String | Name of the model to delete  | 
- Source
 
displayModel(name)
Render a model
| Name | Type | Default | Description | 
|---|---|---|---|
name | String | null | Name of the model to display. If empty, just clear the renderer window.  | 
- Source
 
getScreenshotData() → {String}
Recover a data URL of a PNG screenshot of the current scene
- Source
 
A data URL of the PNG screenshot
- Type:
 - String
 
loadModels(contents, format, prefix, parameters) → {Object}
Load one or more atomic models from a file's contents
| Name | Type | Default | Description | 
|---|---|---|---|
contents | String | The contents of the structure file  | |
format | String | cif | The file's format (cif, xyz, etc.). Default is cif.  | 
prefix | String | null | Prefix to use when naming the models. Default is empty.  | 
parameters | Object | Loading parameters: 
  | 
- Source
 
Names of the models we tried to load, and values of true/false for successful loading or not
- Type:
 - Object
 
onAtomBox(callback)
Set a callback function for an event where a user drags a box around multiple atoms. The function should take as arguments a ModelView including the atoms in the box:
function callback(view) { ... }
| Name | Type | Default | Description | 
|---|---|---|---|
callback | function | null | Callback function for the event. Passing "null" restores default behaviour  | 
- Source
 
onAtomClick(callback, modifiers)
Set a callback function for an event where a user clicks on an atom. The function should take as arguments the atom image for the clicked atom and the event object:
function callback(atom, event) { ... }
| Name | Type | Default | Description | 
|---|---|---|---|
callback | function | null | Callback function for the event. Passing "null" restores default behaviour  | 
modifiers | int | Click event. Use the following flags to define it: 
 For example, CrystVis.LEFT_CLICK + CrystVis.SHIFT_BUTTON defines the event for a click while the Shift key is pressed.  | 
- Source
 
reloadModel(name, parameters)
Reload a model, possibly with new parameters
| Name | Type | Description | 
|---|---|---|
name | String | Name of the model to reload.  | 
parameters | Object | Loading parameters as in .loadModels()  | 
- Source
 
removePrimitive(p)
Remove a primitive shape from the drawing
| Name | Type | Description | 
|---|---|---|
p | THREE. | Primitive to remove  | 
- Source