For the longest time, the weird product ideas I had in the shower just stayed there. Now you can actually build anything you can describe, so when I wanted a home for mine, a plain grid of links felt wrong.
I built a 3D shower shelf in Three.js instead. Every project is an apothecary glass bottle you can inspect, rotate, and click into, sitting on travertine stone under morning light.
Getting WebGL glass to look like real glass without shipping a 40 MB asset bundle or freezing phones on load took a few hard lessons. Here are the three biggest ones from the build.
Fix the environment before you blame the object
My first pass at the glass bottles looked like cloudy Tupperware. I spent an hour nudging roughness, IOR, and transmission sliders on MeshPhysicalMaterial and barely moved the needle.
The fix had nothing to do with the bottle material. Glass only looks like glass because of sharp contrast between bright highlights and dark negative fill around it. Instead of downloading a multi-megabyte 4K HDRI, I built a tiny 6-panel studio scene in memory and baked it through PMREMGenerator:
export function createShowerEnvironment(renderer, theme = 'travertine') {
const pmrem = new THREE.PMREMGenerator(renderer);
pmrem.compileEquirectangularShader();
const envScene = new THREE.Scene();
envScene.background = new THREE.Color(cfg.bg);
// High-contrast bright strips next to dark negative-fill panels
addPanel(cfg.top, cfg.topInt, [-0.8, 5.4, 0.8], [Math.PI * 0.46, 0, 0], 3.4, 1.8);
addPanel(0xfff1dc, cfg.leftInt, [-4.4, 2.0, 2.1], [0, Math.PI * 0.34, 0], 0.52, 7.6);
addPanel(0xdcf0ff, cfg.rightInt, [4.4, 1.6, 1.9], [0, -Math.PI * 0.36, 0], 0.36, 7.2);
addPanel(0x060908, 1.0, [-3.0, 1.4, -2.4], [0, Math.PI * 0.22, 0], 2.8, 8.0);
addPanel(0x060908, 1.0, [3.0, 1.4, -2.4], [0, -Math.PI * 0.22, 0], 2.8, 8.0);
addPanel(cfg.bounce, 1.65, [0, -2.1, 0.4], [-Math.PI / 2, 0, 0], 6.4, 4.6);
const rt = pmrem.fromScene(envScene, 0.008);
pmrem.dispose();
return rt.texture;
}
Two razor-thin vertical light bars (warm morning window on the left, cool kicker on the right) paired with dark panels behind the glass instantly gave every curve crisp Fresnel edges.
Bonus win: switching between the four bathroom stone themes (travertine, emerald, basalt, terracotta) just re-bakes that tiny studio with a different color preset in a few milliseconds, zero extra network requests.
One Three.js gotcha that bit me early: when using physical transmission, keep transparent: false and tune attenuationColor plus attenuationDistance instead. Setting transparent: true disables the refraction pass and brings the cloudy plastic look right back.
Generate what you can instead of shipping heavy pipelines
I opened Blender to model the bottles, lasted about 20 minutes, and closed it. Every apothecary bottle is radially symmetric, which means it is really just a 2D silhouette spun around the Y axis.
Each bottle on the shelf is defined by roughly 12 (x, y) control points passed into THREE.LatheGeometry:
function addLathe(parent, points, mat, segs = 128, castShadow = true) {
const pts = points.map(([x, y]) => new THREE.Vector2(Math.max(0.0001, x), y));
const geo = new THREE.LatheGeometry(pts, segs);
geo.computeVertexNormals();
const mesh = new THREE.Mesh(geo, mat);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
const glassProfile = [
[0.0, 0.012], [r * 0.76, 0.012], [r * 0.90, 0.030], [r * 0.98, 0.068], [r, 0.11],
[r, bodyH * 0.72], [r * 0.97, bodyH * 0.78], [r * 0.82, bodyH * 0.85],
[r * 0.56, bodyH * 0.91], [neck, bodyH * 0.95], [neck, bodyH * 1.00], [0.0, bodyH * 1.00],
];
addLathe(group, glassProfile, glassMat);
Zero .glb downloads, zero export-reimport loops, and tweaking a bottle shoulder or brass collar takes five seconds in code.
The same rule applied to the shower details. Every bottle carries 64 live 3D condensation beads that slowly slip down the glass when the water is running, all drawn in a single InstancedMesh call per vessel using a shared squashed sphere geometry.
Fast on your laptop means nothing if mobile freezes on frame one
On my Mac Studio the shelf felt instant. On an iPhone, the page froze for a beat right on load while WebP PBR maps decoded on the main thread and Three.js compiled physical glass shaders.
To keep first paint smooth, I moved texture fetching and createImageBitmap decoding into a 22-line and transferred the decoded bitmaps straight back to Three.js with zero copies:
self.onmessage = async e => {
const { id, url, flipY = true } = e.data || {};
if (!url) return;
try {
const resp = await fetch(url, { credentials: 'same-origin' });
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
const blob = await resp.blob();
const bitmap = await createImageBitmap(blob, {
imageOrientation: flipY ? 'flipY' : 'from-image',
premultiplyAlpha: 'none',
colorSpaceConversion: 'none',
});
self.postMessage({ id, bitmap }, [bitmap]);
} catch (err) {
self.postMessage({ id, error: err && err.message ? err.message : 'decode failed' });
}
};
Two small details made that worker setup hold up cleanly in production:
- 01Split critical vs non-critical textures. The async loader tracks
whenCriticalReady()separately fromwhenAllReady()so the shelf can stage in cleanly after first paint without flashing untextured white geometry. - 02Always keep a main-thread fallback. If a browser blocks workers or
createImageBitmapfails on an older device, any in-flight texture seamlessly drains back throughTHREE.TextureLoader.
Spin the bottles and break something
The 3D shelf is live at showerthoughts.dev. Turn the shower handle to fog the glass, tap any bottle to inspect it up close, or find a loose wall tile to swap bathroom themes.
If you are building WebGL or Three.js stuff on the web and want to trade notes, reply on X (@srbryers).
-Seb