问题描述
我正在画布上绘制图像(使用 http://haldean.github.com/citycanvas/city.js),然后将其用作纹理.当我使用three.js 的CanvasRenderer 时,这非常有效,但使用WebGLRenderer 时纹理显示为黑色.我将纹理生成为边长为 256 的正方形.
I'm drawing an image to a canvas (using the cityTexture method in http://haldean.github.com/citycanvas/city.js) and then using that as a texture. This works perfectly when I use three.js's CanvasRenderer, but the textures show up as black when using a WebGLRenderer. I'm generating the textures as squares with side lengths of 256.
演示和代码在这里,顶部有一个 CanvasRenderer,底部有一个 WebGLRenderer:http://haldean.github.com/citycanvas/3d.html
Demo and code is here, with a CanvasRenderer on top, and a WebGLRenderer on the bottom: http://haldean.github.com/citycanvas/3d.html
这不会成为问题,除了当渲染大量几何体时 CanvasRenderer 的性能非常差,而 WebGL 的性能似乎要好得多.(考虑到这一点,如果有人对提高 CanvasRenderer 的效率有任何建议,那也太棒了).谢谢!
This wouldn't be an issue, except that the performance of the CanvasRenderer is pretty poor when there's lots of geometry being rendered, and WebGL seems to perform a lot better. (With that in mind, if anyone has any suggestions to make CanvasRenderer more efficient, that would be great too). Thanks!
推荐答案
问题已解决:我需要将 mesh.dynamic = true
添加到我的网格中,并且 texture.needsUpdate = true
到我的纹理.
Problem solved: I needed to add mesh.dynamic = true
to my mesh, and texture.needsUpdate = true
to my texture.
这篇关于Three.js 纹理与 CanvasRenderer 一起使用,但在 WebGLRenderer 中显示为黑色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!