Topish
Topish

Reputation: 3

OBJ to Json to browser not working

I have converted my OBJ 3d Model into a .js file using this python script:

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

but now I am having issues implementing the 3d model into my html. Im not sure what kind of script is necessary to load the .js file or .obj if that works. Any help is appreciated. Thanks!

Upvotes: 0

Views: 1311

Answers (2)

George Profenza
George Profenza

Reputation: 51857

You should check that the version of the converter script is compatible with the json format version used by the three.js release you're using.

Regardless, you can probably simply load the .obj file directly in three.js: check out the loader obj example

loader obj example

Another quick'n'dirty option, if you really must convert the .obj to a .json file is simply to:

  1. load the three.js editor in a tab
  2. drag your .obj file into it (and scale/transform as needed)
  3. export a .json file via File > Export Object or simply grab the whole three.js project from the editor via File > Publish

Upvotes: 1

LucasRT
LucasRT

Reputation: 179

I use https://clara.io/ tool to export to Json. Then in the html use https://threejs.org/ lib to load and render the model.

Upvotes: 0

Related Questions