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

158
Views
ThreeJS returning undefined whenever I try to get a value from UserData

Ive spent so long trying to figure out why I can't get a value from UserData. I think my code works fine, but I'm just lost.

The raycast code is pretty simple.

const interactIntersects = raycaster.intersectObjects( flags, true );

if (interactIntersects.length > 0)
{
  console.log(interactIntersects[0].object.userData.id);
}

I can't figure out why it keeps giving me the undefined value. I was thinking it mightve been the insertion of the data itself, but when I checked it returned the values. (Checking in the place where its being created)

export function createFlag(flag_id, web, desc, x, y, z, orx, ory, orz)
{
  const fbxLoader = new FBXLoader()
  fbxLoader.load('flag.fbx', (object) => 
  {
    object.scale.set(.003, .003, .005);
    scene.add(object)
    object.position.set(x, y, z)
    object.rotation.set(orx, ory, orz);
    object.userData = { id: flag_id };
    console.log(object.userData.id);
    flags.push(object);
  }); 

  createModal(flag_id, web, desc);
}

Can anyone help? Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Found out you cannot set userData to Imported objects.

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