arek3D Posted May 21, 2018 Share Posted May 21, 2018 Hi, I have a problem with export an .obj file using custom mesh. Should it work with this kind of mesh? I created a geometry which is displayed correctly in canvas and after console.log the list of vertexes is empty. I tested that with a standard cube and it worked correctly. Here is how I am doing it (more or less): this.customMesh = new BABYLON.Mesh("custom", this.scene); //... a lot of "positions.push" var normals = []; var vertexData = new BABYLON.VertexData(); BABYLON.VertexData.ComputeNormals(positions, indices, normals); vertexData.positions = positions; vertexData.indices = indices; vertexData.normals = normals; vertexData.applyToMesh(this.customMesh); var mat = new BABYLON.StandardMaterial("mat", scene); this.customMesh.material = mat; var obj = BABYLON.OBJExport.OBJ([this.customMesh],true,'birdie'); var objlink = BABYLON.Tools.FileAsURL(obj); var mtl = BABYLON.OBJExport.MTL(this.customMesh,true); var mtllink = BABYLON.Tools.FileAsURL(mtl); console.log("obj = ", obj); console.log("objlink = ", objlink); console.log("mtl = ", mtl); console.log("mtllink = ", mtllink); Quote Link to comment Share on other sites More sharing options...
arek3D Posted May 22, 2018 Share Posted May 22, 2018 Ok, I have found why my string was empty when I console.log my custom mesh. I do not have UV data in my model and in OBJExport.OBJ() method there is a condition which skips such meshes: if (!trunkVerts || !trunkNormals || !trunkUV || !trunkFaces) { continue; } Quote Link to comment Share on other sites More sharing options...
Guest Posted May 22, 2018 Share Posted May 22, 2018 Good catch! Quote Link to comment Share on other sites More sharing options...
3D for mortals Posted May 27, 2018 Share Posted May 27, 2018 good hour. english not my native. i have not a good result use //some code before download(BABYLON.OBJExport.OBJ(exportobjects,true,"wheelmaterials",false),"scene.obj","text/plain"); function download(text, name, type) { var a = document.getElementById("a"); var file = new Blob([text], {type: type}); a.href = URL.createObjectURL(file); a.download = name; } syntax. After this i try to open->export (scene.obj) file uses freecad and meshlab under linux(not think this is major), and as you can see the model exported wrong way. Hope i can solve this, with your help. Quote Link to comment Share on other sites More sharing options...
3D for mortals Posted May 28, 2018 Share Posted May 28, 2018 solved , by using mesh.bakeCurrentTransformIntoVertices(); but now some parts of exported model need to set two side lighting, or parts always black. And way to create these parts(meshes) is similar, but different only final angle of rotation around axis. Little insane feeling inside...not perfect result : | Quote Link to comment Share on other sites More sharing options...
Guest Posted May 29, 2018 Share Posted May 29, 2018 Feel free to open an issue on the repo. We will try to fix the OBJ exporter if you can provide a repro case Quote Link to comment Share on other sites More sharing options...
3D for mortals Posted May 30, 2018 Share Posted May 30, 2018 On 5/29/2018 at 7:15 AM, Deltakosh said: Feel free to open an issue on the repo. We will try to fix the OBJ exporter if you can provide a repro case what should i do to provide a repro case? is link on repository on github with program , which include this , is enough ? Because the result exported file is close to 100mb size wavefront obj ... insane behavior... my email place forum answer notification mail into spam, but before i create the filter especially for this forum and place it first in order... ? Quote Link to comment Share on other sites More sharing options...
Guest Posted May 30, 2018 Share Posted May 30, 2018 It would be great to have a simpler scene (perhaps just a part of the initial mesh) that can highlight the problem Quote Link to comment Share on other sites More sharing options...
3D for mortals Posted May 30, 2018 Share Posted May 30, 2018 4 hours ago, Deltakosh said: It would be great to have a simpler scene (perhaps just a part of the initial mesh) that can highlight the problem i create this folder in repo. Hope this will be enough. github repo folder with issue description can you create the issue ? i can try but don't know the right form of this, and english is not my native. Quote Link to comment Share on other sites More sharing options...
Guest Posted May 30, 2018 Share Posted May 30, 2018 Me neither, I'm french I need you to create a repro in the Playground and I can take care of it from there Quote Link to comment Share on other sites More sharing options...
3D for mortals Posted May 30, 2018 Share Posted May 30, 2018 2 hours ago, Deltakosh said: Me neither, I'm french I need you to create a repro in the Playground and I can take care of it from there inside my app i use my own handmaded lib written in haxe, and then exported to javascript https://github.com/3dformortals/data/blob/master/trash/objexportissue/web/js/geo.js 4426 lines. And looks like i need to create playground in one file... plus my app depend from gui html(but it possible to cut off all except few numbers). copy all libs to giant js file looks very insane for me. Are you sure this is good idea? Quote Link to comment Share on other sites More sharing options...
3D for mortals Posted May 31, 2018 Share Posted May 31, 2018 not good... i try export scene to glTF format , then import into blender, and result is similar. Some meshes is broked , not coloring and look different when i rotate the view. Looks like something bad with exporters mathematics, or both exporters have same coding way. Because all my meshes created uses for loop, and later some of thier only moved + rotated into new scene position. Feels like some of meshes stay turned inside out, after exporting. I detect something similar when i try use threejs earlier, but threejs show this on scene. But babylonjs only do this in time of export. Is it possible when you recode or use part of threejs algorithm (part of code base)... I hope you don't do this, because threejs is terrible in compare with babylon js Quote Link to comment Share on other sites More sharing options...
3D for mortals Posted May 31, 2018 Share Posted May 31, 2018 i found the way how manually fix this issue inside freecad. Need reverse normals inside mesh designer for every black part and then it stay normal colored etc. this can be math hole inside exporter algorithm, or mesh rotation algorithm (but on screen it look normal , and this direct to exporter as potentially reason of issue) Quote Link to comment Share on other sites More sharing options...
Guest Posted May 31, 2018 Share Posted May 31, 2018 ok this is a really good news then 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.