Search code examples
javascriptinternet-explorerthree.jswebglcompatibility

Exception when running three.js example using iewebgl


I'm trying to use the iewebgl and having trouble running one of the examples from three.js, the webgl_loader_obj. I am getting the following error:

SCRIPT445: Object doesn't support this action iewebgl.html, line 134 character 5

which points to this line

// texture
var manager = new THREE.LoadingManager();  <!-- here  -->
manager.onProgress = function ( item, loaded, total ) {

    console.log( item, loaded, total );
};

I also tried commenting out the texture and model portions and loading the object without the manager but I would receive the following error:

SCRIPT445: Object doesn't support this action OBJLoader.js, line 19 character 3

which points to this line

THREE.OBJLoader.prototype = {

constructor: THREE.OBJLoader,

load: function ( url, onLoad, onProgress, onError ) {

    var scope = this;

    var loader = new THREE.XHRLoader( scope.manager );  <!-- here-->
    loader.setCrossOrigin( this.crossOrigin );

I tried both creating canvas and getting WebGL context from JavaScript and creating WebGL context with helper.

I'm using ie 10 with r.46 of three.js. When I use r.61 of three.js I get the following exception

SCRIPT5007: Unable to get property 'getExtension' of undefined or null reference three.min.js, line 8322 character 2

which is

} catch (Zb) {
    console.error(Zb)
}
Na = j.getExtension("OES_texture_float"); <!-- here -->
j.getExtension("OES_texture_float_linear");
va = j.getExtension("OES_standard_derivatives");

Any idea what may be causing it?


Solution

  • I was able to solve my issue using the Creating canvas and getting WebGL context from JavaScript example

    <div id="container"> 
        <script id="WebGLCanvasCreationScript" type="text/javascript">WebGLHelper.CreateGLCanvasInline('renderCanvas', onLoad)</script>
    </div>
    

    I then placed both the init() and animate() calls in the following block leaving out the global vars var container, stats;

    var camera, cameraTarget, scene, renderer;
    function onLoad() {
        <!-- require(["js/Three.js"], function () { -->
        init();
        animate();
        <!-- }); -->
    }
    

    I didn't use the require code, but included it in case anyone else runs into a similar problem and finds they need it.

    Finally, had to change the render code to the following. (I left the original commented)

    var externalCanvas = document.getElementById('renderCanvas');
    renderer = new THREE.WebGLRenderer({ 'canvas': externalCanvas, 'clearColor': 0xffffff });
    <!-- renderer = new THREE.WebGLRenderer(); -->
    <!-- renderer = new THREE.WebGLRenderer( { antialias: true, alpha: false } ); -->