Perhaps have a look at this 3D function topic