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

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