Myjestic Posted October 26, 2017 Share Posted October 26, 2017 Hi, I have generated a mesh with more than 16k vertices and I want to import it to meshlab to simplify it. Now my first problem is, I need the mesh as OBJ File. I found a link to the babylon asset convert tool, but the link does not work anymore. Second attempt was to export the mesh as OBJ from my scene and I found the "babylon.objSerializer.js". I don't know how to use it. I included the js file after including my babylon.js file and the class is available know. Here is my code so far: var serializedScene = BABYLON.OBJ(maze); download_to_OBJ("maze.obj",serializedScene); function download_to_OBJ(filename, text) { var pom = document.createElement('a'); pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); pom.setAttribute('download', filename); if (document.createEvent) { var event = document.createEvent('MouseEvents'); event.initEvent('click', true, true); pom.dispatchEvent(event); } else { pom.click(); } } Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 27, 2017 Share Posted October 27, 2017 The OBJ serializer provides two static methods: BABYLON.OBJExport.OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean) and BABYLON.OBJExport.MTL(mesh: Mesh) Both returning a string (technically the content of your .obj and .mtl file). So calling those functions, you will get two strings. you can console.log them, you can copy them (if it is a one-time thing) or download them (for example - https://stackoverflow.com/questions/21893463/javascript-to-download-string ) Quote Link to comment Share on other sites More sharing options...
Myjestic Posted October 27, 2017 Author Share Posted October 27, 2017 Hey RaananW, thanks. But I can't get it to work. BABYLON.OBJExport.OBJ(mymesh, false, "", false); OBJ-File holds no info. Can you show me how to use it on this PG? https://playground.babylonjs.com/#6AI2R9 Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 27, 2017 Share Posted October 27, 2017 Hi, we don't include the obj exporter in the playground, and you pasted the code after the return, so this will anyhow never work. Please check the signature I pasted - the first variable is an array of meshes. so in your case it would be: BABYLON.OBJExport.OBJ([mymesh]); the rest of the variables are optional and not needed. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Myjestic Posted October 27, 2017 Author Share Posted October 27, 2017 Myjestic --> hitting his forehead with his hand ... many times Thank you so much. You guys / this forum is so great! RaananW 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.