Add support for geometry with materials

Still needs cleanup and ability to handle changed materials.