Joey Eremondi
Joey Eremondi

Reputation: 8433

What is the current status of JSON mesh formats in three.js?

General question: What is a stable JSON format for loading 3d models that is currently widely used?

Extended question:

I'm a programmer doing some WebGL stuff, particularly with the Elm programming language. I've been looking at different model formats, and it seems like using the three.js JSON format as a kind of standard makes a lot of sense for my project (and potentially for the langauge in general).

However, on the three.js github, it says that version 3 of the model langauge is soon to be depricated.

So, I'd like to know the current status of the model format before I convert. Is version 3 stable for the time being? Has version 4 been released? Will there be a version 4 model format, or is it being replaced by the geometry format? Are the upcoming changes so breaking that adopting the format at this point in time is a bad idea?

I've seenthe new ObjectLoader classes, how do these relate to the Json mesh formats? Is it a format that I can convert .obj to?

Upvotes: 1

Views: 4075

Answers (2)

repsac
repsac

Reputation: 161

According to mrdoob he is planning to change the geometry format but as of this very moment the version 3 model format works fine in a version 4 scene because ObjectLoader passes those geometry (model) definitions to JSONLoader. So until a new format is actually spec'd out and JSONLoader is updated the version 3 model is the current one.

One more note: scene loaders (SceneLoader, ObjectLoader) don't natively load geometry. They always dispatch the tasks to the correct class. Not sure if it is supported yet in version 4 but in version 3 you could directly link the scene to OBJ files. And speaking of OBJ files, if you are just starting to poke at three.js and have assets in OBJ then have you considered just working with the OJBLoader directly?

Upvotes: 0

repsac
repsac

Reputation: 161

To follow up on my github post:

To be honest I don't think its safe to say that version 3 was never too stable. 3 has always had issues and the SceneLoader class that supports grew to be kind of unfriendly to maintain. Now 4 is pretty stable just lacking in support for textures. It is fine for objects, geometry, and materials but there is no exporter yet (that I am aware of).

Now what I think you are most curious about is the actual model format, which is this: https://github.com/mrdoob/three.js/wiki/JSON-Geometry-format-4#example-of-geometry

To be honest the actual geometry format hasn't really changed much that I can tell. The big change between 3 and 4 (so far) is the scene formatting. In fact geometry is parsed with the JSONLoader class. In fact a couple days I committed, to dev branch, a new example file for msgpack compressed JSON scenes. https://github.com/mrdoob/three.js/blob/dev/examples/webgl_loader_msgpack.html

msgpack is just JSON compression, so when it is decoded it is a JSON object. This msgpack file was converted from three.js/blob/dev/examples/scenes/robo_pigeon.js

This scene is a version 4 scene format. Each entry in the "geometries" table is actually an embedded geometry format. This format can also live in an external file. If you compare it to the first link you will see the formats are the same. Geometry files can be individually loaded into a scene with JSONLoader.

Now you asked about converters: glancing at convert_obj_three.py it says "JSON model version," in the documentation so I am going to guess it spits out a basic geometry model format and not a scene format so this may be usable. Even the blender exporter can still export compatible geometry scenes (leave the "Scene" option checked off). How do I know? Because the geometry I used for robo_pigeon.js came from that exporter, I just had to construct the version 4 scene by hand.

Does this begin to answer your question?

Upvotes: 2

Related Questions