GLTFExporter: glb downloads corrupt on MS Edge

When using the GLTFExporter demo and exporting a binary (.glb) file from MSEdge, the resulting model cannot be viewed in https://gltf-viewer.donmccurdy.com/ (using any browser). Same problem is happening for .glb models downloaded from https://gltf-trees.donmccurdy.com/. Also tried swapping out the download code for downloadjs, no effect.

Example of corrupted file: https://github.com/donmccurdy/three-gltf-viewer/files/1486071/tree.zip

Downloads are working as expected from Chrome, Safari, and Firefox.

@bghgary @sbtron I am wondering if Edge handles the application/octet-stream mimeType vs .glb extension differently?

Author: Fantashit

2 thoughts on “GLTFExporter: glb downloads corrupt on MS Edge

  1. I only have IE11 to test this on, but my Chrome supports TextEncoder while my IE11 does not.
    From GLTFExporter.js:

    function stringToArrayBuffer( text ) {
    
    	if ( window.TextEncoder !== undefined ) {
    
    		return new TextEncoder().encode( text ).buffer;
    
    	}
    
    	var buffer = new ArrayBuffer( text.length * 2 ); // 2 bytes per character.
    
    	var bufferView = new Uint16Array( buffer );
    
    	for ( var i = 0; i < text.length; ++ i ) {
    
    		bufferView[ i ] = text.charCodeAt( i );
    
    	}
    
    	return buffer;
    
    }

    Chrome’s TextEncoder has a default encoding of UTF-8, the code above (which IE would then execute) goes for UTF-16 (sorta?). That could explain the 0x00 bytes in the JSON.

Comments are closed.