I am currently working on a mobius strip animation based on this example: Mobius Strip Animation - #6 by glv
However, I am trying to figure out a way to increase the folds and double the strip. This is my first attempt at working with 3D, and it is a tricky entry point and the math may be beyond my skill level, but I wonder if anyone has suggestions on how to increase the folds. Here is my code:
let rad;
let v;
let turn = 0;
let num;
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
colorMode(HSB, 360, 100, 100, 100);
rad = width*.3;
v = width*.1
num = height*.5;
frameRate(30)
}
function draw() {
//background(40, 20, 100);
background(10);
lights();
push();
rotateY(turn);
rotateX(turn);
rotateZ(turn);
//noStroke();
drawTrack(100, rad, v);
drawEdges(100, rad, v);
turn += 0.003
pop();
}
function drawTrack(steps, rad, v) {
beginShape(TRIANGLE_STRIP);
fill(0);
strokeWeight(2);
stroke(255);
for (let step = 0; step < (steps + 1); step += 1) {
let u = step * TAU / steps;
let x = (rad - v * cos(0.5 * u)) * cos(u);
let y = (rad - v * cos(0.5 * u)) * sin(u);
let z = -v * sin(0.5 * u);
vertex(x, y, z);
x = (rad + v * cos(0.5 * u)) * cos(u);
y = (rad + v * cos(0.5 * u)) * sin(u);
z = v * sin(0.5 * u);
vertex(x, y, z);
}
endShape(CLOSE);
}
function drawEdges(steps, rad, v) {
for (let step = 0; step < (steps + 1); step += 1) {
fill(260, random(100), 100);
stroke(0)
let u = step * TAU / steps;
let x = (rad - v * cos(0.5 * u)) * cos(u);
let y = (rad - v * cos(0.5 * u)) * sin(u);
let z = -v * sin(0.5 * u);
push();
translate(x, y, z);
//box(10)c
box(random(6,10))
pop();
x = (rad + v * cos(0.5 * u)) * cos(u);
y = (rad + v * cos(0.5 * u)) * sin(u);
z = v * sin(0.5 * u);
push();
translate(x, y, z);
box(random(6,10))
//box(10);
pop();
}
}
``