Sim bounce (Usb)
Hash: Usb · Demo: /demos/sim-bounce.html
WebGL rigid-body bounce driven by assets/scenes/sim-bounce.json. Five solids — two spheres and three polyhedra — fall under gravity, collide with the ground, and bounce with sphere/AABB contact resolution.
Scene
| Item | Value |
|---|---|
| Fixture | assets/scenes/sim-bounce.json |
| Nodes | ball-a, ball-b, cube-a, oct, tet |
| Sim bodies | b1–b5 linked via nodeId |
| Ground | y: 0, restitution: 0.35 |
| Gravity | [0, -9.81, 0] |
See scene fixtures — sim-bounce.json for per-node detail.
Behaviour
- Load —
UniverseSimGl.mountfetches the scene, callsUniverseWorld.loadSceneandUniverseSim.createSim. - Meshes — one Three.js
MeshStandardMaterialmesh per node (colours match other WebGL demos). - Play — each animation frame runs
UniverseSim.step(sim)and copies poses into meshes. - Reset —
UniverseSim.reset(sim)restores initial positions and velocities from the create-time snapshot. - Ground — visual ground plane at Y=0; physics ground uses
sim.ground.y.
When prefers-reduced-motion: reduce is active, Play sim becomes Step once (one step per click, no continuous loop).
Controls
| Control | data-action |
Effect |
|---|---|---|
| Play sim / Pause | play-sim |
Toggle data-playing on [data-ks-hash="Usb"]; step each frame while playing |
| Step once | play-sim |
Under reduced motion only — single step |
| Reset | reset-sim |
UniverseSim.reset, resync meshes, pause playback |
Script load order
<div id="mount-sim" class="fu-demo-mount"></div>
<script src="/js/vendor/three.min.js"></script>
<script src="/js/universe-world.js"></script>
<script src="/js/universe-sim.js"></script>
<script src="/js/universe-fps-hud.js"></script>
<script src="/js/universe-sim-gl.js"></script>
<script src="/js/universe-demo-boot.js"></script>
universe-demo-boot.js detects #mount-sim and calls:
UniverseSimGl.mount(sim, '/assets/scenes/sim-bounce.json');
API
| Module | Entry |
|---|---|
UniverseSim |
createSim, step, reset, maxSpeed — see Simulation |
UniverseSimGl |
mount(container, sceneUrl, opts) — see JavaScript API |
Oracle
docs/design/universe/oracles/Usb.json — Playwright scenarios on [data-ks-hash="Usb"]:
| Scenario | Checks |
|---|---|
usb-dom-present |
Root mount exists |
usb-play-toggle |
Click play sets data-playing="true" |
Run with the full verifier: Verification.