mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
101.76k stars 35.3k forks source link

(WebGL Error) DrawElements: bound vertex attribute buffers.. #1580

Closed aphex- closed 12 years ago

aphex- commented 12 years ago

I get this Error if I try to inport a jsonmodel. (FireFox 11, WebGL.Verbose = true) WebGL: DrawElements: bound vertex attribute buffers do not have sufficient size for given indices from the bound element array (Three.js:281) Any ideas? :)

{

    "metadata" :
    {
        "formatVersion" : 3,
        "generatedBy"   : "Blender 2.60 Exporter",
        "vertices"      : 116,
        "faces"         : 109,
        "normals"       : 28,
        "colors"        : 0,
        "uvs"           : 0,
        "materials"     : 0,
        "morphTargets"  : 0
    },

    "scale" : 1.000000,

    "materials": [],

    "vertices": [1.000000,-0.000000,-1.000000,1.000000,0.000000,1.000000,-1.000000,0.000000,1.000000,-1.000000,-0.000000,-1.000000,1.000000,0.100000,-0.999999,0.999999,0.100000,1.000001,-1.000000,0.100000,1.000000,-1.000000,0.100000,-1.000000,0.600000,0.000000,1.000000,0.200000,0.000000,1.000000,-0.200000,0.000000,1.000000,-0.600000,0.000000,1.000000,0.600000,-0.000000,-1.000000,0.200000,-0.000000,-1.000000,-0.200000,-0.000000,-1.000000,-0.600000,-0.000000,-1.000000,0.599999,0.100000,1.000000,0.199999,0.100000,1.000000,-0.200001,0.100000,1.000000,-0.600000,0.100000,1.000000,0.600000,0.100000,-1.000000,0.200000,0.100000,-1.000000,-0.200000,0.100000,-1.000000,-0.600000,0.100000,-1.000000,-0.600000,0.100000,-1.000000,-0.600000,0.100000,1.000000,-0.200001,0.100000,1.000000,-0.200000,0.100000,-1.000000,0.199999,0.100000,1.000000,0.200000,0.100000,-1.000000,0.600000,0.100000,-1.000000,0.599999,0.100000,1.000000,-1.000000,0.100000,-1.000000,1.000000,0.100000,-0.999999,-1.000000,0.100000,1.000000,0.999999,0.100000,1.000001,1.000000,0.100000,-0.999999,0.999999,0.100000,1.000001,-1.000000,0.100000,-1.000000,-1.000000,0.100000,1.000000,0.599999,0.100000,1.000000,0.199999,0.100000,1.000000,-0.200001,0.100000,1.000000,-0.600000,0.100000,1.000000,0.600000,0.100000,-1.000000,0.200000,0.100000,-1.000000,-0.200000,0.100000,-1.000000,-0.600000,0.100000,-1.000000,-0.600000,0.100000,-1.000000,-0.600000,0.100000,1.000000,-0.200001,0.100000,1.000000,-0.200000,0.100000,-1.000000,0.199999,0.100000,1.000000,0.200000,0.100000,-1.000000,0.600000,0.100000,-1.000000,0.599999,0.100000,1.000000,0.599999,0.100000,1.000000,0.199999,0.100000,1.000000,-0.600000,0.100000,1.000000,-0.200001,0.100000,1.000000,0.600000,0.100000,-1.000000,0.200000,0.100000,-1.000000,-0.600000,0.100000,-1.000000,-0.200000,0.100000,-1.000000,-0.600000,0.100000,1.000000,-0.600000,0.100000,-1.000000,-0.200001,0.100000,1.000000,-0.200000,0.100000,-1.000000,0.200000,0.100000,-1.000000,0.199999,0.100000,1.000000,0.600000,0.100000,-1.000000,0.599999,0.100000,1.000000,-1.000000,0.100000,-1.000000,1.000000,0.100000,-0.999999,-1.000000,0.100000,1.000000,0.999999,0.100000,1.000001,0.999999,0.365908,1.000001,1.000000,0.365908,-0.999999,-1.000000,0.365908,1.000000,-1.000000,0.365908,-1.000000,0.599999,0.365908,1.000000,-0.200001,0.365908,1.000000,0.199999,0.365908,1.000000,-0.600000,0.365908,1.000000,0.600000,0.365908,-1.000000,-0.200000,0.365908,-1.000000,0.200000,0.365908,-1.000000,-0.600000,0.365908,-1.000000,-0.600000,0.365908,-1.000000,-0.600000,0.365908,1.000000,-0.200001,0.365908,1.000000,-0.200000,0.365908,-1.000000,0.200000,0.365908,-1.000000,0.199999,0.365908,1.000000,0.599999,0.365908,1.000000,0.600000,0.365908,-1.000000,0.199999,0.475939,1.000000,0.599999,0.475939,1.000000,-0.200001,0.475939,1.000000,-0.600000,0.475939,1.000000,0.600000,0.475939,-1.000000,0.200000,0.475939,-1.000000,-0.600000,0.475939,-1.000000,-0.200000,0.475939,-1.000000,-0.600000,0.475939,-1.000000,-0.600000,0.475939,1.000000,-0.200001,0.475939,1.000000,-0.200000,0.475939,-1.000000,0.200000,0.475939,-1.000000,0.199999,0.475939,1.000000,0.599999,0.475939,1.000000,0.600000,0.475939,-1.000000,-1.000000,0.475939,-1.000000,1.000000,0.475939,-0.999999,-1.000000,0.475939,1.000000,0.999999,0.475939,1.000001],

    "morphTargets": [],

    "normals": [0.707083,0.000000,-0.707083,0.707083,0.000000,0.707083,-0.707083,0.000000,0.707083,-0.707083,0.000000,-0.707083,0.000000,0.000000,1.000000,0.000000,0.000000,-1.000000,-0.512589,0.085421,-0.854335,-0.512589,0.085421,0.854335,-0.195166,0.097568,0.975890,-0.195166,0.097568,-0.975890,0.195166,0.097568,-0.975890,0.195166,0.097568,0.975890,0.512589,0.085421,0.854335,0.512589,0.085421,-0.854335,-0.705344,0.070528,-0.705344,0.705344,0.070528,-0.705344,-0.705344,0.070528,0.705344,0.705344,0.070528,0.705344,0.707083,0.707083,0.000000,-0.707083,0.707083,0.000000,-0.894406,0.000000,0.447188,-0.894406,0.000000,-0.447188,0.894406,0.000000,-0.447188,0.894406,0.000000,0.447188,0.577349,0.577349,0.577349,-0.577349,0.577349,0.577349,-0.577349,0.577349,-0.577349,0.577349,0.577349,-0.577349],

    "colors": [],

    "uvs": [[]],

    "faces": [33,0,4,5,1,0,0,1,1,33,2,6,7,3,2,2,3,3,33,5,16,8,1,1,4,4,1,33,16,17,9,8,4,4,4,4,33,17,18,10,9,4,4,4,4,33,18,19,11,10,4,4,4,4,33,19,6,2,11,4,2,2,4,33,0,12,20,4,0,5,5,0,33,12,13,21,20,5,5,5,5,33,13,14,22,21,5,5,5,5,33,14,15,23,22,5,5,5,5,33,15,3,7,23,5,3,3,5,33,19,23,24,25,4,5,6,7,33,22,18,26,27,5,4,8,9,33,17,21,29,28,4,5,10,11,33,20,16,31,30,5,4,12,13,33,23,7,32,24,5,3,14,6,33,21,22,27,29,5,5,9,10,33,4,20,30,33,0,5,13,15,33,6,19,25,34,2,4,7,16,33,18,17,28,26,4,4,11,8,33,16,5,35,31,4,1,17,12,33,7,6,34,32,3,2,16,14,33,5,4,33,35,1,0,15,17,33,35,33,36,37,17,15,15,17,33,32,34,39,38,14,16,16,14,33,31,35,37,40,12,17,17,12,33,26,28,41,42,8,11,11,8,33,34,25,43,39,16,7,7,16,33,33,30,44,36,15,13,13,15,33,29,27,46,45,10,9,9,10,33,24,32,38,47,6,14,14,6,33,30,31,40,44,13,12,12,13,33,28,29,45,41,11,10,10,11,33,27,26,42,46,9,8,8,9,33,25,24,47,43,7,6,6,7,33,23,19,49,48,5,4,7,6,33,18,22,51,50,4,5,9,8,33,21,17,52,53,5,4,11,10,33,16,20,54,55,4,5,13,12,33,22,23,48,51,5,5,6,9,33,20,21,53,54,5,5,10,13,33,19,18,50,49,4,4,8,7,33,17,16,55,52,4,4,12,11,33,52,55,56,57,11,12,18,19,33,49,50,59,58,7,8,18,19,33,54,53,61,60,13,10,19,18,33,51,48,62,63,9,6,19,18,33,55,54,60,56,12,13,18,18,33,53,52,57,61,10,11,19,19,33,50,51,63,59,8,9,18,18,33,48,49,58,62,6,7,19,19,33,43,47,65,64,7,6,0,1,33,46,42,66,67,9,8,2,3,33,41,45,68,69,11,10,0,1,33,44,40,71,70,13,12,2,3,33,47,38,72,65,6,14,3,0,33,45,46,67,68,10,9,3,0,33,36,44,70,73,15,13,3,0,33,39,43,64,74,16,7,1,2,33,42,41,69,66,8,11,1,2,33,40,37,75,71,12,17,1,2,33,38,39,74,72,14,16,2,3,33,37,36,73,75,17,15,0,1,33,75,73,77,76,1,0,0,1,33,72,74,78,79,3,2,2,3,33,71,75,76,80,2,1,1,2,33,66,69,82,81,2,1,1,2,33,74,64,83,78,2,1,1,2,33,73,70,84,77,0,3,3,0,33,68,67,85,86,0,3,3,0,33,65,72,79,87,0,3,3,0,33,70,71,80,84,3,2,2,3,33,69,68,86,82,1,0,0,1,33,67,66,81,85,3,2,2,3,33,64,65,87,83,1,0,0,1,33,62,58,89,88,19,19,20,21,33,59,63,91,90,18,18,22,23,33,61,57,93,92,19,19,20,21,33,56,60,95,94,18,18,22,23,33,93,94,97,96,20,23,24,25,33,89,90,98,99,20,23,24,25,33,95,92,101,100,22,21,26,27,33,91,88,102,103,22,21,26,27,33,94,95,100,97,23,22,27,24,33,92,93,96,101,21,20,25,26,33,90,91,103,98,23,22,27,24,33,88,89,99,102,21,20,25,26,33,83,87,104,105,1,0,27,24,33,85,81,106,107,3,2,25,26,33,82,86,108,109,1,0,27,24,33,84,80,110,111,3,2,25,26,33,87,79,112,104,0,3,26,27,33,86,85,107,108,0,3,26,27,33,77,84,111,113,0,3,26,27,33,78,83,105,114,2,1,24,25,33,81,82,109,106,2,1,24,25,33,80,76,115,110,2,1,24,25,33,79,78,114,112,3,2,25,26,33,76,77,113,115,1,0,27,24,33,100,101,96,97,27,26,25,24,33,103,102,99,98,27,26,25,24,33,104,112,114,105,27,26,25,24,33,108,107,106,109,27,26,25,24,33,113,111,110,115,27,26,25,24,32,63,62,58,18,19,19,32,59,63,58,18,18,19,32,60,61,57,18,19,19,32,56,60,57,18,18,19]
}

Edit: I do only use the geometry of this file and later aply a material.

mrdoob commented 12 years ago

Could you also share the relevant code where you're loading this?

aphex- commented 12 years ago

I found the problem while I reduced my code to the relevant lines. I used the same instance of a THREE.JSONLoader for more files synchronously. This is obviously not the best idea. Thank you for respond again.

aphex- commented 12 years ago

OK.. same problem again (THREE.js r47).

json-file:

{

    "metadata" :
    {
        "formatVersion" : 3,
        "generatedBy"   : "Blender 2.60 Exporter",
        "vertices"      : 48,
        "faces"         : 43,
        "normals"       : 20,
        "colors"        : 0,
        "uvs"           : 0,
        "materials"     : 1,
        "morphTargets"  : 0
    },

    "scale" : 0.200000,

    "materials": [  {
        "DbgColor" : 15658734,
        "DbgIndex" : 0,
        "DbgName" : "Material.006",
        "colorAmbient" : [0.0, 0.0, 0.0],
        "colorDiffuse" : [0.6400000190734865, 0.6400000190734865, 0.6400000190734865],
        "colorSpecular" : [0.5, 0.5, 0.5],
        "mapDiffuse" : "palette.png",
        "mapDiffuseWrap" : ["repeat", "repeat"],
        "shading" : "Lambert",
        "specularCoef" : 50,
        "transparency" : 1.0,
        "vertexColors" : false
    }],

    "vertices": [1.000000,0.007309,-1.000000,1.000000,0.007310,1.000000,-1.000000,0.007310,1.000000,-1.000000,0.007309,-1.000000,1.000000,0.085013,-0.999999,0.999999,0.085013,1.000001,-1.000000,0.085013,1.000000,-1.000000,0.085013,-1.000000,1.000000,0.312176,-0.999999,-1.000000,0.312176,-1.000000,-1.000000,0.312176,1.000000,0.999999,0.312176,1.000001,1.000000,0.391582,-0.999999,0.999999,0.391582,1.000001,-1.000000,0.391582,1.000000,-1.000000,0.391582,-1.000000,0.600000,0.007310,1.000000,0.200000,0.007310,1.000000,-0.200000,0.007310,1.000000,-0.600000,0.007310,1.000000,0.600000,0.007309,-1.000000,0.200000,0.007309,-1.000000,-0.200000,0.007309,-1.000000,-0.600000,0.007309,-1.000000,0.599999,0.085013,1.000000,0.199999,0.085013,1.000000,-0.200001,0.085013,1.000000,-0.600000,0.085013,1.000000,0.600000,0.085013,-1.000000,0.200000,0.085013,-1.000000,-0.200000,0.085013,-1.000000,-0.600000,0.085013,-1.000000,0.600000,0.312176,-1.000000,0.200000,0.312176,-1.000000,-0.200000,0.312176,-1.000000,-0.600000,0.312176,-1.000000,-0.600000,0.312176,1.000000,-0.200001,0.312176,1.000000,0.199999,0.312176,1.000000,0.599999,0.312176,1.000000,0.599999,0.391582,1.000000,0.199999,0.391582,1.000000,-0.200001,0.391582,1.000000,-0.600000,0.391582,1.000000,0.600000,0.391582,-1.000000,0.200000,0.391582,-1.000000,-0.200000,0.391582,-1.000000,-0.600000,0.391582,-1.000000],

    "morphTargets": [],

    "normals": [0.707083,0.000000,-0.707083,0.707083,0.000000,0.707083,-0.707083,0.000000,0.707083,-0.707083,0.000000,-0.707083,0.577349,0.577349,-0.577349,0.577349,0.577349,0.577349,-0.577349,0.577349,0.577349,-0.577349,0.577349,-0.577349,-0.301492,0.301492,0.904508,0.000000,0.000000,1.000000,0.301492,0.301492,0.904508,0.000000,0.000000,-1.000000,-0.301492,0.301492,-0.904508,0.301492,0.301492,-0.904508,-0.316202,0.000000,-0.948668,0.316202,0.000000,-0.948668,0.316202,0.000000,0.948668,-0.316202,0.000000,0.948668,0.000000,0.707083,0.707083,0.000000,0.707083,-0.707083],

    "colors": [],

    "uvs": [[]],

    "faces": [35,0,4,5,1,0,0,0,1,1,35,2,6,7,3,0,2,2,3,3,35,7,6,10,9,0,3,2,2,3,35,5,4,8,11,0,1,0,0,1,35,11,8,12,13,0,1,0,4,5,35,9,10,14,15,0,3,2,6,7,35,5,24,16,1,0,1,8,9,1,35,24,25,17,16,0,8,10,9,9,35,25,26,18,17,0,10,8,9,9,35,26,27,19,18,0,8,10,9,9,35,27,6,2,19,0,10,2,2,9,35,0,20,28,4,0,0,11,12,0,35,20,21,29,28,0,11,11,13,12,35,21,22,30,29,0,11,11,12,13,35,22,23,31,30,0,11,11,13,12,35,23,3,7,31,0,11,3,3,13,35,4,28,32,8,0,0,12,14,0,35,29,30,34,33,0,13,12,14,15,35,31,7,9,35,0,13,3,3,15,35,6,27,36,10,0,2,10,16,2,35,26,25,38,37,0,8,10,16,17,35,24,5,11,39,0,8,1,1,17,35,10,36,43,14,0,2,16,18,6,35,36,37,42,43,0,16,17,18,18,35,37,38,41,42,0,17,16,18,18,35,38,39,40,41,0,16,17,18,18,35,39,11,13,40,0,17,1,5,18,35,8,32,44,12,0,0,14,19,4,35,32,33,45,44,0,14,15,19,19,35,33,34,46,45,0,15,14,19,19,35,34,35,47,46,0,14,15,19,19,35,35,9,15,47,0,15,3,7,19,35,12,44,40,13,0,4,19,18,5,35,44,45,41,40,0,19,19,18,18,35,45,46,42,41,0,19,19,18,18,35,46,47,43,42,0,19,19,18,18,35,47,15,14,43,0,19,7,6,18,35,26,30,31,27,0,8,12,13,10,35,27,31,35,36,0,10,13,15,16,35,26,37,34,30,0,8,17,14,12,35,25,29,33,38,0,10,13,15,16,35,24,28,29,25,0,8,12,13,10,35,24,39,32,28,0,8,17,14,12]
}
        var jsonLoader = new THREE.JSONLoader(true);
        jsonLoader.load("Models/palette.json", function(geo){
            var mesh = new THREE.Mesh( geo, new THREE.MeshFaceMaterial());
            scene.add(mesh);
        } );

Using THREE.MeshFaceMaterial() or any other Material with a texure does not work. Materials without textures are working. The file "palette.png" is in the same directory like the json-file (256x256px). Any ideas? :)

alteredq commented 12 years ago

You don't have texture coordinates in your model. You need to create real UVs in Blender, not just use its procedurally generated coordinates.

aphex- commented 12 years ago

And this worked... thank you :)