I'm using the Collada loader to render models and it works great. But the models I have are too big (about 15MB each), so I need to reduce their quality.
I've never done this before, but I read that it's possible using the 'Decimate' modifier in Blender. I tried it and sure enough, it reduces the filesize. However, if I try to render it now, it doesn't show up, instead it gives me the following:
'GL_INVALID_OPERATION: glDrawXXX attempt to access out of range vertices'.
From a quick comparison of the old (bigger) file to the new (smaller) file, the main difference seems to be that it's combined everything into one polylist. So before I had:
<polylist material="mat11" count="70424">...
<polylist material="mat32" count="15133">...
<polylist material="defaultMat3" count="14690">...
<polylist material="mat24" count="11516">...
Now I have:
<polylist material="mat11" count="101032">....
In this case, I chose a decimate value of 0.9, so the total count going down by about 10% makes sense I guess. (I also tried a value of 0.3; it gave the same error).
I've tried with r48 and r49dev.
Being a newbie, I'm not sure if it's a Blender issue, a Three.js Collada loader issue, or a WebGL issue, but please might anyone be able to give me a pointer for what to look at to try to figure it out? (Or any other suggestions for how to compress/optimise/reduce the model file size?)
Thanks very much,
I recall someone having the same issue and fixing it by loading the .dae in blender and exporting it again.
My memory may be wrong though.
Might you be thinking of the recent comments on #1130? That was me too! But I think this is a different issue - it's a different error (a direct WebGL error this time) and re-exporting didn't help...
Yeah it was that one, feels like ages ago now ;)
Maybe you can share the .dae?
I'm not sure if I'll be allowed to share it, but I've asked for permission and I'll let you know when I hear back! Thank you.
Sorry for the delay, I just got permission to send it to you. Can I email it to you? If so, what's your address? (Mine is peter [dot] oshaughnessy [at] gmail [dot] com).
Seems like you're hitting this issue #1731.
Thank you very much for looking into it, and to AddictArts.
Unfortunately I've tried with the latest ColladaLoader from the dev branch (now moved to examples/js/loaders/) with fix #1767 and I still have problems:
1) With the model I shared with you, it's the same as before: the model doesn't show up, and I get the 'GL_INVALID_OPERATION...' errors in the console.
I can get this to happen by dropping the files that I shared with you in that Dropbox folder into examples/models/collada/, and editing the webgl_loader_json_blender.html line 59 to load:
2) With a decimated version of the Monster Collada model, I get a different error: "Cannot read property 'type' of undefined" on line 645 of ColladaLoader.js (referring to a 'controller' in createSceneGraph).
I can get this to happen by dropping the following file into examples/models/collada/monster:
And editing the webgl_loader_json_blender.html example to use 'monster-decimated.dae' instead of 'monster.dae' (line 59).
3) If I decimate a model in Blender as before, but this time export as Three.js JSON format, I also get the same errors as in number 1) with the JSONLoader too.
I can replicate this with the following Gist:
And the following model file:
(It's those 'GL_INVALID_OPERATION' errors again).
Might anyone else be able to replicate any of these? Do the model files look okay? Since I've experienced problems with two separate formats/loaders, I guess it's sounding more likely that the problem lies with Blender?
If anyone has any suggestions for other ways to optimise models other than Blender decimate, I'd really appreciate that too.
Decimating seems to blow away the texture coordinates, from monster-decimated.dae
<input semantic="POSITION" source="#monster_001-mesh-positions"/>
<polylist material="monster1" count="618">
<input semantic="VERTEX" source="#monster_001-mesh-vertices" offset="0"/>
<input semantic="NORMAL" source="#monster_001-mesh-normals" offset="1"/>
<vcount>3 3 3 ...
That polylist should have an input semantic TEXCOORD. Not sure what the controller issue is, only had a quick look.