points = {
var particles = 5000000;
var geometry = new THREE.BufferGeometry();
var positions = [];
var colors = [];
var color = new THREE.Color();
var n = 1000,
n2 = n / 2;
for (var i = 0; i < particles; i++) {
var x = Math.random() * n - n2;
var y = Math.random() * n - n2;
var z = Math.random() * n - n2;
positions.push(x, y, z);
var vx = x / n + 0.5;
var vy = y / n + 0.5;
var vz = z / n + 0.5;
color.setRGB(vx, vy, vz);
colors.push(color.r, color.g, color.b);
}
geometry.setAttribute(
'position',
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setAttribute('color', new THREE.Float32BufferAttribute(colors, 3));
geometry.computeBoundingSphere();
var material = new THREE.PointsMaterial({
size: 3,
vertexColors: THREE.VertexColors
});
let p = new THREE.Points(geometry, material);
scene.add(p);
return p;
}