Open Strae opened 6 years ago
Hey, sorry if I dont provide a patch but im in a bit of hurry Anyway, file https://raw.githubusercontent.com/antonio-gomez/three-gltf2-loader/master/lib/main.js Used "as is" with GLTF2 models (downloaded from different sources, like sketchfab) give the error "Uncaught SyntaxError: Unexpected end of JSON input (GLTF2Loader.js:69)"
Solved changed this piece of code:
if ( magic === BINARY_EXTENSION_HEADER_MAGIC ) { extensions[ EXTENSIONS.KHR_BINARY_GLTF ] = new GLTFBinaryExtension( data ); content = extensions[ EXTENSIONS.KHR_BINARY_GLTF ].content; } else { content = convertUint8ArrayToString( new Uint8Array( data ) ); } var json = JSON.parse( content );
into this:
if ( magic === BINARY_EXTENSION_HEADER_MAGIC ) { extensions[ EXTENSIONS.KHR_BINARY_GLTF ] = new GLTFBinaryExtension( data ); content = extensions[ EXTENSIONS.KHR_BINARY_GLTF ].content; var json = JSON.parse( content ); } else { try { var json = JSON.parse( data ); } catch ( e ) { content = convertUint8ArrayToString( new Uint8Array( data ) ); var json = JSON.parse( content ); } }
(just check if it is already valid Json)
I'll submit a patch in the next days as soon as i'll find some time ;)
Note that this repository is a mirror of the GLTF(2)Loader file from the threejs repository. I believe this issue has already been fixed in the official copy, you may want to try there.
Hey, sorry if I dont provide a patch but im in a bit of hurry Anyway, file https://raw.githubusercontent.com/antonio-gomez/three-gltf2-loader/master/lib/main.js Used "as is" with GLTF2 models (downloaded from different sources, like sketchfab) give the error "Uncaught SyntaxError: Unexpected end of JSON input (GLTF2Loader.js:69)"
Solved changed this piece of code:
into this:
(just check if it is already valid Json)
I'll submit a patch in the next days as soon as i'll find some time ;)