Tracing the mark and prepping the scene
The starting point is an SVG copy of the DigitalOcean logo from simpleicons.org. That image gets placed underneath the traced elements and is later revealed with a clip-path transition. The traced markup is wrapped in a .scene container so the whole thing can be treated as a 3D stage, and Pug mixins are used to keep the hand-written markup short, since a 3D build multiplies elements quickly.
- const SIZE = 40
.scene
svg(role='img' viewbox='0 0 24 24' xmlns='http://www.w3.org/2000/svg')
title DigitalOcean
path(d='M12.04 0C5.408-.02.005 5.37.005 11.992h4.638c0-4.923 4.882-8.731 10.064-6.855a6.95 6.95 0 014.147 4.148c1.889 5.177-1.924 10.055-6.84 10.064v-4.61H7.391v4.623h4.61V24c7.86 0 13.967-7.588 11.397-15.83-1.115-3.59-3.985-6.446-7.575-7.575A12.8 12.8 0 0012.039 0zM7.39 19.362H3.828v3.564H7.39zm-3.563 0v-2.978H.85v2.978z')
.logo(style=`--size: ${SIZE}`)
.logo__arc.logo__arc--inner
.logo__arc.logo__arc--outer
.logo__square.logo__square--one
.logo__square.logo__square--two
.logo__square.logo__square--three
Only the containing elements for each cylinder, the inner arc, and the outer arc need to be authored. The visible arc is not drawn as a flat shape, because in 3D it can be assembled from two cylinders. If a flat logo were the goal, a single arc element with a solid border and a CSS mask using a conic gradient would be sufficient.
.logo__arc--outer {
border: calc(var(--size) * 0.1925vmin) solid #006aff;
mask: conic-gradient(transparent 0deg 90deg, #000 90deg);
transform: translate(-50%, -50%) rotate(180deg);
}
The elements overlap the underlying logo, and the reveal is handled by transitioning a clip-path.
Why skip extrusion with plain markup
Building container elements first rather than jumping straight to 3D blocks makes the extrusion step much easier. The squares in the logo each become a cuboid, generated through a cuboid mixin.
mixin cuboid()
.cuboid(class!=attributes.class)
if block
block
- let s = 0
while s < 6
.cuboid__side
- s++
.scene
.logo(style=`--size: ${SIZE}`)
.logo__arc.logo__arc--inner
.logo__arc.logo__arc--outer
.logo__square.logo__square--one
+cuboid().square-cuboid.square-cuboid--one
.logo__square.logo__square--two
+cuboid().square-cuboid.square-cuboid--two
.logo__square.logo__square--three
+cuboid().square-cuboid.square-cuboid--three
Each cuboid has six sides, which are targeted with nth-of-type(); the vmin unit keeps the result responsive.
.cuboid {
width: 100%;
height: 100%;
position: relative;
}
.cuboid__side {
filter: brightness(var(--b, 1));
position: absolute;
}
.cuboid__side:nth-of-type(1) {
--b: 1.1;
height: calc(var(--depth, 20) * 1vmin);
width: 100%;
top: 0;
transform: translate(0, -50%) rotateX(90deg);
}
.cuboid__side:nth-of-type(2) {
--b: 0.9;
height: 100%;
width: calc(var(--depth, 20) * 1vmin);
top: 50%;
right: 0;
transform: translate(50%, -50%) rotateY(90deg);
}
.cuboid__side:nth-of-type(3) {
--b: 0.5;
width: 100%;
height: calc(var(--depth, 20) * 1vmin);
bottom: 0;
transform: translate(0%, 50%) rotateX(90deg);
}
.cuboid__side:nth-of-type(4) {
--b: 1;
height: 100%;
width: calc(var(--depth, 20) * 1vmin);
left: 0;
top: 50%;
transform: translate(-50%, -50%) rotateY(90deg);
}
.cuboid__side:nth-of-type(5) {
--b: 0.8;
height: 100%;
width: 100%;
transform: translate3d(0, 0, calc(var(--depth, 20) * 0.5vmin));
top: 0;
left: 0;
}
.cuboid__side:nth-of-type(6) {
--b: 1.2;
height: 100%;
width: 100%;
transform: translate3d(0, 0, calc(var(--depth, 20) * -0.5vmin)) rotateY(180deg);
top: 0;
left: 0;
}
This differs from earlier 3D work in two ways: only depth matters for each cuboid, not height and width, and the individual faces are not colored by hand — filter: brightness shades them. One caveat: a filtered side flattens any 3D children, so nested 3D elements may need to be restructured. The logo has three cuboids, each with its own class:
.square-cuboid .cuboid__side {
background: hsl(var(--hue), 100%, 50%);
}
.square-cuboid--one {
/* 0.1925? It's a percentage of the --size for that square */
--depth: calc((var(--size) * 0.1925) * var(--depth-multiplier));
}
.square-cuboid--two {
--depth: calc((var(--size) * 0.1475) * var(--depth-multiplier));
}
.square-cuboid--three {
--depth: calc((var(--size) * 0.125) * var(--depth-multiplier));
}
For this demo the cuboids are true cubes, with equal height, width, and depth, and the arc depth matches the largest cuboid.
Building the cylinders
A cylinder is two ends with border-radius: 50% plus a set of side elements. The hard part is placement, so the approach is abstracted into a reusable mixin whose configuration covers radius, side count, how many of those sides are displayed, and whether one or both ends are shown.
mixin cylinder(radius = 10, sides = 10, cut = [5, 10], top = true, bottom = true)
- const innerAngle = (((sides - 2) * 180) / sides) * 0.5
- const cosAngle = Math.cos(innerAngle * (Math.PI / 180))
- const side = 2 * radius * Math.cos(innerAngle * (Math.PI / 180))
//- Use the cut to determine how many sides get rendered and from what point
.cylinder(style=`--side: ${side}; --sides: ${sides}; --radius: ${radius};` class!=attributes.class)
if top
.cylinder__end.cylinder__segment.cylinder__end--top
if bottom
.cylinder__end.cylinder__segment.cylinder__end--bottom
- const [start, end] = cut
- let i = start
while i < end
.cylinder__side.cylinder__segment(style=`--index: ${i};`)
- i++
The //- prefix tells Pug to drop the comment from the compiled HTML. Radius is passed in because CSS calc() cannot handle trigonometry yet, and the math for side width and projection distance depends on it. The value travels into the styles as an inline custom property.
.cylinder(
style=`
--side: ${side};
--sides: ${sides};
--radius: ${radius};`
class!=attributes.class
)
+cylinder(20, 30, [10, 30])
That call yields a radius of 20 with 30 sides, rendering only sides 10 through 30.
.cylinder {
--bg: hsl(var(--hue), 100%, 50%);
background: rgba(255,43,0,0.5);
height: 100%;
width: 100%;
position: relative;
}
.cylinder__segment {
filter: brightness(var(--b, 1));
background: var(--bg, #e61919);
position: absolute;
top: 50%;
left: 50%;
}
.cylinder__end {
--b: 1.2;
--end-coefficient: 0.5;
height: 100%;
width: 100%;
border-radius: 50%;
transform: translate3d(-50%, -50%, calc((var(--depth, 0) * var(--end-coefficient)) * 1vmin));
}
.cylinder__end--bottom {
--b: 0.8;
--end-coefficient: -0.5;
}
.cylinder__side {
--b: 0.9;
height: calc(var(--depth, 30) * 1vmin);
width: calc(var(--side) * 1vmin);
transform: translate(-50%, -50%) rotateX(90deg) rotateY(calc((var(--index, 0) * 360 / var(--sides)) * 1deg)) translate3d(50%, 0, calc(var(--radius) * 1vmin));
}
Each side starts centered, then is rotated on the Y-axis and pushed outward by roughly the radius. The flat logo's arcs become two cylinders: the inner one needs no visible ends since they are hidden, while the outer one does. The radius is already known from the diameter used during tracing, and the outer cylinder's ends double as the faces of the logo, shaped with a combination of border-width and clip-path.
.logo(style=`--size: ${SIZE}`)
.logo__arc.logo__arc--inner
+cylinder((SIZE * 0.61) * 0.5, 80, [0, 60], false, false).cylinder-arc.cylinder-arc--inner
.logo__arc.logo__arc--outer
+cylinder((SIZE * 1) * 0.5, 100, [0, 75], true, true).cylinder-arc.cylinder-arc--outer
.cylinder-arc--outer .cylinder__end--top,
.cylinder-arc--outer .cylinder__end--bottom {
/* Based on the percentage of the size needed to cap the arc */
border-width: calc(var(--size) * 0.1975vmin);
border-style: solid;
border-color: hsl(var(--hue), 100%, 50%);
--clip: polygon(50% 0, 50% 50%, 0 50%, 0 100%, 100% 100%, 100% 0);
clip-path: var(--clip);
}
Capping the arc
The remaining gap is the arc's ends. Two elements positioned and rotated on the X or Y axis close it, sized by the end's border-width and the arc depth.
.scene
.logo(style=`--size: ${SIZE}`)
.logo__arc.logo__arc--inner
+cylinder((SIZE * 0.61) * 0.5, 80, [0, 60], false, false).cylinder-arc.cylinder-arc--inner
.logo__arc.logo__arc--outer
+cylinder((SIZE * 1) * 0.5, 100, [0, 75], true, true).cylinder-arc.cylinder-arc--outer
.logo__square.logo__square--one
+cuboid().square-cuboid.square-cuboid--one
.logo__square.logo__square--two
+cuboid().square-cuboid.square-cuboid--two
.logo__square.logo__square--three
+cuboid().square-cuboid.square-cuboid--three
.logo__cap.logo__cap--top
.logo__cap.logo__cap--bottom
.logo__cap {
--hue: 10;
position: absolute;
height: calc(var(--size) * 0.1925vmin);
width: calc(var(--size) * 0.1975vmin);
background: hsl(var(--hue), 100%, 50%);
}
.logo__cap--top {
top: 50%;
left: 0;
transform: translate(0, -50%) rotateX(90deg);
}
.logo__cap--bottom {
bottom: 0;
right: 50%;
transform: translate(50%, 0) rotateY(90deg);
height: calc(var(--size) * 0.1975vmin);
width: calc(var(--size) * 0.1925vmin);
}
With the caps in place the logo is complete and can be rotated freely as a 3D object.
Pointer-driven parallax
Interaction is added using the custom-property approach to parallax: the logo rotates and shifts to follow the cursor. JavaScript is needed only to write the coefficients for movement along the X and Y axes, derived from pointer position. A vanilla implementation of mapRange replaces the GreenSock gsap.utils.mapRange utility used in other work.
const mapRange = (inputLower, inputUpper, outputLower, outputUpper) => {
const INPUT_RANGE = inputUpper - inputLower
const OUTPUT_RANGE = outputUpper - outputLower
return value => outputLower + (((value - inputLower) / INPUT_RANGE) * OUTPUT_RANGE || 0)
}
const BOUNDS = 100
const update = ({ x, y }) => {
const POS_X = mapRange(0, window.innerWidth, -BOUNDS, BOUNDS)(x)
const POS_Y = mapRange(0, window.innerHeight, -BOUNDS, BOUNDS)(y)
document.body.style.setProperty('--coefficient-x', POS_X)
document.body.style.setProperty('--coefficient-y', POS_Y)
}
document.addEventListener('pointermove', update)
The decoupling is deliberate: JavaScript reports the interaction, and CSS decides what to do with it, so entirely different behaviors come from editing styles alone. The coefficients feed calc() and custom properties scoped to .scene:
.scene {
--rotation-y: 75deg;
--rotation-x: -14deg;
transform: translate3d(0, 0, 100vmin)
rotateX(-16deg)
rotateY(28deg)
rotateX(calc(var(--coefficient-y, 0) * var(--rotation-x, 0deg)))
rotateY(calc(var(--coefficient-x, 0) * var(--rotation-y, 0deg)));
}
Adjusting --rotation-x and --rotation-y changes how much the scene swings. Each cuboid also translates independently on the X, Y, or Z axis, from a single declared transform that consumes the scoped variables.
.logo__square {
transform: translate3d(
calc(min(0, var(--coefficient-x, 0) * var(--offset-x, 0)) * 1%),
calc((var(--coefficient-y) * var(--offset-y, 0)) * 1%),
calc((var(--coefficient-x) * var(--offset-z, 0)) * 1vmin)
);
}
.logo__square--one {
--offset-x: 50;
--offset-y: 10;
--offset-z: -2;
}
.logo__square--two {
--offset-x: -35;
--offset-y: -20;
--offset-z: 4;
}
.logo__square--three {
--offset-x: 25;
--offset-y: 30;
--offset-z: -6;
}
Intro wave and a shared timeline
The entrance is a wave that sweeps across and reveals the logo, built from the body pseudo-elements. The 3D elements animate from opacity 0, and their sides animate from a brightness of 1. Since the wave color matches the logo, the fade is invisible. animation-fill-mode: both applies keyframe styling in both directions.
:root {
--hue: 215;
--initial-delay: 1;
--wave-speed: 2;
}
body:after,
body:before {
content: '';
position: absolute;
height: 100vh;
width: 100vw;
background: hsl(var(--hue), 100%, calc(var(--lightness, 50) * 1%));
transform: translate(100%, 0);
animation-name: wave;
animation-duration: calc(var(--wave-speed) * 1s);
animation-delay: calc(var(--initial-delay) * 1s);
animation-timing-function: ease-in;
}
body:before {
--lightness: 85;
animation-timing-function: ease-out;
}
@keyframes wave {
from {
transform: translate(-100%, 0);
}
}
Keeping the timings coherent calls for an animation timeline expressed in custom properties, letting one animation's duration calculate the delays of others. Chrome's Animations Inspector is the practical tool for tuning here; the fade duration can be dropped to 0 if the logo should simply be present once the wave passes, and the filter and fade coefficients map to the 0.75s and 1.15s values in the timeline.
:root {
--hue: 215;
--initial-delay: 1;
--wave-speed: 2;
--fade-speed: 0.5;
--filter-speed: 1;
}
.cylinder__segment,
.cuboid__side,
.logo__cap {
animation-name: fade-in, filter-in;
animation-duration: calc(var(--fade-speed) * 1s),
calc(var(--filter-speed) * 1s);
animation-delay: calc((var(--initial-delay) + var(--wave-speed)) * 0.75s),
calc((var(--initial-delay) + var(--wave-speed)) * 1.15s);
animation-fill-mode: both;
}
@keyframes filter-in {
from {
filter: brightness(1);
}
}
@keyframes fade-in {
from {
opacity: 0;
}
}
The finished result combines the traced logo, extruded cubes, cylinder-based arc, pointer parallax, and the reveal wave — one approach of several, and open to optimization.



