Class MoleculeViewer

Constructors

  • Create a new MoleculeViewer inside the HTML DOM element with the given id.

    Parameters

    • element: string | HTMLElement

      HTML element or HTML id of the DOM element where the viewer will be created

    • propertiesName: string[]

      list of properties keys to be used as options

    Returns MoleculeViewer

Properties

onselect: ((atom: number) => void)

callback called when a new atom is clicked on

positionSettingsModal: PositioningCallback

Callback to get the initial positioning of the settings modal.

The callback is called once, the first time the settings are opened.

Accessors

  • set environments(value): void
  • Parameters

    • value: undefined | (undefined | Environment)[]

      list of atom-centered environments for the current structure

    Returns void

Methods

  • Applies saved settings, possibly filling in with default values

    Parameters

    Returns void

  • Returns a PNG screenshot of the viewer as a URI string

    Returns string

  • Highlight a given atom in the current structure.

    If a supercell larger than [1, 1, 1] is currently displayed, this function accept indexes larger than the result of natoms(), and will then highlight atoms outside of the central image.

    Parameters

    • Optionalcenter: number

      index of the central atom in the environment to show, or undefined to disable highlighting.

    Returns void

  • Load the given structure in this viewer.

    Parameters

    • structure: Structure

      structure to load

    • Optionalproperties: Record<string, (undefined | number)[]>

      properties to used to load the structure

    • options: Partial<LoadOptions> = {}

      options for the new structure

    • OptionalonLoadingDone: (() => void)

      fired when viewer finished rendering

        • (): void
        • Returns void

    Returns void

  • Get the number of atoms in the structure, or undefined if no structure is currently loaded

    Returns undefined | number

    the number of atoms in the currently loaded structure

  • Add the given callback to be called whenever a setting changes. The callback will be given the path to the settings as a list of keys; and the new value of the setting.

    There is currently no way to remove a callback.

    Parameters

    • callback: ((keys: string[], value: unknown) => void)
        • (keys, value): void
        • Parameters

          • keys: string[]
          • value: unknown

          Returns void

    Returns void

  • Recreates structure options

    Parameters

    • envView: boolean

      display target, true if per environments

    • OptionalpropertiesName: string[]

      property names used as the options in the modal

    Returns void

  • Resize the 3Dmol viewer/canvas to the size of the HTML element containing this widget.

    Returns void