Matter.js Soft-Body Jelly Blobs — Free Squishy Physics Snippet

Matter.js Soft-Body Jelly Blobs · Animations · Plain HTML, CSS & JS · Live preview

CategoryAnimations

What's included

Features

Ring-and-spoke soft bodies
A centre particle plus 18 edge particles.
Rim springs
The skin between neighbours.
Bending springs
Skip-one links prevent kinks.
Volume spokes
Softer springs from the centre.
No self-collision
Unique negative group per jelly.
Smooth glossy skin
Quadratic curves plus a highlight.
Live firmness control
Updates every spring in place.
Skeleton view
Each spring type shaded differently.

About this UI Snippet

Soft Bodies in Matter.js — Particles, Three Kinds of Spring and a Smooth Skin

Screenshot of the Matter.js Soft-Body Jelly Blobs snippet rendered live

Matter.js simulates rigid bodies: a box never bends. Soft bodies are faked by joining many small rigid particles with springs — the same trick used in countless games — and hiding the machinery behind a smooth outline. This snippet builds wobbly jelly blobs that way. Tick "Show skeleton" to see what's really moving.

A ring and a centre

Each jelly is a centre particle plus a ring of 18 edge particles. Particles use inertia: Infinity so they don't spin, and they're invisible; only the outline is drawn.

Three kinds of spring, three jobs

- Rim springs join each ring particle to its neighbour. They are the skin and keep the circumference. - Skip-one springs join each ring particle to the one after next. Without them the skin can fold into sharp kinks; they give it bending resistance. - Spokes join the centre to every ring particle. They hold the volume, so a jelly squashes and bounces back instead of collapsing flat. Spokes are a little softer than the rim, which makes the blob squish before it stretches.

stiffness sets how firmly each spring returns to its rest length, and damping stops endless wobbling. Matter also ships Composites.softBody (a grid of particles); a ring gives a rounder, more jelly-like shape.

Collision groups stop self-collision

Particles of one jelly sit close together; if they collided with each other, the jelly would jitter and burst. Body.nextGroup(true) returns a fresh negative group per jelly, and bodies sharing a negative group never collide — while different jellies, with different groups, still bump into each other.

Drawing the skin

In afterRender, a closed path runs through the midpoints between ring neighbours, using each particle as a quadratic control point. That turns an 18-sided polygon into a smooth blob, and a glossy highlight follows the centre particle.

Live firmness

The slider changes the stiffness of every existing spring in place — turn a firm jelly floppy mid-bounce.

Build with AI

Build, Understand, Optimize, and Extend It With AI

Paste this snippet into an AI assistant like Claude and ask it to explain what each spring type contributes and why the spokes are softer. Ask it to add googly eyes that track the cursor, pressure that pushes the ring outward like a balloon, jellies that merge when they touch, or squash-and-stretch sound effects on impact. It can also help tune stability and particle count for mobile devices.

Prompt to recreate it

Copy this into your AI assistant of choice to build the effect from scratch, or as a jumping-off point for your own variant:

text
Build squishy soft-body jelly blobs with Matter.js 0.20 (from a CDN) in plain HTML, CSS and JavaScript.

Requirements:
- A walled canvas with an angled ledge and a round static bump as obstacles.
- Each jelly is a centre particle plus a ring of 18 small invisible edge particles (no rotation), all sharing a fresh negative collision group; join ring neighbours (rim springs), each ring particle to the one two along (bending springs), and the centre to each ring particle (spokes, 60% as stiff), all with small damping.
- In afterRender, draw each jelly as a smooth closed curve through the midpoints of ring neighbours using quadratic curves, filled with its colour, plus a glossy white highlight that follows the centre.
- A "Show skeleton" toggle that draws the three spring types in different shades and every particle.
- A firmness slider that updates all springs live, a Drop button for a random-size jelly, and Reset for three starting jellies.
- Drag and fling jellies with a mouse constraint, removing its wheel listeners so the page scrolls.

Want to tighten it up first? Run this prompt through the AI Prompt Studio to score it across 8 quality dimensions, catch anti-patterns, and tune the wording for Claude, ChatGPT, or Gemini before you paste it in.

Source Code

Requires
<div class="jl">
  <div class="jl-bar">
    <h2>Jelly</h2>
    <label>Firmness <input type="range" id="jlStiff" min="0.01" max="0.3" step="0.01" value="0.06"><output id="jlStiffOut"></output></label>
    <label class="jl-check"><input type="checkbox" id="jlSkeleton"> Show skeleton</label>
    <button type="button" id="jlDrop">Drop jelly</button>
    <button type="button" id="jlReset" class="ghost">Reset</button>
  </div>
  <div class="jl-stage" id="jlStage"></div>
  <p class="jl-hint">Grab a jelly and fling it. Lower firmness = wobblier jelly.</p>
</div>

Step by step

How to Use

  1. 1
    Watch them landThree jellies drop and squish over the obstacles.
  2. 2
    Fling oneGrab a jelly anywhere and throw it.
  3. 3
    Change firmnessLower it for wobbly jelly, raise it for firm.
  4. 4
    Show the skeletonSee the rim, bending and spoke springs.
  5. 5
    Drop moreEach new jelly gets a random size and colour.

Real-world uses

Common Use Cases

Playful landing pages
Squishy hero decorations.
Game prototypes
Slime characters and soft objects.
Learning physics engines
How soft bodies are faked with rigid parts.
Stress-relief toys
Fidget-style interactive widgets.
Creative coding
Organic motion from simple rules.
Related: Matter.js Rope Bridge
Related: Morphing Liquid Blob
A CSS/SVG blob without physics: Morphing Liquid Blob.

Got questions?

Frequently Asked Questions

Build it from small particles joined by Constraints with moderate stiffness and some damping. A ring of edge particles with neighbour springs, skip-one springs and spokes to a centre particle gives a round, squishy body. Give all its particles one negative collision group so they don't collide with each other.

They connect each edge particle to the one two places along, which resists sharp bending. Without them the outline can fold into kinks when squashed.

Usually its particles are colliding with each other. Use Body.nextGroup(true) to create a negative group for each soft body. Very high stiffness with few constraint iterations can also make it unstable.

Collect the edge particles in order and draw a closed path through the midpoints between neighbours, using each particle as a quadratic curve control point.

Yes. Constraints are plain objects; set constraint.stiffness and the next simulation step uses the new value.