Error encountered while trying to run a three.js example with iewebgl

I'm attempting to utilize the iewebgl and encountering difficulties while trying to run an example from three.js, specifically the webgl_loader_obj. Upon execution, I am facing the following error:

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

This error is pointing to the following line:

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

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

I also attempted to comment out the texture and model sections and loading the object without the manager, but encountered a different error:

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

This error points to the following 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 attempted both creating canvas and acquiring WebGL context using JavaScript, as well as creating WebGL context with helper.

I'm utilizing ie 10 with r.46 of three.js. A switch to r.61 of three.js triggers the following exception:

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

This corresponds to:

} 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 insights into what might be causing this issue?

Answer №1

By following the example of Creating canvas and getting WebGL context from JavaScript, I successfully resolved my issue.

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

In order to fix the problem, I placed both the init() and animate() calls within a specific block while excluding global variables like var container, stats.

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

Although I did not use the require code myself, I included it for anyone who may encounter a similar issue and find it necessary.

Lastly, I made changes to the render code as shown below (original code is left commented out):

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 } ); -->

Answer №2

If you opt for the unminified version of three.js, the issue might become apparent when the _gl object (j in the minified version) turns out to be null. It seems like three.js will throw an exception, log the "Error creating WebGL context" message, and then attempt to utilize the _gl object. :)

Have you noticed this message in your console? Below is the unminified source where I suspect the error arises.

function initGL() {

    try {

        var attributes = {
            alpha: _alpha,
            premultipliedAlpha: _premultipliedAlpha,
            antialias: _antialias,
            stencil: _stencil,
            preserveDrawingBuffer: _preserveDrawingBuffer
        };

        _gl = _canvas.getContext('webgl', attributes) || _canvas.getContext('experimental-webgl', attributes);

        if (_gl === null) {

            throw 'Error creating WebGL context.';

        }

    } catch (error) {

        console.error(error);

    }

    _glExtensionTextureFloat = _gl.getExtension('OES_texture_float');
    _glExtensionTextureFloatLinear = _gl.getExtension('OES_texture_float_linear');
    _glExtensionStandardDerivatives = _gl.getExtension('OES_standard_derivatives');

Does your Internet Explorer support WebGL? Have other WebGL tests been successful? I don't have IE Win8.1 preview, but I am interested to know whether three.js functions with it.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Change the appearance of the page when it is being displayed within an iframe using CSS

How can I display a webpage differently using CSS if it is within an iframe? I would like to use jQuery or JavaScript to switch to a different stylesheet specifically when the site is being displayed within an iframe. Any suggestions on how to achieve th ...

In JavaScript, an HTTP request file includes a JavaScript variable

I am currently working on a Node.js project that involves making an HTTP request to fetch a JavaScript file. For example, let's say we have a file named a.js: var a = 'i am a.js'; var b = 'please convert me to js'; Here is the a ...

Refresh the information displayed in the open Google Maps Infowindow

Experimenting with extracting JSON data from a bus tracker website and integrating it into my own version using Google Maps. Although not as visually appealing, I'm struggling to update an infowindow while it remains open. Despite finding some example ...

What approach does JavaScript take when encountering a value that is undefined?

Having recently delved into JavaScript and exploring a book, I came across an interesting example in the recursive chapter: function findSolution(target) { function find(current, history) { if (current == target) return history; else if (c ...

React encountered an error: Unable to destructure the property 'id' of '_ref' as it has been defined

After spending several hours trying to solve this issue, I am completely stuck. The console shows that the patch request successfully updates the information, but then my map function breaks, leading to a blank page rendering. Here is the problematic comp ...

Three.js globe experiencing issues with splines arc functionality

I have been experimenting with mapping arcs around a three.js globe, following some examples. I am close to getting it to work but I am struggling with the calculations and the resulting projection appears to be incorrect. If anyone could review my code an ...

Error: The 'length' property cannot be searched for using the 'in' operator

Hmm, I keep getting an error that says "Uncaught TypeError: Cannot use 'in' operator to search for 'length' in" Every time I attempt a $.each on this JSON object: {"type":"Anuncio","textos":["Probando ...

Scale.set not only affects the size of the node it is applied to, but also changes the size of its children

Is there a way to resize only one node in a three.js scene graph without affecting its child nodes? I have been using scale.set() to adjust the size, but it seems to scale all the child nodes as well. Any suggestions on how to selectively resize individu ...

I seem to be having an issue with the decimal point on my calculator - I only want to see one dot

Only need one dot for the calculator to function properly. The current situation with multiple dots is causing confusion. I intend to address other aspects of the code later, but I'm currently struggling with this issue. function dec(d) { let ...

Triggering transitionend event once with an added if condition

Currently, I have an application of an if statement that examines whether an element contains a style attribute. In the event that the style attribute is absent, it appends inline styling. Conversely, if the style attribute exists, it is removed. Furthermo ...

Safari on iOS9 is inaccurately calculating the total sum

My code involves calculating the sum of key/value pairs in a hash within a loop. I have noticed that there is a discrepancy in how the sum is calculated on ios9 Safari compared to other platforms. While I can address this issue for this specific scenario, ...

What is the best way to create a clickable table from a nested array of objects?

I am currently working with an array of objects that holds some variable information and another array of objects containing more details. My goal is to create a table that initially displays the main array, and when a user clicks on a specific row, it sho ...

Which is better: specifying a name in window.open() or using replace?

If the current window is www.myparent.com and a button labeled "a" is clicked, it triggers the following function window.open('children','same','',??). Subsequently, a new page will open as www.myparent.com/children. On the o ...

Learn the process of transmitting JSON data from a server-side (nodejs) to the client-side using Ajax

I have successfully set up a Node.js/express server to make a GET call to an API, which returns JSON data. Now, I am looking for ways to send this JSON data to my local JavaScript (client-server) in order to manipulate it by looping through and appending i ...

The directive attribute in AngularJS fails to connect to the directive scope

I have been attempting to pass an argument to a directive through element attributes as shown in the snippet below: directive app.directive('bgFluct', function(){ var _ = {}; _.scope = { data: "@ngData" } _.link = function(scope, el ...

A bug encountered with AngularJS and dojox.charting: Error message 'nodeType' of null

My goal is to dynamically populate a div with various graphs from Dojo, depending on the current data model. However, I keep encountering the error message "Cannot read property 'nodeType' of null" when running my code. I suspect that this issu ...

Using HTML and CSS to stack a DIV on top of another using z-index

I have 3 main layers on my website: 1) The main view with elements inside (#views in jsbin) - BOTTOM LAYER 2) An overlay (with a white background opacity of .8 #overlay in jsbin) - MIDDLE LAYER 3) A context menu (#contextmenu in jsbin) - TOP LAYER Wh ...

AngularJS: enhancing $http with custom functionality

I am facing an issue with my simple controller, which looks like this: function MyController($scope, $http) { ... $http.post(url).success(function(data) { console.log(data) }); } MyController.$inject = ['$scope', &ap ...

Navigating through JSON arrays can be achieved by utilizing iteration techniques

I'm having trouble with a script and can't figure out how to make it display in the designated div. It may have something to do with how I'm handling the response. In Chrome devtools, the response looks like this: { "[\"record one& ...

The error "TypeError: ollama.chat is not a function" has occurred when trying to use the ollama module in

Currently, I am grappling with a Node.js project that requires me to utilize the ollama module (ollama-js). The problem arises when I invoke the async function chatWithLlama() which contains ollama.chat(), resulting in the following error being thrown: Ty ...