Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

134
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda