Can I place obects on a sphere surface evenly

I current studying at Sprite and want to place lot of photos on a sphere and select them . After fiddle with Three.Spherical I finally success . But now I can only place radomly on the sphere by the following code

	let spherical = new THREE.Spherical();
	let point = new THREE.Vector3();
	function randomOnSphere(radius, PhiRange, ThetaRange) {
		let randomPhi = Math.random() * PhiRange * Math.PI / 180;
		let randomTheta = Math.random() * ThetaRange * Math.PI / 180;
		spherical.set(radius, randomPhi, randomTheta);
		point.setFromSpherical(spherical);
		return point;
	}

sometimes photo behind others never show completely. Is there any function that I can place them evenly
here is my result https://relaxslow.herokuapp.com/

Did you see that?
http://discourse.threejs.hofk.de/PictureBall/PictureBall.html

In the collection

I documented how I did a random even distribution on a sphere at the bottom of this article. You need an acos call.

Great collection, I’ll take time to view them one by one

Hi, joshmarinacci
I put your code into my program

function randomOnSphereEven(radius) {
		//pick numbers between 0 and 1
		var u = Math.random();
		var v = Math.random();
		// create random spherical coordinate
		var theta =Math.acos(2 * u - 1);
		var phi = Math.acos(2 * v - 1);
			spherical.set(radius, phi, theta);
		
		 point.setFromSpherical(spherical);
		 return point;
	}

and get following result
Untitled%2029

Maybe I have misunderstood the code , I don’t get desired result .Can you explain the code . Sorry , I’m not good at math , but I do want to learn them.

var phi = Math.acos(2 * v - 1);

Inspired by your examples , there are finally some math sparks in my brain. In fact it’s really simple, I changed my function to

function randomOnSphereEven(radius, PhiNum, thetaNum) {
		let points = [];
		phiSpan = Math.PI / (PhiNum+1);
		thetaSpan = Math.PI * 2 / thetaNum;
		// create random spherical coordinate
		for (let i = 1; i < PhiNum+1; i++) {
			phi = phiSpan * i;
			for (let j = 0; j < thetaNum; j++) {
				theta = thetaSpan * j
				spherical.set(radius, phi, theta);
				let point=new THREE.Vector3();
				point.setFromSpherical(spherical)
				points.push(point);
			}
		}
		return points;
	}
	let points= randomOnSphereEven(500,4,5);

So I must specify the span of U and V on the sphere,
Untitled%2030
Thank you everyone!!

2 Likes

In the latest revision this part can be simplified to one-liner:

let point = new THREE.Vector3().setFromSphericalCoords(radius, phi, theta);

https://threejs.org/docs/index.html#api/en/math/Vector3.setFromSphericalCoords
Thus, there’s no need for using of THREE.Spherical().

Hi , prisoner849
more simple now !! There is such a convinient function, thank you !