Generates a mesh of light spots in 3D space, extremely efficiently.
const m = massSpotMesh({
spots: [...Array(4000)].map(() => ({
x: Math.sqrt(Math.random()) * Math.sign(Math.random() - 0.5),
y: Math.sqrt(Math.random()) * Math.sign(Math.random() - 0.5),
z: Math.sqrt(Math.random()) * Math.sign(Math.random() - 0.5),
mass: Math.random() * 0.01,
rgb: new THREE.Color().setHSL(-Math.sqrt(Math.sqrt(Math.random())) + 1, 1, 0.3).getHex()
}))
});
Live demo: https://raw.githack.com/mihailik/three-g/refs/heads/main/index.html


- spots particles that may have coordinates, colour and mass
- get if metrics of the spots are stored elsewhere, you can provide them via this callback
MIT Oleg Mihailik