A 3D engine for the web that starts at 24,837 bytes gzipped.
A TypeScript engine with a Rust kernel compiled to WebAssembly, WebGPU rendering, an optional WebGL2 fallback, and optional packs.
Five lines to a rendered scene
The margoengine facade mounts a canvas, enables orbit controls and starts rendering.
import {createStage} from 'margoengine';
const app = await createStage('#scene');
const orb = app.sphere({color: '#84d6bd', roughness: 0.25});
app.onTick(delta => {orb.rotation.z += delta;});
window.addEventListener('pagehide', () => app.dispose(), {once: true});
Install from npm, once published
npm install @margoengine/core
npm publication is pending. Choose core or stage alone, a domain profile (@margoengine/game, @margoengine/web, @margoengine/viz or @margoengine/react-kit), or margoengine for everything. Compare contents and measured installs. Browse packages and runnable examples
What the core gives you
- 24,837 B gzip
- Core plus the stage facade, with the embedded Wasm kernel and the WebGPU backend. The build fails at 25,000 bytes gzip or above;
npm run measure:sizeprints the current figure. WebGL2 lives in the optional@margoengine/webgl2-compatpackage; its lower-tier/previewentry is 3,443 B gzip. - Transforms in Wasm memory
- Hierarchy, culling and world matrices run in a Rust kernel over flat typed arrays. An engine starts with 1,024 entity slots and doubles them on demand, up to 8,388,608.
- Instancing by default
- Visible meshes sharing a geometry instance render in one instanced draw call per scene pass, with per-instance material values.
- WebGPU first, WebGL2 fallback
- Reversed float depth, GPU picking and automatic device-loss recovery on WebGPU. Without WebGPU, install
@margoengine/webgl2-compatto run the real renderer on WebGL2. Its optional/previewentry draws basic scenes on lower-tier WebGL2. - Plugins, not a monolith
- Frame-graph passes and shader hooks let optional packs add features without growing the base bundle.
Optional packs
Each pack is a separate, side-effect-free package. Your bundle includes only the ones it imports.
Assets
gltf and gltf-pro for static and textured glTF, blender for prepacked .margo exports, plus loaders for STL, OBJ, PLY, 3MF, USDZ and IFC.
Rendering
environment for HDR image-based lighting, shadows, clustered lights, post for SSAO, taa, tonemap and lines.
Interaction
controls for orbit, fly and transform gizmos, selection for outlines and picking, and react for ordinary React 18 and 19 components.
Domains
creative and vfx for particles and post effects, scenery, terrain and splats.
See it running
Every demo below runs live in your browser. They need WebGPU, so use a current Chrome or Edge on desktop.
Orrery A brass clockwork orrery under a glass dome. Pick any date and the planets move to their real positions, within arcminutes of JPL Horizons. Built with Margo Engine and Blender only.
Storm Light A lighthouse in a night storm: its beam sweeps through volumetric fog and rain over a heaving ocean, with lightning. Built with Margo Engine and Blender only.
Earth Orbit a globe with HDR city lights, drifting clouds, ocean highlights and atmosphere.
Gameplay sandbox Terrain, water, scattered foliage, lights and effects in one real-time scene.
Flight helmet Textured PBR leather, glass and wood with an ambient occlusion toggle.
Character study A walking robot with animation clips and facial morph sliders.
Windy meadow Wind-blown grass, drifting clouds, and daylight you control.
Boulder · A robot climbs a wall with arms that keep clear of the wall and of itself. Choose a hold, or a route.
Molten Words · Any word you type becomes dripping liquid chrome. Cathedral Light · Sun through stained glass into a dusty hall; scrub the time of day. Biomes · Change the climate of a 4 km landscape and its forests, snow and sand follow; paint a biome by hand.
Optional effects: Depth of field · Tonemapping and color grading
Harrow Head gallery · Live pages by feature: Khronos sample models · Voxel sandbox
Several views of one engine: Split-screen two players · Minimap
Feature demos: Batched mesh · Clipping planes · Scene targets · Depth texture · Collada and animation pointers · Texture formats · Weather
Data and science: GPU data lab (@margoengine/compute) · MRI head volume · Star catalogue · Wind field · Moving wind · Surface plot (@margoengine/sciviz)
Game interface: Menus, a health bar, an inventory and dialogs (@margoengine/ui) · drawn in the engine, with keyboard, gamepad and screen reader support
CCD reach · A skinned ten-joint tentacle reaching for a target you drag, with joint limits.
Where it stands
Margo Engine is at version 0.1.0 and Apache-2.0 licensed. WebGPU needs a supporting browser on HTTPS or localhost. Particles, image-based lighting and the scenery pack require WebGPU. Its real-GPU test suites run in Edge (Chromium) on a Windows laptop with an Intel Arc 140V; Chrome uses the same engine. Firefox, Safari and mobile GPUs are not yet verified.
The Margo Engine whitepaper gives the design and every measured number behind this page, each with its source and hardware. The Margo Voxel whitepaper covers the voxel editor, path tracer and multiplayer packages built on it.