Reputation: 1374
I have a .obj, .mtl files with multiple materials for a specified material, I want to print the vertices and their corresponding uv coords. Is there a way to e.g. parse a .obj, and .mtl file and export them to json? When using
EDIT:
I tested with an example 3d model
step1: converted the .obj and .mtl with multiple materials into a .json file
step2: loaded the generated .json file (foo1.json) within a threejs example
TypeError: vertices is undefined
Some links indicate that Blender Exporter and Json File Loader are not so reliable (see here, here, here, and here in general) Is there any other converter from .obj, .mtl to .json that anybody can recommend? (not necessarily in relation to three.js)
Assuming that I can convert to glTF format, is there a tool, (e.g. a command line utility in python) that will let me specify a material index and get the vertices and corresponding uv coords for this material?
Solved: I ended up using meshlab plugin export to json. It works (almost) fine for me
Upvotes: 0
Views: 3219
Reputation: 2683
Sure, you can use Blender and THREE JS plugin (exporter):
https://github.com/mrdoob/three.js/tree/dev/utils/exporters/blender
Exported file have materials as array if you use JSON Loader function
https://threejs.org/docs/#api/loaders/JSONLoader
Upvotes: 0