Skip to main content

Featured

Learning To Work With Python Frameworks: FLASK vs DJANGO

                 Image:  https://www.bitcot.com/flask-vs-django/ Breakdown I had experience building with Python and other APIs, but I’d never worked with a web framework. I wanted to learn how a full-stack web application fits together, so I learned two of the most popular Python ones: Flask first, as the small and simple option, then Django, as the larger one with more built in. This post breaks down what I learned from each, and how they compare. Tools Python 3.14 VS Code Virtual Environments Flask Django The Use Cases For Each Flask Built for simple projects, with a small core and a minimal set of features. Easy to install and quick to get started with. Fast and lightweight, but not designed for high-workload projects. Built on a synchronous model, so each worker handles one request at a time. Handling several requests at once means running multiple workers or threads. Best for quick projects and prototyping, like getting a ...

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:

Blender & Substance Painter: getting the model out of the sculpting stage and into a form the web can handle, plus how the texture and material get applied in Three.JS.

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

It starts the way any asset does, with a sculpt in ZBrush & modeling in Blender. The web changes what happens next, because the high-poly mesh has to become a lightweight one that still reads as the same model. The rule I followed was to keep detail in the texture rather than in the triangles. I also kept the UVs clean, since Three.JS reads them directly.

From there the model goes into Substance Painter for texturing. For the web I export one albedo map at 2048×2048, which means one download and one texture in GPU memory. I converted it to WebP because it’s much smaller than TGA or PNG at a similar visual quality.

const texture = new THREE.TextureLoader().load('assets/textures/T_Portrait_Albedo2048.webp');
texture.colorSpace = THREE.SRGBColorSpace;
texture.flipY = false;

const portraitMaterial = new THREE.MeshPhysicalMaterial({ map: texture });
portraitMaterial.roughness = 0.8;
portraitMaterial.iridescence = 0.05;

portrait.traverse((child) => {
  if (child.isMesh) {
    child.material = portraitMaterial;
    child.castShadow = true;
    child.receiveShadow = true;
  }
});




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

Additionally, I added the ability to rotate the model so I could inspect it within the browser, adding some interactivity. The real work is choosing what the visitor is allowed to do. These were my decisions with the code: 

const controls = new OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.enablePan = false;
controls.enableZoom = true;
controls.minPolarAngle = 1;
controls.maxPolarAngle = 1.4;
controls.minAzimuthAngle = -0.5;
controls.maxAzimuthAngle = 0.5;
controls.update();

Damping gives the rotation a bit of inertia, so the model eases to a stop instead of halting dead the moment you let go. It’s the cheapest way to make the page feel polished. The one catch is that controls.update() has to run every frame in the animation loop, or the damping does nothing.

Panning is off. Dragging the model off-centre only makes it easy to lose, so I locked it. Visitors can rotate and zoom, and the model stays framed.

Rotation limits. Polar angle is the vertical rotation, measured from straight up (0) to straight down (π). I clamped it between 1 and 1.4 radians, roughly 57° to 80°, so you can look slightly down on the model or level with it, but never underneath or from directly above. The azimuth is the horizontal rotation, and ±0.5 radians (about ±29°) means a gentle swing left and right rather than a full spin. Limits like this also keep people in the part of the model that has been built and textured for the camera.

Orbiting the right point. 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.

2. The renderer. 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.

3. The fullscreen quad. ShaderToy gives you a screen to paint on for free, and Three.js doesn’t, so you build one. A 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.

4. The ShaderMaterial. Your GLSL goes in as 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:
  • iTime becomes the u_time uniform
  • iResolution becomes the u_resolution uniform
  • mainImage(out vec4 fragColor, in vec2 fragCoord) becomes void main(), reading gl_FragCoord & writing to gl_FragColor
5. The animation loop. A 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.

Why it’s fast. One quad, two tris, one draw call and no textures. Easy Peasy.


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: value is 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.

Comments

Popular Posts