如何测试WebGLTexture对象是否"完整"?
目前我收到此消息:
[WebGLRenderingContext]RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering or is not 'texture complete'
我得到这个警告,因为渲染循环试图在其图像加载完成之前使用纹理,那么如何解决这个问题呢?
我得到的错误[.WebGLRenderingContext]RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering or is not 'texture complete',当我在dartium运行我的web应用程序.我一直在尝试解决这个问题两天,包括完全重写代码,但我不能隔离这个问题.
我认为问题在于这段代码.
void main() {
...
var texture = gl.createTexture();
var image = new ImageElement();
image.onLoad.listen((e) {
gl.bindTexture(webGL.TEXTURE_2D, texture);
gl.texImage2DImage(webGL.TEXTURE_2D, 0, webGL.RGBA, webGL.RGBA,
webGL.UNSIGNED_BYTE, image);
gl.texParameteri(webGL.TEXTURE_2D, webGL.TEXTURE_MAG_FILTER, webGL.NEAREST);
gl.texParameteri(webGL.TEXTURE_2D, webGL.TEXTURE_MIN_FILTER, webGL.NEAREST);
gl.bindTexture(webGL.TEXTURE_2D, null);
});
image.src = "tex.png";
...
}
Run Code Online (Sandbox Code Playgroud)
tex.png是32x32
关于问题是什么的任何想法?
我试图将纹理添加到我转换为json并从3ds Max导入的模型.我搜索但没有找到任何在线使用three.js r53将纹理应用于json模型的代码.我想Three.js处理纹理的方式与以前的版本有所不同.任何指导?
以下是我的代码:
var texloader = new THREE.TextureLoader();
var tex=texloader.load("second.jpg");
var mat = new THREE.MeshBasicMaterial({ map: tex });
loader = new THREE.JSONLoader();
loader.load( "js/JsonModels/toothz.js", function( geometry, mat ) {
mat[0].shading = THREE.SmoothShading;
var material = new THREE.MeshFaceMaterial( mat);
mesh = new THREE.Mesh( geometry, material );
mesh.scale.set( 3, 3, 3 );
mesh.position.y = 0;
mesh.position.x = 0;
scene.add( mesh );
} );
Run Code Online (Sandbox Code Playgroud)