Error in material mapping: glDrawElements is trying to access vertices that are out of range in attribute 2

I have developed an algorithm that allows users to input data or a function and then generates a graphical representation of the function. It essentially creates a surface map, similar to the one you can see here. The graphing functionality is working well, but I want to enhance it by adding black lines connecting points, just like in the example. However, I keep encountering the GL_INVALID_OPERATION error: glDrawElements: attempt to access out-of-range vertices in attribute 2. This error indicates that I am trying to draw something beyond the buffer range, but I'm struggling to pinpoint the issue. I have verified that the variables used for the x and y lengths provided for mapping align with the number of x and y indices. For instance, I set the repeat value to 76 for both x and y for a mesh containing 76 x entries and 76 y entries, totaling 5776 points.

The example utilizes a parametric geometry, whereas I need to use a standard THREE.Geometry because my system sometimes accepts data rather than just functions. Despite following the example closely, I continue to face the error. Perhaps I am misunderstanding the necessary mapping numbers for the texture repeat. My understanding is that they should reflect the number of X and Y points, but there may be other considerations at play.

Below is the method where I define 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(); }
}

While I am confident in the correctness of the surface geometry, it appears that there is a discrepancy in the number of elements I have compared to the repeat values. Additionally, any insights on what attribute 2 represents would be greatly appreciated.

Thank you

Answer №1

Ensure that your geometry includes UV coordinates. If they are not defined, the absence of UVs may be the reason for the error message you are seeing.

A mesh cannot have a texture applied unless the geometry contains UVs.

In THREE.Geometry, UVs can be set using the faceVertexUVs property.

In THREE.BufferGeometry, UVs are specified through a geometry attribute.

Version three.js r.71

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Determine the exact location of a click within an SVG element

This block of HTML includes SVG elements: <div class="container"> <div class="spacer"></div> <svg> <g id="polygonGroup" transform="translate(80, 50)"> <polygon points="-60,-10 -35,-30 -10,-10 -10,30 -60,30"&g ...

Is there a way for me to detect if the user has manipulated the CSS or JavaScript in order to alter the look of my website?

Is there a way to determine if someone is utilizing script or CSS extension tools? For instance, if they have adjusted alignments, applied display: none; to multiple elements, or utilized jQuery's .hasClass to manipulate divs. ...

Is it possible to execute a specified quantity of Promises simultaneously in Nodejs?

Currently, I am working on developing a web scraping application that utilizes a REST API to gather information from multiple entities on the server. The core functionality of this application can be summarized as follows: let buffer = [] for(entity in ent ...

hashSync function needs both data and salt to generate the hash

I can't figure out why I am encountering this issue, I have checked the documentation and couldn't find my mistake. Any suggestions? Error: data and salt arguments required const {create} = require('./user.service'); const {genSaltS ...

IE compatibility with CSS2 selectors

Is there a plugin, preferably jQuery, that can enable the use of CSS2 selectors like 'parent > child' and 'element:first-child' in my stylesheet for IE6, which doesn't seem to support them natively? ...

Leveraging nested objects within React state

A React child cannot be an object. If you intended to render a collection of children, utilize an array Encountering the error mentioned above has left me puzzled regarding its restrictions. Below is the code where I am facing this issue. It includes an o ...

Tips for minimizing database queries for each data type

I'm currently developing an App that requires the user to input numbers into two different fields. The first field is for entering numbers, while the second field displays a calculation based on the input. Each time the user enters a number, a call to ...

Angular 7 features a table with multiple timers indicating the remaining time until expiration

I have a table with multiple rows where I need to display a timer showing the remaining time in days, hours, minutes, and seconds. After researching how to calculate the remaining time using this link, I found a solution that works well. I am calling the ...

Enforcing object keys in Typescript based on object values

I'm looking to design a structure where the keys of an object are based on values from other parts of the object. For example: type AreaChartData = { xAxis: string; yAxis: string; data: { [Key in AreaChartData['xAxis'] | AreaChart ...

Learn how to execute shell commands on a Linux server from a Node.js application by utilizing Socket.io for establishing a connection. This includes tasks such as running "ls -ltr", changing

After successfully establishing a connection with my Linux server, I aim to execute shell commands for automation purposes such as changing directories and creating new folders. The main objective is to connect to the Linux server through a webpage, wher ...

Empower your presentations with slick cloning technology

I am facing an issue with my slider that I cannot seem to resolve. Currently, I am using slick to display 3 slides, but only the center one shows all the content. To achieve a continuous infinite slider effect where all slides appear in the center, I need ...

Icons are failing to display in the dropdown menu of MUI after an option is selected in ReactJS

There seems to be an issue with the icon in the select tag. Initially, it is not showing which is correct. However, when you click the dropdown, the icon appears as expected. But after selecting an option, if you click the dropdown again, the icon disapp ...

Loading the Facebook JavaScript SDK asynchronously using React and Redux

I have a process that involves loading a JavaScript SDK, which looks like this: class Facebook{ constructor(){ window.fbAsyncInit = () => { FB.init({ appId : 'myappID', ...

Seems like ngAfterViewInit isn't functioning properly, could it be an error on my end

After implementing my ngAfterViewInit function, I noticed that it is not behaving as expected. I have a hunch that something important may be missing in my code. ngOnInit() { this.dataService.getUsers().subscribe((users) => {this.users = users) ; ...

Is it normal for the protractor cucumber tests to pass without observing any browser interactions taking place?

Having recently started using protractor cucumber, I have created the following feature. Upon launching protractor protractor.conf.js, the browser opens and immediately closes, displaying that my tests have passed. Is this the expected testing behavior? Sh ...

The object tag does not function properly for video fallbacks when using the appendChild method

My video player application utilizes a modified version of video For everybody. The setup involves an HTML5 <video> tag encompassing an <object> tag for flash fallback on Internet Explorer. Everything functions smoothly when I employ this setup ...

Combining JSON objects in Node.js

I am extracting data from my database and converting it to JSON format. However, I now want to merge all the JSON data into a single JSON object. I have attempted various methods, but due to my limited knowledge of JavaScript syntax, I have not been able ...

I must only assign the result to "value" if the condition of the map is true

I am looking to set the variable "value" to only contain the value that meets the condition in the map function const arr= [1,2,3,4,5]; value = arr.map(item => item > 4 && item) console.log(value); The resulting value is currently [false, false, fa ...

Using Vue.js to submit a form in Laravel and redirecting with a flash message

I am facing an issue where I have two components named Index and Create, loaded from separate blade files. The challenge is passing a flash message as a prop between these components due to their file separation. How can I redirect after submitting a form ...

Is searching for duplicate entries in an array using a specific key?

Below is an array structure: [ { "Date": "2020-07", "data": [ { "id": "35ebd073-600c-4be4-a750-41c4be5ed24a", "Date": "2020-07-03T00:00:00.000Z", ...