Model or convert 3D assets to glTF/GLB for the web with poly and texture budgets, Draco or meshopt plus KTX2 compression via gltf-transform, a Three.js or model-viewer preview, and size plus gltf-validator checks. Triggers: "optimize this GLB", "3D model for the web", "convert FBX to glTF", "compress textures KTX2".
25 stars
0 votes
0 copies
0 views
Added December 3, 2026
ai-agentspythongoshellbashgitapi
Works with
cursor
cli
api
Security analysis
A92/100
mediumInstalls packages at runtime which could introduce malicious dependencies
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Studio Gltf Web Asset?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/tinh2-studio-gltf-web-asset)
---
name: studio-gltf-web-asset
description: Model or convert 3D assets to glTF/GLB for the web with poly and texture budgets, Draco or meshopt plus KTX2 compression via gltf-transform, a Three.js or model-viewer preview, and size plus gltf-validator checks. Triggers: "optimize this GLB", "3D model for the web", "convert FBX to glTF", "compress textures KTX2".
version: "1.0.0"
category: build
platforms: [CLAUDE_CODE, CURSOR, CODEX_CLI]
---
# glTF web asset
A web 3D asset is done when it looks right, loads fast on a mid-range phone and passes the validator with zero errors.
## Inputs to agree on
- Source: Blender file, FBX, OBJ, CAD export, photogrammetry scan, or an existing GLB.
- Viewer: Three.js app, `<model-viewer>`, Babylon.js, or AR (Scene Viewer, Quick Look needs USDZ).
- Budgets (typical product viewer on mobile):
- Triangles: 50k to 100k hero, under 20k for many-object scenes.
- Textures: 2048 max for hero base color, 1024 for normal/ORM on small items; KTX2 compressed.
- Download: under 5 MB hero, under 1 MB for inline items.
- Draw calls: as few materials as possible (1 to 5).
- Required features: animations, morph targets, variants (`KHR_materials_variants`), AR.
## Toolchain
- Blender 4.x glTF exporter (built in) for modeling, baking and export.
- `@gltf-transform/cli` for inspect, optimize, compress: `npm i -g @gltf-transform/cli`.
- KTX-Software (`toktx`) is required by gltf-transform for KTX2 encoding; install it and ensure it is on PATH.
- `gltf-validator` (Khronos): `npm i -g gltf-validator` provides the library; the CLI binary is published on the KhronosGroup glTF-Validator releases page. The web drop-in at github.khronos.org/glTF-Validator also works.
- Alternatives: `gltfpack` (meshoptimizer) for one-shot simplify plus compress; FBX2glTF for FBX; `obj2gltf`.
## Workflow
### 1. Prepare in Blender
- Apply scale and rotation (Ctrl+A), real-world meters, Y-up is handled by the exporter.
- Remove hidden geometry, inner faces and unused materials. Merge materials where possible and bake to a single texture set (base color, normal, ORM where R=occlusion, G=roughness, B=metallic).
- For high-poly scans or CAD: decimate or retopologize, then bake normals from high to low.
- Export:
```python
import bpy
bpy.ops.export_scene.gltf(
filepath="asset.glb", export_format="GLB",
export_apply=True, export_yup=True,
export_texcoords=True, export_normals=True,
export_draco_mesh_compression_enable=False, # compress later with gltf-transform
export_animations=True,
)
```
Converting an FBX directly: `FBX2glTF -b -i model.fbx -o model` (outputs GLB).
### 2. Inspect
```bash
gltf-transform inspect asset.glb
```
Read the meshes table (vertices, primitives), textures (resolution, size in bytes, format) and extensions used. Large textures are usually most of the file.
### 3. Optimize
One command covering dedup, prune, weld, simplify, texture resize and compression:
```bash
gltf-transform optimize asset.glb asset.opt.glb \
--compress meshopt \
--texture-compress ktx2 \
--texture-size 2048 \
--simplify true --simplify-ratio 0.5 --simplify-error 0.001
```
Step-by-step when you need control:
```bash
gltf-transform dedup asset.glb a.glb
gltf-transform prune a.glb a.glb
gltf-transform weld a.glb a.glb
gltf-transform simplify a.glb a.glb --ratio 0.5 --error 0.001
gltf-transform resize a.glb a.glb --width 2048 --height 2048
gltf-transform etc1s a.glb a.glb --slots "{baseColorTexture,emissiveTexture}" --quality 255
gltf-transform uastc a.glb a.glb --slots "{normalTexture,occlusionTexture,metallicRoughnessTexture}" --level 2 --zstd 18
gltf-transform meshopt a.glb asset.opt.glb
```
Use UASTC for normal and ORM maps (ETC1S artifacts break normals) and ETC1S for color maps where size matters. Choose Draco (`gltf-transform draco`) for the smallest geometry on static meshes; choose meshopt for faster decode and support for animation and morph targets. Flags change between versions, so confirm with `gltf-transform <command> --help`.
### 4. Validate
```bash
gltf_validator asset.opt.glb -o # writes asset.opt.report.json
```
Require 0 errors. Review warnings (unused objects, non-normalized vectors). Then re-run `gltf-transform inspect` to confirm budgets.
### 5. Preview
`<model-viewer>` (fastest to ship):
```html
<script
type="module"
src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"
></script>
<model-viewer
src="asset.opt.glb"
alt="Product name, 3D view"
camera-controls
touch-action="pan-y"
shadow-intensity="1"
environment-image="neutral"
exposure="1"
ar
ar-modes="webxr scene-viewer quick-look"
style="width:100%;height:480px"
></model-viewer>
```
model-viewer decodes Draco, meshopt and KTX2 automatically.
Three.js (needs decoders wired):
```js
import * as THREE from "three";
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
import { KTX2Loader } from "three/addons/loaders/KTX2Loader.js";
import { DRACOLoader } from "three/addons/loaders/DRACOLoader.js";
import { MeshoptDecoder } from "three/addons/libs/meshopt_decoder.module.js";
import { RoomEnvironment } from "three/addons/environments/RoomEnvironment.js";
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.toneMapping = THREE.ACESFilmicToneMapping;
const scene = new THREE.Scene();
scene.environment = new THREE.PMREMGenerator(renderer).fromScene(
new RoomEnvironment(),
).texture;
const ktx2 = new KTX2Loader()
.setTranscoderPath("/basis/")
.detectSupport(renderer);
const draco = new DRACOLoader().setDecoderPath("/draco/");
const loader = new GLTFLoader()
.setKTX2Loader(ktx2)
.setDRACOLoader(draco)
.setMeshoptDecoder(MeshoptDecoder);
loader.load("asset.opt.glb", (gltf) => scene.add(gltf.scene));
```
Copy the transcoder and decoder files from `three/examples/jsm/libs/basis` and `.../draco` into your public folder.
### 6. Serve correctly
- MIME: `model/gltf-binary` for .glb, `image/ktx2` for .ktx2.
- Long cache with a content hash in the filename. Do not gzip an already compressed GLB heavily; Brotli gains little on Draco/meshopt data.
## Variants
- AR on iOS: export USDZ (Blender USD export or Reality Converter) and pass it via `ios-src`.
- Many small assets: share textures in a `.gltf` plus external files, or atlas them.
- Animated characters: meshopt (Draco does not cover animation), keep skin weights to 4 influences, resample animations with `gltf-transform resample`.
- Photogrammetry: simplify aggressively, bake detail into a normal map, cap at 4096 texture only for hero.
## Quality checks
- Validator: 0 errors.
- File size within budget (`ls -l`, plus each texture's size from inspect).
- Triangle count within budget.
- Visual diff: screenshot the original and optimized models from the same camera; no visible seams, flipped normals or banded color.
- Load on a mid-range phone over throttled 4G: first render under about 3 s for a hero model.
- GPU memory: KTX2 textures stay compressed on GPU; PNG/JPG expand to width x height x 4 bytes each.
## Pitfalls and fixes
- Black or missing textures in Three.js: KTX2Loader not registered or transcoder path wrong.
- Model too small or rotated: scale not applied before export.
- Normal map looks inverted: glTF uses OpenGL-style (Y+) normals; flip green channel from DirectX bakes.
- Simplify destroyed silhouette: lower the ratio change, raise `--error` limit carefully, or lock borders; check UV seams.
- Transparent materials sorting wrong: use alpha mode MASK where possible instead of BLEND.
- toktx not found: install KTX-Software; gltf-transform shells out to it.
## Deliverables
- [ ] `asset.opt.glb` within budgets
- [ ] Validator report JSON with 0 errors
- [ ] Inspect output before and after (size, triangles, textures)
- [ ] Preview page (model-viewer or Three.js) with decoders set up
- [ ] USDZ if AR on iOS was requested
- [ ] Source .blend and the exact optimize commands