Using layerMask disables animation

I have a scene where I have an avatar with a number of animationGroups where I can switch between each one. Setting the layerMask for the meshes in the scene disables the animations from running.

The animations were imported from Mixamo and applied to ReadyPlayerMe avatars.

Here is a video demonstrating the issue with the Debug Layer.

switching the layerMask from 0x1000000 to 0xFFFFFFFF makes the animation work. Moving back and forth should animate the avatar as shown at 18 seconds. In this case, every element but the avatar has the layerMask 0x10000000.

The mirror camera does not have a layer mask but the active camera has the layerMask 0x10000000.

I am using this to prevent the avatar from showing up for the active camera but to be visible in the mirror.

    const layerMask = 0x10000000;

    scene.meshes.forEach((mesh:BABYLON.AbstractMesh)=>{
        mesh.layerMask = layerMask;
    });

    scene.activeCamera.layerMask = layerMask;

I have a complex issue that I can’t build a playground for that demonstrates the issue. Any suggestions?

Hello!

I’ll tag @PatrickRyan, maybe he has seen this before

Something to try is to call skeleton.prepare() at each frame (in scene.onBeforeRenderObservable, for eg) for the skeleton used by your mesh.

2 Likes

That fixed it!
Thank you so much, Evgeni!
Michael

1 Like

To elaborate on the fix:

The call to skeleton.prepare() is made as part of the process of collecting active meshes. If the meshes are not rendered by the main camera, the list of active meshes is empty and the animations are not processed.

1 Like

This should definitely be added to the documentation page here for using the layermask:

You are more than welcome to update the page! :slight_smile:

Just click on the little “github” button at the bottom right of the page, edit the page, make the changes and submit them.

done!

3 Likes