# How to load asset?

**URL:** <https://forum.8thwall.com/t/how-to-load-asset/2621>\
**Category:** Technical Support\
**Created:** [September 2, 2024, 5:26pm UTC](https://forum.8thwall.com/t/how-to-load-asset/2621 "2024-09-02T17:26:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Liuchuan\_Yu](https://avatars.discourse-cdn.com/v4/letter/l/eb9ed0/32.png) [@Liuchuan\_Yu](https://forum.8thwall.com/u/Liuchuan_Yu)\
**Post date:** [September 2, 2024, 5:26pm UTC](https://forum.8thwall.com/t/how-to-load-asset/2621/1 "2024-09-02T17:26:06Z")

</div>

I was trying to load the asset via the following code, but it didn’t work.

```auto
        const loader = new THREE.GLTFLoader()
        const gltf = loader.load('./assets/piano.glb')

```

The error message was `Error: fetch for "https://xxxxxxxxxxxxxxxxxxxxxx/assets/piano.glb" responded with 404: `.

Thanks

---

<div class="post-metadata">

**Author:** ![GeorgeButler](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/georgebutler/32/1903_2.png) [@GeorgeButler](https://forum.8thwall.com/u/GeorgeButler)\
**Post date:** [September 3, 2024, 3:56pm UTC](https://forum.8thwall.com/t/how-to-load-asset/2621/2 "2024-09-03T15:56:52Z")

</div>

Could you share a screenshot of your assets folder in the project? A capture of the entire editor window would be even more helpful.

---

<div class="post-metadata">

**Author:** ![Liuchuan\_Yu](https://avatars.discourse-cdn.com/v4/letter/l/eb9ed0/32.png) [@Liuchuan\_Yu](https://forum.8thwall.com/u/Liuchuan_Yu)\
**Post date:** [September 3, 2024, 4:13pm UTC](https://forum.8thwall.com/t/how-to-load-asset/2621/3 "2024-09-03T16:13:39Z")

</div>

Sure. Here it is.

 ![2024-09-03_121249](https://us1.discourse-cdn.com/flex019/uploads/x8thwall/original/1X/057e5db7c48d7a9dbb78d047e61119bf24c4b18d.png)

---

<div class="post-metadata">

**Author:** ![TonyT](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/tonyt/32/88_2.png) [@TonyT](https://forum.8thwall.com/u/TonyT)\
**Post date:** [September 3, 2024, 5:09pm UTC](https://forum.8thwall.com/t/how-to-load-asset/2621/4 "2024-09-03T17:09:29Z")

</div>

Have you tried wrapping the path to your asset in `require()`? That function maps the asset name to the actual location on CDN

e.g.

```auto
const gltf = loader.load(require('./assets/piano.glb'))

```

---

<div class="post-metadata">

**Author:** ![GeorgeButler](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/georgebutler/32/1903_2.png) [@GeorgeButler](https://forum.8thwall.com/u/GeorgeButler)\
**Post date:** [September 3, 2024, 5:43pm UTC](https://forum.8thwall.com/t/how-to-load-asset/2621/5 "2024-09-03T17:43:12Z")

</div>

You can use `ecs.assets.load()` as well, just pass in the asset path.

_I’ll edit this comment with the docs link once we get it published._

---

<div class="post-metadata">

**Author:** ![Liuchuan\_Yu](https://avatars.discourse-cdn.com/v4/letter/l/eb9ed0/32.png) [@Liuchuan\_Yu](https://forum.8thwall.com/u/Liuchuan_Yu)\
**Post date:** [September 3, 2024, 6:11pm UTC](https://forum.8thwall.com/t/how-to-load-asset/2621/6 "2024-09-03T18:11:07Z")

</div>

It returns “undefined”, so it seems failed.

---

<div class="post-metadata">

**Author:** ![Liuchuan\_Yu](https://avatars.discourse-cdn.com/v4/letter/l/eb9ed0/32.png) [@Liuchuan\_Yu](https://forum.8thwall.com/u/Liuchuan_Yu)\
**Post date:** [September 3, 2024, 6:28pm UTC](https://forum.8thwall.com/t/how-to-load-asset/2621/7 "2024-09-03T18:28:41Z")

</div>

Thanks for your suggestion. I tried but ended up not working.

Could you give a code snippet of getting the animations attribute from loading a glb model file?

---

<div class="post-metadata">

**Author:** ![Liuchuan\_Yu](https://avatars.discourse-cdn.com/v4/letter/l/eb9ed0/32.png) [@Liuchuan\_Yu](https://forum.8thwall.com/u/Liuchuan_Yu)\
**Post date:** [September 4, 2024, 2:34pm UTC](https://forum.8thwall.com/t/how-to-load-asset/2621/8 "2024-09-04T14:34:38Z")

</div>

Solved by myself.

```
   ecs.GltfModel.set(world, component.eid, {
        animationClip: animationName,
        loop: shouldLoop,
        paused: false,
      })

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/x8thwall/original/2X/9/9212a857458f1b03a6accb129e0f8cbea408e3e5.png) [@system](https://forum.8thwall.com/u/system)\
**Post date:** [September 8, 2024, 2:34pm UTC](https://forum.8thwall.com/t/how-to-load-asset/2621/9 "2024-09-08T14:34:50Z")

</div>

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.
