How to convert object to json file for three.js model loader

user2259103 picture user2259103 · Apr 8, 2013 · Viewed 36.9k times · Source

I am building a browser game with three.js and I want to load a model from Maya 2013 into my scene. I have exported the model as an obj file.

Now I need to know how to convert it into an JS file for the three.js-loader.

This is my loader so far:

 var jsonLoader = new THREE.JSONLoader();
 jsonLoader.load( "models/model.js", addModelToScene );

Thanks in advance

Answer

captDaylight picture captDaylight · Jun 6, 2014

If you don't want to use blender, mrdoob(made threejs) has a simple python script to convert obj to json. Just run --this script-- in terminal like so:

python convert_obj_three.py -i infile.obj -o outfile.js