Search the Community
Showing results for tags 'babylon to obj'.
-
Hello! I need to export my objects to obj. I found an example that I could adapt. But I can not incorporate the position of the object in the scene. Any idea? note: I'm a beginner*** BABYLON.Mesh.prototype.exportOBJ = function() { var output=[]; output.push("mtllib savedFile.mtl"); for(var i2 = 0; i2< selectedItems.length; i2++) { output.push("g object"+i2); output.push("o object_"+i2); output.push("usemtl material"+i2); var g = window[selectedItem[i2]].geometry; console.log(selectedItem[i2]); trunkVerts = g.getVerticesData('position'); trunkNormals = g.getVerticesData('normal'); trunkUV = g.getVerticesData('uv'); trunkFaces = g.getIndices(); for(var i=0;i<trunkVerts.length;i+=3){ output.push("v "+trunkVerts[i]+" "+trunkVerts[i+1]+" "+trunkVerts[i+2]); } for(i=0;i<trunkNormals.length;i+=3){ output.push("vn "+trunkNormals[i]+" "+trunkNormals[i+1]+" "+trunkNormals[i+2]); } for(i=0;i<trunkUV.length;i+=2){ output.push("vt "+trunkUV[i]+" "+trunkUV[i+1]); } for(i=0;i<trunkFaces.length;i+=3) { output.push( "f "+(trunkFaces[i+2]+1)+"/"+(trunkFaces[i+2]+1)+"/"+(trunkFaces[i+2]+1)+ " "+(trunkFaces[i+1]+1)+"/"+(trunkFaces[i+1]+1)+"/"+(trunkFaces[i+1]+1)+ " "+(trunkFaces[i]+1)+"/"+(trunkFaces[i]+1)+"/"+(trunkFaces[i]+1) ); } } var text = output.join("\n"); var fileBlob; try{ fileBlob=new Blob([text]); }catch(e){ var blobBuilder=window.BlobBuilder || window.MozBlobBuilder || window.WebKitBlobBuilder; var bb=new blobBuilder(); bb.append([text]); fileBlob=bb.getBlob(); } var URL=window.URL || window.webkitURL; var link=URL.createObjectURL(fileBlob); return link; }
- 38 replies
-
- obj
- babylon to obj
-
(and 1 more)
Tagged with: