Jump to content

reload/refresh the scene by file babylon


Recommended Posts


I was wondering if it was possible to reload/refresh the already loaded scene from the babylon file. 

I was thinking of something like a scene.Refresh that reloads the babylon file and updates the scene. 

You will ask me why? I would like to make a collaborative system on my editor and to make things easier to achieve, I thought a scene.Refresh () would make this task easier. 

In fact, User 1 modifies the scene (adding objects, editing ...) which are serialize and save to a file.babylon. And I would like the user 2 after a delay of x seconds with a setTimeout, that file.babylon, called with $.Ajax, refresh the scene of the user 2. This is the simplest theory I have in mind. 

 Do you have any idea how to reload/refresh the scene from a file.babylon? 

 Thank you for your help.

Link to comment
Share on other sites

Hi D!  Can I contribute a weird idea?

1st... We can load more than one .babylon file.  User 1 and user 2 start with same normal .babylon file.

2nd... both users (all users) load-in a file called... umm... eventDB.babylon

Inside eventDB... is one BJS non-rendered node with a HUGE .metadata property on it.  Json parse that metadata json-string (after load-in)... and it turns into a little database object. 

In that database... are stored editorEvent objects.  You created them... (and stored them) when user 1 or 2 does a change in the editor. 

If user did something, create event object, time stamp, insert into the DB.

Then... um...  notify server of new events or... serialize the DB and somehow send back to the server?  (not sure how/what)

Then server builds a new eventDB.babylon file, and quickly publishes to the folder where the OTHER user could load it.  ??

Then a "ping" is sent to all users who have not loaded-in the latest eventDB.babylon.   ??  hmmm.

After eventDB load-in... node.metadata becomes database.  It is compared to the database that the editor is currently "using".  (check for new events)

Comparisons are made... and "new events" are acted upon.  All "listeners" must update per the current server-published eventDB.babylon.

Essentially, all collaborators using the editor and whiteboarding the same scene... would OFTEN load eventDB.babylon, "growing" its .metadata into a DB object, and doing updates to the local scene per info found in the NEW DB.

Complete scene reloading sounds... painful. 

Instead, you create your own "what has changed?" messaging system... using a shared eventDB.babylon.  Since .metadata is a general-purpose property... put whatever you wish in there.  Why not a database of recent editor changes (events)?   Goofy idea, eh?  Nod.

Link to comment
Share on other sites

Hi Wingnut,

Even though I'm not sure I fully understood everything 100% (I think I have to read several times) , I see your general idea and it seems to me much better than my original idea. I think I will study your ideas.

So you propose me to put in a file eventDB. Babylon everything that is changing. I have to make one file per user or only one?

I did not understand too much for me metadata.

Otherwise I agree that recharging the scene completely every x seconds will be really no good when the scene will be more important.

Thank you Wingnut

Link to comment
Share on other sites

You can do ONE eventDB for all to share, but then "event sorting"  (see which events are new, which are old) must be done within the scene JS.  EventDB might be a mix of old and new events.  Some will have been already "serviced", and some will still need servicing (at each editor).

Or, a separate file for each user, and which client needs which events... could be maintained at server.

Not sure what is the best method.  You are much smarter than I... for these things.

I think .metadata is defined on node... as ANY-type.  Start by making a .babylon file with one node (or mesh, light, camera) and put a .metadata property in the .babylon file... that is one big fat serialized chunk of json object (my terminology is terrible, sorry).  It would be a big long string, yes?

Now import that .babylon file, with that ghost mesh (blank/abstract mesh)... check its .metadata property.  Is the string there?  If so, json parse that puppy, and see if you can make it into an object.  If so... you party.

Do you know how to send data back to the server?  That area I am REALLY stupid.  :)  I would likely use a web form submission to a web server.  :)  There are probably newer, cooler ways, these days.  Blob-shooting... with a blob cannon?  :)

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