# Rotating randomly generated spheres

**URL:** <https://discourse.threejs.org/t/rotating-randomly-generated-spheres/26677>\
**Category:** Questions\
**Created:** [May 27, 2021, 6:50pm UTC](https://discourse.threejs.org/t/rotating-randomly-generated-spheres/26677 "2021-05-27T18:50:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miguel\_Angel\_Espindola](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/miguel_angel_espindola/32/17517_2.png) [@Miguel\_Angel\_Espindola](https://discourse.threejs.org/u/Miguel_Angel_Espindola)\
**Post date:** [May 27, 2021, 6:50pm UTC](https://discourse.threejs.org/t/rotating-randomly-generated-spheres/26677/1 "2021-05-27T18:50:47Z")

</div>

hi, I watch this video [for creating an awesome portafolio](https://www.youtube.com/watch?v=Q7AOvWpIVHU&t=603s)  
and now I want that the random stars that are generated to spin around in a circular path, I have no idea where I can start, I’ve been watching post about simulating particle systems but that doesn’t seem like the solution I want, also I achieved to make an object spin around another, here is my code:  
[main.js](https://discourse.threejs.org/uploads/short-url/vuAnN2djFYOE03xNpZoPHt8tjFx.js) (1.6 KB)

and this is the one with the randomly generated stars:  
[main.js](https://discourse.threejs.org/uploads/short-url/2It2U2wDgc0ywpuC2QiAeGGOCLR.js) (2.0 KB)

also, I figured out that you can create the stars with the function or with a for loop  
I hope some can help me to know where to start searching  
Thanks 🙂

---

<div class="post-metadata">

**Author:** ![prisoner849](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/prisoner849/32/535_2.png) [@prisoner849](https://discourse.threejs.org/u/prisoner849)\
**Post date:** [May 27, 2021, 7:26pm UTC](https://discourse.threejs.org/t/rotating-randomly-generated-spheres/26677/2 "2021-05-27T19:26:11Z")

</div>

Hi!  
Maybe this will give you some ideas: [Shift vertices of circle geometry not working - #11 by prisoner849](https://discourse.threejs.org/t/shift-vertices-of-circle-geometry-not-working/26664/11)

---

<div class="post-metadata">

**Author:** ![prisoner849](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/prisoner849/32/535_2.png) [@prisoner849](https://discourse.threejs.org/u/prisoner849)\
**Post date:** [May 27, 2021, 8:27pm UTC](https://discourse.threejs.org/t/rotating-randomly-generated-spheres/26677/3 "2021-05-27T20:27:04Z")

</div>

Sine and cosine are your friends. They’ll force the spheres to run on their orbits 🙂 Pure trigonometry.  
Example: [https://jsfiddle.net/prisoner849/aersLb0g/](https://jsfiddle.net/prisoner849/aersLb0g/)  
Picture:

 ![изображение](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/2/2/223451dc00f8714083419df9e8936e4585fcb184.png)

PS It’s just an option, not the ultimate solution.

---

<div class="post-metadata">

**Author:** ![Miguel\_Angel\_Espindola](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/miguel_angel_espindola/32/17517_2.png) [@Miguel\_Angel\_Espindola](https://discourse.threejs.org/u/Miguel_Angel_Espindola)\
**Post date:** [May 27, 2021, 8:36pm UTC](https://discourse.threejs.org/t/rotating-randomly-generated-spheres/26677/4 "2021-05-27T20:36:00Z")

</div>

Thank you so much, tbh I’m new to this stuff so I didn’t know where to start, now my web page would look more awesome thanks to you:"3

---

<div class="post-metadata">

**Author:** ![prisoner849](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/prisoner849/32/535_2.png) [@prisoner849](https://discourse.threejs.org/u/prisoner849)\
**Post date:** [May 27, 2021, 8:39pm UTC](https://discourse.threejs.org/t/rotating-randomly-generated-spheres/26677/5 "2021-05-27T20:39:04Z")

</div>

You’re welcome 🙂 🍻

---

<div class="post-metadata">

**Author:** ![Miguel\_Angel\_Espindola](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/miguel_angel_espindola/32/17517_2.png) [@Miguel\_Angel\_Espindola](https://discourse.threejs.org/u/Miguel_Angel_Espindola)\
**Post date:** [May 27, 2021, 10:55pm UTC](https://discourse.threejs.org/t/rotating-randomly-generated-spheres/26677/6 "2021-05-27T22:55:07Z")

</div>

![stars](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/3/0/30f0246b62965474764ce9c274784ff9bc3bdd1b.png)  
this is the result
