
The dash relief
WebGL, 3D, Hover
A made-up brand’s sunglasses in 3D: a glossy black acetate frame, curved lenses that really reflect a landscape (sky, sun, hills and the sea with the sun’s path) which slides as they turn, metal hinges with their pin and temples on spring hinges. You spin them with a finger and a spring brings them back to three quarters; a tap folds the temples one after the other, and the four swatches tint the lenses with a wave that opens from the centre. Morphin style with Libraries.dev light.
A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.
<!doctype html>
<!--
"Spinning sunglasses" from Animorio · https://animorio.com
License: free on your own sites and your clients’ sites, paid work included.
Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Halvern Cove</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/index.css">
<link rel="stylesheet" href="style.css">
<script type="importmap">
{ "imports": {
"three": "https://cdn.jsdelivr.net/npm/three@0.178.0/build/three.module.min.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.178.0/examples/jsm/"
} }
</script>
</head>
<body>
<!-- a made-up brand, Halvern, and its sunglasses in 3D: drag spins them with inertia and a spring brings them back,
a tap folds or unfolds the temples on their spring hinges, the swatches tint the lenses from the centre out -->
<main class="palco" data-palco>
<header class="testa" data-testa>
<span class="etichetta">Halvern Cove</span>
<span class="sotto"><span class="rullo" data-sotto>Polarised acetate · $185</span></span>
</header>
<div class="scena" data-scena>
<canvas class="tela" data-tela role="img" aria-label="A pair of sunglasses turning in 3D, with four lens tints and temples that fold"></canvas>
<!-- if WebGL is missing: flat glasses -->
<div class="ripiego" data-ripiego aria-hidden="true"><span></span><span></span></div>
</div>
<div class="piede" data-piede>
<div class="lenti" role="radiogroup" aria-label="Lens tint">
<button class="campione attivo" type="button" role="radio" aria-checked="true" data-lente="0" aria-label="Smoke lens"><span style="--c: var(--smoke)"></span></button>
<button class="campione" type="button" role="radio" aria-checked="false" data-lente="1" aria-label="Amber lens"><span style="--c: var(--amber)"></span></button>
<button class="campione specchio" type="button" role="radio" aria-checked="false" data-lente="2" aria-label="Sea mirror lens"><span style="--c: var(--sea)"></span></button>
<button class="campione" type="button" role="radio" aria-checked="false" data-lente="3" aria-label="Rose lens"><span style="--c: var(--rose)"></span></button>
</div>
<p class="nome-lente"><span class="rullo" data-nome-lente>Smoke lens</span></p>
</div>
<!-- the fake pointer of the autopilot -->
<svg class="puntatore" data-puntatore viewBox="0 0 24 24" aria-hidden="true">
<path d="M5 3l14 8-6.2 1.6L10 19z"/>
</svg>
</main>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
<script type="module" src="script.js"></script>
</body>
</html>Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.
23 values to change
With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:
Take “Spinning sunglasses” from Animorio and fit it into my siteThe lens outline is a superellipse a little wider at the top, with the outer corner lifted; each rim is a Shape with the wider outline and the lens one as a hole, extruded with a bevel. The bridge is a TubeGeometry along a curve, the temples are their side profile (tall at the hinge, slimmer toward the ear, then bent down) extruded to their thickness, in the same acetate: a black MeshPhysicalMaterial with clearcoat.
Each lens is a fine grid squeezed into the outline and bent back like a real lens. The shader works out the reflected view ray and draws a landscape along it: the gradient sky, the sun, hills made of waves over the angle and the sea with the sun’s path; the edge catches more light with Fresnel, and the lens is a little darker at the top.
The shader gets the old colour and the new one, with how dark and how mirrored each is, and a progress from 0 to 1: where the distance from the centre of the lens is below the progress there is the new colour, and a thin light edge runs along the front of the wave. A change halfway starts again from the colour on screen.
Each temple turns on a group placed on the pin: folding takes them to 86 and 91 degrees inward, the right one first and the left one over it, with back.out; opening uses elastic.out, like a spring hinge that overshoots and comes back. As each one lands the frame gives a small knock and the hinge swells a touch.
| Name | File | Default | What it changes |
|---|---|---|---|
TILT | script.js | 12 | How many degrees the glasses lean toward the pointer. |
FRICTION | script.js | 1.8 | How fast a thrown spin slows down (higher = sooner). |
MAX_SPIN | script.js | 900 | The fastest spin a throw can give, in degrees per second. |
SPRING | script.js | 55 | How firm the spring that brings them back to three quarters is. |
REFLECTION | script.js | 1 | How strong the landscape reflected in the lenses is. |
TINT_TIME | script.js | 0.9 | How many seconds the new tint takes to open from the centre of the lens. |
IDLE_SWAY | script.js | 1 | How much the glasses sway by themselves at rest (0 = still). |
AUTO_PILOT | script.js | 1 | 1 shows the gestures with a fake pointer when nobody touches the glasses, 0 turns it off. |
For the page of a pair of sunglasses or glasses, in an optician’s or a fashion accessories shop, or on the launch page of a summer collection: where you want people to turn them in their hand, try the lenses and see how they fold.
The same glasses, smaller: they spin as you drag with a finger, a tap folds and opens the temples, and the lens swatches stay below within thumb reach.
The glasses stay still at three quarters, without sway or spring: dragging brings them straight back, the temples fold without a bounce and the new tint arrives all at once.
Three.js 0.178.0, GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 13 KB; the libraries: GSAP 28 KB, Three.js + RoomEnvironment 176 KB.
Tested on 28 October 2026
Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.
Support Animorio
Animorio stays free thanks to the people who support it. If you like, buy us a coffee: it helps us make the next animations.
You asked for
We made it for you: it’s in the library, with the preview, the Playground and the code to copy.
An animation you can’t find, or a site to take apart in the journal: tell us which. We pick the next ones from here.
With your account’s email and password.
or with your email
You’re signed in as .
With your account, you can download the zip of every animation and every pack, for free.