collide
Objects keep their distance: overlapping neighbors ease apart; a gravity center and its orbiters hold still. List it last so it sees where the other interactions moved things.
Add the script once, then use the tags anywhere.
<script type="module" src="https://mmaxence.github.io/solids/solids.js"></script>
Or copy the library into your project: download solids.js from the repo and serve it yourself. No build step, no other files.
Usage
Set interaction="collide" on the scene. Interactions are scene rules: they work on every object inside, whatever its type. Several run in the order written.
Options
| Attribute | Type | Default | Range | Description |
|---|---|---|---|---|
collide-gap | number | 8 | 0 to 80 | Space kept between objects (px) |
License
MIT. Use it anywhere, credit appreciated.