
Threejs Textures
Load, configure, and optimize textures—including UVs, cubemaps, and HDR environments—for Three.js materials in web 3D projects.
Overview
threejs-textures is an agent skill for the Build phase that guides Three.js texture loading, UV mapping, environment maps, and material map configuration.
Install
npx skills add https://github.com/cloudai-x/threejs-skills --skill threejs-texturesWhat is this skill?
- TextureLoader patterns with progress/error callbacks and Promise.all batch loading
- Color-space guidance: sRGB for albedo vs linear data maps (normal, roughness, metalness, AO)
- MeshStandardMaterial map wiring for PBR-style texture stacks
- Covers cubemaps, HDR environments, and texture optimization triggers from the skill description
- Copy-paste JavaScript snippets aligned with modern Three.js imports
Adoption & trust: 3.4k installs on skills.sh; 2.3k GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
You are building a Three.js scene but maps look washed out, misaligned, or fail to load because color space, UVs, and loader async behavior are easy to get wrong.
Who is it for?
Indie devs and solo builders adding textured meshes, HDR skies, or multi-map PBR materials in a Three.js web or game-like experience.
Skip if: Teams that need a full DCC UV unwrap pipeline, non-Three engines, or production CDN/asset-pipeline design without writing Three.js code.
When should I use this skill?
Working with images, UV coordinates, cubemaps, HDR environments, or texture optimization in Three.js.
What do I get? / Deliverables
You get working loader snippets, correct sRGB vs data-texture settings, and material assignments so PBR maps and environments render predictably in the browser.
- TextureLoader and Promise-based load helpers
- Configured MeshStandardMaterial map assignments
- Documented color-space choices per map type
Recommended Skills
Journey fit
Texture work happens while implementing the visual layer of a Three.js product, before ship-time perf passes. UV mapping, material maps, and environment lighting are frontend 3D rendering concerns, not backend or launch distribution.
How it compares
Reference skill for Three.js texture APIs—not a texture CDN, Blender UV tutorial, or a generic image optimization CLI.
Common Questions / FAQ
Who is threejs-textures for?
Frontend and creative-coders shipping WebGL/Three.js who want agent-guided snippets for loaders, maps, and environment textures.
When should I use threejs-textures?
During Build when you add images to materials, fix UV stretching, configure cubemaps or HDR environments, or tune texture settings before performance work.
Is threejs-textures safe to install?
It is documentation-style procedural knowledge; review the Security Audits panel on this Prism page before trusting any third-party skill in your repo.
SKILL.md
READMESKILL.md - Threejs Textures
# Three.js Textures ## Quick Start ```javascript import * as THREE from "three"; // Load texture const loader = new THREE.TextureLoader(); const texture = loader.load("texture.jpg"); // Apply to material const material = new THREE.MeshStandardMaterial({ map: texture, }); ``` ## Texture Loading ### Basic Loading ```javascript const loader = new THREE.TextureLoader(); // Async with callbacks loader.load( "texture.jpg", (texture) => console.log("Loaded"), (progress) => console.log("Progress"), (error) => console.error("Error"), ); // Synchronous style (loads async internally) const texture = loader.load("texture.jpg"); material.map = texture; ``` ### Promise Wrapper ```javascript function loadTexture(url) { return new Promise((resolve, reject) => { new THREE.TextureLoader().load(url, resolve, undefined, reject); }); } // Usage const [colorMap, normalMap, roughnessMap] = await Promise.all([ loadTexture("color.jpg"), loadTexture("normal.jpg"), loadTexture("roughness.jpg"), ]); ``` ## Texture Configuration ### Color Space Critical for accurate color reproduction. ```javascript // Color/albedo textures - use sRGB colorTexture.colorSpace = THREE.SRGBColorSpace; // Data textures (normal, roughness, metalness, AO) - leave as default // Do NOT set colorSpace for data textures (NoColorSpace is default) ``` ### Wrapping Modes ```javascript texture.wrapS = THREE.RepeatWrapping; // Horizontal texture.wrapT = THREE.RepeatWrapping; // Vertical // Options: // THREE.ClampToEdgeWrapping - Stretches edge pixels (default) // THREE.RepeatWrapping - Tiles the texture // THREE.MirroredRepeatWrapping - Tiles with mirror flip ``` ### Repeat, Offset, Rotation ```javascript // Tile texture 4x4 texture.repeat.set(4, 4); texture.wrapS = THREE.RepeatWrapping; texture.wrapT = THREE.RepeatWrapping; // Offset (0-1 range) texture.offset.set(0.5, 0.5); // Rotation (radians, around center) texture.rotation = Math.PI / 4; texture.center.set(0.5, 0.5); // Rotation pivot ``` ### Filtering ```javascript // Minification (texture larger than screen pixels) texture.minFilter = THREE.LinearMipmapLinearFilter; // Default, smooth texture.minFilter = THREE.NearestFilter; // Pixelated texture.minFilter = THREE.LinearFilter; // Smooth, no mipmaps // Magnification (texture smaller than screen pixels) texture.magFilter = THREE.LinearFilter; // Smooth (default) texture.magFilter = THREE.NearestFilter; // Pixelated (retro games) // Anisotropic filtering (sharper at angles) texture.anisotropy = renderer.capabilities.getMaxAnisotropy(); ``` ### Generate Mipmaps ```javascript // Usually true by default texture.generateMipmaps = true; // Disable for non-power-of-2 textures or data textures texture.generateMipmaps = false; texture.minFilter = THREE.LinearFilter; ``` ## Texture Types ### Regular Texture ```javascript const texture = new THREE.Texture(image); texture.needsUpdate = true; ``` ### Data Texture Create texture from raw data. ```javascript // Create gradient texture const size = 256; const data = new Uint8Array(size * size * 4); for (let i = 0; i < size; i++) { for (let j = 0; j < size; j++) { const index = (i * size + j) * 4; data[index] = i; // R data[index + 1] = j; // G data[index + 2] = 128; // B data[index + 3] = 255; // A } } const texture = new THREE.DataTexture(data, size, size); texture.needsUpdate = true; ``` ### Canvas Texture ```javascript const canvas = document.createElement("canvas"); canvas.width = 256; canvas.height = 256; const ctx = canvas.getContext("2d"); // Draw on canvas ctx.fillStyle = "red"; ctx.fillRect(0, 0, 256, 256); ctx.fillStyle = "white"; ctx.font = "48px Arial"; ctx.fillText("Hello", 50, 150); const texture = new THREE.CanvasTextur