Jump to content

[solved] Load custom object properties from babylonjsfile -> metadata


MarianG
 Share

Recommended Posts

Hi. I have two scene. In the first scene I configure the object from babylon basic elements and csg, I serialize it and upload it to server. All good ;)
In the second scene I import the serialized object from first scene. All good again. 

But in the first scene I set some flags to the object and after I serialize it, they gone, ... no problem I add them manual. like that.

var myser = BABYLON.SceneSerializer.SerializeMesh(component, false, true);
var jsonData = JSON.stringify($.extend({}, myser, {"setings":settings}));

And it works again :) but when I use SceneLoader.ImportMesh I get only the informations from "myser", and this is somewhat expected.

But my question is, how can I hack the ImportMesh function to access "setings" property too? Or can I add the flags from 'seting' to my original mesh before to serialize, and it don;t lose them when I serialize it?

Thank you guys B)

Link to comment
Share on other sites

Hiya MG... sorry for the slow replies.

I think you can use node.metadata as a "suitcase" that will serialize/de-serialize just fine.

Would that work?  You can put "stuff" inside any mesh.metadata, camera.metadata, or light.metadata.

So maybe, before you serialize scene1... do...

var bigFatObject = anything;  (maybe bigFatObject.installExtraSettings() is a function on that obj)
var myInvisibleDatabase = new BABYLON.Mesh("blank", scene);
myInvisibleDatabase.metadata = bigFatObject;

When scene is imported, you should be able to run a pre-installed function... myInvisibleDatabase.metadata.installExtraSettings().

You are better at JSON stuff than I, but... I believe all node.metadata values are "carried-along" with all serializations/imports.

Perhaps that will work for you.  Holler if you have problems.  I hope I am on-subject.  :)

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