Actually, obj.selectedFaces is a live set, it changes when the selection changes. There are more issues with the code, though, first of all the gatherInfo function is equivalent to selection[selection.count].selectedFaces, pickFace function doesn't follow the single responsibility principle (and its name) and apart from…