Skip to main content

megane

Spectacles for atomistic data.

1M+ atoms at 60fps. Visual pipelines. Jupyter, browser, React, VSCode.

$pip install megane
import megane

# One-liner to view a structure
viewer = megane.view("protein.pdb")
viewer

# With trajectory
viewer = megane.view_traj("protein.pdb", xtc="trajectory.xtc")
๐Ÿงช

Interactive 3D molecular viewer

Try Demo

๐Ÿš€ 1M+ Atoms at 60fps

Billboard impostor rendering scales from small molecules to massive protein complexes in real time. Run `megane serve` to stream XTC trajectories from disk over WebSocket โ€” scrub thousands of frames without loading everything into memory.

๐ŸŒ Runs Everywhere

Jupyter widget, CLI server, React component, VSCode extension, JupyterLab labextension. Rust parsers (PDB, GRO, XYZ, MOL/SDF, MOL2, CIF, LAMMPS data, XTC, ASE .traj, LAMMPS dump) shared between Python (PyO3) and browser (WASM): parse once, run anywhere.

๐Ÿงฉ Visual Pipeline Editor

Build visualization workflows by wiring 11 node types โ€” load data, filter atoms, adjust styles, generate labels, render coordination polyhedra, overlay vectors. No code required. 7 typed data channels flow through color-coded edges. An AI generator can build pipelines from natural language.

๐Ÿ”— Embed & Integrate

Control the viewer from Plotly via ipywidgets events. Embed in MDX / Next.js docs. React to frame_change, selection_change, and measurement events. Use the framework-agnostic renderer from Vue, Svelte, or vanilla JS.

Scale

megane renders over 1 million atoms at 60fps in the browser using GPU-accelerated billboard impostor rendering โ€” atoms are drawn as screen-aligned quads with a ray-sphere shader, so a single instanced draw call covers the whole structure. No desktop app, no plugin โ€” just a browser tab.

With the megane serve CLI, multi-GB XTC trajectories stream over a local WebSocket via a binary protocol โ€” scrub through thousands of frames without reading the whole file into memory. (Other hosts load trajectories fully into memory; see Platform Support.)

Anywhere

One codebase, every environment.

EnvironmentHowInstall
Jupyteranywidget inline viewerpip install megane
Browsermegane serve local serverpip install megane
React<MeganeViewer /> componentnpm install megane-viewer
VSCodeCustom editor for .pdb, .gro, .xyz, .mol, .sdf, .cifExtension

The secret: PDB, GRO, XYZ, MOL/SDF, MOL2, CIF, LAMMPS data, XTC, ASE .traj, and LAMMPS dump parsers are written in Rust and compiled to both PyO3 (Python) and WASM (browser). Parse once, run anywhere.

megane in Jupyter Notebook

Visual Pipelines

Wire nodes to build visualization workflows โ€” no code required.

11 node types across 5 categories: load data (structure, trajectory, streaming, vector), process (filter, modify), overlay (bonds, labels, polyhedra, vectors), and display in a 3D viewport.

7 typed data channels โ€” particle, bond, cell, label, mesh, trajectory, vector โ€” flow through color-coded edges. Only matching types can connect.

Pipelines serialize to JSON, so you can save, share, and version-control your visualization recipes.

Visual Pipeline Editor

Integrate

megane is not a walled garden. It fits into your existing workflow.

Plotly โ€” Click a point on a Plotly FigureWidget to jump to a trajectory frame. Use megane's on_event("frame_change") callback to update Plotly markers in sync.

MDX / Next.js โ€” Drop <MeganeViewer /> or <Viewport /> into your .mdx documentation. WASM parsing works out of the box with a one-line webpack config.

ipywidgets โ€” React to frame_change, selection_change, and measurement events. Compose megane with any widget in the Jupyter ecosystem.

Framework-agnostic โ€” MoleculeRenderer is a plain Three.js class. Mount it in Vue, Svelte, or a vanilla <div>.