I’m looking at the file format used by threejs.
I see that geometry for the objects are inside “faces” and “vertices”.
My understanding of “faces” was that they were listed in order and each group of three represented one triangle inside a mesh.
However, while the vertices count matches what is being reported into the file, the faces count does not, in fact the real number of faces is exactly 8 times the figure reported.
What is the correct way to read the “faces” list so that they represent the triangles of a mesh?
This is true for the older Geometry format. Now we are using BufferGeometry which saves the data in big arrays called attributes.
Can you share the file here? It sounds like you are dealing with a very old file.
jsonnew.json (2.8 KB) jsonold.json (1.1 KB)
The files come from clara.io, they have 2 exporters, one is deprecated and the corresponding file is jsonold.json
What I was talking about is jsonnew.json which is the “new” exporter for clara, as you can see the faces array contains more elements than the faces count written in the metadata section.
By the way I figured out that the pattern in this particular file format is that the real triangle information is inside a group of 8 elements, the first being an index of some sorts, the real vertices are always in position 1,2,3 and then probably there’s vertex color; the sequence repeats at the next triangle.
I’m doing some gis stuff, can you suggest a program that can read some common gis-related files (such as .shp) and output to the newer format you were talking?
and then probably you want to take a look at three.js/src/core/Geometry.js at 3cfe5ed63f964614fd41cf4aec52e4bbb5ca4d12 · mrdoob/three.js · GitHub
the loader was removed already, but you can still find it and maybe make it work, see
https://rawcdn.githack.com/mrdoob/three.js/r110/examples/js/loaders/deprecated/LegacyJSONLoader.js