question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
peterderivazcommented, Mar 5, 2018

carpet_berber_multi

As requested, the carpet jpg

1reaction
Mugen87commented, Mar 3, 2018

The current version of ColladaLoader does not parse the file correctly. It is able to setup the multiple materials and the respective groups of the buffer geometry but it can handle the definition of uv coordinates of the dae file.

That’s the problematic section:

<polylist count="1" material="Material2">
	 <input offset="0" semantic="VERTEX" source="#ID7" />
	 <vcount>4</vcount>
	 <p>0 1 2 3</p>
</polylist>
<polylist count="1" material="Material3">
	 <input offset="0" semantic="VERTEX" source="#ID7" />
	 <input offset="1" semantic="TEXCOORD" source="#ID13" />
	 <vcount>4</vcount>
	 <p>4 0 5 1 6 2 7 3</p>
</polylist>

Each polylist results in a group with the respective material index. The first polylist has no uv-coordinate (TEXCOORD) definition. But the second one. And that’s the problem. As @crobi suggested, we need to fill default values to the uv buffer for the first polylist.

@mrdoob Unfortunately, it looks like we need a more comprehensive refactoring to enable this feature. I’ll try to code something so we can better see the scope of this change.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Three JS | Collada loader textures - Stack Overflow
I receive dae model with all textures from backend. After, i parse images (textures) and create materials array. let materials = []; textures....
Read more >
texturing - Problem with exporting a proxy object (to collada ...
No textures / materials will be copied to the destination. The animation doesn't work, because it seems like the "Body" object is not...
Read more >
How to Texture Walls - The Home Depot
Learn how to texture a wall with a roller and other common supplies. ... It does not contain sand or other materials to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found