How to move stair up and down using control buttons

Hello best forum ever seen

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).

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).

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ā. Stay tuned.

Why are you trying to reinvent the wheel? We have the physical mechanical laws from the real world. All you have to do is look at the technical drawings of an escalator: There is a motor. There are the stairs as a closed chain. When the motor turns, it moves the stairs. Actually quite simpleā¦

@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

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)

ok, I understand.

What about the idea to create objects with different stair positions and show them in a sequence-loop?

@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

When I load my scene I can identify the meshes by there ID and then the magic happens: I can modify anything with the single meshes.

``````      Promise.all([

BABYLON.SceneLoader.ImportMeshAsync(null, "scenes/", "Cub3_Plane_v06.obj", scene).then(function (result) {
for(var i=0;i<result.meshes.length;i++) {
result.meshes[i].position.x = 0;
result.meshes[i].position.y = 0;
result.meshes[i].parent = meshes_hinges[1];
}

}),
]);``````

@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ā? 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.

@Wingnut, what would you pay me?
Iām not an artist - I canāt live from applause aloneā¦
and Iād like a motivation to work for you.

1 Like

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.

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. 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.

omni engine is ā¦ &%/(zensored)\$Ā§!!!

I took my turtles and created by accident a tank chain! ā¦ which can be used as a starways too.
https://www.babylonjs-playground.com/#3MR41H

The rotation algorithm should be optimized by suitable fourier serie

Some suggestions for architects:

@aWeirdo I think that ur proposition has been done by @Wingnut here https://playground.babylonjs.com/#KI8BJH#5 (thank you @Wingnut by the way ) 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