You want the vertices to form a sphere? Something like:
const v = new Vector3();
function randomPointInSphere( radius ) {
const x = _Math.randFloat( -1, 1 );
const y = _Math.randFloat( -1, 1 );
const z = _Math.randFloat( -1, 1 );
const normalizationFactor = 1 / Math.sqrt( x * x + y * y + z * z );
v.x = x * normalizationFactor * radius;
v.y = y * normalizationFactor * radius;
v.z = z * normalizationFactor * radius;
return v;
}
It’s helpful with questions if you explain fully and completely what you mean to start with btw, don’t make people who want to help you play guessing games.
forgive me but English is not my native language. I’m grateful for your help. I just incorrectly expressed the thought. I hope this does not cause your resentment
If you use THREE.Geometry(), then for each vertex you can set coordinates of start, coordinates of end and then interpolate start to end with .lerpVectors() method of THREE.Vector3() object.
var geometry = new THREE.Geometry();
var spherical = new THREE.Spherical();
for(let i = 0; i < 50000; i++){
geometry.vertices.push(setRandomPointInSphere(10)); // 10 is the desired radius
}
function setRandomPointInSphere(radius){
var v = new THREE.Vector3(
THREE.Math.randFloatSpread(radius * 2),
THREE.Math.randFloatSpread(radius * 2),
THREE.Math.randFloatSpread(radius * 2)
);
if (v.length() > radius){
return setRandomPointInSphere(radius);
}
return v;
}