Featured
- Get link
- X
- Other Apps
3D/Interactive Web Experiences: Blending Game & Software Development Principles
Breakdown
What started as a personal modeling project, ended up as a webpage where you could inspect the model. I have always been interested in web development, particularly frontend, but I needed a bridge without getting bored over the fundamentals. This where Three.JS comes in. Using it as a stepping stone to learn frontend fundamentals with my background. So this post follows one of my own models all the way from the sculpt to something you can rotate in a browser. Should be easy enough, right?Here’s what’s covered:
Draco compression: shrinking the model file so the page loads quickly, and what the browser needs to unpack it.
Camera Controls & Rotation: how visitors interact with the model, and why I limited what they can do.
Bonus: Learning How To Understand & Work With YAML: my attempts to deploy the page with GitHub workflows, and what I learned about the file along the way.
The Tools
- ZBrush
- Blender
- Substance Painter
- gltf.report
- squoosh.app
- Three.JS
- ShaderToy
- Vite
Integrating 3D models with HTML, CSS & JavaScript/Three.JS
My models always ended up as renders: a few angles of the sculpt, a turntable if I was feeling generous. That’s fine on ArtStation, but I wanted people to pick the model up and turn it around on my own webpage. The catch is that a sculpt straight out of Blender isn’t web-ready. Every triangle gets downloaded and drawn on every visitor’s device, phones included. The modelling was the fun part, and getting the file size down was the real fight.Blender & Substance Painter
Draco Compression
Draco is Google’s mesh compression. It shrinks the geometry data in the file (vertex positions, normals, UVs and indices), often by a large factor. You turn it on at export in Blender, under the glTF exporter’s compression options. The quantisation settings trade size for precision: fewer bits means a smaller file, but go too low and surfaces start to look lumpy. Though a caveat for me, was keeping the head with a bit more resolution and retain some detail, so I could ditch the normal map.
The browser then needs to decompress it, which is the job of Three.JS’s DRACOLoader:
const loader = new GLTFLoader();
const dracoLoader = new DRACOLoader();
dracoLoader.setDecoderPath('/examples/jsm/libs/draco/');
loader.setDRACOLoader(dracoLoader);
Draco only compresses geometry, so it does nothing for the texture. That’s why the 2048 WebP matters. WebP shrinks the download, but once the texture is on the GPU it’s uncompressed again.
Camera Controls & Rotation
controls.update() has to run every frame in the animation loop, or the damping does nothing.OrbitControls rotates around the world origin by default. If the model’s pivot point sits somewhere else, which happens easily after exporting from Blender, it swings around like it’s on a string.
GLSL Shaders With Three.JS For Webpages
My shaders lived on ShaderToy for a long time, and they were never going to end up anywhere else. I’d taken them into Unreal through HLSL, but what about the web? My portfolio could have a live shader running behind it instead of a static background, so the shaders could finally be part of something I built myself. The structure was already there, all I needed was something to host it. Enter Three.JS.
The whole thing is a five-step pipeline that I needed help bridging knowledge of game development principles & frontend, with the help of Claude
1. The canvas. Drop a <canvas> into your HTML and pin it behind everything with position: fixed, full viewport size & z-index: -1. The hero content sits on top with position: relative & z-index: 1.
new THREE.WebGLRenderer({ canvas }) wraps that canvas in WebGL. Call setSize on load & again on every window resize. Pass false as the third argument so Three.JS doesn’t touch the canvas’s CSS size and your stylesheet stays in control.PlaneGeometry(2, 2) fills clip space exactly, and an OrthographicCamera(-1, 1, 1, -1, 0, 1) removes perspective. The vertex shader just hands position straight to gl_Position. No matrices, no fuss, pixel-perfect fullscreen.vertexShader & fragmentShader strings, and a uniforms object feeds data in from JavaScript. Porting from ShaderToy, like to Unreal Engine for custom nodes, only needs a few swaps:iTimebecomes theu_timeuniformiResolutionbecomes theu_resolutionuniformmainImage(out vec4 fragColor, in vec2 fragCoord)becomesvoid main(), readinggl_FragCoord& writing togl_FragColor
THREE.Clock updates u_time every frame, then renderer.render(scene, camera) draws it. JavaScript only touches two uniforms per frame & the GPU does everything else.Bonus: Learning How To Understand & Work With YAML
I wanted my webpage live, not just running on localhost. GitHub can do that for free, and the way you tell it how is a YAML file. I’ve never written one, so I pulled up a template. I failed. Then I failed again. Somewhere in there I realised that I didn’t understand the file I was copying, and that this was the real problem. So I stopped trying to fix the deployment and read the file line by line instead. Deployment still isn’t working, and that’s a story for another post, but the file itself finally makes sense, and that’s what this section is about.
What YAML is. YAML is just structured text, a way of writing settings that both people and machines can read. There are only a few rules:
key: valueis a setting.- Indentation shows what belongs to what. It must be spaces, never tabs, and one wrong space can break the whole file.
- A line starting with
-is an item in a list. #starts a comment.
That’s nearly all of the syntax. The rest is knowing which keys GitHub expects.
What I Learned
Getting a model onto the web comes down to budgeting. I spent extra triangles on the face so I could skip the normal map, then used one 2048 WebP albedo map for the rest, with flipY = false and SRGBColorSpace to stop the texture looking upside down or washed out. Draco shrinks the geometry, but it needs a decoder at the right path, or the model silently never loads. OrbitControls is easy to set up, so the real work was limiting panning and angles, calling controls.update() every frame for damping, and using geometry.center() so the model rotates around its middle. Finally, a YAML workflow is just a checklist of triggers, permissions and steps that a robot follows, and reading it line by line taught me more than copying a template ever did.
Conclusion
The model that started as a sculpt in Blender is now something anyone can turn around in their browser. Getting there came down to a handful of decisions: keep the detail in the texture instead of the triangles, compress the geometry with Draco, keep the texture to one sensible size, and limit the camera so people only see the model at its best. None of them is complicated on its own, and together they’re the difference between a heavy file and a page that opens instantly.
The bonus section is the honest part. I haven’t got the deployment working yet, and I’m still struggling with it. What I did get out of it was a proper understanding of what a YAML workflow file is, which is more than I had when I started. Deploying it is a lesson for another post, once I’ve worked out where it keeps going wrong.
- Get link
- X
- Other Apps
Popular Posts
Converting GLSL to HLSL For Custom Nodes
- Get link
- X
- Other Apps


Comments
Post a Comment