Cast Shadows in Shader Material with alpha map

A working fiddle.js for anyone who comes to this later: ThreeJS Casting shadows through alpha masked mesh geometry three.js v0.170.0 - JSFiddle - Code Playground
This solution of using custom shaders for the customDepthMaterial works in v0.170.0 where as this solution that used customDistanceMaterial worked for older versions of three.js does not seem to work anymore.