Skip to content
Projetos

Sobre

Mathematical animations for the web — Manim in TypeScript

Ciência e engenharia

Como estes números são medidos

O que você pode fazer

  • 3D Molecules - Drug Binding - Function Graphs
  • LaTeX Equations - Reaction Mechanisms - DNA and Biology
  • Maps and Routes - Text Animations - Geometry Transforms
  • Geometry — Circle, Rectangle, Polygon, Arrow, Arc, Star, Brace, and more

Crescimento medido de estrelas

em 24 h
0
em 7 dias
+1
em 15 dias
+11
em 1 mês
Coletando histórico

Variações líquidas em períodos sobrepostos, não totais diários. Medições ausentes ficam em branco. Estrelas indicam interesse, não qualidade.

README.md

Original

manim-web

Manim in the browser. No Python.

A TypeScript port of 3Blue1Brown's Manim that runs client-side, plus native modules for molecular and drug-binding, chemistry, biology, and maps.

Square to Circle demo

npm version CI codecov License: MIT

Quick Start · Docs & Examples · Parity · Comparison · npm


Why manim-web

Three open-source libraries expose the Manim API: ManimCE, ManimGL, and manim-web. manim-web is the only one that runs client-side in the browser, and the only one that ships chemistry, biology, molecular, and geographic modules. Every claim below links to the module or document that proves it.

Capability What you get Source
Browser runtime Import from a CDN module script and render in a <canvas>. No Python, no install. Quick start
ManimCE API parity 429 of 429 feasible ManimCE 0.22.0 public symbols ported (100% of the feasible surface). PARITY.md
Molecular / drug-binding 3D molecules from PDB, MOL/SDF, and SMILES; Protein, BindingPocket, docking, van der Waals / solvent / density surfaces. src/mobjects/molecular/
Chemistry Reaction arrows and schemes, electron-pushing arrows, Bohr diagrams, CPK colors. src/mobjects/chemistry/
Biology DNAHelix, Cell, AminoAcidChain, and a cutaway 3D cell (Cell3D) with 12 organelle classes and process animations. src/mobjects/biology/
Maps / geo Globe, ChoroplethMap, FlowArc, map projections, GeoJSON and TopoJSON. src/mobjects/geo/
Interactive player A built-in player with play/pause, scrub, and segment navigation. src/player/
Export GIF and video (WebCodecs/MP4/WebM) with an audio track, in the browser or from the command line. src/export/
3D explainer videos Manim look for 3D meshes, 3D build-up, camera focus, captions and callouts, a tour runner, narration, mp4 from the CLI. Guide
Framework integrations React, Vue, a web component, and a notebook entry point. Framework integrations

The chemistry, biology, molecular, and geo modules do not exist in the ManimCE or ManimGL reference APIs. See COMPARISON.md for the full, source-backed comparison.

Quick Start

Browser (30 seconds, no install)

<div id="container"></div>
<script type="module">
  import {
    Scene,
    Circle,
    Create,
  } from 'https://cdn.jsdelivr.net/npm/manim-web@latest/dist/manim-web.browser.js';

  const scene = new Scene(document.getElementById('container'), {
    width: 500,
    height: 300,
  });
  const circle = new Circle({ radius: 1.5 });
  await scene.play(new Create(circle));
</script>

Locally

npm install manim-web
import { Scene, Circle, Square, Create, Transform, FadeOut } from 'manim-web';

async function squareToCircle(scene: Scene) {
  const square = new Square({ sideLength: 3 });
  const circle = new Circle({ radius: 1.5 });

  await scene.play(new Create(square));
  await scene.play(new Transform(square, circle));
  await scene.play(new FadeOut(square));
}

See the docs and examples for more, including a molecular and maps gallery.

What You Can Build

Caffeine molecule morphing from ball-and-stick to space-filling
3D Molecules
A ligand docking into a protein pocket with hydrogen bonds
Drug Binding
Function Graphs
Function Graphs
LaTeX Equations
LaTeX Equations
SN2 reaction mechanism with electron-pushing arrows
Reaction Mechanisms
DNA double helix zipping and unzipping its base pairs
DNA and Biology
Flight routes from Yerevan on a Robinson world map
Maps and Routes
Text Animations
Text Animations
Geometry Transforms
Geometry Transforms

Features

  • Geometry — Circle, Rectangle, Polygon, Arrow, Arc, Star, Brace, and more
  • Text & LaTeX — Text, MathTex, Tex, Paragraph via KaTeX; Typst via an opt-in WASM compiler
  • Graphing — Axes, NumberPlane, FunctionGraph, ParametricFunction, VectorField, BarChart
  • 3D — Sphere, Cube, Cylinder, Torus, Surface3D, ThreeDAxes with orbit controls
  • Animations — FadeIn/Out, Create, Transform, Write, GrowFromCenter, AnimationGroup, LaggedStart
  • Interaction — Draggable, Hoverable, Clickable mobjects, plus a scrub player
  • Export — GIF and video (MP4/WebM via WebCodecs)
  • 3D explainers — applyManimStyle3D, Create3D, scene.focusOn, CaptionCard, Callout3D, ExplainerTour, narrate, and Cell3D for biology (guide)
  • Science modules — molecular/drug-binding, chemistry, biology, and maps (see Why manim-web)
  • Graphs & Tables — Network graphs, Matrix, Table

Render an example page to mp4 (video and narration) from a checkout of this repo. The page opts in with registerRender(scene, { construct }):

npm run render -- cell_tour_3d --width 1080 --height 1080 --fps 30 --bitrate 6000000 --out cell_tour_3d.mp4

Framework Integrations

React

The ManimScene component builds the scene in the onSceneReady callback. It runs once, after the scene mounts.

import { ManimScene } from 'manim-web/react';
import { Circle, Create } from 'manim-web';

function App() {
  return (
    <ManimScene
      width={800}
      height={450}
      onSceneReady={async (scene) => {
        const circle = new Circle({ radius: 1.5 });
        await scene.play(new Create(circle));
      }}
    />
  );
}

Vue

The ManimScene component emits a ready event with the scene instance. Build the scene in the handler.

<script setup lang="ts">
import { ManimScene, Circle, Create, type Scene } from 'manim-web/vue';

const onReady = async (scene: Scene) => {
  const circle = new Circle({ radius: 1.5 });
  await scene.play(new Create(circle));
};
</script>

<template>
  <ManimScene :width="800" :height="450" @ready="onReady" />
</template>

A manim-web/element web component and a manim-web/notebook entry point are also published.

When to use ManimCE or ManimGL instead

manim-web is young and trades ecosystem size for a browser runtime. Reach for the Python libraries when they fit better:

  • ManimCE — the reference API, a mature ecosystem, far more tutorials and examples, and the full LaTeX package set (manim-web uses KaTeX, a large but incomplete LaTeX subset).
  • ManimGL — native OpenGL rendering with the architectural edge on heavy scenes, plus 3Blue1Brown's own interactive playback window.

manim-web trails both on stars, age, and downloads. The exact numbers, with sources, are in COMPARISON.md.

Python to TypeScript

Have existing Manim scripts? Convert them:

node tools/py2ts.cjs input.py -o output.ts

Logging

manim-web logs through a small structured logger. Subscribe to log messages with onLog — useful for surfacing errors in your UI or forwarding them to a server (handy for AI agents that write and debug scenes):

import { onLog } from 'manim-web';

const unsubscribe = onLog((entry) => {
  // entry = { level, message, timestamp } — always JSON-serializable
  fetch('/__log', { method: 'POST', body: JSON.stringify(entry) });
});

unsubscribe(); // stop receiving log messages

Forwarded messages are sanitized (tokens, keys, and emails are redacted) and respect the LOG_LEVEL environment variable (debug | info | warn | error).

Contributing

git clone https://github.com/maloyan/manim-web.git
cd manim-web
npm install
npm run dev

How it was built

The port was written with coding agents. The story, with numbers from the git history: Porting Manim to TypeScript with Coding Agents.

License

MIT. Created by Narek Maloyan.

Explore projetos relacionados

Carregando…