0

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!

1 Answers1

0

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.

https://threejs.org/examples/#misc_exporter_gltf

Mugen87
  • 28,829
  • 4
  • 27
  • 50
  • I'll give this a try yet I was hoping to export in the obj format. I would like to export in obj, dae and glTF... – solarfingers Sep 06 '18 at 13:07
  • I wonder why this is... the actual makehuman model is imported from a JSON file: /data/models/human_full_size.json – solarfingers Sep 06 '18 at 14:09
  • I guess it's in `three.js` JSON format. You can create such an output if you just call `.toJSON()` of an `Object3D` like a scene. – Mugen87 Sep 06 '18 at 20:11
  • I have tried a number of things including .toJSON(). I can see the object and it appears to be an array of all the available entities in Makehuman. So, it's upon me to figure how to get what I want. I was hoping that I would be able to export what was displayed in the viewport. I'm not sure if any of this will export nicely in any format. I will continue to dig until I find a way to make it work but it doesn't look like there will be a straight forward way of doing it.. Thanks for your input. I'll update this post when I find an answer. – solarfingers Sep 07 '18 at 12:54
  • I wonder why when using gui.dat to transform the mesh why when we export we get the base model and not a mesh with the transforms... – solarfingers Sep 08 '18 at 14:09
  • I guess it's better to create a new thread than posting more questions in this one. Don't forget to include a live example for debugging. In this way, it's way easier to provide useful feedback. – Mugen87 Sep 08 '18 at 15:32