majidmanzarpour GitHub avatar

threejs-procedural-spider

majidmanzarpour

A self-stabilizing procedural spider that walks over any terrain using closed-form inverse kinematics, with no animation clips, skeleton rig, or physics engine.

Stars

67

7-day growth

No data

Forks

17

Open issues

0

License

MIT

Last updated

2026-06-26

AI repository intelligence
FR-AI / ANALYSIS

Why it is worth attention

It demonstrates a fully analytic, physics-free approach to procedural animation—each leg is solved with a single formula, the terrain is a function, and the body adapts to slopes, walls, and overhangs in real time, all in ~1,200 lines of code.

Who it is for

  • Game developers interested in procedural animation
  • Robotics enthusiasts and IK researchers
  • Three.js and WebGL developers
  • Educators teaching computer graphics or kinematics

Use cases

  • Learning and experimenting with closed-form inverse kinematics
  • Prototyping procedural locomotion for games or simulations
  • Sandbox for testing gait parameters and terrain adaptation
  • Technical demo or portfolio piece for computational creativity

Strengths

  • Analytic IK provides exact, per-frame foot placement without iteration
  • Terrain as a height field enables robust climbing on walls and overhangs
  • Minimal dependencies and small codebase (Three.js only ~1,200 lines)
  • Live tuning panel allows real-time adjustment of all locomotion parameters

Considerations

  • Terrain is limited to a closed-form height field, not arbitrary meshes
  • Requires mathematical understanding to extend or modify the core algorithms
  • No physics engine means no dynamic collisions or momentum-based interactions
  • Primarily a sandbox; not a full game or production-ready locomotion system

README quick start

🕷️ Procedural Spider

Play the live demo · by @majidmanzarpour

A self-stabilizing procedural spider you can walk over any terrain. Eight legs solved with closed-form inverse kinematics, a gait that improvises its own footfalls, and a body that leans into slopes, walls, and overhangs — with no animation clips, no skeleton rig, and no physics engine. Just math, every frame. Built with Three.js.

Drag the sliders, drive it around, watch the legs find their own footing. It's strangely calming.


✨ Features

  • Analytic IK legs — each leg is solved with a two-bone closed-form solver (hip → knee → foot). No baked animation, no IK iterations to converge: one formula, exact, every frame.
  • Improvised gait — feet are planted in the world, not on the body. When the body outruns a foot, that leg lifts, arcs to a fresh foothold, and plants. Step timing is an alternating-gait state machine, so the walk re-times itself naturally as you speed up, slow down, or turn.
  • Terrain that's a function, not a mesh — the ground is a closed-form height field, so the spider can sample the exact height and normal at any point. That's what makes foot placement and body alignment rock-solid.
  • Climbs walls & overhangs — the body's up-vector blends toward the surface normal under it, so the spider tilts onto inclines and clings to steep faces instead of clipping or sliding.
  • A body that bends — two segments (cephalothorax + abdomen) joined at a flexible pedicel, so the abdomen folds at the waist: it hangs down on a wall, droops over a crest, and sags under its own weight. The spider flexes like a real spider, not a rigid blob. (Toggle: BODY FLEX.)
  • Knee-swivel collision avoidance — each leg searches a fan of knee orientations and picks the one that keeps the limb out of the ground and obstacles (tunable live).
  • Live tuning panel — speed, ride height, step height, gait rate, turn rate, stride, and the knee-swivel search, all adjustable while it walks.
  • Tiny & dependency-light — ~1,200 lines across 8 modules, with three as the only runtime dependency. Runs at hundreds of FPS.
  • Desktop & touch — WASD + mouse, or an on-screen joystick on phones/tablets.

🎮 Controls

| Action | Desktop | To

Description

Procedural spider that walks, climbs walls, and leaps onto any terrain. Analytic IK legs, a flexible articulated body, wall-latching. Three.js, no rig or animation clips.

Related repositories

Similar projects matched by category, topics, and programming language.

react
Featured
react GitHub avatar

react

React is a JavaScript library for building user interfaces with declarative, component-based, and cross-platform design.

Web DevelopmentFrontend Frameworks
246,741
tandpfun
Featured
tandpfun GitHub avatar

wardrobe

A GPT‑image powered app that extracts individual garment cutouts from photos, organizes them into a digital wardrobe, and generates modeled outfit previews.

JavaScript
1,570
mshumer
Featured
mshumer GitHub avatar

Claude-of-Duty

A browser-based first-person shooter built entirely with procedural generation and orchestrated AI agents, featuring 55k lines of Three.js/WebGL2 code and no art assets.

AI & Machine LearningAI Agents
1,234