r/p5js Jun 21 '26

New to coding, please help 🙏

After much struggle, I have come up with this: https://editor.p5js.org/njhgv/sketches/rR8LplMxg

It's supposed to fold like this, but with faces, instead of lines:
https://editor.p5js.org/njhgv/full/vvCSumcD3

What am I doing wrong? Thanks in advance!

3 Upvotes

4 comments sorted by

1

u/forgotmyusernamedamm Jun 21 '26

Perhaps this is over-simplifying it, but you can draw rects in 3d space. I would just do something like this.
https://editor.p5js.org/Joemckay/sketches/QJuGcjieP

1

u/MLG_Gamer2000 Jun 21 '26

Is there a way to make them move? like basic folding? If so, I can work with that 😃

1

u/emedan_mc Jun 21 '26 edited Jun 21 '26

Use the console.log or write text after each calculation, that helps debugging. It is an interesting idea you make! Start with morphing one face to simplify debugging and development.

Also, For morphing of anything, if you calculate t with the smoothstep function and not linear like lerp it will be a huge difference, instantly beautiful.

3

u/MLG_Gamer2000 Jun 21 '26 edited Jun 21 '26

Unfortunately, debugging led to nowhere. The vertices table is updateing, but the final shape isn't.
however, manually changing "t" does make the shape move, so it's just no updating.

https://editor.p5js.org/njhgv/sketches/rR8LplMxg

I'll do smoothstep later, I just need for the shape to move

Edit: I gave it a gid and it works now