add 3d optimization