# \[SOLVED\] Detecting engine model loads/unloads?

**URL:** <https://forum.playcanvas.com/t/solved-detecting-engine-model-loads-unloads/26331>\
**Category:** Help & Support\
**Created:** [June 26, 2022, 1:47pm UTC](https://forum.playcanvas.com/t/solved-detecting-engine-model-loads-unloads/26331 "2022-06-26T13:47:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Newbie\_Coder](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/newbie_coder/32/21065_2.png) [@Newbie\_Coder](https://forum.playcanvas.com/u/Newbie_Coder)\
**Post date:** [June 26, 2022, 1:47pm UTC](https://forum.playcanvas.com/t/solved-detecting-engine-model-loads-unloads/26331/1 "2022-06-26T13:47:57Z")

</div>

Hi there, currently I’m using simple variable to determine if model finished loading as:

```javascript
var modelLoads = true
//Some code where external models are loaded or unloaded etc
var modelLoads = false

```

I have to share it trough several script files and well, I feel like it’s not the best way to do it, any smarter/built-in solutions to this? Thanks

---

<div class="post-metadata">

**Author:** ![Leonidas](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/leonidas/32/6495_2.png) [@Leonidas](https://forum.playcanvas.com/u/Leonidas)\
**Post date:** [June 26, 2022, 2:48pm UTC](https://forum.playcanvas.com/t/solved-detecting-engine-model-loads-unloads/26331/2 "2022-06-26T14:48:03Z")

</div>

Hi @Newbie_Coder,

All assets have a loaded property which indicates if they are loaded or not:

```javascript
asset.loaded;

```

You can also subscribe to the following event to get a callback at the exact time an asset will finish loading and it will be ready:

```javascript
asset.ready ( () => {
   console.log('I am ready! Asset name: ' + asset.name);
});

```

---

<div class="post-metadata">

**Author:** ![Newbie\_Coder](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/newbie_coder/32/21065_2.png) [@Newbie\_Coder](https://forum.playcanvas.com/u/Newbie_Coder)\
**Post date:** [June 26, 2022, 3:21pm UTC](https://forum.playcanvas.com/t/solved-detecting-engine-model-loads-unloads/26331/3 "2022-06-26T15:21:32Z")

</div>

Hmm, still not quite getting result I was expecting, what about lag/freeze end after asset has been applied to the world? Thanks

---

<div class="post-metadata">

**Author:** ![Leonidas](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/leonidas/32/6495_2.png) [@Leonidas](https://forum.playcanvas.com/u/Leonidas)\
**Post date:** [June 26, 2022, 3:23pm UTC](https://forum.playcanvas.com/t/solved-detecting-engine-model-loads-unloads/26331/4 "2022-06-26T15:23:08Z")

</div>

That’s the materials compiling their shaders most likely.

---

<div class="post-metadata">

**Author:** ![Newbie\_Coder](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/newbie_coder/32/21065_2.png) [@Newbie\_Coder](https://forum.playcanvas.com/u/Newbie_Coder)\
**Post date:** [June 27, 2022, 5:39am UTC](https://forum.playcanvas.com/t/solved-detecting-engine-model-loads-unloads/26331/5 "2022-06-27T05:39:19Z")

</div>

I think we can mark this as solved, thank you @Leonidas
