Three.js Map material showing warnings despite updating buffers

强颜欢笑 提交于 2019-12-24 14:40:34

问题


I'm trying to load an OBL object and, on pre-specified containers (plains) display a texture. However, after I load an object, I start getting the following errors:

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.

Following Three JS Map Material causes WebGL Warning, I explicitly started to set following flags, although I had (even beforehand) modified material attributes before adding anything to the scene.

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

Despite this, problem still persists. Any ideas?


Code

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
}

来源:https://stackoverflow.com/questions/18317637/three-js-map-material-showing-warnings-despite-updating-buffers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!