From a3fc4b556c6cac9a7e048493f5136a4ee75e1459 Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Wed, 5 Aug 2015 11:34:00 +0200 Subject: glTF Parser: Support loading binary json scene data We support generating gltf files using binary json rather than plain text with our qgltf tool. This reduces metadata file sizes and load times. Change-Id: I99a4c270aa4b0b828cddfbdcce02dce206606708 Reviewed-by: Sean Harmer --- src/plugins/sceneparsers/gltf/gltfparser.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/sceneparsers/gltf/gltfparser.cpp b/src/plugins/sceneparsers/gltf/gltfparser.cpp index a4a0602c2..ba39e74ba 100644 --- a/src/plugins/sceneparsers/gltf/gltfparser.cpp +++ b/src/plugins/sceneparsers/gltf/gltfparser.cpp @@ -189,7 +189,12 @@ void GLTFParser::setSource(const QUrl &source) QFile f(path); f.open(QIODevice::ReadOnly); - if (!setJSON(QJsonDocument::fromJson(f.readAll()))) { + QByteArray jsonData = f.readAll(); + QJsonDocument sceneDocument = QJsonDocument::fromBinaryData(jsonData); + if (sceneDocument.isNull()) + sceneDocument = QJsonDocument::fromJson(jsonData); + + if (!setJSON(sceneDocument)) { qCWarning(GLTFParserLog) << "not a JSON document"; return; } -- cgit v1.2.3