/threejs-skills:threejs-model-optimizefrom three.js Skills
Shrinking a glTF/GLB model for the web with use-case presets over gltf-transform, plus a before/after report and the loader wiring the output needs. Use when a model is too big, slow to load, heavy on GPU memory, or about to ship. Hands off to `threejs-model-fix`.
Ships in three.js Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
gltf-transform optimize with default flags joins named meshes, merges materials into palettes and flattens the
hierarchy. That is right for scenery and silently breaks any code that finds parts by name, swaps materials or
attaches objects to nodes. Pick a preset from what the app does with the model, then check that the names it uses
survived.
Paths: <this-skill-dir> is the directory containing this SKILL.md and <inspect-skill-dir> the one containing
threejs-model-inspect's; replace them with absolute paths and quote them. The script needs Node 22+ and npx
with network access; its before/after report needs threejs-model-inspect installed next to this skill.
Run threejs-model-inspect on the source and note where the bytes are (geometry, textures, animation) and which
names, materials and clips the app references (search the code for getObjectByName, nodes., materials.,
clip names). Check for an existing pipeline first (package.json scripts running gltfpack or gltf-transform,
a generator of gltfpack in the report): files it already compressed rarely shrink further. Improve that
pipeline's flags instead of replacing it, and keep the original whenever the script reports no meaningful gain.
Choose a preset:
| Preset | Use for | Trades |
|---|---|---|
web (default) | most models | nothing visible; textures capped at 2048 px |
hero | the model the camera lingers on | larger file; textures up to 4096 px |
configurator | parts recolored, swapped, hidden or attached at runtime | keeps hierarchy and separate meshes, so more draw calls |
animated | rigged or animated characters | no simplification |
background | props and scenery | simplified geometry, 1024 px textures, names and materials merged |
mobile | phones, low GPU memory | KTX2 textures (needs the ktx CLI), light simplification |
lossless | cleanup with no decoders at runtime | little size saved |
Run the script. It never writes over the input; the default output is <name>.<preset>.glb next to it:
node <this-skill-dir>/scripts/optimize.mjs model.glb --preset web
node <this-skill-dir>/scripts/optimize.mjs model.glb public/model.glb --preset configurator
node <this-skill-dir>/scripts/optimize.mjs model.glb --preset web --draco # Draco instead of meshopt
node <this-skill-dir>/scripts/optimize.mjs model.glb --preset web -- --texture-size 1024 # extra gltf-transform flags
node <this-skill-dir>/scripts/optimize.mjs --list
Read the report: the before/after table, Names removed by this pass and the loader wiring. If a removed name is
used in code, rerun with configurator or pass -- --join false --flatten false.
Wire the decoders the report lists into the loader (threejs-model-fix has the error table). drei useGLTF
already wires Draco and meshopt.
Compare the output with the original visually. The script prints the exact command; it renders both through
threejs-model-inspect's render.mjs with identical framing and a pixel-diff row:
node <inspect-skill-dir>/scripts/render.mjs model.glb --compare model.web.glb --max-diff 2
Look at the image, not just the percentage: under 1% is usually texture recompression; red outlines around the
silhouette mean simplification moved geometry; a whole part in red means it was dropped or re-materialed. For
animated models add --clip <name> --time <s> to compare a pose.
--transform for R3F) is in
threejs-asset-pipeline.gltf-transform optimize on a configurator model, then debugging undefined parts.Next: threejs-model-fix if the optimized model renders differently.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub emiliodominguez/threejs-skills --plugin threejs-skills28 skills in this plugin
/threejsMap of the threejs-* skills for three.js and React Three Fiber work: 3D models, scenes, materials, lighting, animation, shaders, performance and model generation. Use when a 3D web task spans several areas or the right skill is unclear. Routes to `threejs-model-inspect` and the rest of the suite./threejs-animationKeyframe, skeletal and morph-target animation, procedural motion and clip blending, on WebGL or with WebGPU and TSL. Use when animating objects, playing glTF animations, posing bones, driving morph targets, or mixing and crossfading clips./threejs-asset-pipelineShrinking glTF assets for three.js with gltf-transform: inspect, validate and optimize commands, Draco, meshopt and quantization, KTX2, WebP and AVIF textures, the loader setup each output needs, and gltfjsx for React. Use when compressing, optimizing or validating 3D models before loading them.Other plugins' skills for the same job