Capítulo 850 de 859
Basic transparency (transparent: true + opacity) is easy, but correct-looking transparency is hard: three.js sorts whole objects back-to-front, not individual triangles, so overlapping or self-intersecting transparent geometry commonly shows visual artifacts with no single perfect fix.
material.transparent = true and material.opacity (1 = opaque, 0 = fully transparent).THREE.FrontSide, so a transparent cube appears to be missing its back faces unless side: THREE.DoubleSide is set.Meshes) back-to-front for transparency, but not individual triangles within one geometry (too slow) — so within a single mesh, triangles farther from the camera can still fail to draw behind nearer ones, causing missing/wrong-looking backfaces even with DoubleSide.BackSide-only material, once with FrontSide — relying on stable draw order between the two.alphaTest: pixels below the alpha threshold aren't drawn at all, sidestepping the depth-sorting problem entirely — works well for sharp-edged cutout textures (leaves, grass) but isn't a general transparency solution.const material = new THREE.MeshPhongMaterial({
map: texture,
transparent: true,
alphaTest: 0.5,
side: THREE.DoubleSide,
});
alphaTest with transparent/DoubleSide so a cutout texture (e.g. a tree/leaf sprite) skips drawing fully-transparent pixels, avoiding depth-sort artifacts for sharp-edged alpha content.transparent: true + opacity is easy but incomplete — you'll also usually need side: THREE.DoubleSide to see backfaces at all.alphaTest avoids the sorting problem entirely for sharp cutout textures by not drawing below-threshold pixels at all, at the cost of hard (not soft) edges.