My Stars won't appear!

Yea my Stars wo’t appear…
My Output say:
Uncaught TypeError: Cannot read property ‘push’ of undefined
at addBackground (VM59 code.html:171)
at VM59 code.html:39
at VM56 _.html:10
addBackground @ code.html:171
And my Url is:
https://www.code3dgames.com/3de/#B/lVhtU9s4EP7Or1D5EqcEk4SEzgHtDFCOdo5SJtD2Zm5uOoqtJGptyycppIHhv9+uJNtyYlJgmMRZPSvtPvsiycdjES/fHe+Zr61jFUmea6Jk9HZ7T88kY+EPtQ3jdmAVkc+Wijcj3m0RsrdHrhERKaKY1jybKpAa0Q8VWpwKaZoK8pa09vABJmsdNYAWQv5k0sByO/TdiqyCXex2xsi2iljGtglXZDFjkhGl55MJ4RkRc0mmNGVkwZOEzGies+wQFO+oJEYJZs/Yolz6BmVBG60xwyH4cCHpHdfLAHG3H0bn5+FXFmkh9wPS7ZDdXhc+u6RtlHDeSUI1TPuA3zczGgMFh0TLOXssEAmfzrRb2c54ko45y/QlDgStxYxr1oJZw75nCo3jwGi2a75H4J6kznlYWTGmiJ45EgpnqcrB6BHVHHlf8CwWi5BnGZPfeKxnZK8m+8BwncJcu0LN3msmzYT8jp2Z0eDNsOMv0iE9+O/Cn/HAThHmQnEYzMJ7mG3Y7dads6C6d5JlMURUbpNY0oVzEb1zRhlvRaaFdTmC7C0DXOjWLP/GxheXIzcSPNBMc5pwqlyIjLWFIkb/ht+zYI2vTgNdRjUW0TyFSIZYXKHJt/hsxpM4KCeNRXqeMAQZjQZ2YNmga+jrkH6dwUSInye6IRcxCeG/veIA5J9YfKJ5yDI6TlgMXKCfBcev3R+5uT0Z3ZKzz+8/Xl2Qz1cw+Tm5Ov/7llx+vDovYVtl9iqYCGJmElZhweDImEKRGfkpPJVSQWXsxPhYyKeCOvQFPKF0SzJ0HZ6c0NaD/X1Ko59TKeaZmWBrMs8iJMu3gjz4BaZqcf88/gFM7b8PCtJLXL+e2YI31OHAaFl4PU5DYH3o+oAPiqgy1S8WJeVuTFWV3C+MWalw5aKo5zJzSkdb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HM3JTxpQjGsEwwiwqqZP9vzpS2ygD4E7frwKHKGnC3TPsQGBs6pLzGW1fKmYs752iekdy+IvItQItuNMtLE7AU6/vpEjIMdnioyFotujc1PIWNUbNCCit9yWP03C1GDrpEQ4kqgq8NIpHFROFrA6pLbhRRqRB6ZqetKrqwzb7S2Dvolt5VVptaKa//awW+/ZMt4TiXbUMJAl1/seV7+FW7yXrygKGyf3WJsfKMNMQfRa+yA29J60RKsbhkE91qkwS+rEHrkBF2Q8DI4mrdBPqSA2KePzWMFgIA3WmAgAujlhcil8+lm9Y68gDBSOCSfW8u2F3YUAyh1aGsOEh4uN0m4Dz3UL+eQlljazgP5iMNAA5LHULTajP7/Tlq9ST1DwD/hfEm6Y6bu6z38l3q/w==

There is a small problem at the start of the addBackground() function. The shape and cover variables are mixed up:

  var shape = new THREE.PointsMaterial({color: 'white', size: 2});
  var cover = new THREE.Geometry();

Shapes are always a kind of “geometry” and covers are always a kind of “material.” So, you can fix the error by switching the two variables:

  var cover = new THREE.PointsMaterial({color: 'white', size: 2});
  var shape = new THREE.Geometry();

Also, at the bottom of the addBackground() function, the code currently tries to add the cover to the scene:

  var stars = new THREE.Points(shape, cover);
  scene.add(cover);

You’ll need to change that to add the stars to the scene instead:

  var stars = new THREE.Points(shape, cover);
  scene.add(stars);

There is one other small problem in the addBackground() function. Instead of Math.PI when computing the declination, the code currently has Math.Pi (lowercase i):

    var ra = 2 * Math.PI * Math.random();
    var dec = 2 * Math.Pi * Math.random();

If you change that so it’s Math.PI like the right ascension, then the background code will work just fine:

    var ra = 2 * Math.PI * Math.random();
    var dec = 2 * Math.PI * Math.random();

Let me know if you run into any other problems,

-Chris

Perfect! now everything is working fine!