Hello! I’m completely new to pixelBlazes, and I’m amazed by how powerful those controllers are!
Expected behavior:
Constantly rotate my weird ring along the z-axis without it dancing around the shape, similar to this gif: Sonic Ring 1991 GIF by augustoodashi on DeviantArt
What happens instead:
Rotates for a bit, swaying all over the place, then freezes up. Even the counter stops changing.
I suspect I may be misunderstanding how rotateZ(angs) is supposed to be used. I’ve tried the below code with rotateZ(1) in beforeRender with same results. Is this like an owl turning its head around until its head pops off?
Set-up:
Load a 3D cube into the mapper with ~500 pixels, and run the pattern below. It should look like this:
export var rotate
export var pixelCount
export var indexWatcher
export var counter
export function beforeRender(delta) {
/*
This 0..1 time() output cycles every (0.1 * 65.535) seconds. We'll use this
both as the single output hue, as well as a basis for the function that
creates the rotating / bouncing pulse(s).
*/
counter += delta
if(counter > 100){ // 10 times a second
counter = 0
if(rotate > 180)
rotate = 0
else
rotateZ(rotate++)
}
}
export function render3D(index, x, y, z) {
indexWatcher = index
/*
The formula for a 3D plane is:
a(x − x1) + b(y − y1) + c(z − z1) = 0
x y z?
where the plane is normal to the vector (a, b, c). By setting out output
brightness to the right hand side, the initial defined plane is the dark
region, where `v == 0`. This pattern oscillates a, b, and c to rotate the
plane in space. By using the `triangle` function, which is repeatedly
returning 0..1 for input values continuing in either direction away from 0,
we get several resulting 0..1..0.. layers all normal to the vector.
The `3 * wave(t1)` term introduces a periodic phase shift. The final result
is a series of parallel layers, rotating and slicing through 3D space.
*/
v = triangle(x + 0 * y + 0 * z + 0)
// Aggressively thin the plane by making medium-low v very small, for wider
// dark regions
v = pow(v, 15)
// Make the highest brightness values (when v is greater than 0.8) white
// instead of a saturated color
s = v < 0.8
hsv(time(0.1), s, v)
}