# Question about sphere positions dynamically

## Recommended Posts

Now I have other doubt, How can I dynamically do multiple spheres and how do they position themselves as a circle. Exemples below:

in put 5 in the input on the html. but netx I put 8, so how i can do this ? someone can help me with this? plz

##### Share on other sites

If spheres were contained in an array:  var spheres = [ ];

Any time a sphere was added or removed,  I would have a function which (re-)positioned ALL of them in a loop, based on a center point, radius, the length of the array, and the index into the for loop.

##### Share on other sites

31 minutes ago, JCPalmer said:

If spheres were contained in an array:  var spheres = [ ];

Any time a sphere was added or removed,  I would have a function which (re-)positioned ALL of them in a loop, based on a center point, radius, the length of the array, and the index into the for loop.

Can you make an example plz ?

##### Share on other sites

Nah.  I'll credit you for not trying to hide you are a student.  I do not do students homework / projects for them.  Others might though.

##### Share on other sites

``````    var spheresCount = 20;
var alpha = 0;
for (var index = 0; index < spheresCount; index++) {
var sphere = BABYLON.Mesh.CreateSphere("Sphere" + index, 32, 3, scene);
sphere.position.x = 10 * Math.cos(alpha);
sphere.position.z = 10 * Math.sin(alpha);

alpha += (2 * Math.PI) / spheresCount;
}``````

Stolen from here: http://babylonjs.com/Demos/CustomRenderTarget/

##### Share on other sites

1 hour ago, JCPalmer said:

Nah.  I'll credit you for not trying to hide you are a student.  I do not do students homework / projects for them.  Others might though.

Ok, i understand

##### Share on other sites

I am expecting an A+ on this one though!

##### Share on other sites

Hey @JCPalmer... wouldn't you crap a log if Jim's last name was "Student"?  [ link

##### Share on other sites

27 minutes ago, Wingnut said:

Hey @JCPalmer... wouldn't you crap a log if Jim's last name was "Student"?  [ link

xD

##### Share on other sites

18 hours ago, Wingnut said:

Hey @JCPalmer... wouldn't you crap a log if Jim's last name was "Student"?  [ link

Nah, the impersonal nature of the internet is one its "features" (wing bait).  I didn't have the internet when I was in university.

The best advantage I could get was going to the data center building, and using the keypunch machine on the loading dock.  No lines, and your print out came out really quick submitted from there.  You had to type standing up, but no competition from legions of Cobol muggles from the college of business.  Takes 100 cards to blow your nose in Cobol.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.