Jump to content

Storing custom data on mesh


masterdon
 Share

Recommended Posts

Hi Team,

I am working on an editor for room planner using babylon js. I am storing some custom properties for few of the meshes in my scene. 

shearWall.maxXPos = maxXPos;
shearWall.minXPos = minXPos;

These properties are having their use for dragging. there are other properties as well. each one of it having its own purpose.

I need to save all the data and store it in database. so that user can revisit and work from where he have left the design. to export the data, i am using:

var serializedScene = BABYLON.SceneSerializer.Serialize(scene);var strScene = JSON.stringify(serializedScene);

The issue is, the custom properties set are not part of json data above.

Is there a way to store the custom properties which becomes part of serializer above?

Link to comment
Share on other sites

Hi again, Masterdon.  Umm... I think scene.metaData and node.metaData... are included in serializations.  Node includes lights, cameras, and mesh... any BJS type scene item that is an extension of node.

Sooo... I suppose... make an object similar to one of our options objects.  var mySuitcase = {};  mySuitcase.maxXPos = whatever;  etc etc etc.

Then... shearWall.metaData = JSON.serialize(mySuitcase);  Does that sound sane?  When it arrives somewhere, JSON.parse it, and re-install the custom properties onto the mesh.... from the mesh's suitcase.

.metaData is your suitcase, but you must pack it before traveling, and unpack it upon arrival somewhere.  With me?  I hope so.  Others may comment... and I could have said something incorrect.  But, I think this is a WAY to do what you wish.  Report back if you discover things, okay?  thx.

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