Skip to main content
← Back to Lab

Elastic Lanyard

Physics-based lanyard with tension, elasticity, and drag interaction.

PhysicsCanvasInteraction

Loading Interactive Lanyard...

What this explores

Verlet integration for rope physics, elastic constraints, and responsive drag handling.

Principles demonstrated

  • Physics simulation with Verlet integration
  • Canvas rendering with gradients
  • Touch and mouse interaction handling
  • Performance optimization with requestAnimationFrame

Build It Yourself

Step-by-step guide to recreate this experiment

Intermediate45-60 min

Prerequisites

  • Basic JavaScript/TypeScript
  • HTML Canvas fundamentals
  • Understanding of 2D vectors

Verlet integration is a way of calculating motion that skips storing velocity. Instead, it works out movement from the difference between the current and previous positions. That makes it naturally stable, and it's a great fit for ropes and cloth.

javascript
// Traditional physics: velocity-based
position += velocity;
velocity += acceleration;

// Verlet integration: position-based
const velocity = position - previousPosition;
previousPosition = position;
position += velocity + acceleration;

Verlet integration is self-correcting. Small errors don't accumulate over time the way they do with Euler integration.