During his entire run in “Hamilton,” actor-writer-composer Lin-Manuel Miranda wasn’t only thinking about political leaders in 18th-century America. His mind was also on islanders in the South Pacific some 2,000 years ago.

That’s because he’s the primary songwriter on Disney’s animated “Moana.” “It was like a joyous break. I don’t have to deal with American history, I don’t have to deal with facts,” he remembers thinking. “I’m going to go write really wonderful songs for a totally different part of the world.”

Miranda joins Samoan-born Opetaia Tavita Foa‘i, who with his vocal group Te Vaka provides many of the ethnic colors of the “Moana” music; and Mark Mancina, whose Disney track record includes “Tarzan” and “Brother Bear” and who collaborated with both, produced all the songs, and scored the film.

Just as Disney animated features have transported audiences to Africa (“The Lion King”), the Middle East (“Aladdin”), ancient China (“Mulan”), and Scandinavia (“Frozen”), studio execs hope “Moana” will introduce them to a Polynesian culture about which they may know little or nothing.

Within days after being hired in March 2014, Miranda and Mancina found themselves on a plane for New Zealand, where they attended a music festival featuring singers from various South Pacific cultures. “They sent me and Lin and Opetaia to a studio in the remote countryside, where we got to know each other, listened to music, and jammed,” Mancina says.

It was the start of a 2½-year odyssey for the songwriters and the studio. “Originally, we weren’t even sure what the score was going to be,” concedes Mancina. “It was really more about getting the songs together, and seeing how the personalities work: Lin, having a theater and pop-music background, being more on the lyric side of things; and Opetaia, from pop but Polynesian, with dancing and all the things he brings to it.”

The story — about a teenage girl who, with the help of a demigod named Maui, sets out to become a master wayfinder — needed that exotic musical approach. “I’ve been promoting my Polynesian culture for 20 years now,” says Foa‘i. “My ancestors were the greatest navigators the world has ever seen, so when this came up, it aligned very well with what I was doing.”

For much of the choral music of the score, “I used the language of Samoa, Tokelau and Tuvalu. I’m very biased toward the Pacific languages,” he adds with a laugh. “Whenever there’s a gap I put them in. I leave the awesome English lyrics to Lin.”

For Miranda, as a lifelong Disney musical fan, “this felt heaven-sent to me.” He liked the idea of collaborating with Foa‘i and working with the music of a rich, not widely known Pacific culture.

“The fun for me, working in theater, is it’s all about collaboration and the best idea in the room wins.

“We did a lot of jam sessions around drums,” Miranda adds. “It would start with a rhythmic bass line from Opetaia, then I would go and write music and lyrics, and then he’d come in with choral stuff, and then Mark would make it feel all of a piece.”

Miranda reveals that he didn’t intend to sing on the score, but his demo for the song “We Know the Way” (written with Foa‘i) wound up in the final version, and some of his demo for “You’re Welcome,” sung by Dwayne Johnson as Maui, can still be heard in the background.
Other “Hamilton” cast members sang demos, too, including Phillipa Soo and Christopher Jackson; the latter ended up playing the Chief in the cast.

Foa‘i’s professional 12-voice ensemble, which came to the U.S. for the final recordings in late August, put the finishing touches on the songs. But, reports Mancina, “one of the layers we wanted to add was a Pacific island choir, to add a depth to the score but not a traditional choral aspect.”

So he flew to Fiji to record them, singing lyrics that he wrote and which Foa’i translated into Samoan, supplying a musical flavor unlike any previously heard in a Disney film.

“I didn’t want this to sound like a score that you could drop into another movie,” Mancina says.

“If it’s strictly authentic, it becomes a documentary. But if it ignores the culture, then it’s shallow and thin,” the composer notes. “We’ve tried to be very aware of the culture musically,” going so far as to import rare log drums for the kind of percussion sounds one might expect to hear in the South Pacific.

As he completed production on the songs, Mancina also recorded about an hour of score with a 90-piece L.A. orchestra.

Foa‘i says he hopes that “Moana” will spread the word about his “beautiful culture in the South Pacific. I’d like them to understand that this culture offers a lot more than what they see on the tourist side of things.”