Intermact API Reference
This overview covers the architecture and entry points for v0.1–v1.0 (Phase-1 / Phase-2 / Phase-3) public API; individual symbol pages are generated by TypeDoc from exports and TSDoc comments in packages/*/src. Phase-3 (PCG / 3D / serialization export / plugins) API map is in §Phase-3 below; concept guides at PCG / 3D / Export & embed / Performance / Extensibility.
Full contract and revision history in repo
dev-docs/design.md. Conceptual tutorial: Guide · Architecture overview.
Vision and API boundaries
| Phase | Version | Theme | Relation to this doc |
|---|---|---|---|
| Phase-1 | v0.1 | Interactive Manim alternative: 2D primitives, seekable timeline, coordinate axes, reactive tuning | Overview §Phase-1 |
| Phase-2 | v0.2 | Math toolbox: Scale, LaTeX, Morph matching, interaction picking, layout | Overview §Phase-2 |
| Phase-3 | v1.0 | PCG, full 3D, serialization/export/embed, plugins | Symbol pages + Plugin guide |
Core execution model: seekable timeline
Intermact uses a retained-mode timeline (design.md §3.2):
| Phase | Responsibility | Key API |
|---|---|---|
| Build | Register objects; scene.play appends tracks to Storyboard | createProgram, buildProgram, Scene2D |
| Playback | seek / update pure-function evaluation; deterministic snapshot | Player, Track, RenderSnapshot |
await scene.play(...) is build-time syntax sugar: logical clock advances instantly, no wall-clock time consumed.
Object three layers: definition · instance · runtime state
IMObject2D (immutable definition: geometry + trait)
└── scene.register(...) → RegisteredObject2D (animation handle: create / moveTo / morphTo …)
└── Track evaluation → RuntimeState2D (position, reveal, opacity, geometryOverride …)- Definition layer:
IMObject2D+ traits (stroke/fill/morphable/textLayout); primitive factories likecircle,polygon. - Instance layer:
RegisteredObject2D— animation methods returnAnimationdata, compiled atplay. - Runtime layer:
RuntimeState2D+applyPatch2D; renderer consumesRenderSnapshot.
Scene · Camera · Canvas decoupling
Unlike Manim, scene, camera, and canvas are layered (design.md §9–10):
| Layer | Role | Key API |
|---|---|---|
| Scene2D | Coordinate domain, object registration, getAxes, orchestrates play | Scene2D |
| Camera | Orthographic camera description, mounted to viewport | createCamera2D |
| Canvas | React entry: build program, R3F canvas, timeline overlay | IntermactCanvas |
Coordinate transforms: CoordinateTransform2D (abs/rel, polar). Axis objects register via Scene2D.getAxes; ticks generated by Scale (Phase-2).
Package layers and render pipeline
@intermact/react
└── @intermact/render-r3f SceneView, computeFit
└── @intermact/render-three stroke/fill geometry, ThreeSceneView
└── @intermact/core no React / three / DOM| Package | Responsibility |
|---|---|
@intermact/core | Model, geometry, timeline, reactive, Scale/constructs/text/interaction; headless in Node |
@intermact/render-three | RenderSnapshot → three.js geometry (stroke trim, earcut fill) |
@intermact/render-r3f | R3F diff update, camera fit, HiDPI |
@intermact/react | IntermactCanvas, useSignal, timeline controls, Inspector |
Data flow: Player.getSnapshot() → ThreeSceneView diff → R3F SceneView.
Phase-1 (v0.1): basic 2D narrative
Guides: Program and scene · Timeline · Geometry · Rendering · Animation · Coordinates · Reactive
| Capability | API entry |
|---|---|
| 2D primitives | circle, rectangle, polygon, bezierCurve, arrow |
| Create / Fade / Move / Tween | RegisteredObject2D, compileSpec |
| Orchestration | sequence, parallel, stagger, wait |
| Coordinates and axes | CoordinateTransform2D, Scene2D.getAxes |
| Reactive tuning | signal, derived, tweenSignal, useSignal |
| Side effects (not seekable) | call |
Phase-2 (v0.2): math toolbox
Guides: Scale · Math constructs · Morph · Text and LaTeX · Interaction · Layout and Inspector
Scale and ticks (M7)
| Capability | API entry |
|---|---|
| Scale types | linearScale, logScale, normalizeScale |
| Tick generation | numericTicks |
| Axis handle | createAxesHandle, AxesHandle (c2p / xScale / yScale) |
Math construct library (M8)
| Capability | API entry |
|---|---|
| Coordinate planes | numberLine, numberPlane, polarPlane, complexPlane |
| Curves and integration | functionGraph, parametricGraph, areaUnderCurve, riemannRectangles, tangentLine |
| Expression and annotation | matrixObject, tableObject, brace, decimalNumber |
Morph and part matching (M9)
| Strategy | API entry |
|---|---|
arc-length / anchor / matching / cross-fade | morph, transformMatching |
| Composite object part keys | group2D |
| Instance methods | RegisteredObject2D.morphTo, transformMatchingTo |
Text and LaTeX (M10)
| Capability | API entry |
|---|---|
| Fonts | loadOutlineFontFromBuffer, setDefaultFont, createAssetManager |
| Text objects | textObject, glyphText |
| LaTeX | layoutMathJaxLatex, latexObjectFromGlyphs |
| Writing animation | glyphLocalReveal, computeGlyphRevealSpans |
| Formula part morph | transformMatchingTex (token → part key, reuses matching) |
Interaction system (M11)
| Capability | API entry |
|---|---|
| Draggable sources | draggablePoint, draggableValue, draggablePointSource, draggableValueSource |
| Hit testing | hitTest, hitProxy, interactive |
| Pick helpers | pickRectFromObject, pickBandFromObject |
Layout and Inspector (M12)
| Capability | API entry |
|---|---|
| Relative layout | LayoutHandle (RegisteredObject2D.layout: alignTo / nextTo / arrange / fitTo) |
| Layout handle factory | createLayoutHandle |
| Dev tools | Inspector (React-side scene tree / signals / snapshot debug) |
Phase-3 (v1.0): PCG · 3D · serialization export · plugins
Guides: Procedural generation · 3D scenes and cameras · Export, share, and embed · Performance and big data · Extensibility
PCG procedural generation (M13)
| Capability | API entry |
|---|---|
| Parametric / lattice / tiling | parametricCurve2D, lattice, tiling |
| Fractal / rules | fractal, recursiveTree, lSystem, cellularAutomaton, cellularAutomatonFrames |
| Fields | functionGraph, isoline, heatmap, streamlines |
| Graph / data | graphObject, barChart, scatter, lineChart, mapData |
| Combinator operators | transformObject, repeatObject, instanceField, mapPoints, along, booleanOp |
Full 3D (M14)
| Capability | API entry |
|---|---|
| Scene / camera | Scene3D, RegisteredCamera3D, CoordinateTransform3D |
| 3D factories | polyline3D, curve3D, meshObject, surface3D, pointCloud3D, axes3D |
| Scalar field isosurface | isosurface, marchingCubes |
| Nested sub-scenes | RegisteredObject2D.layout · render(scene, camera) (render-r3f RenderedScene) |
Serialization / export / embed (M15)
| Capability | API entry |
|---|---|
| Serialization | serialize, deserialize |
| Share links | encodeShareUrl, decodeShareUrl, SerializedCanvas |
| Headless frames | snapshotToSVG, sampleFrames, sampleFrameHashes |
| Video / GIF | recordCanvasVideo, captureFrameSequencePng, encodeGif, exportCanvasGif |
| Embed | defineIntermactEmbed, buildEmbedIframe |
Performance and extensibility (M16 / M17)
| Capability | API entry |
|---|---|
| GPU instancing / point cloud | instanceField, pointCloud3D |
| Registries | createRegistries, globalRegistries |
| Plugins | definePlugin, installPlugin, defineObjectType, defineGenerator |
| Generator dispatch | runGenerator, selectRenderer |
Reactive layer (interactive state)
Aligned with Manim ValueTracker + add_updater (design.md §8), for parameter-driven geometry recomputation:
Each frame: Player.prepareFrame → ReactiveEngine.flush → then generate RenderSnapshot.
How to browse symbols
- Enter package index pages from Packages below.
- Sidebar browse by Classes / Interfaces / Functions (includes all Phase-2 exports).
- To change API docs, edit source TSDoc and run
pnpm run gen:referenceto regenerate.