Refactor 3d drawing