threejs-loaders
Coordinates loading of 3D assets, textures, and models in Three.js with progress tracking and async patterns.
Install
mkdir -p .claude/skills/threejs-loaders && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/4671" && unzip -o skill.zip -d .claude/skills/threejs-loaders && rm skill.zipInstalls to .claude/skills/threejs-loaders
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Three.js asset loading - GLTF, textures, images, models, async patterns. Use when loading 3D models, textures, HDR environments, or managing loading progress.Key capabilities
- →Synchronizes multiple assets via LoadingManager
- →Reports granular loading percentage for progress bars
- →Manually controls color space settings (SRGB vs Linear)
- →Implements custom error handling per asset
How it works
Uses a LoadingManager object to aggregate state from multiple individual loaders and triggers callbacks upon cumulative completion.
Inputs & outputs
When to use threejs-loaders
- →Loading GLTF 3D models
- →Managing texture asset queues
- →Tracking model load progress
- →Implementing asset preloading logic
About this skill
Three.js Loaders
Targets three.js r186. Examples use WebGLRenderer; the WebGPU and TSL section uses WebGPURenderer.
Quick Start
import * as THREE from "three";
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
import { RoomEnvironment } from "three/addons/environments/RoomEnvironment.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();
scene.environment = new THREE.PMREMGenerator(renderer).fromScene(new RoomEnvironment(), 0.04).texture; // glTF PBR materials render black without lights or an environment
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().loadAsync("model.glb");
scene.add(gltf.scene);
function animate() {
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
LoadingManager
One manager coordinates several loaders and reports combined progress. loadAsync still rejects on failure; manager.onError fires as well.
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
const manager = new THREE.LoadingManager();
manager.onStart = (url, loaded, total) => {
console.log(`Started loading: ${url}`);
};
manager.onProgress = (url, loaded, total) => {
console.log(`Loading: ${((loaded / total) * 100).toFixed(1)}%`);
};
manager.onLoad = () => {
console.log("All assets loaded");
};
manager.onError = (url) => {
console.error(`Error loading: ${url}`);
};
const gltfLoader = new GLTFLoader(manager);
const textureLoader = new THREE.TextureLoader(manager);
// onLoad fires when every tracked item has finished
await Promise.all([
gltfLoader.loadAsync("model.glb"),
textureLoader.loadAsync("texture.jpg"),
textureLoader.loadAsync("normal.jpg"),
]);
manager.abort() cancels in-flight requests for loaders that load through FileLoader (models, HDR, EXR, KTX2). Loaders that load through an HTML image element, such as TextureLoader, ignore it.
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
const manager = new THREE.LoadingManager();
const timeoutId = setTimeout(() => manager.abort(), 30000);
try {
const gltf = await new GLTFLoader(manager).loadAsync("model.glb");
scene.add(gltf.scene);
} catch (error) {
console.error(error);
} finally {
clearTimeout(timeoutId);
}
Texture Loading
TextureLoader.load() returns the texture immediately and fills it in when the image decodes; assign it right away and the first render picks it up. Adding a map to a material that has already rendered without one needs material.needsUpdate = true. onProgress is never called for image loading.
new THREE.TextureLoader().load(
"texture.jpg",
(map) => {
map.colorSpace = THREE.SRGBColorSpace; // a color map; scalar maps keep NoColorSpace
mesh.material.map = map;
mesh.material.needsUpdate = true; // the material rendered without a map before
},
undefined, // onProgress: not supported for image loading
(error) => {
console.error("Could not load texture", error);
},
);
Texture configuration
const map = new THREE.TextureLoader().load("color.jpg");
map.colorSpace = THREE.SRGBColorSpace; // LDR color images; scalar maps keep NoColorSpace
map.wrapS = THREE.RepeatWrapping; // ClampToEdgeWrapping (default), RepeatWrapping, MirroredRepeatWrapping
map.wrapT = THREE.RepeatWrapping;
map.repeat.set(2, 2);
map.offset.set(0.5, 0.5);
map.rotation = Math.PI / 4;
map.center.set(0.5, 0.5);
map.minFilter = THREE.LinearMipmapLinearFilter; // default
map.magFilter = THREE.LinearFilter; // default; NearestFilter for a pixelated look
map.anisotropy = renderer.capabilities.getMaxAnisotropy(); // sharper textures at grazing angles
mesh.material.map = map;
// wrap, filters, anisotropy, colorSpace and flipY (true by default) apply at upload: set them before the first render or set map.needsUpdate = true; repeat, offset, rotation and center apply every frame
Color spaces: LDR color images (albedo, emissive) are SRGBColorSpace; scalar maps (normal, bump, roughness, metalness, ao, alpha) keep the default NoColorSpace. GLTFLoader sets the correct color spaces for the textures it loads, and the HDR loaders below set LinearSRGBColorSpace themselves. A texture you load yourself for a glTF model's material needs map.flipY = false to match the textures GLTFLoader loads.
CubeTextureLoader
For skyboxes and cube environments, six faces in +X, -X, +Y, -Y, +Z, -Z order; the loader sets sRGB itself.
const cubeTexture = await new THREE.CubeTextureLoader().loadAsync([
"px.jpg",
"nx.jpg",
"py.jpg",
"ny.jpg",
"pz.jpg",
"nz.jpg",
]);
scene.background = cubeTexture;
scene.environment = cubeTexture;
HDR Environments
HDRLoader (Radiance .hdr) and EXRLoader return floating-point equirectangular textures. Both renderers prefilter an equirectangular environment themselves, so no PMREM step is needed for a file — set mapping and assign it.
import { HDRLoader } from "three/addons/loaders/HDRLoader.js";
import { EXRLoader } from "three/addons/loaders/EXRLoader.js";
const env = await new HDRLoader().loadAsync("environment.hdr");
env.mapping = THREE.EquirectangularReflectionMapping;
scene.environment = env;
scene.background = env; // without mapping, a background texture draws as a flat screen quad
const exr = await new EXRLoader().loadAsync("environment.exr");
exr.mapping = THREE.EquirectangularReflectionMapping;
scene.environment = exr;
Dim the environment with scene.environmentIntensity (and rotate it with scene.environmentRotation); material.envMapIntensity scales only a material's own envMap, which stays null on models lit by scene.environment.
UltraHDRLoader reads gain-map JPEGs — HDR dynamic range at JPEG file sizes — the same way:
import { UltraHDRLoader } from "three/addons/loaders/UltraHDRLoader.js";
const env = await new UltraHDRLoader().loadAsync("environment.jpg");
env.mapping = THREE.EquirectangularReflectionMapping;
scene.environment = env;
Use PMREMGenerator for generated environments, not files:
import { RoomEnvironment } from "three/addons/environments/RoomEnvironment.js";
const pmremGenerator = new THREE.PMREMGenerator(renderer);
const room = new RoomEnvironment();
scene.environment = pmremGenerator.fromScene(room, 0.04).texture;
room.dispose(); pmremGenerator.dispose(); // the room's geometries and materials, then the generator
glTF and GLB
The primary format for web delivery. The result carries scene, animations, cameras, asset (version, generator) and userData (authoring custom data).
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
const gltf = await new GLTFLoader().loadAsync("model.glb");
scene.add(gltf.scene);
if (gltf.animations.length > 0) {
const mixer = new THREE.AnimationMixer(gltf.scene);
mixer.clipAction(gltf.animations[0]).play();
const timer = new THREE.Timer();
timer.connect(document);
function animate() {
timer.update();
mixer.update(timer.getDelta());
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
}
Draco, meshopt and KTX2 compression
The Draco decoder and the Basis transcoder load from the three package by default; call setDecoderPath / setTranscoderPath only when you host them yourself, and then pin the path to the three release you ship. A file that requires EXT_meshopt_compression or KHR_meshopt_compression fails to load unless setMeshoptDecoder is set.
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
import { DRACOLoader } 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 gltfLoader = new GLTFLoader()
.setDRACOLoader(new DRACOLoader())
.setMeshoptDecoder(MeshoptDecoder)
.setKTX2Loader(new KTX2Loader().detectSupport(renderer));
const gltf = await gltfLoader.loadAsync("compressed-model.glb");
scene.add(gltf.scene);
Processing loaded content
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
const gltf = await new GLTFLoader().loadAsync("model.glb");
const model = gltf.scene;
model.traverse((child) => {
if (child.isMesh) {
child.castShadow = true; // shadows also need renderer.shadowMap.enabled = true and a light with castShadow
child.receiveShadow = true;
}
});
model.getObjectByName("Head"); // look up named nodes
scene.environmentIntensity = 0.5; // dim scene.environment for this scene
// Center the model and scale it into a unit box
const box = new THREE.Box3().setFromObject(model);
const center = box.getCenter(new THREE.Vector3());
const size = box.getSize(new THREE.Vector3());
const scale = 1 / Math.max(size.x, size.y, size.z);
model.scale.setScalar(scale);
model.position.copy(center).multiplyScalar(-scale); // the offset is scaled too
scene.add(model);
Other Model Formats
OBJ + MTL
import { MTLLoader } from "three/addons/loaders/MTLLoader.js";
import { OBJLoader } from "three/addons/loaders/OBJLoader.js";
const materials = await new MTLLoader().loadAsync("model.mtl");
materials.preload();
const object = await new OBJLoader().setMaterials(materials).loadAsync("model.obj");
scene.add(object);
FBX
import { FBXLoader } from "three/addons/loaders/FBXLoader.js";
const object = await new FBXLoader().loadAsync("model.fbx");
object.scale.setScalar(0.01); // FBX files are often exported in centimeters
const mixer = new THREE.AnimationMixer(object); // ca
---
*Content truncated.*
When not to use it
- →Simple scenes with single small assets
- →Situations where blocking synchronous loading is acceptable for very low-latency requirements
Prerequisites
Limitations
- →Requires explicit definition of color spaces for accuracy
- →Loading progress events are unavailable for image-based texture loads
How it compares
Standardizing asset lifecycle management prevents fragmented loading logic and race conditions in complex scenes.
Compared to similar skills
threejs-loaders side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| threejs-loaders (this skill) | 1 | 10mo | Review | Intermediate |
| zustand | 113 | 5mo | No flags | Intermediate |
| threejs-skills | 61 | 7mo | No flags | Intermediate |
| accessibility-compliance | 45 | 5mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by CloudAI-X
View all by CloudAI-X →You might also like
zustand
lobehub
Zustand state management guide. Use when working with store code (src/store/**), implementing actions, managing state, or creating slices. Triggers on Zustand store development, state management questions, or action implementation.
threejs-skills
sickn33
Three.js skills for creating 3D elements and interactive experiences
accessibility-compliance
wshobson
Implement WCAG 2.2 compliant interfaces with mobile accessibility, inclusive design patterns, and assistive technology support. Use when auditing accessibility, implementing ARIA patterns, building for screen readers, or ensuring inclusive user experiences.
react-modernization
wshobson
Upgrade React applications to latest versions, migrate from class components to hooks, and adopt concurrent features. Use when modernizing React codebases, migrating to React Hooks, or upgrading to latest React versions.
3d-graphics
samhvw8
3D web graphics with Three.js (WebGL/WebGPU). Capabilities: scenes, cameras, geometries, materials, lights, animations, model loading (GLTF/FBX), PBR materials, shadows, post-processing (bloom, SSAO, SSR), custom shaders, instancing, LOD, physics, VR/XR. Actions: create, build, animate, render 3D scenes/models. Keywords: Three.js, WebGL, WebGPU, 3D graphics, scene, camera, geometry, material, light, animation, GLTF, FBX, OrbitControls, PBR, shadow mapping, post-processing, bloom, SSAO, shader, instancing, LOD, WebXR, VR, AR, product configurator, data visualization, architectural walkthrough, interactive 3D, canvas. Use when: creating 3D visualizations, building WebGL/WebGPU apps, loading 3D models, adding animations, implementing VR/XR, creating interactive graphics, building product configurators.
d3-visualization
lyndonkl
Use when creating custom, interactive data visualizations with D3.js—building bar/line/scatter charts from scratch, creating network diagrams or geographic maps, binding changing data to visual elements, adding zoom/pan/brush interactions, animating chart transitions, or when chart libraries (Highcharts, Chart.js) don't support your specific visualization design and you need low-level control over data-driven DOM manipulation, scales, shapes, and layouts.