A game is () => HTMLElement
new FPS(), add entities, start(player) â you get back a container element. Mount it anywhere; disposeGame(el) tears everything down, physics included.
A lightweight 3D game engine for people making small browser games. Write TypeScript on Three.js; Bullet physics runs as WebAssembly. An FPS player with desktop and touch controls, voxel terrain and a DOM HUD come in the box.
import * as THREE from 'three';
import { FPS } from '@maomi/sge';
import { Player } from '@maomi/sge/player';
import { Box } from '@maomi/sge/object';
import { Grid } from '@maomi/sge/terrain/grid';
import { defaultLights } from '@maomi/sge/lights';
export const createGame = (): HTMLElement => {
const camera = new THREE.PerspectiveCamera(70, innerWidth / innerHeight, 0.1, 4000);
const fps = new FPS();
fps.scene.add(defaultLights());
fps.add(new Grid(100));
const crate = new Box();
crate.position = new THREE.Vector3(0, 5, -4);
fps.add(crate);
const player = new Player({ camera });
fps.add(player);
return fps.start(player);
};The package is still published under its first name, @maomi/sge; the getting-started guide covers the install and the two Vite settings it needs.
Bullet is the C++ physics engine; ammo.js compiles it to WebAssembly with Emscripten. Wasmotion gets it through bullet-ts, its companion project, maintained by the same author: the ammo.js WASM build packaged as one typed ESM namespace (import * as bullet from 'bullet-ts') that boots its WASM with a top-level await, so it is ready before any importer runs.
On top of that, Wasmotion builds and frees the dynamics world, turns entities into rigid bodies, and adds the character controller, raycasts and collision callbacks â while fps.world stays the real btDiscreteDynamicsWorld for anything the wrappers don't cover. See Physics.
bullet-ts is a fork of giniedp/ammojs-typed (MIT); Bullet and ammo.js are under the zlib license. Wasmotion itself is MIT.