简体   繁体   中英

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!

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.

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

加载器obj示例

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM