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

159
Views
Is there a way to access a GLTF model after it has been loaded?

I have loaded a model with GLTFLoader and I can use it normally with three.js inside the Loader method. However, I can't seem to access it from outside of it and I'm not sure why.

class Model {
  constructor(link) {
    this.link = link;
    this.gltfLoader = new GLTFLoader();
  }

  load() {
    this.gltfLoader.load(
      this.link,
      (gltf) => {
        scene.add(gltf.scene);
      }
    );
  }
}

const girl = new Model("/imported/girl/scene.gltf");

girl.load();

How can I access the gltf parameter from outside the loader?

I've tried setting a global value but It's not working because it's an async method and the value is always undefined. For example, I've setted a variable right before the class (let globalGLTF;), then, within the loader.load method, I assigned a global value (globalGLTF = gltf.scene;). When I call this variable from outside the method, it always returns undefined because the loader is async. I also think this isn't the best way of accessing it because I'm using a class to load the models. I'm trying to find a way where I can simply call something like girl.model and access the GLTF file. Is this possible?

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!