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

122
Vistas
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 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