MCPcopy Index your code
hub / github.com/codenameone/CodenameOne / parse

Method parse

CodenameOne/src/com/codename1/gpu/GltfLoader.java:135–157  ·  view source on GitHub ↗
(byte[] data)

Source from the content-addressed store, hash-verified

133 }
134
135 private static Object[] parse(byte[] data) {
136 if (data == null || data.length < 4) {
137 throw new IllegalArgumentException("empty glTF data");
138 }
139 String json;
140 byte[] binChunk;
141 if (readUInt32(data, 0) == GLB_MAGIC) {
142 // Binary glTF: 12 byte header then length-prefixed chunks.
143 String[] jsonHolder = new String[1];
144 binChunk = parseGlb(data, jsonHolder);
145 json = jsonHolder[0];
146 } else {
147 json = utf8(data, 0, data.length);
148 binChunk = null;
149 }
150 try {
151 Map root = new JSONParser().parseJSON(
152 new InputStreamReader(new ByteArrayInputStream(utf8Bytes(json)), "UTF-8"));
153 return new Object[] { root, binChunk };
154 } catch (IOException ex) {
155 throw new RuntimeException("Failed to parse glTF JSON: " + ex.getMessage(), ex);
156 }
157 }
158
159 private static byte[] parseGlb(byte[] data, String[] jsonHolder) {
160 long totalLength = readUInt32(data, 8);

Callers 2

loadMethod · 0.95
loadModelMethod · 0.95

Calls 6

readUInt32Method · 0.95
parseGlbMethod · 0.95
utf8Method · 0.95
utf8BytesMethod · 0.95
getMessageMethod · 0.65
parseJSONMethod · 0.45

Tested by

no test coverage detected