How to move stair up and down using control buttons

Hello best forum ever seen :two_hearts:

I need your help in this 3d electrical stair, so here is the playground : https://playground.babylonjs.com/#KI8BJH#1

I import 3d stair from github and you find the the stair mesh that I want to move (red one), and I create buttons and their functions to move up and down, I donā€™t know how to move the stair (animation).

please help

Best regards

Anes

1 Like

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