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

159
Visualizações
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 Respostas
Responde à pergunta

0

Found out you cannot set userData to Imported objects.

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