ColladaLoader fails with objects containing mixture of textured and non-textured materials

STEPS TO REPRODUCE

  1. Launch Google sketchup
  2. Draw rectangle
  3. Texture just the top surface
  4. Export as DAE
  5. Load into three.js editor (drag file to http://mrdoob.github.io/three.js/editor/)

The object is not displayed and firebug stops on an error:

WebGL: DrawElements: bound vertex attribute buffers do not have sufficient size for given indices from the bound element array

Line 450

DEBUGGING

The problem may be related to the UV coordinates.

In SetMeshBuffers there is the code:

if ( dirtyUvs && obj_uvs && uvType ) {
        for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
            fi = chunk_faces3[ f ];
            uv = obj_uvs[ fi ];
            if ( uv === undefined ) continue;

The code spots that obj_uvs is an array with 2 entries, but fi is the number 2, so accesses the array out of bounds and the uv==undefined condition is triggered.

I suspect the problem is actually in ColladaLoader. My suspicion is that faceVertexUvs are only written for faces using a textured material and so the obj_uvs array is too short but I can’t quite understand the details.

WORKAROUND

Using textures for all sides of a model fixes the problem.

Author: Fantashit

1 thought on “ColladaLoader fails with objects containing mixture of textured and non-textured materials

Comments are closed.