The shooting at the U.S. naval base in Pensacola is the latest heartrending act of violence against innocent Americans.

Three Americans died while serving their country: Joshua Kaleb Watson, a 23-year-old graduate of the U.S. Naval Academy; Airman Mohammed Sameh Haitham, 19, of St. Petersburg, Florida, who joined the Navy after graduating high school last year; and Airman Apprentice Cameron Scott Walters, 21, of Richmond Hill, Georgia.

Walters was on his very first assignment. “Fresh out of boot camp, Cameron Walters proudly told his father in Georgia during their nightly chat that he had passed the exam qualifying him to stand watch and help secure building entrances at Naval Air Station Pensacola in Florida,” the Navy Times reported.

The Navy lauded all three flight school students for their “exceptional heroism and bravery in the face of evil.”

Watson’s brother said in an online posting that Joshua “died a hero,” performing his duty despite mortal wounds. “After being shot multiple times [Joshua] made it outside and told the first response team where the shooter was, and those details were invaluable,” Adam Watson wrote.

The loss to the families is tragic and irrecoverable. But they have the consolation of knowing that their sons conducted themselves nobly in terrifying, tragic circumstances.

A clear motive was indicated, and it will likely be confirmed by investigators in the coming days.

Unlike so many similar incidents in recent years, where the violence was as inexplicable as it was murderous — seemingly motiveless, senseless killings — sense of a kind can be made of the Pensacola shooting, which is at least traceable to an identifiable hatred for the United States and Israel.

The gunman, 2nd Lt. Mohammed Alshamrani of the Royal Saudi Air Force, apparently went on Twitter shortly before the shooting to denounce U.S. support of Israel and accuse America of being anti-Muslim, a U.S. official said. The FBI is proceeding on the assumption the attack was an act of terrorism.

Furthermore, Alshamrani hosted a dinner party a few days before, where he and his guests watched videos of mass shootings, an official told the Associated Press.

The case is still under investigation, and no firm conclusions can be drawn until all the facts are in. Most urgently, the FBI wants to know whether Alshamrani acted alone or whether he was part of a terrorist network. To that end, the FBI is questioning his friends, classmates and other associates.

The question on everyone’s mind is, of course, how did such a person enter the United States? Was there any way to prevent these killings?

Florida Gov. Ron DeSantis thinks it could have been prevented with better vetting. “You have to take precautions” to protect the nation, DeSantis said at a news conference on Sunday.

The fact is, though, that precautions were — and are — taken. Foreigners allowed into the U.S. for military training undergo background checks to identify security risks.

Still, the question must be answered: How did Alshamrani slip through? Should the system have flagged him? Would upgrading the system prevent it from happening again?

To answer that, Defense Secretary Mark Esper said he has ordered a review of procedures for vetting foreign nationals and security on military installations. The precautions have been in place for many years and it would not be surprising that they have need of updating, or that they were insufficient in the first place.

Nor can Saudi Arabia be spared special scrutiny. More than 850 Saudis are in the United States for various training activities. They are among more than 5,000 foreign students from 153 countries in the U.S. going through military training, said the AP.

It is imperative to review the file on each one of them, which it is fair to assume the FBI is now doing.

President Donald Trump spoke Sunday with Saudi Crown Prince Mohammed bin Salman, who “reiterated Saudi Arabia’s commitment to working with the United States to prevent a horrific attack like the Pensacola shooting from ever happening again,” the White House said in a statement. Salman promised his country will continue to cooperate with the investigation. Meanwhile, a Saudi military officer has ordered all students from the country to remain at one location at the base, authorities said.

Saudi Arabia is not on the list of predominantly Muslim countries whose citizens have been subject to the Trump administration’s travel ban.

The Saudis are allies, and their people — especially those who come here to benefit from educational and training opportunities — are presumed to be friendly to the United States. But this terrible experience teaches that the U.S. cannot take the friendliness of individual foreigners, including Saudis, for granted.

Realistically, it is not possible to hermetically seal the nation’s borders to all who harbor hate in their hearts against the U.S. but have no record to suggest they represent a threat. The most that can be done is to take reasonable precautions, be vigilant and ask for the help of the only One Who knows what truly goes on inside the mind of a human being.