【问题标题】:3D object created using Three.JS/WebGL not loading in Firefox使用 Three.JS/WebGL 创建的 3D 对象未在 Firefox 中加载
【发布时间】:2014-02-14 23:33:45
【问题描述】:

我使用 Three.js 示例创建了一个 3d 对象,它们在 Chrome 和 IE 11 中运行良好,但无法在 Firefox 上加载,我有最新版本的 Firefox (FF 27.0)

在我创建的 Fiddle 中,Firefox 上没有加载任何内容,而在我的应用程序中,我收到此 Firefox 中的错误

这是我的代码: 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:http://jsfiddle.net/Mvz2b/1/

如果您需要任何其他信息,请告诉我。

请提出建议。

【问题讨论】:

  • 第一步,在你的小提琴中链接到当前版本的three.js:threejs.org/build/three.min.js
  • 试过了……还是不行!!!
  • 我没有说这会解决问题;这只是避免使用旧版本库的提示。
  • 在 Firefox 29 中对我来说很好
  • 小提琴在 Firefox 27.0.1 Win7 Intel 集成中为我工作

标签: javascript firefox plugins firefox-addon three.js


【解决方案1】:

得到解决方案伙计们!!!

如果您拥有 2007 年之后制造的 NVIDIA 或 ATI 显卡,我似乎有一个较旧的显卡并且在 Firefox 中启用了 WebGL。

要手动启用,我所做的一切:

在地址栏中输入 about:config 并在搜索框中输入 webgl。至 启用 WebGL,将 webgl.force-enabled 设置为 true。

在进行这些更改后,我在 Firefox (version 27.0) 中测试了我的 Fiddle "http://jsfiddle.net/Mvz2b/1/" 并且它工作正常,而最初我遇到了一些 JS 错误我的脚本中提到了 WebGL。

这是提供解决方案的文章

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

希望这对将来的人有所帮助!

【讨论】:

  • 感谢分享答案,以便我们通过搜索遇到此问题时可以帮助其他人
猜你喜欢
  • 2022-11-02
  • 1970-01-01
  • 2019-09-30
  • 2017-01-21
  • 1970-01-01
  • 2015-09-15
  • 1970-01-01
  • 2014-09-21
  • 2014-11-15
相关资源
最近更新 更多