UID
UID

Reputation: 4514

3D object created using Three.JS/WebGL not loading in Firefox

I have created a 3d Object using Three.js examples, they are working fine in Chrome and IE 11, but its not loading on Firefox, I have latest version of Firefox (FF 27.0)

In the Fiddle I have created, nothing is loading on Firefox, where as in my application, I am getting this error in Firefox:

enter image description here

Here is my Code: HTML

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

JS

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

// this function is executed on each animation frame
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();
    });
}

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

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

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

// cylinder
// API: THREE.CylinderGeometry(bottomRadius, topRadius, height, segmentsRadius, segmentsHeight)
var cylinder = new THREE.Mesh(new THREE.CylinderGeometry(150, 150, 400, 100, 100, false), new THREE.MeshPhongMaterial({
    // light
    specular: '#cccccc',
    // intermediate
    color: '#666666',
    // dark
    emissive: '#444444',
    shininess: 100
}));
cylinder.overdraw = true;
cylinder.rotation.x = Math.PI * 0.2;
//cylinder.rotation.y = Math.PI * 0.5;
scene.add(cylinder);

// add subtle 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
animate();

FIDDLE for the same: http://jsfiddle.net/Mvz2b/1/

Let me know if you need any other information.

Please suggest.

Upvotes: 0

Views: 1094

Answers (1)

UID
UID

Reputation: 4514

Got the solution Guys!!!

Seems I have an older graphic card and WebGL is enabled in Firefox if you have NVIDIA or ATI graphic card manufactured after 2007.

To enable Manually, All I did:

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

And after making these changes I tested my Fiddle "http://jsfiddle.net/Mvz2b/1/" in Firefox (version 27.0) and its working fine, whereas initially I was getting a some JS error for WebGL in mentioned in my script.

Here is the Article which provided the solution :

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

Hope this will help someone in future!!

Upvotes: 1

Related Questions