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

175
Visualizações
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
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