Galaxy of donuts

The galaxy is composed of 2000 torus shapes created in a loop. Each torus is positioned according to a spiral pattern calculated using polar coordinates with a bit of random variation on the y-axis to give depth and make the distribution more galaxy-like. When the web page is interacted with, the onMouseMove function updates the mouse variable to reflect the mouse's position in normalized device coordinates. This is necessary for raycasting, which is used to determine what objects are under the mouse cursor.

  • Imagine you're looking at a star-filled sky where each star is a torus-shaped object.

  • This sky is interactive. When you click on a star (donut), it changes color from light blue to pink.

  • The stars are not randomly placed. They form a spiral shape, like many galaxies we see through telescopes.

  • You can rotate the view to see this galaxy from different angles, thanks to the controls added to the camera.

  • If you click a pink star, it will turn back to light blue, and vice versa, creating an interactive, dynamic galaxy of torus-shaped stars.

Previous
Previous

Class 4

Next
Next

Class 6