4
votes

My Model in Blender is comprised of many groups of objects. The Model was exported as a .obj from C4D to Blender. Each group of objects was placed under a Null in Blender. When I export in three.js, only the last selected object in Blender will be exported as a .json file.

I tried selecting several different objects, and again only a single object will export. I verified this by seeing the resulting .json files in an editor. In fact it shows only a single object is being exported.

I separated each object do I could easily make selections and apply different materials to each object. In the past I combined all of the objects into a single mesh before exporting the .obj from C4D and everything worked fine with Blender and the resulting .json file

In blender, what I did was to try and link all of the objects to a single parent in the hopes that the whole model would export. This did not work.

My questions is this normal behavior?

How do I convert all of the separate pieces into a single mesh after I have applied materials to each one in Blender?

Or is there some sort of export setting I have wrong when working with multiple objects, each with its own null?

2

2 Answers

2
votes

Be careful grouping objects under a Null (empty) in Blender. I tried this awhile ago with my light setups as its normally a logical work flow but found that there were transformation issues when the scene was constructed in three.

When I export in three.js, only the last selected object in Blender will be exported as a .json file.

The key word here is "last selected", which is telling me that you possibly didn't click on the Scene option for the export. By default the export only produces a .json with a single geometry which is the current selection in Blender.

Posting the output of the log file helps to see what your options were. You don't need to pastebin the entire thing for that, just find a line (towards the top of the log) that looks like this:

Three.Export - DEBUG: 
Scene().__init__(G:\cleanflight_json_test\cfc_gui_def_green_a.json, 
{'animation': False, 'cameras': False, 'embedGeometry': True, 
'faces': True, 'colors': False, 'influencesPerVertex': 2, 
'scene': True, 'faceMaterials': False, 'precision': 6, 'embedAnimation': True, 'lights': False, 'logging': 'debug', 
'scale': 1.0, 'frameStep': 1, 'bones': False, 'vertices': True, 
'uvs': False, 'copyTextures': True, 'geometryType': 
'geometry', 'mixColors': False, 'maps': False, 'compression': 
'None', 'normals': False, 'enablePrecision': False, 'materials': False, 
'skinning': False, 'morphTargets': False})

That will at least tell me what your options were

1
votes

As Repsac said, it is important to check the Scene option in the Three.js json exporter settings. But it is important to know that the exported json file isn't just a Geometry anymore. It is labeled with the Scene type by now and it must be handled in a different way.

You can follow the complete process of exporting a entire scene from Blender and the right way of handling the exported meshes on my answer to this post.

Besides, as you both said, all the meshes can be merged into a single mesh and handle the multiple materials of it using THREE.MeshFaceMaterial like in the following code:

var mat1 = new THREE.MeshLambertMaterial( { map: texture1 } );
var mat2 = new THREE.MeshLambertMaterial( { map: texture2 } );
var materials = [mat1, mat2];
var faceMat = new THREE.MeshFaceMaterial(materials);
mesh = new THREE.Mesh( geometry, faceMat );
scene.add( mesh );

Hope this clears the steps a little bit more. Thanks for your help, guys :)