Having trouble with a Three.JS/WebGL 3D object not loading in Firefox?

After creating a 3D Object using Three.js examples, I noticed that it works perfectly in Chrome and IE 11, but for some reason, it's not loading on Firefox. I am currently using the latest version of Firefox (FF 27.0).

When I tested the code on Firefox in my application, I encountered this error specifically in Firefox:

Below is the code snippet: HTML

<div id="container"></div>

JS

// revolutions per second
var angularSpeed = 0.2;
var lastTime = 0;

// animation function
function animate() {
    // update
    var time = (new Date()).getTime();
    var timeDiff = time - lastTime;
    var angleChange = angularSpeed * timeDiff * 2 * Math.PI / 1000;
    cylinder.rotation.x += angleChange;
    cylinder.rotation.z += angleChange;
    lastTime = time;

    // render
    renderer.render(scene, camera);

    // request new frame
    requestAnimationFrame(function () {
        animate();
    });
}

// create renderer
var container = document.getElementById("container");
var renderer = new THREE.WebGLRenderer();
renderer.setSize(container.offsetWidth, container.offsetHeight);
container.appendChild(renderer.domElement);

// setup camera
var camera = new THREE.PerspectiveCamera(55, window.innerWidth / window.innerHeight, 1, 1000);
camera.position.z = 700;

// scene
var scene = new THREE.Scene();

// add cylinder to scene
var cylinder = new THREE.Mesh(new THREE.CylinderGeometry(150, 150, 400, 100, 100, false), new THREE.MeshPhongMaterial({
    specular: '#cccccc',
    color: '#666666',
    emissive: '#444444',
    shininess: 100
}));
cylinder.overdraw = true;
cylinder.rotation.x = Math.PI * 0.2;
scene.add(cylinder);

// add ambient lighting
var ambientLight = new THREE.AmbientLight(0x222222);
scene.add(ambientLight);

// directional lighting
var directionalLight = new THREE.DirectionalLight(0xffffff);
directionalLight.position.set(1, 1, 1).normalize();
scene.add(directionalLight);

// start animation loop
animate();

FIDDLE link for reference: http://jsfiddle.net/Mvz2b/1/

If you require additional information or have any suggestions, feel free to let me know.

Please advise accordingly.

Answer №1

Just found the solution!

It turns out that my older graphics card was causing issues with WebGL in Firefox. If you have an NVIDIA or ATI graphics card manufactured after 2007, WebGL should be enabled.

To manually enable it, all I did was:

Type about:config in the address bar and search for webgl. To enable WebGL, set webgl.force-enabled to true.

After making these changes, I tested my Fiddle "http://jsfiddle.net/Mvz2b/1/" in Firefox (version 27.0) and it worked fine. Previously, I was encountering JavaScript errors related to WebGL in my script.

For more information on this solution, check out this article:

How to Enable WebGL in Firefox [For Blacklisted Graphic Cards]

I hope this helps someone else in the future!

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

Ways to transform a group of strings into an array of separate strings

function categorizeMember(data) { let resultArr = [] let userData = [data] return userData.forEach(data => { data.map(data => { let category = (data[0] >= 55 && data[1] > 7) ? console.log("Senior") : console.lo ...

Is there a way to transfer the submitted data to a different page without being redirected to it using #php and #ajaxjquery?

Hey there, I could use a little assistance. How can I send data to page update.page.php when submitting a form on index.php without being redirected? I want the functionality of sending a message from one page to another without having to refresh the ent ...

Enhance the Header component by incorporating a logout button that seamlessly navigates with the NextJS App

Currently, I am utilizing NextJS 14 with App router alongside Spring Boot on the backend. Within my application, I have both public and private routes set up. For the private routes, users are required to log in through a designated login page. Upon succes ...

An error of `SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data` is occurring in relation to Django Channels

Whenever I attempt to access a JSON array object sent by the consumer (channels), I encounter the following error message: "SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data" async def websocket_connect(self,event): pri ...

jQuery may not function properly in a dynamic content environment

I'm encountering an issue with my web application. I've developed a chat feature using Ajax, and I want it to load when a button is clicked. The functionality works, but the dynamic data loaded doesn't seem to be compatible with jQuery. Aft ...

Performing Ajax requests according to the selected checkbox data

Hey, I'm just starting out with Jquery and Ajax and could use some help to solve my issue. Currently, I am populating checkboxes based on my model values and making an ajax call to get a list of countries for each selected value. Now, I want to chan ...

Navigating through the sidebar on Next.js

I am currently exploring how to utilize next.js routes for dynamically populating a sidebar component with route instructions. The goal is to have the main div display the relevant component when a sidebar option is clicked. While I've come across tu ...

Checking for mouse button press during Firefox mouse movement

Trying to drag a div without needing to add a mouseup function to avoid potential bugs if the user's mouse is outside the window. Tested with chrome, IE and firefox - "e.which" works fine in IE and chrome but firefox retains the last clicked button s ...

Is it possible to maintain HTML, JS, and CSS files as separate entities when developing Vue.js components, similar to how it is

Is it possible to maintain separate HTML, JS, and CSS files while creating Vue.js components? I recently read the "Why Vue.js doesn't support templateURL" article which discusses this topic. "Proper modularization is a necessity if you want to bu ...

Issues with Cordova and JQuery ajax functionality not operating as expected

I am facing an issue with implementing AJAX functionality in my Cordova app (CLI 6.3.1) on Visual Studio 2017. It works fine on the emulator, but I encounter a connection error when installing it on a mobile phone. I have already included CSP as shown bel ...

There is no response provided by the function

Here is the code for inserting data into the database. However, it seems to be going into the else section as the response is empty. I have checked by alerting the response, but it remains empty. // Function to add donation via AJAX function ccjkfound ...

Setting up Tipsy with titlesorting

Recently, I attempted to incorporate the Tipsy jQuery plugin into my website to display title tags as attractive tooltips. However, I am facing issues with the plugin not working correctly. Can anyone offer assistance with this? Specifically, I am looking ...

Delaying Jquery on scroll Event

Hey there, I've got a set of icons that I'd like to reveal one by one as you scroll down. I've incorporated some animations from , but now I'm wondering how I can implement a delay function in my jQuery so the icons appear sequentially ...

Illuminating individual table cells as a user drags their mouse across a row

My goal is to create a feature that allows users to highlight cells in a table by dragging the mouse over them, similar to what is discussed in the question and answer provided here. However, I would like to limit this drag/highlight effect to only span w ...

Implementing USB trigger for cash drawer in web development

I am wondering about how to use a USB trigger to open a cash drawer (BT-100U). Can someone provide guidance on integrating this into a website? Here is a brief description of the BT-100U Cash Drawer Driver Trigger with USB Interface: This device allows fo ...

Encountered a Vue.js Vuex error: "Unable to dispatch function in context."

I have implemented a stopwatch function that can run the stopwatch as shown below : Stopwatch.vue <script> export default { data() { return { time: "00:00.000", timeBegan: null, timeStopped: null, stoppedDurat ...

Setting character limits within textareas based on CSS classes in a dynamic manner

I'm looking to develop a JavaScript function that can set text limits for multiple textareas at once using a class, allowing for flexibility in case specific textareas need to be exempt. However, I'm facing issues with my debuggers - Visual Studi ...

Vue-router vulnerability allowing for DOM-based open redirects

I am currently working on a Vue application that was created using Vue-cli. Vue version: 2.6.11 vue-router version: 3.2.0 Link for Reproduction https://github.com/keyhangholami/dom-based-open-redirect Instructions to replicate To reproduce the i ...

Encountering parameter issues while working with Google Maps React in TypeScript

Currently, I'm utilizing TypeScript in this particular file. import React, {Component} from 'react' import {Map, InfoWindow, Marker, GoogleApiWrapper, mapEventHandler, markerEventHandler} from 'google-maps-react'; import { coordina ...

Encountering net::ERR_CONNECTION_RESET and experiencing issues with fetching data when attempting to send a post request

I am facing a React.js task that involves sending a POST request to the server. I need to trigger this POST request when a user clicks on the submit button. However, I keep encountering two specific errors: App.js:19 POST http://localhost:3001/ net::ERR_CO ...