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

189
Visualizações
ThreeJS - Assigning Individual Colors to Lines in an Icosahedron Wireframe

I'm working on rendering an icosahedron wireframe using threejs and react-three/fiber. I'd like to be able to change the color of an individual line in the frame.

This is the code I have currently:

import { Canvas } from "@react-three/fiber";
import ReactDOM from "react-dom";

function Icosahedron(
  props: JSX.IntrinsicElements["mesh"] | JSX.IntrinsicElements["line"]
) {
  return (
    <Canvas style={{ width: "100vw", height: "100vh" }}>
      <ambientLight />
      <pointLight position={[10, 10, 10]} />
      <mesh position={[0, 0, 0]}>
        <icosahedronGeometry args={[2, 1]} />
        <meshStandardMaterial
          wireframe={true}
          color="black"
          wireframeLinewidth={10}
        />
      </mesh>
    </Canvas>
  );
}

ReactDOM.render(<Icosahedron />, document.getElementById("root"));

Which produces the following result: Icosahedron where all line colors are the same.

What I'm looking for is this: Icosahedron where one line is a different color (blue).

I've tried the following:

  1. Rendering the wireframe through the LineSegments geometry, and providing an array of materials instead of a single one. This just ends up with a blank canvas and no console error output.

  2. Binding a ref to the icosahedronGeometry, accessing the position attribute and rendering another line to cover the wireframe line. This seems bulky and inefficient.

Is there a simple way to change the colors of the lines individually?

about 4 years ago · Juan Pablo Isaza
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