Three.js asset loading — GLTFLoader with DRACO/KTX2/Meshopt compression, OBJLoader+MTLLoader, FBXLoader, STLLoader, PLYLoader, RGBELoader for HDR, LoadingManager with progress/error tracking, async/Promise patterns, asset caching, and error handling. Use when loading 3D models, HDR environments, or managing multi-asset loading pipelines. Adapted from CloudAI-X/threejs-skills (MIT).
Instrucciones de origen · Vista previa de solo lectura
name
threejs-loaders
description
Three.js asset loading — GLTFLoader with DRACO/KTX2/Meshopt compression, OBJLoader+MTLLoader, FBXLoader, STLLoader, PLYLoader, RGBELoader for HDR, LoadingManager with progress/error tracking, async/Promise patterns, asset caching, and error handling. Use when loading 3D models, HDR environments, or managing multi-asset loading pipelines. Adapted from CloudAI-X/threejs-skills (MIT).
license
MIT
compatibility
Portable reference skill for agents that support markdown skills or prompt files. Works best alongside project Three.js source files and asset pipeline configuration.
disable-model-invocation
true
metadata
{"owner":"game-delivery","version":"2.0.0","language":"en-GB","category":"web-rendering","upstream_references":["https://github.com/CloudAI-X/threejs-skills (MIT — see NOTICE.md)"],"tags":["three-js","loaders","gltf","glb","draco","ktx2","fbx","obj","hdr","loading-manager","async","asset-pipeline"],"intents":["model-loading","compression-setup","hdr-loading","load-progress-tracking","asset-caching","error-handling"],"output_types":["code-example","api-reference","loading-pipeline-plan"]}
loader.load('model.glb', gltf => {
// Full hierarchyconsole.log(gltf.scene); // THREE.Groupconsole.log(gltf.scenes); // All scenes in the file// Animationsconsole.log(gltf.animations); // THREE.AnimationClip[]// Camera from GLTF (optional)console.log(gltf.cameras); // THREE.Camera[]// Named objectsconst player = gltf.scene.getObjectByName('Player');
// Materials
gltf.scene.traverse(child => {
if (child.isMesh) {
console.log(child.material.name);
}
});
});
Use .glb over .gltf — single binary file, no separate texture requests
DRACO-compress geometry — 60–90% size reduction, CPU cost only on first load
KTX2-compress textures — 4–8× VRAM reduction vs PNG/JPG
Cache loader instances — create one GLTFLoader per loader type, not per load call
Use LoadingManager — track all assets together, show a real progress bar
Clone, don't re-load — for multiple instances of the same model, gltf.scene.clone(true)
// Reuse loader instance — DO NOT create per callconst gltfLoader = newGLTFLoader(); // Create once// All subsequent loads reuse the same loader
loader.load('a.glb', ...);
loader.load('b.glb', ...);
loader.load('c.glb', ...);
See Also
threejs-animation — using gltf.animations with AnimationMixer
threejs-textures — texture loading and colour space configuration
threejs-lighting — RGBELoader for HDR environment maps