Reputation: 162
I built a THREE.JS program using older models (ginger demo). After upgrading from r44 to r58, I was no longer able to use the models that were created using version 2 of the python based OBJ -> Three.js converter. The issue, I am assuming, is due to the formatting of the files.
I do not have the original .OBJ models, so I'm trying figure out how to upgrade the older json format to the newer one so that the parser can read it. I considered importing it into the THREEJS Editor and then exporting again, but the models have morphing targets and those were not preserved using that technique.
Here is an example of a JSON file I'm trying to upgrade.
The following is my progress thus far: When importing using the JSONLoader, the initial error I get is:
Uncaught SyntaxError: Unexpected token /
That is due to commenting of metadata, so I added the commented metadata to a metadata field to match the format seen near line 160 of this converter file. I also removed all other non-JSON code (variables, etc). I also got rid of the "edges" field because it was empty and I didn't find taht string in the .py code.
The json file loaded successfully, but I got the following errors when I used it:
Uncaught TypeError: Cannot read property 'map' of undefined
Uncaught TypeError: Cannot read property 'attributes' of undefined
The 'attributes' error repeated indefinitely.
The json file looks like this:
{
"metadata": {
"formatVersion" : 2,
"generatedBy" : "OBJConverter",
"vertices" : 168,
"faces" : 144,
"normals" : 576,
"colors" : 0,
"uvs" : 175,
"materials" : 1
},
"scale" : 1000.000000,
"materials": [ {
"DbgColor" : 15658734,
"DbgIndex" : 0,
"DbgName" : "phong1SG",
"colorAmbient" : [0.0, 0.0, 0.0],
"colorDiffuse" : [0.8, 0.8, 0.8],
"colorSpecular" : [1.0, 1.0, 1.0],
"illumination" : 4,
"mapDiffuse" : "ginger_color.jpg",
"opticalDensity" : 1.0,
"specularCoef" : 98.0
}],
"vertices": [1900,6776,...],
"morphTargets": [],
"morphColors": [],
"normals": [-0.024569,-0.94821,...],
"colors": [],
"uvs": [[0.37164,0.65357,...]],
"faces": [43,1,...]
}
What is the error in my manual conversion? Is it even possible to use the same data from different converter versions? Is there a better way to do this?
Upvotes: 1
Views: 488