← ClaudeAtlas

threejs-textureslisted

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.
ahmedamin20/hmcv-ui-studio-public · ★ 0 · Web & Frontend · score 62
Install: claude install-skill ahmedamin20/hmcv-ui-studio-public
# Three.js Textures Targets three.js r186. Examples use WebGLRenderer; the WebGPU and TSL section uses WebGPURenderer. ## Quick Start ```javascript 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 ```javascript // 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; ```