Animations outside frumstrum

Hi, some time ago i testes animation perfomance in my game. During debug that i saw problem with many animations of enemies outside frumstrum. What that mean? That mean… When i play animation and mesh is not visible engine still animate it. Is excepted behavior?

Now i checking it like that:

setInterval(function() {
let activeEnemies = 0;
game.enemies.forEach(function(enemy) {
if(enemy.isDeath) {

            let isActiveMesh = gameCamera.isInFrustum(enemy.mesh);
            if(isActiveMesh) {
                activeEnemies = 1;

            if(!enemy.animation && isActiveMesh) {
            } else if(enemy.animation && !isActiveMesh) {
                enemy.animation = null;
    }, 1000);


1 Like

This is expected because else you may miss some animation steps. Plus what if the animation brings the mesh back to the screen?
If you want to stop that behavior you can add a function in the scene.registerAfterRender and stop animations on all meshes which are not in scene.activeMeshes

1 Like

I create cache in my game object, which store all enemies. I want to avoid scan all meshes in scene to optimize that process. After render function will be faster then interval?

I just start animation from the beginning, when mesh is visible.

So OK, stay with actual optimization :).

1 Like

So cool. Like this concept very much. :black_heart:

Optimization: optionally, start enemy animation once in frustum.



Also, great to consider… animation steps may be skipped. So concept of PAUSE… interesting. :grin:

Into and out of the anm sequence when in the frustum~zone (alarm).

Cool concept. :slight_smile:

You can also leverage the AssetContainer as it is dedicated to store data in the scene ?

1 Like