This page is a high-level index of all public APIs in the algovivo codebase. It covers the JavaScript core simulation library, the rendering system, the neural network module, and the Python interface. Detailed per-class documentation is found in the child pages:
System, Vertices, Muscles, Triangles, mmgrten.Engine, TensorSystemViewport, Tracker, LineRenderer, mm2dnn.MLPPolicy, Linear, SequentialNativeInstance, Python System, Vertices, Muscles, TrianglesFor conceptual background on the simulation model, see Core Concepts. For build and compilation details, see Build System.
The JavaScript library's public surface is exported from the core package components.
Top-level exports of the algovivo package
Sources: algovivo/index.js1-19 algovivo/render/index.js1-5
For full details, see JavaScript Core API.
SystemThe central orchestrator for the simulation algovivo/System.js9 It manages the lifecycle of vertices, muscles, and triangles algovivo/System.js31-45 and interfaces with the WebAssembly backend via backward_euler_update algovivo/System.js194
Methods
| Method | Description |
|---|---|
set(args) | Configure all components: pos, muscles, musclesL0, musclesK, triangles, trianglesRsi algovivo/System.js160-173 |
setVertices(pos) | Set vertex positions algovivo/System.js136-138 |
setMuscles(args) | Set muscle indices, l0, k algovivo/System.js140-142 |
setTriangles(args) | Set triangle indices and rest-shape inverses algovivo/System.js144-146 |
step() | Advance one time step via backward_euler_update WASM call algovivo/System.js192-200 |
dispose() | Free all WASM-heap-allocated tensors algovivo/System.js202-209 |
Sources: algovivo/System.js9-210 algovivo/index.js12
VerticesManages vertex state and constraints. It handles buffer management for positions (pos0, pos1) and velocities (vel0, vel1) algovivo/System.js197-198
Key methods: set(pos), toStepArgs(), dispose().
Sources: algovivo/System.js31-35 algovivo/index.js13
MusclesManages muscle elements and activations. It provides properties to control muscle stiffness k algovivo/System.js84-90 and activation levels a algovivo/System.js120-126
Key tensors: indices, l0, k, a
Key methods: set(args), toStepArgs(), dispose()
Sources: algovivo/System.js37 algovivo/System.js120-135 algovivo/System.js140-142
TrianglesHandles triangle mesh elements and material properties algovivo/Triangles.js1-12 It uses the WASM export rsi_of_pos to compute rest-shape inverses from initial vertex positions algovivo/Triangles.js84-90
Key tensors: indices, rsi, mu, lambda algovivo/Triangles.js8-11
Key methods: set(args), toStepArgs(), dispose() algovivo/Triangles.js42-123
Sources: algovivo/Triangles.js1-124 algovivo/System.js39-42
mmgrten.Engine and mmgrten.TensorMemory management system bridging JavaScript and WebAssembly. Tensors are allocated on the WASM heap and must be manually disposed algovivo/Triangles.js106-123
Engine key methods: zeros(shape, dtype), tensor(data), dispose().
Tensor key methods: fill_(value), toArray(), typedArray(), dispose().
Sources: algovivo/index.js14 algovivo/System.js17-20 algovivo/Triangles.js55-69
For full details, see JavaScript Rendering API.
Class relationships in the rendering system
Sources: algovivo/render/index.js1-5 algovivo/render/LineRenderer.js50-112 algovivo/render/TriangleRenderer.js1-20
For full details, see Python API. The Python API mirrors the JavaScript structure but uses torch.Tensor and ctypes for interfacing with the native shared library.
Python Interface Architecture
NativeInstanceLoads the compiled shared library and defines the function signatures for the FFI.
SystemOrchestrates the simulation on the Python side, coordinating the Vertices, Muscles, and Triangles components to prepare arguments for the native backward_euler_update call.
VerticesManages vertex state using PyTorch tensors.
pos (returns pos0), vel (returns vel0).set(pos) initializes position, velocity, and gradient buffers.MusclesManages muscle actuators.
set(indices, pos, k, l0) configures muscle parameters. Rest lengths l0 can be computed automatically from positions.TrianglesManages FEM triangle elements.
set(indices, pos, rsi) configures mesh topology and material properties (mu, lambda). Rest-shape inverses rsi are computed via native FFI calls.The compiled WASM module and native library (.so/.dll) expose these raw exports, which are consumed by both the JavaScript and Python layers:
| Export | Description |
|---|---|
backward_euler_update(...) | Run one backward Euler optimization step to advance simulation algovivo/System.js194 |
rsi_of_pos(...) | Compute triangle rest-shape inverses (RSI) from vertex positions algovivo/Triangles.js84 |
l0_of_pos(...) | Compute muscle rest lengths (l0) from vertex positions. |