Sign in to follow this  

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

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)

Share this post

Link to post
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.  :)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.