I would like to create an export as OBJ or STL link for a parametric Three.js mesh object. Just like the export option on http://www.3dtin.com
Any advice would be appreciated.
To get mesh in .obj format I use this simple function:
THREE.saveGeometryToObj = function (geometry) {
var s = '';
for (i = 0; i < geometry.vertices.length; i++) {
s+= 'v '+(geometry.vertices[i].x) + ' ' +
geometry.vertices[i].y + ' '+
geometry.vertices[i].z + '\n';
}
for (i = 0; i < geometry.faces.length; i++) {
s+= 'f '+ (geometry.faces[i].a+1) + ' ' +
(geometry.faces[i].b+1) + ' '+
(geometry.faces[i].c+1);
if (geometry.faces[i].d !== undefined) {
s+= ' '+ (geometry.faces[i].d+1);
}
s+= '\n';
}
return s;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With