How to move stair up and down using control buttons

Hiya Anes
The stairs mesh… https://playground.babylonjs.com/#KI8BJH#3 …is not easily animated in any realistic way, because it is a single mesh. We can position-animate the entire mesh… but the top/bottom stairs “landings” (the flatter areas at top/bottom of stairs)… will also move up/down the ramp… not looking correct.

#1 way: There IS a way to make this look/act correctly, but it will take some work. You would disable/remove the stairs mesh, and then build (in BJS scene) a top-landing, a bottom landing, and a single stair-step. Then we would “create-instance” that single stair step… about 20 times. Now we have about 20 single stair-steps, and we can apply a semi-complex animation “system”… to those 20 stair-steps. This is a substantial bit of work.

#2 way: We/Someone could “morph” the current full-stairs mesh… by moving/animating the mesh vertices (position points) of the full stairs… in a way that makes it look realistic. A guess… we would need to move about 240 position-vertices… every step of the animation/morph. This is also a fairly serious challenge.

I would say that method #1 is the wiser/easier way. The BJS ExtrudeShape should work, for making a single stair-step… like this: https://www.babylonjs-playground.com/#165IV6#821

I tried to do some instancing… to make many single-steps… but I failed. (Apparently I need to study more). :slight_smile:

Anyway, now you have more info, and a single stair-step. Others will likely comment soon… with more ideas… and maybe someone can get the instancing/cloning working for extruded mesh. And I’m sure that there are some “mad scientists” nearby… that would try (to get you started-with…) “The Escalator Animation Challenge”. :slight_smile: Stay tuned.

@Wingnut thank you for ur reply.
about #1 if I use one stair-step it will not be realistic because I need this to visualize a real escalator.
about #2 I tried but faaaail :sob::sob::sob::sob::sob::sob::sob:

1 Like

@Necips the problem is that I have this escalator Sketshup which I export it to BJS format and I can not modify it (it is for a metro station vizualisation)

@Necips but how to create objects in different position, and if yes does this will affect the performance of my interface because there is a lot of meshes inside

@Necips yes but here inside your Cub3_Plane_v06.obj there is a lot of meshes that u want to annimate via your loop, not the case of me I have one stair object and not a lot of stair-steps meshes

@Anes
Can you not separate the stairs in sketchup before exporting ?

That would be the simplest.
Other option could be to do it in babylon, this is slightly more complicated and has to be done each time it is loaded… (at cpu / loading time cost)

@aWeirdo I have it in SketchUp and I can export it to blender, do you mean seperate the stair into step-stair meshes ?

Yes, just a single step and the two platforms(at bottom and top of stairs) as others also mentioned, delete the rest of the steps, then re-make them with instances within babylon

Okey, I’ll try it

1 Like

Hi again, A. #1 would be many clones/instances of a single stair… all positioned in a way to appear much like your current stairs (like aWeirdo mentions, too). I got the extruder instancing working… dumb wingnut mistake in positioning them. https://www.babylonjs-playground.com/#165IV6#822 I may try some animating… soon.

Heya Necips. Are you going to build one of those (200 physics joints?) motor-driven chains… for us, seeing it’s “quite simple”? :wink: Sprockets on the primary motor drive and secondary pulley? Each chain link able to accept a sprocket tooth INSIDE it, and moved-along by the teeth? Yeah, I’d love to have one of those physics engine demos… for all sorts of future projects, especially physics-driven bicycles and other vehicles. Make one for us… full powered… and you’d be fizzix-famous. I have never seen a physics-active chain’n’sprockets demo, anywhere, so far.

What about the FAME? That’s what pays the bills, no? Do it for posterity. Do it for mankind… for world sprockets/chain peace… for the little woodland critters… for the noobs, for the babes, for the hell of it. :smiley:

1 Like

Hey @Anes - a starter kit… https://playground.babylonjs.com/#KI8BJH#5

Currently, shape and path aren’t set perfect… so slope-angle and stair-size is not very accurate. BUT… we got UP and DOWN buttons doing a small up/down animation movement on the gray staircase (just a little… for each button press). Might have problems in my vector3’s for lines 139 & 145, too. That issue is possibly improved in PG #6.

Also, ease is disabled in moveTo() func. Just add ease as the last param in line 69… to-re-activate it, as wanted.

Plus, I have no “loop-around” happening. When top step gets too high, or bottom step gets too low… we have to move it to opposite end of staircase. :slight_smile: Fun. Plenty of tweaking needed… but… I think you can see the possibilities, there.

Do you want to “run with it” from here? Do you want some explanation of the playground, so far? Maybe other forum helpers will want to advance this a bit, now that I have started it. The moveTo() animation-helper function might need tweaking. It might need to change from a “moveTo” to a “move”, or maybe it needs replacing, possibly with moveUpAndCheckWrap() and moveDownAndCheckWrap().

Good fun, BJS-style.

@aWeirdo I think that ur proposition has been done by @Wingnut here https://playground.babylonjs.com/#KI8BJH#5 (thank you @Wingnut by the way :innocent: ) the problem is on the animation of the stairs, I want to move them the same way of a real metro station escalator (not up down), I don’t know I have an idea and I don’t find a way to implement it, the idea is :

  • If I click to move up : the top-stair-step will move and take place of bottom-stair-step and the bottom-stair-sep will move to first-stair-step, the first-stair-step will move to secons-stair-step ans so on.
  • but when moving the top-stair-step to to bottom it happen invisible (we don’t see the mouvement of the step-sair like it is hidden by escelator chain )
1 Like

similar to @Necips first example:

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

https://www.babylonjs-playground.com/#WXQ2S4#1

2 Likes

@Wingnut @aWeirdo I tried this https://playground.babylonjs.com/#KI8BJH#8 so when I click move up it moves once, I need to

  • hide the movement of the top-step to the buttom
  • and repeat the scene

Hi Anes and all helpers. Ya know, I think @adam’s and @Necips’ escalator looks pretty good (they’re both geniuses, ya know?)

So… I merged their code into your scene, added a (bad Wingnut-coded…) direction-adjusting system, and hooked up the GUI buttons.

https://playground.babylonjs.com/#KI8BJH#10

It still needs rotating and size-adjusting, and, to be frank, I have no idea how to do that (to that gorgeous sinusoidal escalator formula of Adam’s/Necip’s). We might need to rotate entire main model.

Scary stuff, but, damn… these guys are as smart as they come, eh? Math Gods. (sigh, drool, envy, etc). Thanks for the assistance, guys! Well done!

And Anes… you are/were advancing real well… in your previous playgrounds. I can see your deductive reasoning and brave experimenting at-work… and you are surely headed towards becoming a BJS pro. But this algorithm/formula… is/was semi-complex, so we should probably TRY to use what the guys have built for us, somehow. You gotta admit, it looks pretty darned nice.

I lead you astray with the moveTo function. We needed a better animator than that, one with an onAnimationEnd callback function… so you could hide the end-around stair-step during the long-move, and NOT use moveTo for that move. Instead, set its .visibility=0 and then make it JUMP to the other end… with a quick step.position = someVector3. Possibly, a real HIGH SPEED moveTo would work, but still, our moveTo has no onAnimationEnd… and we needed that… for the “hiding”.

There were other logjams, too… because… I was hurrying and hadn’t let smarter people than I… reply. Sorry about that. And again… you were/are doing a great job with BJS so far… but your project is a “big gulp”… complexity-wise.

Perhaps… we can beg Adam/Necips/others… to help us “apply it” to your mostly-disabled main model. (fingers crossed) :slight_smile:

@Wingnut @aWeirdo so I will thank @adam and @Necips, so I hide my stair and replae it by step generator here the PG https://playground.babylonjs.com/#KI8BJH#15.

but when I test it using my stair (I devide it into sumeshes in blender), and I want to use the same algo presented by @Necips here the PG https://playground.babylonjs.com/#KI8BJH#16
is looking so big comparing with my stair mesh :thinking:

https://playground.babylonjs.com/#KI8BJH#19

I changed your ‘y’ variable… to be named root. You should avoid naming a variable x, y, or z… when swimming in 3d waters. :slight_smile: Might be wise to avoid u, v, w, too… which is same as x,y,z, but for textures.

In lines 34-37… root needed some fresh scaling, rotation, and positioning. In BJS… parenting is sort-of the same as grouping. Mesh-parents… pass-along their scaling, rotation, and position… to their children (group members), which can ADD/SUM their own values… to/with the handed-down parent-values.

All in all, we can rotate, scale, position the topmost parent (group), and all the members of the model… go along. YAY!

Ignore lines 38/39… Wingnut trying something and failing. :slight_smile: I was trying to get the master model to… “reset yourself back to 0,0,0 rotation and position values, and 1,1,1 scaling values”. Sort of a “naturalize” this mesh at current rotation, position, and scaling, yet don’t visually change ANYTHING… attempt.

That “bake” would likely work… but… I think your “root” node… is SOME distance from the top, bottom or center… of the e-stairs. There is a rather wide space-gap. It can be fixed in JS or modeler, I suspect. Meantime, no baking, yet. :slight_smile: Updated to pg#19… a little “cleaner” PG, but same functionality.

Looks like the sine wave needs a little increase in peak-to-peak AC voltage. A little more audio amplitude (volume) for that tone. :slight_smile:

1 Like

@Wingnut thank u so much dud for ur effort now the escelator works fine (I should remove my stairs and replace them with BJS step meshes and then ajust the position and the rotation to have a nice stair :smile: ).
don’t worry there is only problems I’ll show you my metro station soon (with problems of course :smiley: )
we learn from you guys, thank you so much again
peace :v:

1 Like

That’s excellent news, A! We all look forward to your station. That sounds like a challenging-but-sweet project.

I was able to learn TONS of useful things… from ALL of you… during this little challenge, and it was fun, too.

Welcome to Lake Babylon, the friendliest geometrical and geographical community… ever rendered. :slight_smile:

We built you a nice ranch-style home on the east shore of the lake - in the Explorado community. Hackerville, up-on the north shore, is about 2.5 miles from your new home. Lake Babylon township, on the south shore, is about the same distance away.

I still live on the west-side of the lake… in Toddler Town… a little neighborhood of “children with power tools” :slight_smile: Most of the Lake Babylon emergency services… are based-in Toddler Town, too… where most of the BJS scene explosions occur. :smiley: Your new home is safely beyond Toddler Town’s flying shrapnel zone. heh.

We could probably use some nice transit stations… when we build Lake Babylon’s Under-The-Lake light-rail system. :wink: I hear that the center-of-lake transit station… is going to be 24 stories high. 3 stories into the lake bed, 14 stories in-water, and 7 stories above the lake, with marina, light-show projectors, fireworks launching platform, heli-port, and digital TV/radio transmitter/studio (LBTV). I think you have been assigned as lead architect for Lake Center Station. :slight_smile: