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

207
Visualizações
Is there a way to insert html elements inside of a 3D image rendered using Three.js?
Framework used: React
3D Image: glb/gltf format
Rendered using: three.js packages
Mission: To insert a number to each of the object and display it above them 

Approach: I have tried to get the canvas element and then add a text using

    var parentofCanvas = document.getElementById("untitled.glb");
    var childCanvas = parentofCanvas.firstChild;
    var context = childCanvas.getContext("webgl");
    console.log(childCanvas);
    console.log(parentofCanvas.firstChild.nodeName);
    console.log(context);
    // var text = "Howdy World!";
    // context.font = "25px Arial";
    // context.fillStyle = "red";
    // var x = 50;
    // var y = 100;
    // context.fillText(text, x, y);
  }, []);

where x and y are the coordinates. I am getting an error saying fillText is not a function. So,what did I miss? Is there any other way to insert/render html elements in a 3D canvas image?

Link to codesandbox: https://codesandbox.io/s/dreamy-lichterman-lbb4z?file=/src/Test.js

(FYI: This is a forked project of dreamy-lichterman)

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

0

There is a Html Component in @react-three/drei which can be used to insert HTMl elements inside. Below is the link to the sandbox with the same example and explanation(comments): https://codesandbox.io/s/embed-html-3d-63uep?file=/src/Test.js

Documentation can be found at: https://github.com/pmndrs/drei#html

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