Jelly softbodies
Two jelly blocks, same mesh, same 0.3 kg ball. The left block pulls each vertex back to where it started. The right block is 23,653 springs, one between every pair of vertices.
The problem
A jelly prop should dent where it's hit, shake and come back to its shape. A full finite-element solver is a lot of machinery for a dessert on a table. Both methods here move the mesh vertices directly.
How it works
Softbody gives every vertex a velocity and remembers its start position. Each step the vertex moves, the velocity is pulled back by displacement times bounciness, then scaled by 1 minus stiffness times the step. An impact adds velocity to all vertices, pointing away from the contact point and weaker with distance: pressure / (1 + 4 d²). Vertices never interact.
Jellybody turns each vertex into a small rigid body of 0.01 kg with drag 3 and gravity. A spring joins every pair of vertices at their starting distance, and every vertex also has a spring to a core body in the middle. A hit on one corner pulls on the whole block.
What I hit
The source spring strength of 20 was set for a cube with 8 distinct vertices. My block has 218, which gives 23,653 pairs. At 20 per spring the block barely moved. I settled on spring 0.3 and damper 0.006 by test, integrated with 240 substeps per 1/60 s frame. Even then the block sags about 4 cm under its own weight before the first ball lands.
The source code adds a joint for (i, j) and again for (j, i), so each pair is linked twice. I kept one spring per pair.
Jellybody collides through small spheres on the vertices plus one around the core, as the source README describes. In early runs with smaller vertex spheres a 0.12 m ball slipped between them into the block. The shot uses the source's 0.1 m spheres and a 0.16 m ball.
Softbody has the opposite problem: the ball bounces off the undeformed shape, so it never sinks into its own dent.
My build
I ported the C# Softbody, SoftVertex and Jellybody classes to JavaScript typed arrays and replaced Unity's Rigidbody and SpringJoint with my own explicit integration. Frames are simulated offline and drawn with three.js.
The block is 1 x 0.8 x 1 m with rounded edges, 218 vertices and 432 triangles. Softbody uses the source defaults, bounciness 100 and stiffness 8, with 1/60 s steps instead of Unity's 0.02 s.
In the sweep, the top vertex after impact makes 4 swings past ±5 mm with the defaults. Stiffness 2 gives 11 swings over 3.4 s. Bounciness 30 gives 1 slow swing.
Trade-offs
Softbody costs one update per vertex, but the shape cannot move as a whole and the collider stays rigid. Jellybody gives real mass and squash, but the spring count grows with the square of the vertex count, and collisions leak through gaps.
When to use it
Softbody for a prop that reacts to hits while staying in place, like a pudding or a cushion. Jellybody for a small low-poly object that has to fall and bounce, like a slime with a few dozen vertices.
Source and credits
Technique source: Softbodies by Ideefixze (Dominik Zimny), https://github.com/Ideefixze/Softbodies, MIT license, commit f56bfe969175b14b4e51ab5315fe9cc661d2a5c3. Ported to JavaScript from its Softbody and SoftVertex classes (per-vertex velocity, return spring, settle damping, distance-weighted pressure) and its Jellybody class (one body per vertex, springs between all vertex pairs, springs to a core body). Parameter values come from its Softbody and Jellybody scenes and the JellyVertex prefab.
Render framework: three.js by mrdoob and contributors, https://github.com/mrdoob/three.js, MIT license, r170. Used for drawing and lighting. It is not the source of the softbody technique.
My own code: the explicit integrator and collisions that replace Unity's Rigidbody, SpringJoint and colliders, the rounded block mesh, the falling balls, the scene, the debug views, camera moves, labels and video. No external models or assets.