3D games, real physics, in the browser
Make 3D games with real physics.
A small JavaScript engine for the web. A few lines of code, and things fall, bounce and swing.
This is the engine running, not a video.
Open this scene in the sandbox
demos
Pick a demo and run it
Every one is a short sketch. Open it in the sandbox to read the code and change it.
the whole idea
Short enough to read in one go
There is no loop to write and nothing to import. You write the functions the engine calls, and use a few globals.
setup()Runs once. Make your starting scene here.update()Runs 60 times a second. Read the keyboard and the mouse, push things around.Cube,Sphere,Floorand friendsEvery one is aSolid: it can be seen, it can fall, and it can be touched.
function setup() {
world.gravity.y = -10; // gravity starts off. Turn it on.
new Floor();
const box = new Cube(0, 4, 0);
box.color = 'tomato';
box.bounciness = 0.6;
}
function update() {
// Space blows everything away from the middle
if (kb.presses('space')) world.explodeAt(0, 0, 0, 6, 8);
}
docs & sandbox
What is in the box
Six shapes, your own hulls and meshes, textures, glTF models, joints, forces, ray casts, cameras, lights, sound, saving, a level built from text, and online play between two tabs. Each page of the docs has demos you can run.
honest limits
What it cannot do yet
spaSHial is young. These are not built, and the docs say so in one place.
- Online play between two computers
- Vehicles and ragdolls
- Terrain from a height map
- Animated models
- Motorised and 6-axis joints