R, 62 55 51 bytes
Edit: -7 bytes thanks to Giuseppe, and -4 bytes thanks to pajonk
\(a,d,`*`=array)a[t(t(which(T*d,T)-1)%%dim(a)+1)]*d
R, 49 bytes
\(a,d)array(a[t(t(which(!a*0,T)-1)%%dim(a)+1)],d)
Works with arrays of finite numbers. In this case, we don't need to create a new array of TRUE
elements to get the indices, as we can just multiply the elements by zero and take the logical NOT.