← all projects
3D Library

GLTF Handler

JavaScript library for dynamic 3D texture swapping. Real-time material customization for product configurators and interactive 3D experiences.

Enables runtime texture swapping in GLTF/GLB models without re-export. Perfect for e-commerce configurators and interactive 3D applications.

TypeScript
Three.js
WebGL

Problem Statement

Product configurators (sneaker builders, furniture finishes, car colors) need to change a 3D model's appearance at runtime — swap a material, recolor a part, adjust roughness/metalness — without re-exporting a new GLTF/GLB for every variant. Doing this by hand against a raw three.js/Babylon scene graph is fiddly: you have to traverse meshes, find the right material by name, mutate it safely, and dispose old GPU resources or you leak memory. Every configurator reinvents this plumbing.

Proposed Solution

GLTF Handler is a TypeScript library that wraps a loaded 3D model and exposes a clean API for dynamic texture/material swapping: change materials by name, adjust colors and PBR properties, and discover available materials programmatically — with LRU caching of textures and memory-safe disposal built in, so configurators stay fast and don't leak.

Full Solution Details

  • Swap by name — target a material/part by its name and replace its texture or color without touching the rest of the scene.
  • Property adjustment — tweak color and material properties (the PBR knobs configurators expose to users) at runtime.
  • Material discovery — enumerate the materials present in a model programmatically, so a UI can be generated from the asset itself rather than hard-coded.
  • LRU caching — recently-used textures are cached and evicted by least-recent-use, avoiding repeated decode/upload on rapid swaps.
  • Memory-safe disposal — old textures/materials are disposed correctly to prevent the classic WebGL GPU-memory leak when swapping repeatedly.

Technical Documentation

TypeScript library targeting the WebGL/3D layer (three.js / Babylon-style scene graphs and the GLTF/GLB format). The core value is correctness around two notoriously error-prone areas of browser 3D: (1) resource lifecycle — WebGL textures and materials hold GPU memory that must be explicitly disposed, and (2) caching — re-decoding/re-uploading the same texture on every swap tanks performance. GLTF Handler centralizes both behind a small API so application code stays declarative ("set part X to texture Y") while the library handles traversal, caching, and disposal.

Tech Stack

TypeScript, WebGL, three.js / GLTF-GLB model handling, LRU caching, GPU resource management.

System Design

Loaded GLTF/GLB model
        │
        ▼
  GLTF Handler (wrapper)
   ├── discover()          → list materials/parts by name
   ├── swap(name, texture) → traverse → bind new texture
   ├── setColor/props(...) → mutate PBR material
   ├── LRU texture cache   → reuse decoded textures, evict LRU
   └── dispose()           → free old GPU textures/materials (no leaks)
        │
        ▼
  Configurator UI (sneaker / furniture / car builder)

Smart Architectural Decisions

  • Treat GPU memory as a managed resource. Building disposal in by default addresses the single most common WebGL bug (texture leaks on repeated swaps) — a sign the author has actually shipped real-time 3D, not just rendered a static model.
  • LRU cache for textures turns rapid back-and-forth swapping (exactly what configurator users do) from janky to instant.
  • Material discovery lets a configurator UI be driven by the asset (data) instead of hard-coded per model — a more scalable integration.
  • Swap-by-name API keeps application code declarative and decoupled from the scene-graph traversal details.

Impacts

Makes runtime 3D product customization (configurators, builders) practical and leak-free without per-variant re-exports — directly reusable in the kind of enterprise 3D work seen in MARTECH3D.

Demonstrated Skills

Real-time 3D / WebGL engineering; GLTF/GLB material and scene-graph manipulation; GPU resource lifecycle management (disposal, leak prevention); caching strategy (LRU); TypeScript library API design for a specialized domain.

Notes

  • Specialized, scarce skill: WebGL/3D material manipulation with correct GPU-memory disposal is niche expertise most frontend engineers never touch — it differentiates strongly.
  • Shows real-world 3D experience: baking in LRU caching and disposal is something you only do after being burned by performance/leak bugs in production 3D (cf. his MARTECH3D enterprise work).
  • Clean domain API design: swap-by-name + material-discovery is an elegant abstraction over messy scene-graph traversal.
  • Note: no public repo is currently linked (the portfolio entry points to the GitHub profile); the library is described from the author's project metadata and pairs with his BabylonJS/3D track record.
Ask me anything