javascript - calculation to arrange spheres in a ring -
i'm trying arrange 10 spheres in ring. calculation have put far, not working
var bubblegeo = new three.spheregeometry(300, 20, 20); var bubblemat = new three.meshlambertmaterial( { color: 0x888888 } ); var numbubbles = 10; var bubblemesh; var bubbles = []; var startx = 0; var starty = 500; var spacing = 80 * math.sin( angle ); (var i=0; i<numbubbles; i++) { bubblemesh = new three.mesh(bubblegeo, bubblemat); console.log("bubble" + i); var angle = 360/numbubbles*i*math.pi/180; bubblemesh.position.set((startx + math.cos(angle)*bubbler) + spacing, (starty + math.sin(angle)*bubbler) + spacing, 100 ); scene.add(bubblemesh); bubbles.push(bubblemesh); } i don't know math. if folks there see have went wrong, appreicated. thanks!
var bubbler = 400; var bubblegeo = new three.spheregeometry(bubbler, 10, 10); var bubblemat = new three.meshlambertmaterial( { color: 0x888888 } ); var numbubbles = 5; var bubblemesh; bubbles = []; var startx = 1000; var startz = 1000; (var i=0; i<numbubbles; i++) { bubblemesh = new three.mesh(bubblegeo, bubblemat); var angle = 360/numbubbles*i*math.pi/180; bubblemesh.position.set((startx + math.sin(angle)*bubbler) * 2, 1000, startz + (math.cos(angle)*bubbler) * 2 ); scene.add(bubblemesh); bubbles.push(bubblemesh); } for reason, if add array scene after loop, doesn't work. wish in new three.group, position whole group, doesn't seem work @ moment either
Comments
Post a Comment