From 3dfe25a201201574b757633d0ed79df030e02669 Mon Sep 17 00:00:00 2001 From: Samy Lange Date: Wed, 26 Dec 2018 13:23:09 +0100 Subject: [PATCH 1/3] Handle the case where a gltf file is loaded as a string --- sources/osgPlugins/ReaderWriterGLTF.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/osgPlugins/ReaderWriterGLTF.js b/sources/osgPlugins/ReaderWriterGLTF.js index 41b0128d8..44eb5f245 100644 --- a/sources/osgPlugins/ReaderWriterGLTF.js +++ b/sources/osgPlugins/ReaderWriterGLTF.js @@ -964,6 +964,9 @@ ReaderWriterGLTF.prototype = { this._localPath = index === -1 ? '' : url.substr(0, index + 1); // Else it is a usual XHR request return fileHelper.requestURI(url).then(function(file) { + if(typeof file === 'string'){ + file = JSON.parse(file); + } return self.readJSON(file); }); }, From 4de7c9c9c6b6e412842997a6fa50a791f9532525 Mon Sep 17 00:00:00 2001 From: Samy Lange Date: Wed, 26 Dec 2018 13:26:33 +0100 Subject: [PATCH 2/3] Prevent images from being loaded incorrectly as string, when they are loaded from a gltf file that is outside an archive. --- sources/osgPlugins/ReaderWriterGLTF.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/osgPlugins/ReaderWriterGLTF.js b/sources/osgPlugins/ReaderWriterGLTF.js index 44eb5f245..c4e03d056 100644 --- a/sources/osgPlugins/ReaderWriterGLTF.js +++ b/sources/osgPlugins/ReaderWriterGLTF.js @@ -945,7 +945,7 @@ ReaderWriterGLTF.prototype = { var result = this._filesMap[uri]; if (result !== undefined) return result; - return fileHelper.requestURI(uri, options); + return fileHelper.requestResource(uri, options); }), readNodeURL: function(url, options) { From 6de37960e5184a3d06b057fa19a0ed75e769c8cd Mon Sep 17 00:00:00 2001 From: Samy Lange Date: Mon, 31 Dec 2018 15:58:36 +0100 Subject: [PATCH 3/3] Fix code style. --- sources/osgPlugins/ReaderWriterGLTF.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/osgPlugins/ReaderWriterGLTF.js b/sources/osgPlugins/ReaderWriterGLTF.js index c4e03d056..a8a4b841b 100644 --- a/sources/osgPlugins/ReaderWriterGLTF.js +++ b/sources/osgPlugins/ReaderWriterGLTF.js @@ -964,8 +964,8 @@ ReaderWriterGLTF.prototype = { this._localPath = index === -1 ? '' : url.substr(0, index + 1); // Else it is a usual XHR request return fileHelper.requestURI(url).then(function(file) { - if(typeof file === 'string'){ - file = JSON.parse(file); + if (typeof file === 'string') { + file = JSON.parse(file); } return self.readJSON(file); });