0.1.0-beta.1Parser and generator for CIF (Crystallographic Information File) format. Supports CIF1 (text key-value + loop_ blocks).
Handles:
Lattice parameters for a crystal structure. Stores conventional cell parameters (a, b, c in Angstroms; angles in degrees) and provides conversion between fractional and Cartesian coordinates.
(number
= 5)
Length of a-vector (Angstroms)
(number
= 5)
Length of b-vector (Angstroms)
(number
= 5)
Length of c-vector (Angstroms)
(number
= 90)
Angle between b and c (degrees)
(number
= 90)
Angle between a and c (degrees)
(number
= 90)
Angle between a and b (degrees)
Build LatticeParams from three Cartesian lattice vectors.
(THREE.Vector3)
@param {THREE.Vector3} vb @param {THREE.Vector3} vc
(any)
(any)
LatticeParams:
Convert angles to lattice vectors using the standard crystallographic convention. a-vector lies along x-axis, b-vector in the xy-plane.
{a: THREE.Vector3, b: THREE.Vector3, c: THREE.Vector3}:
Unit cell volume in ų
Crystal structure: a periodic solid with a unit cell. Extends Molecule so that existing rendering and selection code works unchanged. Adds:
Extends Molecule
(any
= 'Crystal')
Type: (LatticeParams | null)
Marker so code can distinguish Crystal from Molecule
Add an atom using fractional coordinates.
Also stores Cartesian position for rendering.
Throws a RangeError if any coordinate is NaN or non-finite,
preventing invalid geometry from entering the scene graph.
(any)
(any)
(any)
(any)
Get stored fractional coordinates of an atom (or null).
(any)
Return fractional coordinates for an atom, falling back to computing them
from the stored Cartesian position via lattice.cartToFrac() when the
fracCoords cache has no entry.
Unlike getFrac(), this method always returns a valid coordinate object
and never returns null.
(Atom)
Atom whose fractional coordinates are requested.
{x: number, y: number, z: number}:
Fractional coordinate triple. Always valid; never null.
Wrap all atoms into the unit cell [0, 1). Updates both fracCoords and Cartesian positions.
Generate a supercell using a general 3×3 integer transformation matrix S.
Convention (row form, same as ASE/pymatgen): new_a = S[0][0]*a + S[0][1]*b + S[0][2]*c new_b = S[1][0]*a + S[1][1]*b + S[1][2]*c new_c = S[2][0]*a + S[2][1]*b + S[2][2]*c
Fractional coordinate transformation: f_new = (S^T)^{-1} * f_old
The resulting supercell contains |det(S)| × (original atom count) atoms.
(any)
Crystal:
Represents an atom in the molecular structure
(any)
(any)
(any)
Represents a chemical bond between two atoms
(any)
(any)
(any
= 1)
Represents a molecular structure containing atoms and bonds
(any
= 'Molecule')
Manages crystal-specific 3D rendering:
This manager works alongside the standard RenderManager. Call drawUnitCell(crystal) after rebuildScene() to overlay the cell box.
(any)
Type: (THREE.LineSegments | null)
Elements that are polyhedra centres (empty = all with CN ≥ 3)
Draw (or redraw) the unit cell box for the given crystal. The parallelepiped has its origin at (0, 0, 0).
(any)
Render semi-transparent ghost atoms in the first shell of neighbouring cells (±1 in each lattice direction) for the given crystal.
(any)
(any)
Render semi-transparent coordination polyhedra.
Each atom whose element is in polyhedralElements (or all atoms with CN ≥ 3
if the list is empty) is used as a polyhedron centre; its bonded neighbours
form the vertices.
For crystal structures, neighbour positions are obtained via the minimum-image convention so that face-sharing polyhedra across PBC look correct.
(any)
(any)
Draw a semi-transparent Miller plane for the given (hkl) indices and
register it in activePlanes. If a plane with identical indices already
exists it is silently ignored (no duplicates). The plane colour is chosen
automatically from a fixed palette based on the current number of active
planes before the new entry is added, keeping the colour assignment
consistent even if planes are added in different orders.
Remove all Miller-index label sprites from the scene and release their GPU and CPU resources (texture, material, and the off-screen canvas). Call this before hiding Miller labels or before destroying the renderer.
Redraw all crystal-specific overlays for the current active molecule. Should be called after rebuildScene().
Manages file import/export operations Handles XYZ, SMILES, SDF formats and coordinate conversions
(any)
Import SMILES string
(any)
(Object
= {})
| Name | Description |
|---|---|
options.shouldClear boolean
(default true)
|
|
options.autoBond boolean
(default false)
|
|
options.generate3D boolean
(default false)
|
Use OpenChemLib to generate 3D coordinates |
options.addHydrogens boolean
(default false)
|
Use OpenChemLib to add explicit hydrogens |
(string)
Download XYZ file
Download the active structure as a .cif file.
Download the active structure as POSCAR.
Controls geometry manipulation sliders and operations Handles bond length, angle, and dihedral adjustments
(any)
Bind geometry slider events
Bind bond length slider
Bind bond length slider and input
Bind angle slider and input
Bind dihedral slider and input
Get moving fragment specifically for dihedral rotation This version starts BFS from neighbors of axisEnd, not from axisEnd itself
(Object)
Start of rotation axis (e.g., a2)
(Object)
End of rotation axis (e.g., a3) - this atom stays fixed
(Array
= [])
Additional atoms to exclude (e.g., a1)
Set:
Set of atoms to move (excludes axisEnd)
Calculate distance between two points
(THREE.Vector3)
(THREE.Vector3)
number:
Distance in Angstroms
Calculate angle between three points (p1-p2-p3)
(THREE.Vector3)
(THREE.Vector3)
Vertex
(THREE.Vector3)
number:
Angle in degrees
Calculate dihedral angle (p1-p2-p3-p4)
(THREE.Vector3)
(THREE.Vector3)
(THREE.Vector3)
(THREE.Vector3)
number:
Dihedral angle in degrees
Calculate new positions for bond length adjustment Moves 'movingAtoms' to satisfy target distance between atom1 and atom2
(THREE.Vector3)
Position of fixed atom
(THREE.Vector3)
Position of moving atom (pivot)
(Array<THREE.Vector3>)
Positions of all atoms to move (including pos2)
(number)
Target distance
Array<THREE.Vector3>:
New positions for moving atoms
Calculate new positions for bond angle adjustment Rotates 'movingAtoms' around axis (pivot-normal) to satisfy target angle p1-pivot-p3
(THREE.Vector3)
Fixed atom position
(THREE.Vector3)
Pivot atom position (vertex)
(THREE.Vector3)
Moving atom position (defines current angle)
(Array<THREE.Vector3>)
Atoms to rotate
(number)
Target angle in degrees
Array<THREE.Vector3>:
New positions
Calculate new positions for dihedral angle adjustment Rotates 'movingAtoms' around axis p2-p3
(THREE.Vector3)
(THREE.Vector3)
Axis start
(THREE.Vector3)
Axis end
(THREE.Vector3)
(Array<THREE.Vector3>)
Atoms to rotate
(number)
Target dihedral
Array<THREE.Vector3>:
New positions
Calculate center of mass of atoms
THREE.Vector3:
Center of mass
Get positions rotated by Euler angles (degrees) around (0,0,0)
Array<THREE.Vector3>:
Get translated positions
Array<THREE.Vector3>:
Calculate smart offset to avoid overlap
(number)
Minimum distance required
THREE.Vector3:
Offset vector
Calculate alignment transform (Rotation only) Aligns Source Vector (Anchor -> Leaving) to be Anti-Parallel to Target Vector (Anchor -> Leaving)
(THREE.Vector3)
(THREE.Vector3)
(THREE.Vector3)
(THREE.Vector3)
{rotation: THREE.Quaternion}:
Manages JSME (Java Script Molecule Editor) instance
Manages OpenChemLib 2D Editor instance
Manages OpenChemLib operations for 3D generation and hydrogen addition
Parser and generator for VASP POSCAR / CONTCAR format.
Supported variants:
File layout (VASP 5): Line 1 : comment / structure name Line 2 : universal scale factor Lines 3-5: lattice vectors a1, a2, a3 (one per line, 3 floats) Line 6 : element symbols (VASP 5) or counts (VASP 4) Line 7 : atom counts (VASP 5) Line 8 : "Selective dynamics" (optional) Line 9 : "Direct" or "Cartesian" Lines 10+: atom positions
Manages RDKit WASM instance and provides wrapper methods
Manages 3D rendering of atoms and bonds Handles mesh creation, color management, and scene updates
(any)
Update colors for all atoms based on current color scheme
Update bond meshes
Rebuild entire scene from scratch
Update bond visuals
Update bond visuals
Manages atom selection state and UI Handles selection highlighting, order tracking, and status updates
(any)
Clear all selections
Select all atoms
Invert selection
Cycle through selection modes
Update selection status display
Clear selection status display
Update highlights for all atoms (refresh visual state)
Delete selected atoms
Greatest common divisor (positive)
(any)
(any)
Builds surface slab models from a 3D crystal by cutting along an (hkl) plane.
Algorithm:
layers atomic planeslayers planes; optionally centre the slab in the vacuumGenerate a surface slab from a bulk crystal by cleaving along the (hkl)
plane. The method constructs a new orthorhombic-like unit cell whose
c axis is perpendicular to the surface, stacks the requested number of
atomic layers, and adds a vacuum region. The slab cell matrix is checked
for singularity before inversion; degenerate in-plane vectors raise an
explicit Error rather than producing silently wrong coordinates.
(any)
(number)
Miller index h
(number)
Miller index k
(number)
Miller index l
(number
= 4)
Number of atomic layers to include
(number
= 10)
Vacuum thickness in Å
(boolean
= true)
Centre the slab symmetrically in the vacuum
Crystal:
Slab structure
Manages UI interactions, modals, and labels Handles toolbar events, periodic table, coordinate editor, and atom labels
(any)
Bind all toolbar button events
Bind mode selection buttons (edit/select/move)
Bind Edit submode buttons (manual/smart)
Bind Select submode buttons (lasso/rectangle)
Bind Move submode buttons (translate/orbit/trackball)
Bind view control buttons
Bind label toggle button
Bind export PNG button
Bind console toggle button
Bind molecule management buttons
Bind sidebar toggle events
Bind undo/redo buttons
Bind periodic table events
Bind auto-bond button
Bind coordinate editor button
Bind JSME button
Bind bond threshold slider
Update label button text to reflect current mode
Close periodic table modal
Render periodic table grid
Bind Functional Groups modal events
Open Functional Groups modal
Close Functional Groups modal
Render Functional Groups grid by category
Open coordinate editor modal
Close coordinate editor modal
Toggle maximize state of JSME modal
Open 2D Editor modal (JSME or OCL)
Switch active editor
"jsme" | "ocl"))(("jsme" | "ocl"))
Update editor visibility based on active state
Close JSME modal
Toggle modal maximize
(HTMLElement)
Modal element
Export current view as PNG
Create label element for an atom
(Object)
Atom object
HTMLElement:
Label element
Update label text for an atom
(Object)
Atom object
(HTMLElement
= null)
Label element (optional, will find if not provided)
Update all atom labels
Update label positions (2D screen coordinates)
Update atom count display
Functional Groups definitions with pre-computed 3D coordinates from OCL The first atom (index 0) is the one that connects to the parent molecule NOTE: OCL converts * to C when parsing, so we manually mark the attachment
Category display names
Centralized error handling utility Provides consistent error/success response format across the application
Optimized label rendering with dirty checking and RAF batching Reduces DOM updates from every frame to only when needed
Initialize renderer with references
(THREE.Camera)
Camera for projection
(HTMLCanvasElement)
Canvas for size
Mark all labels as dirty
Schedule a label update using requestAnimationFrame Ensures updates happen at most once per frame
Update only dirty labels in batched manner Separates DOM reads and writes to minimize reflow
Update all labels (fallback for full updates) Used when camera moves or all labels need refresh
Cancel any pending update
Cleanup
Object pool for THREE.Vector3 to reduce garbage collection Reuses Vector3 instances instead of creating new ones
(any
= 100)