Jump to content

How to achieve Hot Code Replacement (without Browser reload)?


Nodragem
 Share

Recommended Posts

4 hours ago, Nodragem said:

wouldn't it hinder performance to have a watcher watching for texture change?

It's not the Engine or BabylonJS watching, just our dev server, which answers the next question that there is no HMR in production

4 hours ago, Nodragem said:

can we make a general method that works for any game assets: mesh, animation, sounds, fonts, etc...?

Possibly that is a good way to do it.  Definitely the textures at least are cached at engine level, although that presents a difficulty, it also means hopefully that we can hot swap easier scene wide generically.

I am still trying to figure out how some logic will be able to participate in HMR.  One good example is the "size" parameter of MeshBuilder.CreateBox() these factory methods create objects that have no concept of their constructor parameters.  Box is easy if you look at the position indices, we can edit them directly, but that's why I have been experimenting for a few weeks already on intermediate "proxy" classes.  I have no trouble setting "size" directly when recreating :)

Animations is interesting as well, because if you change an animation then it could change the entire state you were in - or even make the current state invalid.  So, I think it's good for me to start with assets and work outwards.

Link to comment
Share on other sites

Concerning the code swapping, I can see 2 kinds of code for now:

- the code that is called only once: when reloading this kind of code, nothing happens because it was already called once in the past. We need to re-execute the code. However, some times, the code won't be re-executable without restarting the game, or it won't make sense to re-execute it. For instance, you have a line of code that creates a blue box at position (x, y). In game, you move the box to position (x+10, y+5). Then, you want to change the color of the box. You go in your code and you change the line "creates blue box at position (x,y)" to "create red box at position (x,y)". It does not work, and it would not make sense to re-execute that line of code to change the box's color. In this situation, what we would need is to edit object's properties from the debugger (as in Vue.js).

- the code that is called every frame or on events: that case should be simple. I just need to reload the code, and the code will be called on the next frame or event.

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.

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

  • Recently Browsing   0 members

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