Skip to content

OBJ impoter does not work in IE - see fix #500

@AdamMcM

Description

@AdamMcM
Description of the problem

Loading OBJ files in IE (in my case IE 11) causes a state exception in the Ajax request object. This occurs when, the xhr is set to "arraybuffer". This is a known problem in IE. The work around is to not set xhr to "arraybuffer", but keep its default as "text". Download the file as a string, and then convert it to an arraybuffer before passing it to ok()

Here is the full load() function with comments at the changes.

   function load(url, ok, error) {
            var xhr = new XMLHttpRequest();
            //xhr.responseType = "arraybuffer";  // *** CHNAGED

// xhr.addEventListener('progress',
// function (event) {
// // TODO: Update the task? { type:'progress', loaded:event.loaded, total:event.total }
// }, false);
xhr.addEventListener('load',
function(event) {
if (event.target.response) {
var s = event.target.response; // *** CHANGEs HERE!!!
var uintArray = new Uint8Array(s.split('').map(function(char) {return char.charCodeAt(0);}));
ok(uintArray);
} else {
error('Invalid file [' + url + ']');
}
}, false);
xhr.addEventListener('error',
function() {
error('Couldn't load URL [' + url + ']');
}, false);
xhr.open('GET', url, true);
xhr.send(null);
}
})();

SceneJS version
  • Dev
  • [x ] Master
  • ...
Browser
  • [] All of them
  • Chrome
  • Firefox
  • [ x] Internet Explorer
OS
  • [] All of them
  • [ x] Windows
  • Linux
  • Android
  • IOS
Hardware Requirements

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions