Phys Playground
Overview
Phys Playground is the Portal Network browser physics playground. The project is centered around interactive physics experiments and the GravityLab experience.
The codebase should keep simulation logic, interaction tools and presentation concerns separable enough that experiments can evolve without turning the main loop into a single giant script.
Simulation
The simulation is responsible for stepping the physics engine, updating bodies and synchronizing the rendered scene. Keep fixed-step or engine timing decisions in one place.
Objects
Objects represent the things users can spawn, manipulate or observe. When adding a new object type, document its physical properties, controls and any special rendering behavior.
Tools
- Spawn and delete objects.
- Manipulate objects with pointer or touch input.
- Experiment with forces, gravity and constraints.
- Use debugging controls to inspect unexpected behavior.
Architecture
A useful mental model is input → simulation → render → UI. Keeping those boundaries clear makes it easier to port experiments or build a single-file version when needed.
Debugging
// Basic Matter-style debugging pattern
engine.world.bodies.forEach(body => {
console.log(body.label, body.position);
});When something does not render, first verify that the renderer was created, the world contains bodies, and the engine loop is actually running.
Deployment
Browser builds should be tested from a local HTTP server as well as the production host. Module imports, worker behavior and asset paths can behave differently under file://.