private static void parseBuffers()

in app/src/main/java/com/facebook/sample/rendering/SampleGLTFReader.java [230:253]


    private static void parseBuffers(GLTFScene output, JSONArray buffers) {
        for (int i = 0; i < buffers.length(); ++i) {
            try {
                JSONObject jsonObject = buffers.getJSONObject(i);
                GLTFScene.Buffer buffer = new GLTFScene.Buffer();
                if (jsonObject.has("name")) {
                    buffer.name = jsonObject.getString("name");
                }
                buffer.byteLength = jsonObject.getInt("byteLength");
                // For this hello-world loader we'll only support loading from a data URI
                buffer.uri = jsonObject.getString("uri");
                String dataURI = buffer.uri.replaceFirst(DATA_URI_PREFIX, "");
                byte[] bufferData = Base64.decode(dataURI, Base64.DEFAULT);
                // Important to allocateDirect(...); wrap(...) doesn't work as GLES20.glBufferData wants a direct buffer.
                buffer.data = ByteBuffer.allocateDirect(bufferData.length).order(ByteOrder.nativeOrder());
                buffer.data.put(bufferData);
                buffer.data.rewind();
                output.buffers.add(buffer);

            } catch (JSONException e) {
                Log.e(TAG, e.getMessage());
            }
        }
    }