Align items in a specific layout

Hi!

I would like to insert N objects in a scene and align them in a spherichal mood.
Here is an image:
image

How can i achieve this?
any idea?

One approach to achieve such an effect is demonstrated in the following example:

https://threejs.org/examples/webgl_buffergeometry_constructed_from_geometry.html

The idea is to use Vector3.setFromSpherical() or Vector3.setFromSphericalCoords() to generate euclidian coordinates organized in a spherical shape. You can calculate the necessary parameters like this:

const radius = 2;

for ( let i = 1, l = count; i <= l; i ++ ) {

    const phi = Math.acos( - 1 + ( 2 * i ) / l );
    const theta = Math.sqrt( l * Math.PI ) * phi;

    vector.setFromSphericalCoords( radius, phi, theta );

    // do something with vector

}

count is the amount of your objects.

1 Like

Have a look at this:


It’s also in the sample collection:


Perhaps this example from the collection is helpful:

http://discourse.threejs.hofk.de/Tree%20on%20a%20Sphere/Tree%20on%20a%20Sphere.html

1 Like