Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

threejs-asset-pipeline

БесплатноБез исполняемых скриптовНе проверен

Shrinking glTF assets for three.js with gltf-transform: inspect, validate and optimize commands, Draco, meshopt and quantization, KTX2, WebP and AVIF…

CloudAI-Xот CloudAI-X★ 4 632 звезды на GitHub

Об этом скилле

Three.js Asset Pipeline

Targets three.js r186. Examples use WebGLRenderer; the WebGPU and TSL section uses WebGPURenderer.

Quick Start

Compress on the command line, then load the result. Run inspect before and after to see what the pass saved:

npx @gltf-transform/cli inspect model.glb
npx @gltf-transform/cli optimize model.glb model.opt.glb --compress draco --texture-compress webp --texture-size 2048
npx @gltf-transform/cli inspect model.opt.glb

Draco output needs a DRACOLoader attached; WebP textures decode in the browser:

import * as THREE from "three";
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
import { DRACOLoader } from "three/addons/loaders/DRACOLoader.js";

const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

const scene = new THREE.Scene();
const sun = new THREE.DirectionalLight(0xffffff, 2); // glTF PBR materials render black without lights or an environment
sun.position.set(3, 5, 2);
scene.add(sun, new THREE.HemisphereLight(0xffffff, 0x444444, 1.5));

const camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.1, 100);
camera.position.set(2, 1.5, 3);
camera.lookAt(0, 0, 0);

const gltf = await new GLTFLoader()
  .setDRACOLoader(new DRACOLoader()) // the Draco WASM decoder loads from the three package
  .loadAsync("model.opt.glb");
scene.add(gltf.scene);

function animate() {
  renderer.render(scene, camera);
}

renderer.setAnimationLoop(animate);

Inspect and Validate

Never guess where the bytes are. inspect prints an overview (generator, extensionsUsed, extensionsRequired) and one table each for scenes, meshes, materials, textures and animations, so a geometry-heavy file and a texture-heavy file are obvious at a glance.

npx @gltf-transform/cli inspect model.glb
npx @gltf-transform/cli inspect model.opt.glb --format csv
npx @gltf-transform/cli validate model.glb --ignore ACCESSOR_WEIGHTS_NON_NORMALIZED

extensionsRequired is the runtime contract: KHR_draco_mesh_compression, EXT_meshopt_compression and KHR_texture_basisu each map to a piece of loader wiring below, while KHR_mesh_quantization, EXT_mesh_gpu_instancing, EXT_texture_webp and EXT_texture_avif need nothing at runtime. validate runs the official glTF validator and reports errors, warnings and hints; it exits nonzero when errors are found, so it works as a CI gate. The commands in this skill that write a file log the input and output sizes when they finish; inspect the output to see which table the savings came from.

The optimize Command

optimize chains the common passes in one run: dedup, instance, palette, flatten, join, weld, simplify, resample, prune and sparse data, then texture compression, and geometry compression last. With no flags it applies meshopt compression and recompresses textures in their original format. Defaults are aggressive but generic — inspect first, then tune:

# draco geometry + webp textures, capped at 2048px
npx @gltf-transform/cli optimize model.glb model.opt.glb --compress draco --texture-compress webp --texture-size 2048
# GPU textures instead of download size, keep every triangle
npx @gltf-transform/cli optimize model.glb model.opt.glb --texture-compress ktx2 --simplify false

Main flags (booleans take an explicit value, like --simplify false):

  • --compress draco|meshopt|quantize — geometry and animation compression (default meshopt).
  • --texture-compress ktx2|webp|avif — texture codec (default auto, recompress in the original format).
  • --texture-size <px> — cap texture dimensions, default 2048.
  • --simplify <bool>, --simplify-ratio <0-1>, --simplify-error <fraction>, --simplify-lock-border <bool> — mesh simplification; ratio 0 and error 0.0001 by default.
  • --instance <bool>, --instance-min <count> — GPU instancing for repeated meshes.
  • --join <bool>, --join-meshes <bool>, --join-named <bool>, --flatten <bool> — draw-call reduction; --join requires --flatten.
  • --weld <bool> — merge duplicate vertices; draco welds by itself even with --weld false, while simplify welds only unindexed primitives, so keep --weld true when simplifying.
  • --prune <bool>, --resample <bool>, --palette <bool>, --sparse <bool>, --meshopt-level medium|high.

With --texture-compress ktx2, optimize picks bitstreams itself: UASTC for the normal, occlusion and metallic-roughness slots, ETC1S for everything else. For alternatives outside this skill's lane, gltfpack covers similar ground; gltf-transform is enough here.

Geometry Compression

Three codecs with different tradeoffs — pick per model, not per project:

  • Draco (--compress draco, draco command): compresses triangle-mesh geometry only — animation, morph targets, textures, points and lines a
Полный SKILL.md на GitHub

Установить threejs-asset-pipeline в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл threejs-asset-pipeline?

Shrinking 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.

Как установить скилл threejs-asset-pipeline?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл threejs-asset-pipeline запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить threejs-asset-pipeline с