I have an algorithm that lets users enter data or a function and then graphs the function. Essentially, its a surface map just like here. The graphing works fine. However, I want to add a mapping to add in black lines going from point to point just like in the example. However, I keep getting the standard error of : GL_INVALID_OPERATION : glDrawElements: attempt to access out of range vertices in attribute 2. I know that this error means that I am trying to draw something that is out of the range of the buffer, but I can't see where I am doing that. I have confirmed that the variables used for the x and y lengths given to the mapping are indeed the number of x and y indices. For example, I am setting the repeat to 76 and 76 for a mesh that has 76 x entries and 76 y entries and therefore 5776 points.
In the example, they use a parametric geometry and i have to use a standard THREE.Geometry since I am sometimes taking in data and not a function. Other than that, I have followed the example and still get the error. I may be confused about the mapping numbers required for the repeat on the texture. I believe that they are supposed to represent the number of X and Y points and maybe it is supposed to be something else.
Here is the method where I set my meshes:
Surface.prototype.setMeshes =function(DataID, callback)
{ var graphMesh={};
var PlotID=this.Format_id;
if (PlotID['Chart_dataobj'][DataID]['type']=="Surface")
{ if (PlotID['Chart_dataobj'][DataID]['sWireFrame']=="Solid")
{
var wireTexture = new THREE.ImageUtils.loadTexture( 'http://www.cadwolf.com/Images/square.png' );
wireTexture.wrapS = wireTexture.wrapT = THREE.RepeatWrapping;
wireTexture.repeat.set( parseInt(PlotID['Chart_dataobj'][DataID].xLength), parseInt(PlotID['Chart_dataobj'][DataID].yLength) );
wireMaterial = new THREE.MeshBasicMaterial( { map: wireTexture, vertexColors: THREE.VertexColors, side:THREE.DoubleSide } );
wireMaterial.map.repeat.set( parseInt(PlotID['Chart_dataobj'][DataID].xLength), parseInt(PlotID['Chart_dataobj'][DataID].yLength) );
graphMesh = new THREE.Mesh( window[PlotID]['Chart_dataobj'][DataID].surfaceGeometry, wireMaterial );
graphMesh.doubleSided = true;
}
}
graphMesh.id = DataID;
graphMesh.name = DataID;
window[PlotID].Scene.add(graphMesh);
if (typeof(callback)=="function") { callback(); }
}
I know that everything is correct with the surface geometry, there is just an error with the number of elements I have matching the numbers for the repeat. Also, if anyone knows what attribute 2 is, that would be helpful.
Thanks