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
}