Published
Edited
Mar 8, 2020
8 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
position = (u, v, r) => {
const spherePoint = [
r * Math.cos(v) * Math.cos(u),
r * Math.cos(v) * Math.sin(u),
r * Math.sin(v)
];
// Noise value at this point on sphere
const offset = perlin3(...spherePoint.map(d => d*scale));
return new THREE.Vector3(
...spherePoint.map((d, i) => d * (1 + coeff * offset))
);
}
Insert cell
sphere = {
const meshes = [];

const du = Math.PI / 30;
const dv = Math.PI / 30;
d3.range(0, 2*Math.PI, du).forEach(u => {
d3.range(-Math.PI/2, Math.PI/2, dv).forEach(v => {
const param = [
{u: u, v: v },
{u: u+du, v: v },
{u: u+du, v: v+dv},
{u: u, v: v+dv}
];

const r = 1;
meshes.push(rect(
...param.map(p => position(p.u, p.v, r)),
materials[material]
));
});
});

return meshes;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more