Jump to content

Best Practices for Managing Renderloop, Scenes and Obj Comm Logic


Recommended Posts

Hey guys,

still after having read quite a lot on the boards here and having worked through the book "Learning Babylonjs" by Julian Chenard Im always feeling like hacking away on projects and building crappy architecture.

I feel the Documentation should provide best Practices and Examples on:

  • Manage your Renderloop
  • When to apply Logic on objects and when globally or inside the Renderloop
  • When to use Actionmanager, when Animations and when to hardcode Animations in the renderloop
  • Switch in Between Scenes, Serialize and Load them including their and their objects logic

Are there any good resources on this? Especially considering building bigger games and doing things in a proper and non-hacky but more sophisticated OOP way? Will Julien Moreau-Mathis' Book help me? I guess a lot of confusion on the messageboards could be avoided if well documented examples were given. Or if we could fund someone to provide them for the docs..

Best Regards

Link to comment
Share on other sites

2 hours ago, leanderr said:

Are there any good resources on this? Especially considering building bigger games and doing things in a proper and non-hacky but more sophisticated OOP way?

I would say that if you want to do more OOP and especially bigger games that TypeScript is the best way to go, as the compiler will enforce your intentions as opposed to coding by convention.  Lots of resources on that; even Babylon.js itself made the switch from JavaScript to TypeScript.  Switching over to TypeScript has saved me the most time in the long run, but I also have a strong OO background.

I think you have asked a very wide open question that depends a lot on what is being built and has many 'correct' answers, so there can't be a single recipe.  There are so many examples on github and from Ludum Dare that are essentially free working recipes.  I am relatively new with babylon.js and have only been working on a turn-based (VR) interactive puzzle game.  I ended up using redux-saga to control my game loop using Test Driven Development (TDD).  Most movements are controlled by Animations and I don't use ActionManager or any globals.  Logic is encapsulated in all the in-game classes.  I have a basic renderLoop with no logic:

engine.runRenderLoop(() => {
  if (scene) {

Here is the article (not babylon.js related) that inspired my game loop and tries to answer the larger question (his emphasis) Where does my application logic belong in general?:


Link to comment
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.

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.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...