无法在Firefox

时间:2017-07-28 17:13:37

标签: firefox three.js webgl

在Firefox上运行时,我似乎无法渲染浮点RGB纹理。 Chrome工作得很好。 Firefox给了我这个:

  

帧缓冲未完成。 (状态:0x8cd6)COLOR_ATTACHMENT0具有RGB32F的有效格式,不可渲染

我尝试启用扩展程序

  

的console.log(renderer.context.getExtension(“WEBGL_color_buffer_float”));   的console.log(renderer.context.getExtension(“OES_texture_float”));

并且都返回非空值,但渲染仍然失败。

下面的代码在屏幕上不显示任何内容,但在屏幕外浮点纹理上呈现。在Firefox上,错误将显示在控制台上。 代码:

var width = 400
var height = 200

var renderer = new THREE.WebGLRenderer()
renderer.setSize(width, height)
document.body.appendChild(renderer.domElement)

console.log(renderer.context.getExtension('WEBGL_color_buffer_float'));
console.log(renderer.context.getExtension('OES_texture_float'));

renderer.setClearColor(0x000000)

var scene = new THREE.Scene()
var geometry = new THREE.SphereGeometry(1, 32, 32)
var material = new THREE.MeshBasicMaterial({color: 0xffff00})
var sphere = new THREE.Mesh(geometry, material)
sphere.position.set(0, 10, 0)
scene.add(sphere)

var target = new THREE.WebGLRenderTarget(width, height, {
  format: THREE.RGBFormat,
  type: THREE.FloatType,
  minFilter: THREE.NearestFilter,
  magFilter: THREE.NearestFilter,
  stencilBuffer: false,
  depthBuffer: true,
})

var camera = new THREE.PerspectiveCamera(45, width / height, 1, 1000);
camera.position.set(0, 0, 0)
camera.lookAt(sphere.position);

renderer.render(scene, camera, target, true)
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/86/three.min.js"></script>

0 个答案:

没有答案