Use a map to cache indices for saving meshes.