Start to build tf3d

Start to build tf3d
Fix some bugs in 2d version