threejs-textures
Skill2 starsChanged 21 days agoMITView on GitHub
Three.js textures: image loading, color spaces, UV channels and transforms, texture types from canvas to HDR and KTX2, render targets, texture memory. Use when working with images on materials, UV coordinates, cubemaps, render targets or texture optimization; on WebGL or with WebGPU and TSL.
24 other projects use a version of this, 18 of them edited; 16 of 16 edited versions we compared changed its rules.
How people change it
16 of 16 edited versions changed its rules, and some changes recur.
Of the 16 edited versions we compared: 16 made changes of their own.
Rules people drop
- Do not run a loaded equirect file through PMREMGenerator "for better reflections" — direct assignment with
mappingset produces the same prefiltering.dropped by 16 of 16
Rules people add
- A rule we can't quote: its licence doesn't allow itadded by 16 of 16
We split this file and each edited version into the rules they give an agent and match them by wording. A version that adds no rule of its own and has not changed since this file last did reads as an older text, so what it lacks is not counted as dropped. We keep no past texts of a file, so that is inferred, and an edited version that started from an older text still counts its gaps as drops.
Adopted by
Most recently taken up by
- gromov0737/skillsedited, first seen Nov 29, 2026
- mrrajrumel/claude-video-skillsedited, first seen Nov 29, 2026
- SnoozleStudio/opencode-wp-settingsedited, first seen Nov 15, 2026
- calesthio/OpenMontageedited, first seen Nov 9, 2026
- DaraBoth/skilljmskillword for word, first seen Nov 8, 2026
- OpenMontageInc/OpenMontageedited, first seen Nov 8, 2026
Used with
Projects with it also use bfl-api, flux-best-practices and 7 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
LinHao-citySkillbfl-api
BFL FLUX API integration guide covering endpoints, async polling patterns, rate limiting, error handling, webhooks, and regional endpoints with Python and TypeScript code examples.
Also in 3 projects that use this
LinHao-citySkillflux-best-practices
Comprehensive guide for BFL FLUX image generation models. Covers prompting, T2I, I2I, structured JSON, hex colors, typography, multi-reference editing, and model-specific best practices for FLUX.2 and FLUX.1 families.
Also in 3 projects that use this
jaron-goh-centrSkillwebsite-to-video
Capture a general website/URL and turn it into a video OF the site — tour, showcase, or social clip built from captured screenshots and the site's own brand assets. Use for portfolio / blog / docs / landing-page showcases. Not a product launch or promo, even from a URL (/product-launch-video). Unclear → /hyperframes.
Also in 4 projects that use this
- +6 more from LinHao-city
Other versions24 projects use a version of this.
Word for word · 2
- CloudAI-X/threejs-skills★ 3.7k100% same
- DaraBoth/skilljmskill★ 8100% same
Edited · 18
- calesthio/OpenMontage★ 84k11% same
- OpenMontageInc/OpenMontage★ 84k11% same
- educlopez/thegridcn-ui★ 40111% same
- quiet-node/gesture-lab★ 18511% same
- codetesla51/skills★ 3211% same
- ruloCode/hermes-os★ 1711% same
- LinHao-city/StoryMind★ 1011% same
- SnoozleStudio/opencode-wp-settings★ 411% same
- chadixearth/graphyloop★ 311% same
- Adhamxon/claude-code-skills★ 210% same
8 more not listed
Wrote their own version · 4
- kumaran-is/claude-code-onboarding★ 35same name
- full-stack-skills/threejs-skills★ 9same name
- ai4brands-design/claude-skills★ 2same name
- Gopyr/gopyr-skills-hub★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository108 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/composition-patterns/AGENTS.mdAGENTS.md
- skills/react-best-practices/AGENTS.mdAGENTS.md
- skills/react-view-transitions/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- skills/master-developer/references/CLAUDE.mdCLAUDE.md
- agent-fabricSkill
- api-anythingSkill
- creator-security-automationSkill
- feature-implementationSkill
- omniroute-free-llm-routingSkill
- repository-auditSkill
- security-reviewSkill
- unslopSkill
- youtube-studioSkill
- agent-developmentSkill
- agent-fabricSkill
- agent-security-hardeningSkill
- algorithmic-artSkill
- api-anythingSkill
- api-designSkill
- backend-patternsSkill
- brand-guidelinesSkill
- build-mcp-appSkill
- build-mcpbSkill
- build-mcp-serverSkill
- canvas-designSkill
- claude-apiSkill
- claude-md-improverSkill
- coding-standardsSkill
- command-developmentSkill
- vercel-composition-patternsSkill
- creator-security-automationSkill
- database-migrationsSkill
- deployment-patternsSkill
- dispatching-parallel-agentsSkill
- docker-patternsSkill
- e2e-testingSkill
- executing-plansSkill
- finishing-a-development-branchSkill
- frontend-a11ySkill
- frontend-designSkill
- frontend-patternsSkill
- hook-developmentSkill
- master-developerSkill
- mcp-builderSkill
- mcp-dependency-reviewSkill
- mcp-integrationSkill
- mdcp-self-checkSkill
- mdcp-token-meterSkill
- nextjs-turbopackSkill
- omniroute-free-llm-routingSkill
- plugin-settingsSkill
- plugin-structureSkill
- postgres-patternsSkill
- prisma-patternsSkill
- vercel-react-best-practicesSkill
- vercel-react-view-transitionsSkill
- receiving-code-reviewSkill
- replica-architectSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 20 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 267
Do not run a loaded equirect file through PMREMGenerator "for better reflections" — direct assignment with mapping set produces the same …
“Common” is measured: kept by at least 6 in 10 of the 20 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Three.js Textures
Targets three.js r186. Examples use WebGLRenderer; the WebGPU and TSL section uses WebGPURenderer.
Quick Start
import * as THREE from "three";
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();
const camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 100);
camera.position.set(0, 0, 2);
// Color images must be tagged sRGB or they render too bright and washed out
const texture = new THREE.TextureLoader().load("diffuse.jpg");
texture.colorSpace = THREE.SRGBColorSpace;
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(2, 2),
new THREE.MeshBasicMaterial({ map: texture }),
);
scene.add(mesh);
renderer.setAnimationLoop(animate);
function animate() {
mesh.rotation.z += 0.01;
renderer.render(scene, camera);
}Loading
// load() returns the texture at once; its image arrives asynchronously
const texture = new THREE.TextureLoader().load("diffuse.jpg");
texture.colorSpace = THREE.SRGBColorSpace;
mesh.material.map = texture; // before the first render; afterwards also set mesh.material.needsUpdate = true
// When the next step needs the loaded image, await it
const colorMap = await new THREE.TextureLoader().loadAsync("diffuse.jpg");
colorMap.colorSpace = THREE.SRGBColorSpace;TextureLoader's onProgress parameter is unsupported and never fires; a LoadingManager reports progress as each file finishes:
const manager = new THREE.LoadingManager();
manager.onProgress = (url, loaded, total) => console.log(`${loaded}/${total}: ${url}`);
const loader = new THREE.TextureLoader(manager);Color Space
Color management is on by default and every texture starts at NoColorSpace:
- LDR color images get
SRGBColorSpace:map,emissiveMap,specularMap, sheen color and specular color maps, LDR matcaps, and canvas or video used as color. - Scalar data keeps
NoColorSpace: normal, bump, displacement, roughness, metalness, ambient-occlusion and alpha maps. - HDR environments are
LinearSRGBColorSpace; the HDR loaders set that themselves. GLTFLoader sets the color spaces of the textures it loads.
const colorMap = new THREE.TextureLoader().load("color.jpg");
colorMap.colorSpace = THREE.SRGBColorSpace; // authored color image
const normalMap = new THREE.TextureLoader().load("normal.jpg");
// normalMap stays at NoColorSpace: it is data, not colorTransform: Wrap, Repeat, Offset, Rotation
const texture = new THREE.TextureLoader().load("diffuse.jpg");
// Tiling requires repeat wrapping; the default clamps edge pixels
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set(4, 4); // tile 4x4
texture.offset.set(0.5, 0.5); // shift in UV units
texture.center.set(0.5, 0.5); // pivot for rotation
texture.rotation = Math.PI / 4; // radiansMirroredRepeatWrapping tiles with a mirror flip on each repeat.
Filtering, Mipmaps, Anisotropy
const texture = new THREE.TextureLoader().load("diffuse.jpg");
// Minification (many texture pixels per screen pixel)
texture.minFilter = THREE.LinearMipmapLinearFilter; // default: trilinear blend between mip levels
texture.minFilter = THREE.NearestFilter; // hard pixel look, samples only the base level
// Magnification (texture magnified on screen)
texture.magFilter = THREE.LinearFilter; // default
texture.magFilter = THREE.NearestFilter; // pixelated
// Mipmaps are generated whenever generateMipmaps is true, whatever the filters.
// Turn generation off to save memory (UI sprites, data textures):
texture.generateMipmaps = false;
texture.minFilter = THREE.LinearFilter; // and do not request a mipmap filter
// Sharper at grazing angles; clamp to what the hardware supports
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();Texture Types
Base class from any image element:
const image = new Image();
image.src = "sprite.png";
const imageTexture = new THREE.Texture(image);
imageTexture.colorSpace = THREE.SRGBColorSpace;
image.onload = () => (imageTexture.needsUpdate = true); // upload once the pixels existDataTexture from raw typed-array pixels. Its defaults differ from Texture: NearestFilter for both filters, flipY false, mipmaps off:
const size = 256;
const data = new Uint8Array(size * size * 4); // RGBA, one byte per channel
for (let i = 0; i < size; i++) {
for (let j = 0; j < size; j++) {
const index = (i * size + j) * 4;
data[index] = i;
data[index + 1] = j;
data[index + 2] = 128;
data[index + 3] = 255;
}
}
const dataTexture = new THREE.DataTexture(data, size, size);
dataTexture.needsUpdate = true;CanvasTexture for dynamically drawn textures (sets needsUpdate on construction):
const canvas = document.createElement("canvas");
canvas.width = 256;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#404040";
ctx.fillRect(0, 0, 256, 256);
ctx.fillStyle = "#ffffff";
ctx.font = "48px sans-serif";
ctx.fillText("Hello", 40, 150);
const canvasTexture = new THREE.CanvasTexture(canvas);
canvasTexture.colorSpace = THREE.SRGBColorSpace; // canvas colors are sRGB
// after each redraw of the canvas:
canvasTexture.needsUpdate = true;VideoTexture for a playing HTMLVideoElement (re-uploads every frame, mipmaps off):
const video = document.createElement("video");
video.src = "video.mp4";
video.loop = true;
video.muted = true;
video.play();
const videoTexture = new THREE.VideoTexture(video);
videoTexture.colorSpace = THREE.SRGBColorSpace;VideoFrameTexture for WebCodecs: each decoded frame is pushed by hand:
const frameTexture = new THREE.VideoFrameTexture();
frameTexture.colorSpace = THREE.SRGBColorSpace;
const decoder = new VideoDecoder({
output(frame) {
if (frameTexture.image instanceof VideoFrame) frameTexture.image.close(); // free the replaced frame, or decoding stalls
frameTexture.setFrame(frame);
},
error: (e) => console.error(e),
});HTMLTexture draws an HTML element through the browser's HTML-in-Canvas API: the renderer moves the element into its own canvas and re-uploads it on paint events; where the browser lacks that API the texture stays empty.
Compressed Textures (KTX2)
import { KTX2Loader } from "three/addons/loaders/KTX2Loader.js";
const ktx2Loader = new KTX2Loader();
// No setTranscoderPath call: the transcoder loads from the three package.
// Set one only when self-hosting the decoders, pinned to this release.
ktx2Loader.detectSupport(renderer); // required before loading; works with both renderers
const compressedMap = await ktx2Loader.loadAsync("diffuse.ktx2");
// colorSpace comes from the file's transfer function; nothing to set by handBasis Universal KTX2 transcodes to a compressed format the GPU supports: smaller uploads and less memory than PNG or JPEG, which upload uncompressed (where the GPU supports none of the targets, KTX2Loader also falls back to uncompressed RGBA). Compressed textures cannot be flipped or mipmapped at upload: flipY stays false, so author the file in the orientation your UVs expect, and mipmaps must be embedded in the file.
Environment Maps
Cube maps (the loader tags the result sRGB itself):
const cubeTexture = new THREE.CubeTextureLoader().load([
"px.jpg", "nx.jpg", // +X, -X
"py.jpg", "ny.jpg", // +Y, -Y
"pz.jpg", "nz.jpg", // +Z, -Z
]);
scene.background = cubeTexture;
scene.environment = cubeTexture; // lights Standard and Physical materials (WebGLRenderer also Lambert and Phong)HDR equirectangular files — set mapping, then assign; both renderers prefilter the environment themselves:
import { HDRLoader } from "three/addons/loaders/HDRLoader.js";
const env = await new HDRLoader().loadAsync("environment.hdr");
env.mapping = THREE.EquirectangularReflectionMapping; // without it the background draws as a flat screen quad
scene.environment = env;
scene.background = env;EXRLoader (three/addons/loaders/EXRLoader.js) loads .exr files the same way and UltraHDRLoader loads Ultra HDR JPEGs; both set their own linear color space.
Scene-level controls:
scene.environmentIntensity = 0.5; // dim the image-based lighting
scene.environmentRotation.y = Math.PI / 4;
scene.backgroundBlurriness = 0.5; // 0-1
scene.backgroundIntensity = 1.0;
scene.backgroundRotation.y = Math.PI;Both renderers convert an equirectangular environment into a cube map with a larger texture internally (better sampling, more memory); when memory matters, ship a lower-resolution equirect file.
PMREMGenerator is for generated environments — a scene such as RoomEnvironment captured with fromScene:
import { RoomEnvironment } from "three/addons/environments/RoomEnvironment.js";
const pmrem = new THREE.PMREMGenerator(renderer);
const room = new RoomEnvironment();
scene.environment = pmrem.fromScene(room, 0.04).texture;
room.dispose(); // frees the room's geometries and materials
pmrem.dispose();Do not run a loaded equirect file through PMREMGenerator "for better reflections" — direct assignment with mapping set produces the same prefiltering.
Render Targets
const renderTarget = new THREE.WebGLRenderTarget(512, 512);
const rtScene = new THREE.Scene(); // must not contain the mesh that samples the target
rtScene.add(new THREE.Mesh(new THREE.BoxGeometry(), new THREE.MeshNormalMaterial())); // unlit, visible without lights
renderer.setRenderTarget(renderTarget);
renderer.render(rtScene, camera);
renderer.setRenderTarget(null); // back to the canvas
// the output is a texture like any other
mesh.material.map = renderTarget.texture;Depth buffer as a texture:
const depthTarget = new THREE.WebGLRenderTarget(512, 512);
depthTarget.depthTexture = new THREE.DepthTexture(512, 512); // default type UnsignedIntTypeMSAA and multiple attachments:
// MSAA: resolved into .texture automatically after rendering
const msaaTarget = new THREE.WebGLRenderTarget(512, 512, { samples: 4 });
// MRT: N color attachments, read back through .textures
const mrtTarget = new THREE.WebGLRenderTarget(512, 512, { count: 2 });
const firstAttachment = mrtTarget.textures[0];
const secondAttachment = mrtTarget.textures[1];Dynamic Reflections
const cubeRenderTarget = new THREE.WebGLCubeRenderTarget(256, {
generateMipmaps: true,
minFilter: THREE.LinearMipmapLinearFilter,
});
const cubeCamera = new THREE.CubeCamera(0.1, 1000, cubeRenderTarget);
scene.add(cubeCamera);
mesh.material.envMap = cubeRenderTarget.texture;
// each frame: hide the reflective mesh so it does not see itself
mesh.visible = false;
cubeCamera.position.copy(mesh.position);
cubeCamera.update(renderer, scene);
mesh.visible = true;UV Channels
Every UV-mapped material texture samples the UV attribute chosen by texture.channel: 0 reads uv (the default), 1 reads uv1, 2 reads uv2, 3 reads uv3. So aoMap and lightMap work on the default uv set; a separately unwrapped set goes in uv1 with the texture pointed at it:
const aoTexture = new THREE.TextureLoader().load("ao.jpg");
const geometry = new THREE.BoxGeometry(1, 1, 1);
const uvAttribute = geometry.attributes.uv;
const aoUvs = new Float32Array(uvAttribute.count * 2); // fill with the second unwrap
geometry.setAttribute("uv1", new THREE.BufferAttribute(aoUvs, 2));
const material = new THREE.MeshStandardMaterial({ aoMap: aoTexture });
material.aoMap.channel = 1; // sample "uv1" instead of "uv"
const aoMesh = new THREE.Mesh(geometry, material);
scene.add(aoMesh);Texture Atlas
One image, many sprites, each selected with offset and repeat:
const atlas = await new THREE.TextureLoader().loadAsync("atlas.png");
atlas.colorSpace = THREE.SRGBColorSpace;
// filtering and mipmaps sample across sprite borders: leave padding around each sprite
// one clone per sprite: clones share the image source, so WebGLRenderer uploads it once
function spriteTexture(row, col, gridSize = 2) {
const sprite = atlas.clone();
sprite.offset.set(col / gridSize, 1 - (row + 1) / gridSize);
sprite.repeat.set(1 / gridSize, 1 / gridSize);
return sprite;
}
mesh.material.map = spriteTexture(0, 0); // top-left sprite of a 2x2 sheetStandard Material Slots
Channel conventions worth knowing: aoMap reads red, roughnessMap reads green, metalnessMap reads blue (so one packed occlusion-roughness-metalness image works); alphaMap reads green.
const colorMap = new THREE.TextureLoader().load("color.jpg");
const emissiveMap = new THREE.TextureLoader().load("emissive.jpg");
const normalMap = new THREE.TextureLoader().load("normal.jpg");
colorMap.colorSpace = THREE.SRGBColorSpace;
emissiveMap.colorSpace = THREE.SRGBColorSpace;
// normalMap keeps NoColorSpace, as do roughness, metalness, ao, alpha and displacement maps
const material = new THREE.MeshStandardMaterial({
map: colorMap,
normalMap: normalMap,
normalScale: new THREE.Vector2(1, 1),
emissiveMap: emissiveMap,
emissive: 0xffffff, // non-black, so the emissive map contributes
roughness: 1, // scalar multipliers for the matching maps
metalness: 0,
});
material.aoMap = new THREE.TextureLoader().load("ao.jpg");
material.aoMapIntensity = 1;alphaMap takes effect with transparent: true (blended) or alphaTest (cut out); displacementMap scales with displacementScale and displacementBias and wants a subdivided mesh; normalMapType defaults to TangentSpaceNormalMap, set ObjectSpaceNormalMap for object-space normal maps.
Disposal and Memory
texture.dispose() frees the GPU upload once no other undisposed texture shares it (the atlas clones above share one); the image object remains. Dispose only textures that no other material still uses:
function disposeMaterial(material) {
for (const key of Object.keys(material)) {
const value = material[key];
if (value && value.isTexture) {
value.dispose();
}
}
material.dispose();
}console.log(renderer.info.memory.textures); // texture count currently on the GPU
console.log(renderer.capabilities.maxTextureSize); // largest supported dimensionShare one texture instance across materials rather than loading per mesh. Non-power-of-two sizes are fine: WebGL 2 supports mipmaps and repeat wrapping on them.
WebGPU and TSL
import * as THREE from "three/webgpu";
import { texture, uv } from "three/tsl";
const renderer = new THREE.WebGPURenderer({ antialias: true });
await renderer.init(); // before any other use of the renderer
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x111111); // the WebGPU canvas starts transparent
const camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 100);
camera.position.set(0, 0, 2);
const map = new THREE.TextureLoader().load("diffuse.jpg");
map.colorSpace = THREE.SRGBColorSpace;
map.anisotropy = renderer.getMaxAnisotropy(); // no capabilities object under WebGPU
const mesh = new THREE.Mesh(new THREE.PlaneGeometry(2, 2), new THREE.MeshBasicNodeMaterial());
mesh.material.colorNode = texture(map, uv().mul(0.5).add(0.25)); // custom UV transform in TSL: the center half, zoomed 2x
scene.add(mesh);
renderer.setAnimationLoop(animate);
function animate() {
mesh.rotation.z += 0.01;
renderer.render(scene, camera);
}TSL sampling: texture(map) uses uv() plus the texture's own offset/repeat/rotation; an explicit node takes over the coordinates entirely. The classic slots (map, normalMap, roughnessMap, aoMap) work unchanged on node materials; colorNode is for custom sampling.
import * as THREE from "three/webgpu";
import { texture, uv } from "three/tsl";
const map = new THREE.TextureLoader().load("diffuse.jpg");
map.colorSpace = THREE.SRGBColorSpace;
mesh.material.colorNode = texture(map); // uv() plus the texture's offset/repeat/rotation
mesh.material.colorNode = texture(map, uv(1)); // explicit node: samples the "uv1" attributeKTX2Loader.detectSupport(renderer) queries device features, so call it after await renderer.init(). For dynamic reflections use CubeRenderTarget (not WebGLCubeRenderTarget) with the same hide-update-show CubeCamera pattern.
import * as THREE from "three/webgpu";
const cubeRenderTarget = new THREE.CubeRenderTarget(256); // replaces WebGLCubeRenderTarget
const cubeCamera = new THREE.CubeCamera(0.1, 1000, cubeRenderTarget);
scene.add(cubeCamera);
mesh.material.envMap = cubeRenderTarget.texture;
mesh.visible = false; // hide so the mesh does not reflect itself
cubeCamera.position.copy(mesh.position);
cubeCamera.update(renderer, scene);
mesh.visible = true;Common Mistakes
geometry.setAttribute("uv2", geometry.attributes.uv)→material.aoMap = aoTexture;: aoMap samples the attribute picked bytexture.channel(default 0,uv), so it needs no extra attribute anduv2is read only by textures whosechannelis 2; only a separate baked unwrap goes inuv1, withaoTexture.channel = 1.new RGBELoader()→new HDRLoader(): renamed from RGBELoader to HDRLoader in r180; the old class still runs but logs a deprecation warning.import { EXRLoader } from "three/examples/jsm/loaders/EXRLoader.js"→import { EXRLoader } from "three/addons/loaders/EXRLoader.js": the browser import maps mapthree/addons/to examples/jsm/ and define nothree/examples/key, so the examples path fails to resolve there.texture.encoding = THREE.sRGBEncoding→texture.colorSpace = THREE.SRGBColorSpace:encodingand thesRGBEncodingconstant were removed;colorSpacereplaced them.const texture = loader.load("color.jpg")→const texture = loader.load("color.jpg"); texture.colorSpace = THREE.SRGBColorSpace;: an LDR color image left atNoColorSpacerenders too bright and washed out.texture.minFilter = THREE.LinearFilter; // no mipmaps→texture.generateMipmaps = false;: mipmaps are generated whenevergenerateMipmapsis true, whatever the filter, so LinearFilter alone still uploads them.texture.generateMipmaps = false; texture.wrapS = THREE.ClampToEdgeWrapping; // non-power-of-two size→texture.wrapS = THREE.RepeatWrapping;: WebGL 2 supports mipmaps and repeat wrapping on non-power-of-two textures, so nothing has to be disabled for them.texture.anisotropy = renderer.capabilities.getMaxAnisotropy()→texture.anisotropy = renderer.getMaxAnisotropy(): WebGPURenderer has nocapabilitiesobject; this is the call under WebGPU.material.envMapIntensity = 0.5→scene.environmentIntensity = 0.5:envMapIntensityscales only the material's ownenvMap, notscene.environment.scene.environment = pmrem.fromEquirectangular(hdr).texture→hdr.mapping = THREE.EquirectangularReflectionMapping; scene.environment = hdr;: the renderer prefilters an equirectangular environment itself, so manual PMREM of a loaded file adds nothing.scene.background = hdr→hdr.mapping = THREE.EquirectangularReflectionMapping; scene.background = hdr;: withoutmapping, an equirectangular texture draws as a flat screen-space quad instead of a surround.ktx2Loader.detectSupportAsync(renderer)→await renderer.init(); ktx2Loader.detectSupport(renderer);: the async variant was deprecated in r181, and support detection needs the initialized device.ktx2Loader.setTranscoderPath("libs/basis/")→const ktx2Loader = new KTX2Loader(); ktx2Loader.detectSupport(renderer);: the transcoder loads from the package, so a path is only needed when self-hosting, pinned to three@0.186.0.new THREE.WebGLMultipleRenderTargets(width, height, 2)→new THREE.WebGLRenderTarget(width, height, { count: 2 }): removed in r162; the attachments arerenderTarget.textures[0..count-1].new THREE.WebGLCubeRenderTarget(256)→new THREE.CubeRenderTarget(256): under WebGPURenderer useCubeRenderTargetimported fromthree/webgpu;WebGLCubeRenderTargetis WebGL-only.loader.load(url, onLoad, onProgress, onError)→manager.onProgress = (url, loaded, total) => console.log(url, loaded, total): TextureLoader'sonProgressparameter is unsupported and never fires.mesh.material.map = texture; // after the mesh has rendered→mesh.material.map = texture; mesh.material.needsUpdate = true;: WebGLRenderer builds a material's shader for the maps it has at its first render, so amapadded later stays invisible until the shader is rebuilt, whichneedsUpdateforces.normalMap.colorSpace = THREE.LinearSRGBColorSpace→normalMap.colorSpace = THREE.NoColorSpace: normal, roughness, metalness, ao, alpha and displacement maps hold data, not color, so they keep the defaultNoColorSpace.const texture = await new Promise((resolve, reject) => loader.load(url, resolve, undefined, reject))→const texture = await loader.loadAsync(url):loadAsyncis that promise, built into theLoaderbase class.cubeCamera.update(renderer, scene)→mesh.visible = false; cubeCamera.update(renderer, scene); mesh.visible = true;: while visible, the reflective mesh is drawn into the cube map that its ownenvMapreads.
See Also
threejs-materials— material properties, blending, and physical materials beyond texture slots.threejs-loaders— loading managers, glTF models, and the loader family generally.threejs-shaders— custom GLSL texture sampling under WebGLRenderer.threejs-lighting— environment lighting and light units.threejs-asset-pipeline— encoding a model's textures to KTX2, WebP or AVIF with gltf-transform.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

