Contact shadow not changing with morph targets

Hello All,

I have a problem with the shadows not changing when the gltf mesh is changed using the morph targets.
So as you can see in the images below, once the box width is changed using morph targets, shadows stay the same.
If I use “mesh.scale.y” in that case the shadows update correctly.

Unfortunately, the code is too big at this point I am not sure how to show it all here.
What I do is load a gltf mesh and set

mesh.material.morphTargets = true;

and then get html slider value and change the morph targets to the value:

let slider = document.getElementById("Width");
slider.oninput = function() {
      mesh.morphTargetInfluences[0] = parseFloat(this.value);
}
    

The shadows were implemented by following this example: three.js webgl - contact shadows


Is there any way to update the shadows when morphing the mesh? I looked for similar cases but couldn’t find anything that could help on this.

Thank you.

Hi All,

In case anyone has issues with contact shadows not updating when changing morph targets, I simply added this line and now it works:

depthMaterial.morphTargets = true;
1 Like