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.

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

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) {              
          bPlaneLoaded = true;
          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”? :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.

@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. :slight_smile:

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

omni engine is … &%/(zensored)$§!!!

I took my turtles and created by accident a tank chain! :smiley: … 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:

  1. example:
    https://www.babylonjs-playground.com/#3MR41H#1

  2. example:
    https://www.babylonjs-playground.com/#3MR41H#2

  3. example
    https://www.babylonjs-playground.com/#3MR41H#3

@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