Capítulo 830 de 859
A tour of three.js's material family, from unlit MeshBasicMaterial up through physically-based MeshPhysicalMaterial, and the general rule that more realistic materials cost more GPU time.
MeshBasicMaterial (unlit) → MeshLambertMaterial (per-vertex lighting) → MeshPhongMaterial (per-pixel lighting + specular) → MeshStandardMaterial (PBR: roughness/metalness) → MeshPhysicalMaterial (adds clearcoat), each step more expensive to render.MeshToonMaterial: like Phong but shaded via a small gradient map instead of smooth shading, giving a two-tone cartoon look.roughness/metalness (PBR materials): roughness (0–1) is the rough-vs-shiny opposite of Phong's shininess; metalness (0–1) switches between metal and non-metal reflectance behavior.ShadowMaterial (inspecting shadow data), MeshDepthMaterial (renders per-pixel depth), MeshNormalMaterial (visualizes view-space normals as RGB), ShaderMaterial/RawShaderMaterial (custom shaders, with or without three.js's shader helpers).Material properties: flatShading (faceted vs. smooth, default false) and side (THREE.FrontSide by default; BackSide/DoubleSide for non-solid geometry like planes).material.needsUpdate = true: required after changing certain expensive-to-recompute settings (like toggling flatShading or switching a map on/off) after the material has already been used.material.color.set(0x00ffff);
material.color.set("purple");
material.color.set("rgb(255, 127, 64)");
material.color.setHSL(h, s, l); // h, s, l each 0 to 1
Color property.MeshBasicMaterial if you don't need lighting at all, up to MeshPhysicalMaterial only when you need clearcoat-level realism.MeshStandardMaterial/MeshPhysicalMaterial use roughness/metalness instead of Phong's shininess.side matters most for non-solid geometry like planes, where the back face would otherwise be invisible.material.needsUpdate = true after changing settings that require rebuilding the shader program (e.g. flatShading), or the change won't take effect.