Real 3D, Not a Screenshot
Until now I'd only shared Blender work as rendered images or video. But the fun of 3D is turning it around. I wanted viewers to grab the camera themselves instead of settling for angles I picked. So I built a three.js viewer into this blog.
The subject is Geo DiPin, a ring of extruded typography wrapping around a spinning torus, deformed along a circular curve. Drag it below.
The Pipeline — From .blend to Browser
three.js can't read .blend files. The standard for web 3D is glTF (.glb), a delivery format often called "the JPEG of 3D." I did the conversion headlessly with Blender's CLI, without ever opening the app.
# blender -b model.blend --python export_glb.py -- out.glb
bpy.ops.export_scene.gltf(
filepath=out,
export_format='GLB',
export_apply=True, # bake REMESH/CURVE modifiers into the mesh
export_animations=True, # keep the rotation animation
export_lights=True, # carry the colored spot lights along
export_draco_mesh_compression_enable=True,
)Two things were decisive.
- The first is baking modifiers. The text in this model is a FONT object with REMESH + CURVE modifiers making it flow along a circle. glTF has no concept of modifiers, so
export_applybakes the final shape into the mesh - The second is Draco compression. The remeshed text is heavy, and the first export weighed 12MB. One geometry-compression flag brought it down to 629KB, roughly 1/19th. The browser needs a decoder in return, which I self-hosted under
public/draco/instead of leaning on a CDN
The animation survives intact. The rotation keyframes on the Empty hierarchy (Rotate 1 → Rotate 2) convert into glTF animation tracks and loop the same way on the web.
The Viewer — Thirty Lines with react-three-fiber
The viewer uses @react-three/fiber (three.js the React way) and the helper collection @react-three/drei. The core logic is surprisingly short.
function Model({ src }: { src: string }) {
const gltf = useGLTF(src, "/draco/"); // Draco decoder path
const { actions } = useAnimations(gltf.animations, gltf.scene);
useEffect(() => {
Object.values(actions).forEach((a) => a?.reset().play());
}, [actions]);
return <primitive object={gltf.scene} />;
}- Auto-framing is handled by drei's
<Bounds fit>and<Center>. They frame any model without knowing its size in advance - The original lighting comes along. The scene's three colored spots travel via
KHR_lights_punctual. But Blender watts convert to hundreds of thousands of candela, and untouched they blow the screen out white. One scale factor fixes it - The glow is recreated separately. The light blooms in Blender's render are post-processing, so glTF can't carry them. A Bloom pass on the three.js side brings the same mood back
- Glass was the hardest part. The torus is a transmission-1.0 glass material, which renders ghostly white over a transparent canvas. A real black scene background fixed that, and a manual
thicknessrestored the refraction glTF can't carry. Finally, for the surface reflections that give glass its life, a virtual environment built from a few Lightformers (no remote HDR) added the fresnel. Only then did the glass look like glass - Interaction uses
OrbitControlsfor drag-to-rotate, with a slow auto-rotate when idle. Wheel zoom is off by default so the viewer never hijacks page scrolling - The bundle is split. three.js is not light. The viewer is lazy-loaded via
next/dynamic, so posts without 3D ship not a single byte of it
The resulting <ModelViewer> is registered as an MDX component, so from now on any post can publish a 3D model with one tag.
<ModelViewer src="/models/geo-dipin.glb" title="Geo DiPin" />What I Learned
Key point
Once again, the conclusion is that the format is half the work. A .blend is a working file and glTF is a delivery format. It is the PSD-to-JPEG relationship. The moment you export for the web, modifiers get baked, geometry gets compressed, and animation gets flattened into tracks. Get that conversion right and the browser side turns out to be a well-paved road. Building the viewer as a component also pays forward. The next model is just one .glb and one tag away.