Jump to content

Load Scene from data streams


eucly2
 Share

Recommended Posts

Hello everyone,

 

With BabylonJs we can load a scene from a babylon file but why we can't load a scene from a data steam?

 

In my project we can save BabylonScene to a DataBase on the server with using BABYLON.SceneSerializer and JSON.stringify but after we can't reload this BabyloneScene from the server.

 

Anyone have an idea?

 

Link to comment
Share on other sites

Hello there. You can try to use a database to store the name and path (each one in is own var), then you pass the query result to a var and pass that var to the scene loader (when you instantiate one).  :)

It's not a complete answer to the problem, but i think it can help you out.

Link to comment
Share on other sites

  • 8 months later...

Hi,
 
I end up with the same kind of problem. I added several objects on the stage with importMesh, I use Manipulator to move objects on the ground and seralize my scene I stringnify then I save it in a file with ajax and PHP.
 

var serializedScene = BABYLON.SceneSerializer.Serialize(scene);var strScene = JSON.stringify(serializedScene);$.ajax({ url:"save_json.php", type:'post', data: 'value='+strScene});

in the file PHP (save_json.php): 

function save($terrainName, $value) {    $cheminFichierJson = "./../data_admin/terrain/scene.babylon";    $json = json_encode($value, JSON_UNESCAPED_SLASHES);    $json = str_replace('\"', '"', $json);    chmod($cheminFichierJson, 0777);    file_put_contents($cheminFichierJson, substr($json,1,-1));    chmod($cheminFichierJson, 0644);}

but when I load the file I have a SyntaxError: Unexpected token  

BABYLON.SceneLoader.Load("./data_admin/terrain/", "scene.babylon", engine, function (newScene) {	engine.runRenderLoop(function() {                newScene.render();       });            }); //SyntaxError: Unexpected token

 
I do not understand. Is this a bug? I have no error file name or line number. just:
Uncaught SyntaxError: Unexpected token
 
 
Thanks for help

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