score:1

Accepted answer

missing 4th sphere

you specify:

pivot1.rotation.z = 0;
pivot2.rotation.z = 2 * math.pi / 3;
pivot3.rotation.z = 4 * math.pi / 3;
pivot4.rotation.z = 6 * math.pi / 3;

6 * math.pi / 3 = 2 * math.pi

note, three.js uses radians, therefore 2 * pi is 0 (a full revolution is the same place as no rotation.

so pivot1 and pivot4 have the same effective rotation and your 2 sphere end up in the same place in space.

speed

you currently handle speed by mutating the z rotation on every frame.

parent.rotation.z += 0.01;

this obviously works just fine for a demo. you can speed it up by moving more per frame (or getting more frames, ie better machine or other upgrades)

parent.rotation.z += 0.04;

now it rotates at 4 times the speed!

more spheres

once you get past working with counts larger than your number of fingers on a hand, i recommend getting generic with arrays. instead of listing out pivot1, pivot2, pivot3, . . . pivot0451, generate this with a loop. (functionally you could use ranges if you prefer).

first, we declare how many spheres to make. then divide up the circle (2 * math.pi radians to go around). then for ever sphere, make a pivot. then, for every pivot, add a mesh. and you're done.

var numberofspheres = 10;
var radianspersphere = 2 * math.pi / numberofspheres;
// pivots
var pivots = [];
for (var i = 0; i < numberofspheres; i++) {
  var pivot = new three.object3d();
  pivot.rotation.z = i * radianspersphere;
  parent.add(pivot);
  pivots.push(pivot);
}

var meshes = pivots.map((pivot) => {
  var mesh = new three.mesh(geometry, material);
  mesh.position.y = 5;
  pivot.add(mesh)
  return mesh;
});

i implemented this at this codepen.io

happy coding.


Related Query

More Query from same tag