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

127
Visualizações
three.interact: mesh vs scene issue

i'm using THREE.js to load a .gltf mesh into my scene.

when i load the mesh, i set a variable's value to scene.gltf in the loading sequence.

loader.load(
'donut.gltf',
function ( gltf ) {
    donut = gltf.scene;
    scene.add( gltf.scene );
},

this works, and i'm able to reference that variable to rotate my mesh.

function animation(time) { 
    donut.rotation.x = time / 2000;
    donut.rotation.y = time / 1000;
    renderer.render(scene, camera);
}

however, when i try to use three.interact to detect a mouseover event,

donut.on('mousemove', function(ev) {
        console.log(ev);
    });

i get the error:

gltf.html:87 Uncaught TypeError: Cannot read properties of undefined (reading 'on')

if i declare donut as a THREE.Mesh before i assign the mesh to it, the error goes away, and so does the functionality of the mouseover function. if i change my donut variable to scene instead, i get basically my intended output, but if there is anything else in the scene, it triggers the event as well.

how do i reference only my intended mesh, and call the mouseover function with three.interact?

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