const radius = 20;
const points = [];
for (let i = 0; i < 100; i += 1) {
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);
points.push(new Three.Vector3(
x * normalizationFactor * radius,
y * normalizationFactor * radius,
z * normalizationFactor * radius,
));
}
const geometry = new Three.ConvexGeometry(points);
const wireframe = new Three.WireframeGeometry(geometry);
const material = new Three.LineBasicMaterial({
color: 0xffffff,
lineWidth: 1,
});
const line = new Three.LineSegments(wireframe, material);
// line.material.depthTest = false;
// line.material.opacity = 0.5;
// line.material.transparent = true;
console.log(geometry, wireframe, line);
const scene = new Three.Scene();
scene.add(line);
I tried to create some random points on a sphere, then use some lines to link them. But I failed in using convex geometry.
What’s wrong with my code? Three.WireframeGeometry may link all my points, what’s the true way to create only some random lines on my sphere?