I am using https://github.com/makehuman-js/makehuman-js
The example exports the mesh from the source. So I am trying to get it from the scene with where it is changed.
When I try to export my scene to an obj file it is empty:
var objscene = new THREE.OBJExporter().parse( self.scene );
var output = JSON.stringify( objscene, null, 2 );
saveAs (new Blob([output], {type : 'text/plain;charset=utf-8'} ), 'Avatar.obj');
I can count the objects in the scene. There are four.
var scene_size = app.scene.children.length;
var i = 0;
while(i < scene_size){
alert(app.scene.children[i])
i = i + 1;
}
However they have no names so I add a name to my main human object.
// HUMAN
this.human = new makehuman.Human(this.resources);
this.human.name = 'human';
So now I can retrieve the name of the object named human.
var scene_size = app.scene.children.length;
var i = 0;
while(i < scene_size){
var thisone = app.scene.children[i]
alert(thisone.name)
i = i + 1;
}
So, I can demonstrate the objects exist. I will assign names to the other objects later. What I cannot understand is why my export is empty. The file is 1kb in size and there is only "" in it when I open it in my editor.
Any insight would be appreciated. I've been pounding it for a week and I am at a loss... Thanks!
OBJExporter.parse()
does not return a JSON object. So it makes no sense to use JSON.stringify()
in this context. Have a look at the actual output in this example (you will see it's just a plain string).
In any event, I recommend to use GLTFExporter
instead since glTF
is the recommended format of three.js
. You can use code snippets from the following example for your own project.