Heya folks! So doing some crash course code lessons and decided to see if I can get Geekmoms pattern shifted over from 2D to 3D and I did! Here is the adapted code. Um, I should probably fix the comments since they’re off now.
/* Very simple pattern of three circles, one red, one green, and one blue that
* float around the screen by oscillating with different frequencies in x and y.
* Where they overlap their colors mix.
*
* Debra Ansell (GeekMomProjects)
*/
function randomSpeed(min, range) {
return min + random(range)
}
speed = 5 // Change this value to make the pattern move faster/slower
txr = randomSpeed(.1, .5)/speed // Time values for the x/y motion of the red, green, blue circles
tyr = randomSpeed(.1, .5)/speed
tzr = randomSpeed(.1, .5)/speed
txg = randomSpeed(.1, .5)/speed
tyg = randomSpeed(.1, .5)/speed
tzg = randomSpeed(.1, .5)/speed
txb = randomSpeed(.1, .5)/speed
tyb = randomSpeed(.1, .5)/speed
tzb = randomSpeed(.1, .5)/speed
export function beforeRender(delta) {
rad_r = 0.3 + 0.2*wave(time(.33)) // Make the radii of the balls vary with time
rad_g = 0.3 + 0.2*wave(time(.41))
rad_b = 0.3 + 0.2*wave(time(.29))
xr = wave(time(txr)) // Compute the x,y positions of the balls over time
yr = wave(time(tyr))
zr = wave(time(tzr))
xg = wave(time(txg))
yg = wave(time(tyg))
zg = wave(time(tzg))
xb = wave(time(txb))
yb = wave(time(tyb))
zb = wave(time(tzb))
}
export function render(index) {
render3D(index, index/pixelCount, 0.5)
}
export function render3D(index, x, y, z) {
r = 0 // r,g,b compontnets of pixel color depend on distance from center of ball
g = 0
b = 0
hr = hypot3(x - xr, y - yr, z - zr) // Distance from center of red ball
if (hr < rad_r) { // Red value brightest at center, then falls off
r = 1-hr/rad_r
}
hg = hypot3(x - xg, y - yg, z - zg) // Distance from center of blue ball
if (hg < rad_g) { // Blue value brightest at center than falls off
g = 1 - hg/rad_g
}
hb = hypot3(x - xb, y - yb, z - zb) // Distance from center of green ball
if (hb < rad_b) { // Green value brightest at center then falls off
b = 1 - pow(hb/rad_b,3)
}
rgb(r, g, b)
}
So I tested this out on the 8x8x8 cube and success! Works like a charm! Super happy I was able to mostly figure this out (save for a errant capital letter I needed a friend to find. Coding is hard)!
The issue I’m running in to is on the 16x16x16. It is not acting as a whole. it’s bouncing around as if it’s 4 separate PIxelblazes and is disjointed. I double checked to make sure the mapper wasn’t going screwy but rest of the patterns are just fine! I also went way back and used @zranger1 Bouncer 3D to make sure it’s not just a me problem with my code adjustments and its giving me the same effect. Anyone have some ideas as to why both of these are having the same issue when I use multiple PBs?
Heres a video that (hopefully) shows whats going on.