Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

455
Visualizações
GL ERROR :GL_INVALID_OPERATION : glDrawArrays: attempt to access out of range vertices in attribute 1, three.js

This has had me beat for a while now. I'm making a game, and the main map is a model using the obj format. I load it like this:

var objLoader = new THREE.OBJLoader();
objLoader.setPath('Assets/');

objLoader.load('prison.obj', function(prison){
    prison.rotation.x = Math.PI / 2;
    prison.position.z += 0.1;
    prison.scale.set(15, 15, 15)
    scene.add(prison);
});

So when I was loading the same model, but smaller, it worked normally. But, now I have added more to the model, and it is much bigger. WebGL starts giving me this warning: [.WebGL-0x7fb8de02fe00]GL ERROR :GL_INVALID_OPERATION : glDrawArrays: attempt to access out of range vertices in attribute 1. This warning happens 256 times before WebGL says WebGL: too many errors, no more errors will be reported to the console for this context.

Warnings in console

And with this warning, my model doesn't load completely. In Preview, I see the model as this, as expected:

Correct Model

But in Three.js, I see something different:

Incorrect Model in Three.js

Well, I'm not exactly sure what's wrong here:

  1. Maybe because I'm using OBJLoader CDN
  2. Maybe my model size is too large
  3. Maybe I have no idea what I'm doing

Any help is appreciated, thanks. Let me know if you need more detail.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This error is telling you that your geometry attributes count don't match up. For example, your geometry could have:

  • 100 vertex positions
  • 99 vertex normals
  • 99 vertex UVs

... or something of that nature. When looking up info on that 100th vertex, it says "attempt to access out-of-range vertices"

Ideally, you'd want to re-export the OBJ asset so you don't have to manually find the geometry that's causing the problem. However, in case you cannot get a new OBJ, you could either:

  • prevent the problem geometry from rendering with mesh.visibility = false
  • Fix the geometry attribute count. To fix it, you'll have to find which attribute is short:
// We assume you already found the mesh with the problem.
const problemGeometry = mesh.geometry;

// Now we dig through the console to see each attribute.
// Look up each attribute.count property to see which one is short. 
console.log(problemGeometry.attributes);

// Then you'll have to set the draw range to the lowest of these counts
// Here I assume the lowest is 99
problemGeometry.setDrawRange(0, 99);

Don't forget to also look at the geometry.index attribute, if your geometry has it. That should fix your geometry to render with the lowest common number of attributes. See here for info on setDrawRange

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda