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
Create a Python file named
conversion.py
with the following content: click here to see it.And then run this command in your Terminal:
Thats a pretty late reply. I have written a converter to read obj files and convert to ThreeJS supported JSON format: https://github.com/theMaxscriptGuy/Windows_Programs/tree/master/Obj_To_ThreeJS
Download all the files as zip and run converter.exe...
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:
Use Blender.
Blender 3D
Then install this addon:
Three.js exporter
Note: the python converter script has been updated to a js based tool https://github.com/mrdoob/three.js/tree/dev/utils/converters
Usage:
node obj2three.js model.obj
When exporting 3ds max models to three.js using the
[convert_obj_three.py][1]
script, a little degree of automation can be achieved with the following command in cmd promt:I wrote a 3ds max script that will print the phyton script command for multiple models and also a json with the models relative urls and coordinates. The json is useful for placing multiple models at the correct position in scene.
coordinates.mcr
and drag and drop the file into the 3ds max window. It will automatically open MaxScript Listener window and print the results. Copy paste the python command in cmd. Use the printed json to batch load your models in your project.Edit:
After experimenting a bit with the script I have made a setup that allows me to export my models (counting more than 20) in under 1 minute from 3ds max to open browser tab. Of course, you may need to adjust the json output to your liking. Hope you will find this useful.