我使用Three.js在3D视图中渲染一些网格和一个平面。我在场景中添加了一个聚光灯,因为添加这个我在Firefox上遇到了奇怪的崩溃。第一次加载页面时,场景实际上呈现正常。刷新页面时,firefox崩溃了。我设法在firebug控制台崩溃之前截获它:
THREE.WebGLProgram: shader error: 1285 gl.VALIDATE_STATUS false gl.getProgramInfoLog Failed to create D3D shaders.
THREE.WebGLShader: Shader couldn't compile.
这是我的聚光灯代码:
var spotLight = new THREE.SpotLight( 0xffffff );
spotLight.position.set( 2000, 1500, 300);
spotLight.distance = 3000;
spotLight.penumbra = 1;
spotLight.intensity =2;
spotLight.angle = 1.05;
spotLight.castShadow = true;
spotLight.shadow.mapSize.width = 4096;
spotLight.shadow.mapSize.height = 4096;
spotLight.shadow.camera.near = 500;
spotLight.shadow.camera.far = 4000;
spotLight.shadow.camera.fov = 3000;
scene.add(spotLight );
奇怪的是:它只会在第二次加载页面时崩溃,永远不会在第一次加载时崩溃!当我删除聚光灯的代码时,它不再崩溃。在谷歌浏览器中,它似乎工作正常。