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

113
Views
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
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!