Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

125
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!