# Freeze Active Meshes and instances

**URL:** <https://forum.babylonjs.com/t/freeze-active-meshes-and-instances/38897>\
**Category:** Questions\
**Created:** [March 9, 2023, 10:03pm UTC](https://forum.babylonjs.com/t/freeze-active-meshes-and-instances/38897 "2023-03-09T22:03:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stealman](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/stealman/32/340_2.png) [@stealman](https://forum.babylonjs.com/u/stealman)\
**Post date:** [March 9, 2023, 10:03pm UTC](https://forum.babylonjs.com/t/freeze-active-meshes-and-instances/38897/1 "2023-03-09T22:03:02Z")

</div>

Hello, in my scene I would like to utilize freezing of active meshes as it gives huge performance boost. Usually some “falsely rendered meshes” are cheaper, than analyzing of their activeness each frame.

But I run into big trouble when using instances - in my scene, most of the instances are moving and I am unable to make it work. Each time I create an Instance, it becomes “motionless” as well as the origin mesh that normally moved before.

Please take a look at this playground: [https://playground.babylonjs.com/#5APWUZ#1](https://playground.babylonjs.com/#5APWUZ#1) and just comment this **var box = BABYLON.MeshBuilder.CreateBox(“instancedBox”, {size: 0.1}, scene);** and uncomment this **var box = this.box.createInstance();**

My typical approach is in each loop

1. Unfreeze scene when I need to add some new meshes (or just to actualize active list sometimes)
2. Do the creation of meshes
3. Freeze scene at the end of each loop in which it was unfrozen

Do you have some hint whats wrong ? I am sure that I am not the only one facing this problem, but I was unable to find solution anywhere.

Thanx very much in advance !

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [March 10, 2023, 11:11am UTC](https://forum.babylonjs.com/t/freeze-active-meshes-and-instances/38897/2 "2023-03-10T11:11:06Z")

</div>

cc @sebavan

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [March 10, 2023, 11:22am UTC](https://forum.babylonjs.com/t/freeze-active-meshes-and-instances/38897/3 "2023-03-10T11:22:14Z")

</div>

In frozen mode, the list of active meshes is not recomputed and, by default, the world matrices of instances are not recomputed/updated neither.

To fix the problem, you can pass `false` for the `freezeMeshes` parameter of the `scene.freezeActiveMeshes` call. Or you can update the world matrices of the instances manually. See how it’s done in the PG of this post:

> [@WebGPU instancing does not render](https://forum.babylonjs.com/t/webgpu-instancing-does-not-render/31622/11):
>
> PR created: For this to work, the master mesh must be visible (because it must be an active mesh). If you really don’t want to display it, you can set a material that will hide it (disableColorWrite = true / disableDepthWrite = true). Here’s a PG that will work once the PR is merged:

---

<div class="post-metadata">

**Author:** ![stealman](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/stealman/32/340_2.png) [@stealman](https://forum.babylonjs.com/u/stealman)\
**Post date:** [March 14, 2023, 10:51pm UTC](https://forum.babylonjs.com/t/freeze-active-meshes-and-instances/38897/4 "2023-03-14T22:51:56Z")

</div>

Thanx very much, that “false” argument to `freezeActiveMeshes` resolved this issue 😉
