The performance is based on, and named after, an artwork in the form of a book by Jonathan Safran Foer, published in 2010.
To create the book, Foer took and cut apart a book by Polish author Bruno Schulz, named The Street of Crocodiles, to create a new narrative.
Jamie xx used an algorithm to turn spaces and shapes from the book into melodies, while McGregor created a dance for each of its 134 pages.
It was the "physical nature" and "vibrancy" of the book that inspired Eliasson's set and lighting designs, which included rows of gramophone-shaped mirrors and screens with circular cutouts.
"To me, books have always been about more than just print on paper," said Eliasson. "Tree of Codes addresses the book as a space that relates to our body."
"I look at the book as vibrant matter. It doesn't explain ideas, but vibrates them. It embodies a space and a narrative – or various narratives – within it," he continued. "I tried to translate this feeling into the visual concept."
The show opens in complete darkness. Dancers adorned with star-like lights move around the stage, coming together to form what looks like constellations.
Other scenes incorporated mirrors and coloured films, making single dancers appear as a kaleidoscopic row of many.
Lights in blue, pink and green hues cast colourful beams across the stage. At some points, the audience's faces are picked out by a swooping spotlight, before being reflected back to them in a giant mirror.
Tree of Codes, which features dancers from both McGregor's own company and the Paris Opera Ballet, is on show at Sadler's Wells until Sunday 12 March.
Eliasson is best known for his monumental artworks based around light and optical illusions. In 2003 he bought a monumental glowing sun to the Tate Modern Turbine Hall, which was the installation that made McGregor want to work with him.