GLModel

The model component that handles molecular structure representation and manipulation.

Constructor

new GLModel(viewer: GLViewer, data: ModelData, options?: ModelConfig)

Configuration Options

interface ModelConfig {
  format?: 'pdb' | 'mmtf' | 'gro' | 'cube';  // Input format
  defaultRepresentation?: string;             // Default representation type
  defaultColor?: string;                      // Default color
  defaultOpacity?: number;                    // Default opacity
  loadHetero?: boolean;                       // Load hetero atoms
  loadWater?: boolean;                        // Load water molecules
  loadHydrogen?: boolean;                     // Load hydrogen atoms
}

Methods

setRepresentation

Sets the visualization representation for the model

setRepresentation(type: string, options?: RepresentationConfig): void

updateRepresentation

Updates the current representation with new options

updateRepresentation(options: Partial<RepresentationConfig>): void

getAtom

Retrieves atom information by index

getAtom(index: number): AtomSpec

getBond

Retrieves bond information by index

getBond(index: number): BondSpec

Representation Types

Cartoon

Ribbon representation for protein structures

Surface

Molecular surface visualization

Ball and Stick

Traditional molecular representation

Spacefill

Van der Waals surface representation

Example

// Create model
const model = new GLModel(viewer, modelData, {
  defaultRepresentation: 'cartoon',
  defaultColor: 'chain',
  defaultOpacity: 0.8
});

// Set up representations
model.setRepresentation('cartoon', {
  color: 'chain',
  opacity: 0.8,
  smooth: 0.5
});

model.setRepresentation('surface', {
  color: 'chain',
  opacity: 0.5,
  surfaceType: 'ses'
});

Related Components

Learn more about other core components: