The common ancestor of all vertebrates had not 3 but 4 cones for detecting color. Most mammals later lost two cones from being nocturnal, and primates evolved one back after that.