probs = {
const geometry = new THREE.Geometry();
const material = new THREE.PointsMaterial({
size: 0.2,
vertexColors: true,
blending: THREE.AdditiveBlending
});
const n = 30;
const pdfPoints = []
d3.range(-5, 5, 10/n).forEach(x => {
d3.range(-5, 5, 10/n).forEach(y => {
d3.range(-5, 5, 10/n).forEach(z => {
pdfPoints.push({
pos: new THREE.Vector3(x, y, z),
val: normal.pdf([x, y, z])
});
});
});
});
const max = d3.max(pdfPoints.map(d => d.val));
const color = d => d3.interpolateViridis(d / max);
pdfPoints.forEach(p => {
geometry.vertices.push(p.pos);
geometry.colors.push(new THREE.Color(color(p.val)));
});
return new THREE.Points(geometry, material);
}