xxxxxxxxxx
43
var R = 150
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL)
angleMode(DEGREES)
cursor(CROSS)
}
function draw() {
background(0)
randomSeed(42)
orbitControl()
drawSphere(100 * sin(120), 100 * cos(120), 0)
drawSphere(100 * sin(240), 100 * cos(240), 0)
drawSphere(100 * sin(360), 100 * cos(360), 0)
}
function drawSphere(cx, cy, cz) {
push()
translate(cx, cy, cz)
for (var i = 0; i < 1500; i++) {
// Point on a sphere
// See: https://stackoverflow.com/questions/969798/plotting-a-point-on-the-edge-of-a-sphere
strokeWeight(2)
stroke(random(100, 200))
var s = random(0, 360)
var t = random(0, 360)
var dR = map(noise(s * 0.005, t * 0.005), 0, 1, -20, 20)
var x = (R + dR) * cos(s) * sin(t)
var y = (R + dR) * sin(s) * sin(t)
var z = (R + dR) * cos(t)
point(x, y, z)
}
pop()
}