Fold paper by mid-axis several times

Hi forum,
I got some questions about a project I´m working on, the project is about folding a paper in DIN steps. I generate a plane out of several subplanes that represent a page of DIN A4 paper (means 210x297 mm). The first fold is on the mid-axis of the long side - thats what I got to work as you can see here:

https://playground.babylonjs.com/#Y5SWJ2

I achieved this by doing a 2-way for-loop with horizontal and vertical amount of pages, within those loops I grouped pages on their sheet half and made a simple rotation of the sheet half until 180 degrees. So far so good, now my questions:

  1. Is there a possibility to have planes in several groups (parent transform nodes), because for the next fold I need to move the bottom side up - this includes pages from both sheet halfs.
  2. Useful would also be if I could address to every specific plane by a key, putting: “page_” + i + j seems to be a way, but how do I use those information

Thanks for every help or hint
Regards, Dom

Hello and welcome!

I could image having 4 planes to make a page so you can decide how to animate the fold. Does it make sense?

Hi guys. Welcome dom!

Somebody did SOMETHING… here: https://www.babylonjs-playground.com/#192VEQ#10

And there’s another box-folder playground/project available, too, but I couldn’t find it. I think it might be from old forum days. I’ll keep looking. Pinging @flomotion just in case he/she was involved… possibly.

I have an idea (yikes!). Using onAnimationEnd callback, or similar folding-finished observer… FAKE IT. :slight_smile: There is ALWAYS ONLY two planes. After first folding visually becomes overlapped planes (looks like a single plane)… instead it becomes TWO planes again (un-noticed by users).

Before first fold… planes are side-by-side, as shown in dom’s playground. OnAnimationEnd… quickly place two (down-scaled) planes… above/below each other, and texture them so that you see no visual change during the onAnimationEndSoItsTimeToScaleAndRepositionAndTextureTwoPlanes() function. hehe.

Next foldFinished(), place two new down-scaled planes… side-by-side again… ready for next fold.

Next foldFinished(), place two new down-scaled planes… above-by-below again… ready for next fold.

etc.

In brief, user sees no visual change when any fold/unfold ends, even though you secretly re-adjusted for further folding/unfolding of two fresh planes. (the “fake”).

During unfolds, same thing… except onUnfoldFinished(), replace unfolded dual-planes… with 100% up-scaled single plane (or two up-scaled planes z-stacked, which looks like a single plane)… ready for further unfolding.

“Faking it” has some limitations, of course, but it makes “plane management”… more manageable. :slight_smile:

OR… power-hack the vertices (positions-kind data) of a ground mesh grid. :open_mouth: Plotting. It’s not always easy to animate vertex positions… in curved arcs… but can be done.

Wha-da-ya-figure, dom? 16 cells in the paper? What is that… 4 fold-in-halfs? (Wingy checks his math manual - powers of 2 section) :slight_smile:

Hi Wingnut,

thanks for showing me a new strategy. I had a talk with some colleagues and we all agree to your solution. I´ll post my progress in some time.

Regards, Dom

1 Like

Hi there,

https://www.babylonjs-playground.com/#J06MJ3

as you can see I´ve build two functions:

    // Folding horizontally from left to right or otherwise
    doHorizontalFold(sheetWidth, sheetHeight, step, side, direction, scene);
    // Folding vertically from bottom to top or otherwise
    doVerticalFold(sheetWidth, sheetHeight, step, side, direction, scene);

Those params mean:

sheetWidth/sheetHeight = dimensions of the paper (INT)
step = the number of the fold (INT)
side = top/bottom or left/right (STRING)
direction = up or down (STRING)
scene = the current babylon scene

You can try out by changing line 187: this.doHorizontalFold(sheetWidth, sheetHeight, 1, ‘left’, ‘up’, scene);

After the animation those 2 parts of the sheet become deleted by i.e. “sheetHalfTop.dispose();” as you said, but I have no idea how to begin the following fold step at the last position of the sheet half with its dimensions.

Maybe you could give me additional hints how to achieve that.

Regards, Dom

1 Like

Hi folks,
I have a similar requirement of folding paper multiple times both horizontal and vertical multiple times .the solution you mentioned above is really useful @dom.I would like to know if you had achiedved the solution for the next fold from last position ( how to begin the following fold step at the last position of the sheet half with its dimensions .)and also is it possible to fold the sheet horizontal and vertical 1/3rd or 1/4th instead of half .
Any help is appreciated .

Thanks in advance,