A Many-Sided Object

Twelve faces, each with a randomly placed photo.
As it slowly turns, every new angle shows a different mix of expressions.

Back to all animations

Three.js Dodecahedron Hero with a Photo on Every Face

A Three.js hero visual: a dodecahedron with a different photo on each of its 12 faces, slowly rotating and floating. UVs are rebuilt per face so photos never stretch, and on desktop you can drag to spin it.

Built with
  • JavaScript
  • Three.js
  • WebGL
Published

Where to use it

  • Hero visuals for corporate sites
  • Key visuals for brand sites
  • Home pages for photo studios
  • Intro sequences for recruiting sites

How it works

  • Each of the dodecahedron's 12 pentagonal faces is split out so a Three.js material array can give every face its own photo
  • Vertices are projected onto each face's plane to rebuild the UVs, fitting photos without distortion — the same idea as object-fit: cover
  • World up is projected onto each face to set its reference axis, so photos always appear upright
  • Photos are drawn without replacement and reshuffled once the deck runs out, so random placement never clusters the same image
  • White lines from EdgesGeometry trace the face boundaries for a cut-glass outline
  • The shadow below grows and fades with the gentle up-and-down float
  • On desktop, you can drag to rotate it, and it keeps spinning with inertia after you let go
  • Rendering stops off-screen, and reduced-motion settings show a still polyhedron

Make it your own

  • Polyhedron type and size
  • Number of photos and how they're assigned
  • Rotation and float speed
  • Edge line and shadow strength

Before you ship

Mobile & touch
Camera distance is calculated from the screen's aspect ratio, adding room on tall screens so the polyhedron and the heading don't overlap.
Browser support
Uses Three.js and WebGL. Works in all major modern browsers.
Performance (load: Medium)
A single geometry and its textures are shared across per-face materials, and requestAnimationFrame stops when the canvas is off-screen.
Accessibility
The polyhedron is decorative and hidden from screen readers; the heading and lead are real HTML text that gets announced.
Reduced motion
With prefers-reduced-motion, rotation, floating, and parallax stop, and a still polyhedron is shown.

FAQ

How do I put a different image on each face of a polyhedron?

Split the geometry into per-face groups with addGroup and pass an array of materials. One mesh can then show a different texture on every face.

How do I keep photos from stretching on a polyhedron?

Project the vertices onto two axes built from the face normal, then fit the photo's aspect ratio to that bounding rectangle when computing the UVs. The photo maps on without stretching.

How do I make every photo upright?

Project world up onto the face's plane and use it as the UV's vertical axis. Only for faces whose normal points almost straight up, switch the reference to the forward direction — then every face lines up.

How do I randomize images without the same photo bunching up?

Shuffle the full set, draw until it's empty, then shuffle a new set. Even with more faces than images, you won't get a cluster of the same photo.

How do I make the face edges stand out?

Overlay semi-transparent white lines generated from EdgesGeometry. The borders between neighboring photos read as a crisp outline.

“Can you build this?”
is a great place to start.

From coding and animation to WordPress — talk directly with TANE-⁠be engineers.
The TANE to CODE site is in Japanese.

Visit TANE to CODE

Get in touch

Website projects, memorable motion ideas — we'd love to hear about them.
Our contact form is in Japanese.