threejs-gltf-loading
Was er macht
Dieser Skill erklärt, wie du 3D-Modelle in eine three.js-Webszene bringst und ihre Animationen abspielen lässt. Er ist für Entwickler gedacht, die 3D-Webanwendungen bauen.
Wann du ihn nutzt
- ✓Wenn du ein glTF- oder GLB-3D-Modell in eine three.js-Szene importieren musst.
- ✓Wenn Animationen eines Modells abspielen sollen, etwa Geh- oder Leerlaufbewegungen.
- ✓Wenn eine Modelldatei groß ist und komprimierte Geometrie oder Texturen braucht.
Link zum Skill
https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/web-engines/threejs-gltf-loading/SKILL.mdKopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.
So nutzt du ihn
Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.
Fertige Nachricht zum Einfügen
Für Claude Code, Codex oder Cursor: Führe den Befehl in deinem Projektordner aus, dann wird der Skill installiert.
Lade die SKILL.md herunter und lege sie in den Skills-Ordner deines Agenten.
Beispielanfrage an deine KI
“Lade mein Charaktermodell in meine three.js-Seite und lass seine Gehanimation abspielen.”
5 neue Skills pro Woche. 1 Minute Lesezeit.
So funktioniert es
Der Skill erklärt, wie du die Datei mit dem glTF-Loader lädst, das Modell zur Szene hinzufügst und einen Animation Mixer nutzt, um die mit dem Modell gelieferten Clips abzuspielen.
Technischer Inhalt (originale SKILL.md)
Originaltext des Autors, auf Englisch, direkt von GitHub.
three.js glTF Loading
Load .gltf/.glb models and play their animations in three.js, including
compressed geometry (DRACO/Meshopt) and textures (KTX2). Patterns target
r186; preserve an existing project's pinned release unless migration is requested.
When to use
- Use to import a 3D model, add it to the scene, inspect its node hierarchy, and
play baked/skinned animation clips with an
AnimationMixer. - Use when files are
.gltf/.glb, or code importsGLTFLoader/DRACOLoader/KTX2Loaderfromthree/addons/loaders/....
When not to use: creating the renderer/camera/loop → threejs-scene-setup.
Tuning surface look, lights, or shadows on the loaded model →
threejs-materials-lighting. Authoring/exporting the model itself (Blender) is out
of scope; prefer glTF over OBJ/FBX for runtime.
Core workflow
- Why glTF. It's a transmission format: binary vertex data, PBR materials, and animations are ready to render with minimal parsing. Prefer it over OBJ (no scene graph, no animation) and FBX (heavy) for the web.
- Load with
GLTFLoader.loader.load(url, onLoad, onProgress, onError). The resultgltfhasgltf.scene(theObject3Droot),gltf.animations(AnimationClip[]),gltf.cameras, andgltf.asset. - Add
gltf.sceneto your scene and frame it. Inspect the hierarchy withtraverse/getObjectByNameto find the parts you'll control. - Play animations with an
AnimationMixer. One mixer per animated root;mixer.clipAction(clip).play(); advance withmixer.update(delta)every frame. - Decode compressed assets. Attach a
DRACOLoader, aKTX2Loader, and/or the Meshopt decoder so DRACO meshes, KTX2 textures, and meshopt-compressed buffers load. Since r185 the DRACO and KTX2 loaders find their bundled decoder files on their own. - Validate changed glTF files when the project already has the tool. Run
gltf-transform validate path/to/model.glbfor each changed.gltfor.glb; fix reported errors before loading. - Verify what loaded — log the scene graph and
gltf.animations, and confirm the model is visible (right scale, lit) and the clip actually plays.
Patterns
1. Load a model and frame it
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
const loader = new GLTFLoader();
loader.load(
'assets/robot.glb',
(gltf) => {
const root = gltf.scene;
scene.add(root);
// Inspect: gltf.animations is an array of AnimationClip.
console.log('clips:', gltf.animations.map((c) => c.name));
},
(event) => {
// total is 0 when the server sends no Content-Length (e.g. compressed responses)
if (event.total) console.log(`${(event.loaded / event.total) * 100}% loaded`);
},
(error) => console.error('glTF load failed:', error)
);
2. Play a skinned animation with AnimationMixer
import * as THREE from 'three';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
let mixer; // declare outside so the loop can see it
const timer = new THREE.Timer(); // THREE.Clock is deprecated since r183
new GLTFLoader().load('assets/character.glb', (gltf) => {
scene.add(gltf.scene);
mixer = new THREE.AnimationMixer(gltf.scene); // one mixer per animated root
const clip = THREE.AnimationClip.findByName(gltf.animations, 'Run')
?? gltf.animations[0];
mixer.clipAction(clip).play();
});
renderer.setAnimationLoop((time) => {
timer.update(time);
const dt = timer.getDelta();
if (mixer) mixer.update(dt); // advance the animation by real seconds
renderer.render(scene, camera);
});
3. Cross-fade between two clips
const actions = {};
mixer = new THREE.AnimationMixer(gltf.scene);
for (const clip of gltf.animations) {
actions[clip.name] = mixer.clipAction(clip);
}
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 any old fade
current.crossFadeTo(next, duration, false); // fade the old one out, new one in
current = next;
}
4. DRACO-compressed geometry
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { DRACOLoader, DRACO_GLTF_CONFIG } from 'three/addons/loaders/DRACOLoader.js';
// r185+: DRACOLoader finds the decoder that ships n
Häufige Fragen
Warum glTF statt OBJ oder FBX?
Der Skill sagt, dass glTF für die Laufzeit im Web gebaut ist, OBJ keine Animationen kennt und FBX schwer ist.
Deckt das die Erstellung des 3D-Modells ab?
Nein. Das Erstellen oder Exportieren von Modellen in anderen Werkzeugen liegt außerhalb dieses Skills.
Deckt das die Beleuchtung des Modells ab?
Nein. Materialien und Licht behandelt ein eigener three.js-Skill.
Details
Originalbeschreibung des Autors
Load glTF/GLB models in three.js with GLTFLoader and play their skinned animations with AnimationMixer, including DRACO/Meshopt-compressed meshes and KTX2 textures. Use when importing 3D models into three.js — when the user mentions glTF, GLB, GLTFLoader, AnimationMixer, animation clips, DRACOLoader, or "load a 3D model". For scene/camera/renderer setup use threejs-scene-setup; for materials and lights use threejs-materials-lighting.
Beliebtheit
- GitHub-Sterne
- 6.6k
- Platz im Ranking
- #13861
- Lizenz
- Apache-2.0
- Aktualisiert
- 28.10.2026
Kommentare
- …
Weitere Skills aus diesem Repository
router
6.6kHilft deinem Agenten, für eine Anfrage den passenden Spiele-Entwicklungs-Skill zu finden, indem er deine Engine und die Art der Aufgabe erkennt.
ai-behavior-trees-utility-ai
6.6kHilft deinem Agenten, einen Behavior Tree und eine Utility-KI für Gegner und Figuren zu bauen, die Aktionen nach Priorität und Punktwert wählen.
audio-design
6.6kBringt deinem Agenten das Mischen von Spiel-Audio bei: Busse, Lautstärke in Dezibel, Absenkung unter Dialogen, adaptive Musik und Variationen von Soundeffekten.
camera-systems
6.6kHilft deinem Agenten, Spielkameras zu bauen, die sanft folgen, innerhalb des Levels bleiben und sich in 3D um die Figur drehen oder umschauen lassen.
Ähnliche Skills
angular-developer
280kHilft deinem Agenten bei Angular-Code und gibt Tipps zur Projektstruktur. Nützlich für neue Projekte, einzelne Code-Teile sowie Performance und Barrierefreiheit.
frontend-a11y
280kHilft deinem Agenten, Weboberflächen für alle zugänglich zu machen. Sorgt dafür, dass Websites und Apps gut mit Screenreadern und Tastaturnavigation funktionieren.
frontend-patterns
280kLässt deinen Agenten moderne Muster in der Frontend-Entwicklung anwenden. Optimiert Performance, verwaltet State und folgt Best Practices für React und Next.js.