QuintusHegie

BabylonJS Model Train Simulator - project

Recommended Posts

Hi Guys & Gals,

I just wanted to let you know I'm learning 3D browser game programming in my spare time by developing something like a Model Train Simulator in BabylonJS.

Thanks to the great and easy access framework of BabylonJS I've been able to develop much faster than with C++ / Direct3D 15 years ago.

This project is in early stage but progressing though. I'm having some math-computations challenges on the track turnout points, but hope to have them fixed soon so that you can drive trains on more complex routes.

The app supports keyboard, mouse, touch, gamepad input and also VR-headset device. Multiplayer support currently only on same device (e.g. connect 2 gamepads).

Anyway, here's a teaser-screenshot of what can be called a level inspired by the "Sponza" demo. :-)

Kind regards,

Quintus

babylonjs model train simulator sponza.jpg

Share this post


Link to post
Share on other sites

Sure, will do!

Although the "Sponza" level is not stable yet and will crash your browser now and then...

You can play around a bit in the "basic setup" level consisting of only a simple circle track and a small diesel locomotive:

https://hegieq.home.xs4all.nl/games/gardentrains/circle.html

Yeah :D

Instructions on how to control the locomotive you can find in the mini video:

Press 'Q' to accelerate and 'A' to brake/reverse (works best on QWERTY keyboard).
Or click the green Accelerate button and/or red Brake button with your mouse.
Or press 'A' button on your gamepad to drive and 'B' button on your gamepad to stop/reverse (connect your gamepad BEFORE loading the webpage, though).

Can you collect all 3 marbles?!? ;)

This track doesn't consist of points/turnouts therefore no problems yet as I've still got to solve the switches-mathematics.

Enjoy!

Quintus

babylonjs model train simulator circle.jpg

Share this post


Link to post
Share on other sites

Fixed a small 'bug' caused by a new dependency on 'earcut.min.js' in the BabylonJS framework. So you won't see a heavenly white crash screen any more until the next dependency is introduced. :huh:

Ok anyway now for something a bit more exciting a second "basic setup" level consisting of a simple oval track, a small steam locomotive, a lowboard wagon and a gated level crossing:

https://hegieq.home.xs4all.nl/games/gardentrains/oval.html

Instructions on how to operate coupled wagons you can find in the second mini video:

To couple with a wagon, simply slowly drive towards it with your locomotive.
To decouple a wagon (the last wagon in the train), press keyboard 'D' or click the 'Decouple' button.

The white wireframe around the gated level crossing shows the bounding box for detecting approaching locomotives (used for debugging).

Look at those cozy white puffs expanding as you speed up your model train steam engine! :lol:

Enjoy a Good Friday and a Happy Easter!

Quintus

P.S. If anyone has a hint on how to restrict 'bone' physics movements to world Path3D... happy to hear! It will help me fix the bogies to the track and wagon frame properly, especially in railroad curves. And save me a lot of custom math computations too.

babylonjs model train simulator oval.jpg

Share this post


Link to post
Share on other sites

Short update on the game.

I moved the game startpage to a more official location:
https://quintushegie.com/gardentrains/

I've been working on scene optimization techniques like LOD, as the framerate quickly drops for larger track layouts.

The level construction may take some time during load (repetitive calls to matrix updates when laying the rail track), so please give it 30 seconds or so for the larger demos/levels.

Anyway if you like the work-in-progress game so far and you have some 'special requests' already just let me know, maybe I like the suggestion and include it in the game 🙂

Q

Share this post


Link to post
Share on other sites

Hi Guys and Gals,

Last summer I went to the Technology & Innovation Lab at a well known IT consulting firm near railway station Utrecht Leidscherijn, The Netherlands (guess which one).
Demo'd my game briefly there (in return for trying out their expensive VR headset in my game 😉 ). The game ran awfully slow without any optimization yet but that didn't spoil the fun.

Recently HansR, from that company, wrote a very short article about my Model Train Simulator:
http://hansrontheweb.blogspot.com/2018/10/babylonjs-applied-model-train-simulator.html

And here you can read more about the Wednesday Evening tech tryouts at that firm, for instance playing around with BabylonJS framework:
http://hansrontheweb.blogspot.com/search/label/babylonjs

Looks like a nice place to code collaboratively!

So next time you feel lonely coding BabylonJS, cheer up... and call the innovation department of a major IT related company in your neighborhood.

#happycoding

Q

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.