threejs-gltf-loading
БесплатноБез исполняемых скриптовНе проверенLoads glTF/GLB models into three.js r187 and plays their animations: GLTFLoader, DRACO, Meshopt and KTX2 decoders, AnimationMixer cross-fades and…
от gamedev-skills★ 12 656 звёзд на GitHubОб этом скилле
three.js glTF loading
Loads .gltf / .glb models, including compressed geometry (DRACO, Meshopt) and textures
(KTX2), and plays their animation clips. Patterns target r187; an existing project keeps
its pinned release unless the user asks to upgrade. glTF is the runtime format to default
to: OBJ has no scene graph or animation, and FBX is heavy to parse in a browser.
When to use
- Importing a model or character, inspecting its node hierarchy, playing or blending clips, spawning many copies of an animated enemy, or fixing a model that does not appear.
- Files are
.gltf/.glb, or code importsGLTFLoader,DRACOLoaderorKTX2Loaderfromthree/addons/loaders/.... - Not for the renderer, camera and loop (
threejs-scene-setup), the model's lighting and materials (threejs-materials-lighting), or modelling and export settings in a DCC tool.
Workflow
- Inspect the file before writing loader code when
gltf-transformis available:npx @gltf-transform/cli inspect model.glblists meshes, extensions (for exampleKHR_draco_mesh_compression,EXT_meshopt_compression,KHR_texture_basisu), clips and texture sizes. Each listed compression extension needs its decoder attached. - Load with
GLTFLoader(loadAsyncin async code). The result hasgltf.scene, the rootObject3D, andgltf.animations, anAnimationClip[]. - Add
gltf.sceneand frame it. glTF units are metres; log names and bounds to find the parts code will control. - One
AnimationMixerper animated root, actions frommixer.clipAction(clip), andmixer.update(seconds)every frame. - Attach decoders for the extensions found in step 1. Since r185
DRACOLoaderandKTX2Loaderfind their bundled decoder files without a path. - Verify with Verify.
Patterns
1. Load and frame a model
import * as THREE from 'three';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
const gltf = await new GLTFLoader().loadAsync('assets/robot.glb');
const root = gltf.scene;
scene.add(root);
const box = new THREE.Box3().setFromObject(root);
console.log('size (m):', box.getSize(new THREE.Vector3()).toArray());
console.log('clips:', gltf.animations.map((c) => c.name));
2. Play a clip
const timer = new THREE.Timer(); // THREE.Clock is deprecated since r183
const mixer = new THREE.AnimationMixer(gltf.scene);
const run = THREE.AnimationClip.findByName(gltf.animations, 'Run') ?? gltf.animations[0];
mixer.clipAction(run).play();
renderer.setAnimationLoop(() => {
timer.update();
mixer.update(timer.getDelta()); // seconds, not milliseconds
renderer.render(scene, camera);
});
3. Cross-fade between clips
const actions = Object.fromEntries(gltf.animations.map((c) => [c.name, mixer.clipAction(c)]));
let current = actions.Idle;
current.play();
function transitionTo(name, duration = 0.3) {
const next = actions[name];
if (!next || next === current) return;
next.reset().play(); // rewind and clear an old fade
current.crossFadeTo(next, duration, false);
current = next;
}
4. Compressed geometry and textures
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { DRACOLoader, DRACO_GLTF_CONFIG } from 'three/addons/loaders/DRACOLoader.js';
import { KTX2Loader } from 'three/addons/loaders/KTX2Loader.js';
import { MeshoptDecoder } from 'three/addons/libs/meshopt_decoder.module.js';
const loader = new GLTFLoader()
.setDRACOLoader(new DRACOLoader().setDecoderPath(DRACO_GLTF_CONFIG)) // glTF-only WASM build (r185+)
.setKTX2Loader(new KTX2Loader().detectSupport(renderer)) // needs the renderer
.setMeshoptDecoder(MeshoptDecoder);
// Share this one loader for every model so decoders and workers are created once.
On releases before r185, or when the host does not serve the bundled files, copy
examples/jsm/libs/draco/ and libs/basis/ from the installed three and pass those folders
to setDecoderPath / setTranscoderPath.
5. Find a named part
const wheels = [];
gltf.scene.traverse((node) => {
if (node.name.startsWith('Wheel')) wheels.push(node);
});
// In the loop: for (const w of wheels) w.rotation.x += dt * 4;
6. Shrink a model without losing the parts code needs
# Meshopt, WebP textures at most 1024 px; no flattening, named joins or instancing.
npx @gltf-transform/cli optimize in.glb out.glb \
--compress meshopt --texture-compress webp --texture-size 1024 \
--flatten false --join-named false --instance false
npx @gltf-transform/cli validate out.glb
optimize flattens the hierarchy and joins meshes, named ones included, by default. In a
model without animations it also replaces five or more nodes that use the same mesh
(identical copies count, because it deduplicates first) with one unnamed GPU-instanced node
(EXT_mesh_gpu_instancing). That cuts draw calls, but code t
Установить threejs-gltf-loading в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл threejs-gltf-loading?
Loads glTF/GLB models into three.js r187 and plays their animations: GLTFLoader, DRACO, Meshopt and KTX2 decoders, AnimationMixer cross-fades and SkeletonUtils clones. Use when a model is invisible or tiny, decoder files 404, animations never play, or clones share one skeleton. Not for scene setup (`threejs-scene-setup`) or lighting (`threejs-materials-lighting`).
Как установить скилл threejs-gltf-loading?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл threejs-gltf-loading запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic