# Open world optimization

**URL:** <https://forum.babylonjs.com/t/open-world-optimization/37045>\
**Category:** Questions\
**Created:** [January 2, 2023, 4:44pm UTC](https://forum.babylonjs.com/t/open-world-optimization/37045 "2023-01-02T16:44:07Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![ARAMONIS](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/aramonis/32/27804_2.png) [@ARAMONIS](https://forum.babylonjs.com/u/ARAMONIS)\
**Post date:** [January 2, 2023, 4:44pm UTC](https://forum.babylonjs.com/t/open-world-optimization/37045/1 "2023-01-02T16:44:08Z")

</div>

I’m trying to make an open world out of tiles, but it works slowly. Each tile is a separate mesh. The drawing distance is the minimum required. And there will be more objects, how can it be optimized?

If I use “tiledGround” or merging meshes, will it help?

 ![Screenshot_20230102_193423](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/2/e/2e60be4cdf62953ed48ce6bfe92cd9febf7f3592.jpeg)

![location](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/2/3/234473123b778580d3f51a0b5f74677f7b337104.png)

---

<div class="post-metadata">

**Author:** ![webgrid](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/webgrid/32/24940_2.png) [@webgrid](https://forum.babylonjs.com/u/webgrid)\
**Post date:** [January 2, 2023, 5:23pm UTC](https://forum.babylonjs.com/t/open-world-optimization/37045/2 "2023-01-02T17:23:16Z")

</div>

Hi,

I have made an open world game using babylon, and performance is not an issue for me, I have around thousands of objects in a scene.

This what I’ve done for better performance:

- Streaming data and offloading computing into web workers so less work for the main thread.
- Using instances.
- Freezing objects not needing updating.

Here is a great source for information: [Your Journey Starts Here | Babylon.js Documentation](https://doc.babylonjs.com/journey)

Good luck 🙂

---

<div class="post-metadata">

**Author:** ![ARAMONIS](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/aramonis/32/27804_2.png) [@ARAMONIS](https://forum.babylonjs.com/u/ARAMONIS)\
**Post date:** [January 2, 2023, 11:04pm UTC](https://forum.babylonjs.com/t/open-world-optimization/37045/3 "2023-01-02T23:04:20Z")

</div>

Thanks for the tips

---

<div class="post-metadata">

**Author:** ![ARAMONIS](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/aramonis/32/27804_2.png) [@ARAMONIS](https://forum.babylonjs.com/u/ARAMONIS)\
**Post date:** [March 12, 2023, 4:42pm UTC](https://forum.babylonjs.com/t/open-world-optimization/37045/4 "2023-03-12T16:42:43Z")

</div>

The problem is not in the rendering. Instance, lodLevel, freeze, and other graphical options do not help much. The larger the size of the world and the tiles in it, the more it slows down. And the player sees only a small part on the screen.  
But I’ll try something else.

---

<div class="post-metadata">

**Author:** ![webgrid](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/webgrid/32/24940_2.png) [@webgrid](https://forum.babylonjs.com/u/webgrid)\
**Post date:** [March 12, 2023, 6:13pm UTC](https://forum.babylonjs.com/t/open-world-optimization/37045/5 "2023-03-12T18:13:43Z")

</div>

Have you tried scene.freezeActiveMeshes method ?

This may help as it reduces the number of meshes that need to be updated babylonjs.

---

<div class="post-metadata">

**Author:** ![Alexander\_Sosnovskiy](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/alexander_sosnovskiy/32/30165_2.png) [@Alexander\_Sosnovskiy](https://forum.babylonjs.com/u/Alexander_Sosnovskiy)\
**Post date:** [March 12, 2023, 7:42pm UTC](https://forum.babylonjs.com/t/open-world-optimization/37045/6 "2023-03-12T19:42:50Z")

</div>

The first rule of optimization - measure. Did you open a profiler or inspector?

---

<div class="post-metadata">

**Author:** ![ARAMONIS](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/aramonis/32/27804_2.png) [@ARAMONIS](https://forum.babylonjs.com/u/ARAMONIS)\
**Post date:** [March 13, 2023, 8:38pm UTC](https://forum.babylonjs.com/t/open-world-optimization/37045/7 "2023-03-13T20:38:43Z")

</div>

A good feature, but it causes lag when used. If i freeze meshes once a second, for example, then fps will drop once a second. Thus, solving one problem creates another. I do not know how to use it effectively

---

<div class="post-metadata">

**Author:** ![webgrid](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/webgrid/32/24940_2.png) [@webgrid](https://forum.babylonjs.com/u/webgrid)\
**Post date:** [March 13, 2023, 10:07pm UTC](https://forum.babylonjs.com/t/open-world-optimization/37045/8 "2023-03-13T22:07:39Z")

</div>

In my code, I freeze or unfreeze meshes individually:

To reset the active meshes data instead of rebuilding them, you can use the following code:

```auto
scene.getActiveMeshes().reset();
camera._activeMeshes.reset();

```

This will reset the active meshes data without rebuilding them.

I’m not sure if this is the recommended way of resetting active meshes data 🙂

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [March 14, 2023, 5:01pm UTC](https://forum.babylonjs.com/t/open-world-optimization/37045/9 "2023-03-14T17:01:41Z")

</div>

@ARAMONIS what is the biggest you see in the inspector ???

---

<div class="post-metadata">

**Author:** ![ARAMONIS](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/aramonis/32/27804_2.png) [@ARAMONIS](https://forum.babylonjs.com/u/ARAMONIS)\
**Post date:** [March 14, 2023, 9:15pm UTC](https://forum.babylonjs.com/t/open-world-optimization/37045/10 "2023-03-14T21:15:01Z")

</div>

I specifically tested on a weak PC, I want to achieve stable frame rate on it. It’s easier to identify weaknesses this way. If it succeeds, then you don’t have to worry anymore. On average, it outputs 30fps at a small location. But the location should be 2000x2000 tiles, and in this case it gives 1 fps

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [March 14, 2023, 9:41pm UTC](https://forum.babylonjs.com/t/open-world-optimization/37045/11 "2023-03-14T21:41:20Z")

</div>

We can not help from only this information. We need to know the exact hot path in your code to see what it the best strategy to address it.

What do you see as your biggest hit in the Chrome dev tools ?

---

<div class="post-metadata">

**Author:** ![ARAMONIS](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/aramonis/32/27804_2.png) [@ARAMONIS](https://forum.babylonjs.com/u/ARAMONIS)\
**Post date:** [March 14, 2023, 10:50pm UTC](https://forum.babylonjs.com/t/open-world-optimization/37045/12 "2023-03-14T22:50:43Z")

</div>

I think I have an idea. Freeze the entire location and manually unfreeze only the area around the player. But is it possible to completely freeze only one mesh? I have not found a corresponding method

---

<div class="post-metadata">

**Author:** ![webgrid](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/webgrid/32/24940_2.png) [@webgrid](https://forum.babylonjs.com/u/webgrid)\
**Post date:** [March 15, 2023, 11:08am UTC](https://forum.babylonjs.com/t/open-world-optimization/37045/13 "2023-03-15T11:08:53Z")

</div>

mesh.\_freeze() should do the trick
