1
votes

Using Three.js r64 I'd like to import from Blender an animated object with its smoothing groups, the file is exported as JSON through Three.js Blender exporter.

The animation part is working fine.

In Blender, the model looks fine (there is a small smoothing group around the central part).

Picture: http://www.defresne.fr/demo/so/three/smooth_shading/gears.png

I can achive to get the same result when exporting in OBJ with 'Smooth Groups' and 'Include Normals' options checked. However I can't get it working correctly while exporting a JSON file (with normals). Next are pictures of the scene, with a live demo.

Picture: (append next link with) three_gears.png

Live demo: http://www.defresne.fr/demo/so/three/smooth_shading/

I did intense lookup all over the web and couldn't find correct informations. Best is another question on SO which is a bit old (r55) and never got any accepted answer.

I did try to compute the object's normals with

geometry.computeFaceNormals();
geometry.computeVertexNormals();

but, obviously, it computes the whole object normals and result in a completly smoothed object.

So, what should be a correct approach to make JSON smoothing groups work in three.js ? Wait for a built-in function ? build it myself ? Modify the exporter ?

As three.js seems to load correctly OBJ and Collada models with smoothing groups, maybe I could borrow some of the code in these loaders to get the logic ?

Thanks for your help

[EDIT]

I just found something great !

In Blender, produce 2 exports of the model: first a JSON file, second an OBJ file. Load the second one with three.js online editor then convert it to get the geometry JSON... I can collect the vertices, normals and faces of this freshly exported geometry and copy it to the first exported file.

It works fine ! I got nice shading groups. Even skinning works fine.

But it's a tedious way of processing and I wish I could save myself some extra conversions.

So does that mean there is a problem while exporting geometry from Blender ? Any idea why ?

Any help would be greatly appreciated !

1

1 Answers

0
votes

Ok, I finally found what happens.

The r64 Three.js Blender exporter doesn't export smoothing groups so if you need to preserve these, there is no other solution than export the geometry to an OBJ file, then convert it with the python script 'convert_obj_three.py' avaible within Three.js repository. Converted file will have correct normals. (don't forget to check normal option while exporting the OBJ file)