buildtemplate function

Build 3D surface template