title: How do I make my gltf loader synchronous in three.js?
body: <p>Here's my code, I'm trying to make the <code>loadCone()</code> synchronous with await/async but it isn't working.</p>
  <pre><code>import * as THREE from &quot;three&quot;;
  
  import { GLTFLoader } from &quot;three/examples/jsm/loaders/GLTFLoader&quot;;
  
  import conePath from &quot;../../static/cone.glb&quot;;
  import coneBaked from &quot;../../static/coneBake.png&quot;;
  
  import &quot;regenerator-runtime/runtime&quot;;
  
  export default class Cone {
      constructor() {
          this.cone;
          const textureLoader = new THREE.TextureLoader();
  
          const bakedTexture = textureLoader.load(coneBaked);
          const bakedMaterial = new THREE.MeshBasicMaterial({
              map: bakedTexture,
          });
  
          this.loadCone();
      }
  
      async loadCone() {
          // GLTF loader
          const gltfLoader = new GLTFLoader();
          const cone = await gltfLoader.load(
              conePath,
              (gltf) =&gt; {
                  console.log(&quot;success&quot;);
                  console.log(gltf.scene);
                  this.cone = gltf.scene;
              },
              (progress) =&gt; {
                  // console.log(&quot;progress&quot;);
                  // console.log(progress);
              },
              (error) =&gt; {
                  console.log(&quot;error&quot;);
                  console.log(error);
              }
          );
      }
  
      getCone() {
          return this.cone;
      }
  }
  </code></pre>
  <p>In another file I have this:</p>
  <pre><code>const cone = new Cone();
  this.scene.add(cone.getCone());
  </code></pre>
  <p>However, because <code>getCone()</code> is synchronous, it executes before my <code>loadCone()</code> is done loading the cone, so I get <code>undefined</code> back instead of the cone.</p>
  <p>How do I make my function <code>asynch loadCone()</code> be synchronous? I tried *.loadAsync()` but it didn't change anything.</p>
  <p>Thanks in advance. I am getting no errors other than the fact it says &quot;undefined is not instance of THREE.Object.3d&quot; which I expected it to say.</p>