How to make object visible only inside another object?
You can make parts of objects invisible using multiple tricks. Since your mesh is animated, it's probably not the easiest animating your material as well. As I get it, if you want to change the animation speed, you need to adjust the material separately. Anyways, here's how I would do it:
 
The sphere simply has a transparent shader set to blueish nothing else.
The cube is only visible if a ray has passed through a transparent shader. I guess you can also invert the sphere (animiation) and use a simple holdout shader on it, but I'm guessing that doesn't work for you for other reasons.