Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

332
Visualizações
three.js - can't see through transparent merged geometry

can somebody help to understand why when merging the geometries of these boxes, I can't see through them correctly from some angles?

Blue are normal boxes, Orange are merged geometries. Using MeshLambertMaterial with an opacity of 0.5.

Thanks in advance

code: https://codesandbox.io/s/three-alpha-issue-bfdhk?file=/src/index.ts

screenshot: enter image description here

code fragment:

// create boxes and add them to the scene (right, blue)
const boxGeo = new BoxGeometry(0.1, 0.1, 0.1);
const mat = new MeshLambertMaterial({
  transparent: true,
  opacity: 0.5,
  color: "#4469BE"
});
const boxes = [
  [   0,    0,  0.1], [   0,    0, -0.1], [   0, 0.15,  0.1], [   0, 0.15, -0.1],
  [0.15,    0,  0.1], [0.15,    0, -0.1], [0.15, 0.15,  0.1], [0.15, 0.15, -0.1]
].map((v) => {
  const box = new Mesh(boxGeo, mat);
  box.position.fromArray(v);
  box.updateMatrix();
  return box;
});
const group = new Group();
group.position.x = 0.1;
group.add(...boxes);
scene.add(group);

// merge boxes and add them to the scene (left, orange)
// issue: you can't see through some merged boxes from some angles
const geos = boxes.map((m) => m.geometry.clone().applyMatrix4(m.matrix));
const geo = BufferGeometryUtils.mergeBufferGeometries(geos);
const mergeMat = mat.clone();
mergeMat.color = new Color("#fa6900");
const merge = new Mesh(geo, mergeMat);
merge.position.x -= 0.25;
scene.add(merge);

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You could set depthWrite: false or depthTest: false for the material.

const mat = new MeshLambertMaterial({
  transparent: true,
  opacity: 0.5,
  color: "#4469BE",
  depthWrite: false,
});

Came across the solution from a similar question with material transparency while overlapping with itself

A more detailed explanation of the difference between both is provided here: https://stackoverflow.com/a/37651610/4290781

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda