尽管更新缓冲区,Three.js Map材质显示警告

时间:2013-08-19 15:33:17

标签: javascript three.js textures webgl

我正在尝试加载OBL对象,并在预先指定的容器(平原)上显示纹理。但是,在加载对象后,我开始收到以下错误:

THREE.WebGLRenderer 58 
XHR finished loading: "http://localhost:8000/original-material/room2/soba-5-2.obj".

about to traverse... 
about to add to scene 

WebGLRenderingContext: GL ERROR :GL_INVALID_OPERATION : glDrawElements: attempt to access out of range vertices in attribute 0
WebGL: too many errors, no more errors will be reported to the console for this context.

Three JS Map Material causes WebGL Warning之后,我明确地开始设置以下标志,尽管在向场景添加任何内容之前我已经(甚至事先)修改了材质属性。

child.material.needsUpdate = true;
child.geometry.buffersNeedUpdate = true;
child.geometry.uvsNeedUpdate = true;

尽管如此,问题仍然存在。有什么想法吗?


代码

var container_re_match = /container_/

console.log('about to traverse...');
data.traverse(function(child){
    if (child instanceof THREE.Mesh) {
        child.material = new THREE.MeshPhongMaterial({
                ambient: 0xff0000, color: 0xffffff, specular: 0xffffff, shininess: 30, shading: THREE.SmoothShading});

        if (child.parent.name.match(container_re_match)) {
            var container_data = CONTAINER_DATA[child.parent.name]

            child.material.map = THREE.ImageUtils.loadTexture(container_data.image);
            child.material.needsUpdate = true;
            child.geometry.buffersNeedUpdate = true;
            child.geometry.uvsNeedUpdate = true;
        }
    }
});
console.log('about to add to scene');
scene.add(data) // Adding only after everything has been processed
}

0 个答案:

没有答案