Jump to content

using importMesh to parse mesh data


JohnK
 Share

Recommended Posts

EDIT Less than 30 people read the complete rubbish I have just deleted. All because I did not read a line of code correctly. I think I might now be able to answer my own question. If so I'll give myself a reply if not then I be asking the question differently.

 

When SceneFile.babylon contains a saved scene and Meshes.babylon contains saved meshes is there a direct way of loading the scene from the content of SceneFile.babylon and the meshes from the content of Meshes.babylon?

Link to comment
Share on other sites

Yes now I have read it correctly.

 

When meshes is an array of meshes and you serialize them with

var serializedMesh = BABYLON.SceneSerializer.SerializeMesh(meshes);var content = JSON.stringify(serializedMesh);

Then  leaving the path as an empty string and replacing the filename with 'data:'+content will import the meshes, as in

BABYLON.SceneLoader.ImportMesh("", "", 'data:'+content, scene, function (meshes, particleSystems, skeletons) { });
Link to comment
Share on other sites

  • 8 months later...

Hello, I'm sorry to "wake" an old post but I came across this and I'm trying to do exactly what you describe.

The part of the serialization works fine, but for some reason the parsing afterwards gives me an empty mesh. I copied the code here but it doesn't work. Am I missing something?

 

Link to comment
Share on other sites

Looking back at my actual code I see I have the following before calling sceneLoader

var re = /\s*/gi;
content = content.replace(re, '');

To remove extraneous white spaces, tabs etc.

Try this

Link to comment
Share on other sites

I tried it and it still doesn't work.

The sceneLoader creates a new mesh but for some reason it is not visible and it's flawed in some way. When I try to serialize the new mesh back I get a run-time error. When I try to just print the mesh in an alert it shows some encrypted  name and says the mesh has 0 submeshes and 0 vertices.

I have no idea what the problem is, are you sure the sceneLoader can parse a mesh this way?

Link to comment
Share on other sites

Have a snippet to show you that SceneLoader can parse a mesh as above. However when I try it in the playground I get an error message. Have started a new topic that shows the code. If you copy and paste the code from the new thread see if it works for you.

New topic

 

Link to comment
Share on other sites

@SuperPudding RanaanW has sorted the playground problem in the new topic as above. Perhaps yours is a related problem and the solution will work for you. If not then for further help we will need to see the code you are using, preferably with a version we can run.

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