I need help arranging 10 spheres in a ring using code. So far, this is what I have, but it's not working as expected.
const sphereGeometry = new THREE.SphereGeometry(300, 20, 20);
const sphereMaterial = new THREE.MeshLambertMaterial({ color: 0x888888 });
const numSpheres = 10;
let sphere;
const spheres = [];
let startX = 0;
let startY = 500;
let radius = 80 * Math.sin(angle);
for (let i = 0; i < numSpheres; i++) {
sphere = new THREE.Mesh(sphereGeometry, sphereMaterial);
console.log("sphere" + i);
let angle = (360 / numSpheres) * i * Math.PI / 180;
sphere.position.set((startX + Math.cos(angle) * radius),
(startY + Math.sin(angle) * radius),
100);
scene.add(sphere);
spheres.push(sphere);
}
I'm not very good at math, so if anyone can spot where I've gone wrong, I would really appreciate the help. Thank you!