A member of the National Park Service, left, leads Malia Obama, President Obama, first lady Michelle Obama and Sasha Obama, on a tour of Carlsbad Caverns in New Mexico on Friday, June 17, 2016. (Jacquelyn Martin/AP)

Eight hundred feet below ground, President Obama stopped along a narrow path in the dark, calcium-filled Carlsbad Caverns and gazed up at the craggy stalactites jutting down from the roof.

“How cool is this?” he said with a smile. His wife and daughters looked up with him. Then they kept going, following a tour guide, as well as some heavily armed Secret Service agents, into the depths of the cave.

One day after the president made a somber visit to Orlando, the first family embarked on a three-day vacation.

The Obamas’ trip to national parks in Carlsbad and Yosemite, Calif., was planned long before the tragic attack that killed 49 people at a gay nightclub in Orlando last weekend. Timed to the 100th anniversary of the creation of the national park system, the excursion had a policy component: aiming to draw attention to the conservation of federal lands and protecting the environment.

“The parks belong to all of us; this planet belongs to all of us — it’s the only one we’ve got,” Obama said Saturday in a public address in front of the dramatic vision of the 2,400-foot Yosemite Falls. Pressing lawmakers to act to prevent climate change, the president said, “You can’t give lip service to that notion and then oppose the things required to preserve it.”

While speaking at Yosemite National Park, President Obama reflected on the history of the national park system, which will celebrate its 100th anniversary in August. (The White House)

But regardless of the motivation for the trip, the timing — starting a day after Obama laid flowers at a memorial to the shooting victims in Orlando — made for a sharp juxtaposition at a time of intensified debate over national security and terrorism. The Orlando shooter was a U.S. citizen purportedly inspired by the Islamic State militant group but with no direct ties to organized terrorist networks.

White House aides said the president’s commitment to supporting the law enforcement investigation and helping calm public fears was clear in his reaction after news of the shooting broke early last Sunday. Obama made a statement to reporters that day in the White House briefing room, met with his national security team on Monday and Tuesday, and visited with shooting victims and their families in Orlando on Thursday.

“The president’s response, the entire administration’s response, to tragedy last weekend has been pretty evident throughout the week,” White House spokeswoman Jennifer Friedman told reporters on Air Force One.

Friedman declined to say whether the president or his advisers considered canceling or postponing the national parks trip, which began with a tour of the vast caverns of Carlsbad on Friday. In Yosemite, where Marine One made a scenic landing in a meadow just beyond the dramatic Half Dome granite peak, Obama conducted an interview with National Geographic.

Leaving Washington on Friday morning, the Obamas were dressed casually. Marine One touched down at Joint Base Andrews, and the president emerged in a sport coat and khakis, without a tie. The first lady wore a summery green-and-white-striped dress, and their teenage daughters, Malia and Sasha, bounded onto Air Force One with backpacks on their shoulders.

While on the flight, the president spoke with the husband of Jo Cox, the British member of Parliament who was killed by an attacker on Thursday. He also changed into even more casual clothes — dark blue jeans and a short-sleeve shirt.

The competing and often discordant demands of the White House are part of the job description, and Obama has had to weigh the merits of upending his personal schedule during moments of domestic or international crisis.

President Obama used his weekly address to talk about the mass shooting in Orlando and urge lawmakers to revisit the issue of gun control. (Reuters)

Obama delayed his annual Christmas vacation to Hawaii three consecutive years over contentious fiscal negotiations with Congress.

His summer getaway to Martha’s Vineyard in 2011 was cut short by Hurricane Irene advancing up the East Coast. And in 2012, the president bagged his summer break during his reelection campaign.

At other times, however, the president has maintained his personal schedule in the face of public pressure to cut it short. The first family took a three-day, spring-break vacation to an exclusive resort in Key Largo, Fla., in March 2014, just after Russian troops had invaded the Crimea, escalating a tense standoff with Ukraine and drawing international condemnation. Aides said Obama called German Chancellor Angela Merkel as he traveled to Florida.

“What the president will be doing this weekend in Florida is essentially what the president would be doing back at the White House,” White House press secretary Josh Earnest said during that trip. “It’s just that the weather will be a little warmer.”

A few months later, in August 2014, Obama was on Martha’s Vineyard when news came that the Islamic State had conducted a videotaped execution of American journalist James Foley, an act that shocked the American public. Obama made a brief statement to reporters but went golfing just moments later, a decision that drew criticism from Republicans.

During that same week, Obama attended a private party on the island on the night that demonstrators and police clashed in Ferguson, Mo., after the shooting death of a black resident by a white officer. White House aides released a statement that Obama, who mingled with guests including Hillary Clinton, had enjoyed an evening of music and dancing — just as journalists were reporting breaking news of violence in Ferguson.

“A good time was had by all,” according to the White House statement.

Aides have said that if Obama were to alter his schedule based on the news of the day, he would constantly be in reactive mode and would have difficulty advancing his policies. And they said that the president’s senior national security advisers, as well as the array of secure communications tools, follow Obama everywhere he goes, even to a remote cavern deep below the earth.