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

114
Visualizações
Cant access object from scene

I am having trouble accessing a object in my scene. I've figured out the reason I wasn't able to access it was because the Raytracer was loading before the world had finished loading. It works fine for objects added by code, but it doesn't work when looking for objects imported by GLTFLoader.

I have set up something to trigger an event when all the objects have been loaded. But I am unable to access the variable inside of the check in my update function.

    setRayCaster()
{
    this.rayCaster = new THREE.Raycaster()
    this.foundButton = this.main.scene.children.find(child => child.name === 'Test')
    this.objectsToTest = [this.main.scene.children.find(child => child.name === 'Test')]

    this.resources.on('ready', () =>
    {
        this.UNABLETOACCESSTHIS = this.scene.getObjectByName('Trackpad')
    })
}
update()
{
    this.rayCaster.setFromCamera(this.cursor, this.camera.view)
    this.intersects = this.rayCaster.intersectObject(this.foundButton)
    UNABLETOACCESSTHIS.here
    
    for(const object of this.objectsToTest)
    {
        object.material.color.set('#ff0000')
    }
    for(const intersect of this.intersects)
    {
        intersect.object.material.color.set('#0000ff')
    }
    // console.log(this.intersects)
 }
}
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