How to rotate 2 planet with different speed

Hi everyone,
I wanted to know how to get planets spinning around an axis at different speeds.
I’ve been using this code for now, but I don’t know if it’s the right way. I dynamically create the planets from php and pass them in json, do the loop and then i thought to apply to each item of the loop but only the last one is animated. In another experiment I can make them all rotate but all at the same speed because the pivot is one. How am I supposed to have each planet spin at its speed?

ecco il playground

Hey there, a simple fix is to use const or let instead of var and use the arrow function instead of function, that way new variables and function are created for each loop iteration.

2 Likes

Thank you very much, its’ perfect!

1 Like