in app/src/main/java/com/facebook/sample/rendering/SampleGLTFReader.java [199:228]
private static void parseMeshes(GLTFScene output, JSONArray meshes) {
for (int i = 0; i < meshes.length(); ++i) {
try {
JSONObject jsonObject = meshes.getJSONObject(i);
GLTFScene.Mesh mesh = new GLTFScene.Mesh();
if (jsonObject.has("name")) {
mesh.name = jsonObject.getString("name");
}
JSONArray primitives = jsonObject.getJSONArray("primitives");
for (int j = 0; j < primitives.length(); ++j) {
GLTFScene.Primitive primitive = new GLTFScene.Primitive();
JSONObject jsonPrimitive = (JSONObject)primitives.get(i);
JSONObject attributes = (JSONObject)jsonPrimitive.get("attributes");
Iterator<String> iter = attributes.keys();
while (iter.hasNext()) {
String key = iter.next();
primitive.attributes.put(key, (Integer)attributes.get(key));
primitive.indices = jsonPrimitive.getInt("indices");
}
mesh.primitives.add(primitive);
}
output.meshes.add(mesh);
} catch (JSONException e) {
Log.e(TAG, e.getMessage());
}
}
}