Having been a dedicated user of this website for some time now, I must admit that this is the first instance where I find myself in need of posting a question. The issue at hand revolves around a Json file from which I extract data and manipulate it with my code to prepare it for rendering using ThreeJS. Kudos to mrdoob, westLangley, and the rest of the ThreeJS team for their outstanding work and support.
After successfully rendering a mesh with orbit controls, I proceeded to create a simple exporter similar to ThreeJS.org/editor. However, when I utilized JSON.stringify on various objects, such as "geo," and saved the data to a new Json file (json2), I encountered a problem. My intention was to load json2 into a new program and automatically populate "geo" with its data, bypassing the usual processing steps.
The issue arises when attempting to color a face within the code using the following snippet:
for ( var i = 0; i < sD.geo.faces.length; i ++ ) {
var face = sD.geo.faces[ i ];
face.color.setStyle("#0066FF");
}
An error indicating that "face.color does not have a function called setStyle" (a rough quote) is displayed. Strangely, this code works perfectly in the initial program.
In further investigation, I noticed that while examining the "face" variable via firebug, it lacked a constructor or prototype in its dropdown menu, unlike in the original program. Unfortunately, I am unable to provide screenshots due to insufficient reputation. This discrepancy suggests that the extracted data may lack necessary properties. I even attempted directly assigning the vertices from json2 to sD.geo.vertices, but to no avail.
Could it be that the data assigned to sD.geo is causing the issue? Any suggestions on how to resolve this dilemma would be greatly appreciated, especially if it involves adding methods to json2. I have searched extensively for examples but haven't found a suitable solution yet. Apologies for any confusion in my explanation, and I am open to answering any clarifying questions.
Thank you!