StealThis .dev

3D Face Cursor Tracker

A 3D cartoon face built from Three.js primitives — the pupils track the cursor position and the head rotates subtly to follow, with an automatic blinking animation.

Open in Lab
threejs webgl
Targets: JS HTML

Code

3D Face Cursor Tracker

A 3D cartoon face built entirely from Three.js primitives (no external models) that:

  • Pupils track the cursor position in real time via lerp’d offset within the eye sockets
  • Head rotates subtly toward the cursor (smooth lerp)
  • Blinks automatically at randomized intervals using a squish scale animation
  • Eyebrows raise when the cursor moves upward

Character anatomy

  • Head: SphereGeometry with MeshToonMaterial
  • Eyes: sclera sphere + iris sphere + pupil sphere (the pupil group translates to track cursor)
  • Nose: scaled SphereGeometry
  • Mouth: TorusGeometry arc
  • Ears: scaled spheres
  • Stars: THREE.Points background

Cursor tracking technique

Cursor is projected onto the z=3 plane (in front of the face) via THREE.Raycaster. The resulting 3D position is transformed into the head’s local space, then the pupil group is offset proportionally — clamped to stay within the eye socket.