A star begins as a collapsing cloud of material composed primarily of hydrogen , with helium and trace amounts of heavier elements . A star begins as a collapsing cloud of material composed primarily of hydrogen , along with helium and trace amounts of heavier elements .