How I Compressed 54 3D Models from 220+ MB Down to 15 MB for a 60fps Three.js Power-Grid Tower Defense
Playable Live Demo (100% free, zero download, zero signup): POWER TD: Grid Defense ( power-td.com/en/ ) Β· itch.io HTML5 Build
Full 22-Tower Wiki: Strategy Encyclopedia Β· Global Daily Challenge: power-td.com/daily
When you build a 3D strategy game solo, pathfinding and simulation logic are rarely what stall the project. You can get flow-field mazing and a real-time electrical grid simulation running in a few late nights.
What actually kills momentum is staring at 40 grey placeholder cubes - and sending a playtest link to friends only for them to ask: "Wait, which box is the hydro plant, and why won't this turret fire?"
For POWER TD: Grid Defense ( https://power-td.com/en/ ), a free browser-native Three.js tower defense game combining open-field mazing with live multi-source power grids, I used a 2D-concept β Tripo 3D (H3.1) β headless Blender β Meshopt + WebP pipeline to ship 54 custom 3D assets across 18 handcrafted islands, 22 buildings, and 13 enemy species - while keeping the entire playable web bundle around ~15 MB.
Here is the real production breakdown, including the exact traps I hit when a single 10-gold starter crossbow tower exported at 1.87 million triangles and 60.6 MB.
The Game Architecture: Why Mazing + Electrical Grids Need Crisp Silhouettes
In POWER TD, players don't place turrets along fixed tracks. Instead:
- Freeform Mazing: Cheap 0-watt Bastion Crossbows (
10G, with Drag-Paint[M]) double as physical maze walls with live anti-block flow-field pathfinding. - Physical Electrical Grid: Seven distinct power plants (Geothermal Steam, Day/Night Solar, River Hydro, Wind Ridges, Nuclear Cooling, Kill-Siphon Dynamo, and v3.0's Fusion Torus Core) project blue power rings. Drop any turret or relay inside a blue ring and catenary power cables auto-string without tedious manual wiring.
- Real Logistics Trade-Offs: Solar drops at night (and every 28 seconds during binary eclipses on Island 17). Each generator has finite sockets and W/s cable transfer bandwidth, so players buffer spikes with Capacitor Banks, hop oceans with 0%-loss Phase Warp Conduits, and toggle
[P]Priority Power (3Γ weight) on key DPS carries.
At zoomed-out isometric camera angles, every structure is thumb-sized. If a Crossbow, Copper Pylon, and Arc Coil all looked like "generic glowing stone obelisks," the game would be unreadable.
Three Art Hard-Rules Before Generating a Single Mesh:
- Strict 1Γ1 tile footprint: Roof overhangs beyond 0.88 tile width trick players into thinking adjacent maze lanes are blocked.
- Silhouette-first 2D concepts: Every building started as a numbered 1024Γ1024 2D ortho-style concept sheet (
01 - 45+ expansion waves) so line weight, brass trim, and stone bases matched as one cohesive family before hitting Image-to-3D. - Separate moving parts at concept time: Never ask an AI 3D generator to fuse spinning wind blades or dangling cables onto a building. Hydro waterwheels (
39_hydro_wheel_rotor) and wind rotors (38_wind_rotor) were generated as standalone meshes so Three.js can spin them proportionally to live generator efficiency (0%-185%), while power cables are procedural catenary tubes built at runtime.
The 60.6 MB Wake-Up Call (And the Automated 4-Step Pipeline)
When I imported the raw GLB for 01_bastion_crossbow - the cheapest starter wall players spam 30+ times per map - Blender's stats panel read:
1,876,712triangles60.60 MBfor one single tower (heavier than the entire finished 54-model game!)- The stone base and rotating crossbow head were fused into one rigid mesh.
Fixing 50+ models by hand in Blender wasn't an option. Instead, I kept raw exports in a read-only models_raw/ folder (outside Vite's public/ directory) and built a deterministic 4-step pipeline triggered with one npm command (pnpm run normalize-models):
blender --background --python scripts/normalize_models.py
blender --background --python scripts/normalize_env_and_fx_tripo.py
python3 scripts/optimize_glb_textures.py
node scripts/compress_glbs_meshopt.mjs
What Each Stage Actually Does
- Footprint Normalization & Pivot Grounding (
normalize_models.py): Computes true bounding box, scales every structure proportionally to fit 0.86-0.92 world tiles, grounds bottom vertices cleanly toY = 0, and auto-decimates extreme outliers (like that 1.87M-tri crossbow) down to strict triangle budgets (<= 16,000tris for hero buildings,1,200-6,000tris for instanced FX/projectiles). Horizontally slices rotating turrets (Crossbow, Mortar, Railgun, Laser) along a clean cut plane into a static base +TurretPivotchild group so Three.js can track enemies smoothly without re-rigging. Preserves native skinned skeletal walk clips (e.g., 65-joint rigged crawlers and bosses) while using lightweight procedural hover/pulse animations for hovering enemies. - Texture Downscaling & Delighting (
optimize_glb_textures.py): Caps hero buildings & enemies to 1024px PBR maps and small instanced hardware/projectiles to 512px, re-encoding textures as WebP. Using Delighted albedo maps ensures Three.js real-time sun/night lighting and electric arc point-lights look consistent instead of fighting baked studio shadows. - Meshopt Geometry Quantization (
compress_glbs_meshopt.mjs): Runsgltfpack/ Meshopt compression across every GLB. Example real result on25_capacitor_bank.glb:3.91 MBraw β1.41 MBafter 1K texture pass β0.35 MBafter Meshopt + WebP (with zero geometry lost: still exact13,837triangles). Across the initial 45-asset library:222.81 MBraw β12.16 MBproduction (~94.5% reduction). Even after expanding to v3.0 Stormfront (54 models, 18 islands, 22 towers, 13 monsters), the entire multi-platform build stays around ~15 MB.
Runtime Performance Tricks in Three.js
Keeping download size small is only half the battle - rendering 60+ active towers, glowing power cables, 100+ enemies, and particle bursts at 60fps in a browser tab (including mobile Safari/Chrome) required a few strict guardrails:
- Zero runtime allocations inside hot loops: Projectiles, floating damage pools, and terrain tile meshes reuse
InstancedMeshbuffers and pooled DOM nodes (especially critical at 4Γ combat speed where recreating Live DPS DOM rows detached user clicks). - One mesh, three gameplay states: Rather than loading separate models for unpowered/charged/overdriven states, a single Capacitor Bank GLB communicates grid charge via emissive shader uniforms, pulsing cable color, and an adjacent
+22%-35%fire-rate aura ring once charge passes40%. - Progressive loading + 2D fallback: Only essential boot models load before frame 1 (
loadPolicy.ts+assetQueue.ts); secondary island assets stream in the background. On low-end laptops or mobile data, players can flip to a crisp 2D tactical plane view or cap DPR (1.0Γ / 1.5Γ / 2.0Γ) in one click. - Zero-friction sharing via Cloudflare Pages + D1: Every run can export its entire maze + Lv.2 upgrade branches into a compact
?bp=BP1...URL or a/c/<code>challenge card with dynamic Open Graph meta tags, alongside a deterministic Global Daily Challenge (/daily) and a Community Blueprint Wall.
Try It Live (Zero Download, No Signup Wall)
- Play in Browser (EN): https://power-td.com/en/ (also available in ηΉι«δΈζ, ζ₯ζ¬θͺ, νκ΅μ΄)
- Today's Global Daily Challenge: https://power-td.com/daily
- Full 22-Tower & 8-Synergy Wiki: https://power-td.com/en/guide/
- Trailers & Press Kit: https://power-td.com/press/
I'd love brutal feedback from fellow Three.js / WebGL devs and TD veterans:
- How fast does initial boot + frame rate feel on your GPU/mobile device?
- Is the power-grid readability (blue rings, socket caps, night solar dips) intuitive by Wave 3?
- What do you think of the mazing vs. electrical logistics trade-off on the harder islands (especially Island 17's 28-second rapid eclipses)?
Comments
No comments yet. Start the discussion.