In order to cast shadows through transparent parts of my Mesh I use the MeshDepthMaterial but when I do this, the shadows of the animated parts of my objects stop moving with the animation.
You can take a look at the example here: https://jsfiddle.net/miger/kj8gwue5/
var customDepthMaterial = new THREE.MeshDepthMaterial( {
depthPacking: THREE.RGBADepthPacking,
alphaMap: alphaTex,
alphaTest: 0.5
})
child.customDepthMaterial = customDepthMaterial;
If you comment out the customDepthMaterial-input you can see that the shadow would normally go with the animation, as shown in this example here. However as you can see the shadow does not cast through the the transparent part of my mesh anymore, which is not the effect I'd like to have here.
How can I fix this? Updating the depth material with needsUpdate, did not do anything..
Is it even possible to make the shadows work correctly with animations when using the depth material?
Add skinning: true to your depth material:
var customDepthMaterial = new THREE.MeshDepthMaterial( {
depthPacking: THREE.RGBADepthPacking,
alphaMap: alphaTex,
alphaTest: 0.5,
skinning: true // add this property
})