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

196
Visualizações
Is there a way to efficiently update a grid in Javascript

I'm creating a project site that is essentially a music visualizer. https://218studio.com/space_trip.php

Tutorial was taken from "The Coding Train" https://www.youtube.com/watch?v=IKB1hWWedMk

The problem that I'm running into is that the algorithm to compute the and update the grid in the draw() function is running in n squared time.

  for (var y = 0; y < rows - 1; y++) {
    beginShape(TRIANGLE_STRIP);
    var xoff = 0; 
    for (var x = y; x < cols - y; x++) {
      terrain[x][y] = map(noise(xoff, yoff), 0, 1, -100, 100);
      xoff += 0.2;
      vertex(x * scl, y * scl, terrain[x][y] * size);
      vertex(x * scl, (y + 1) * scl, terrain[x][y] * size);
    }
    yoff += 0.2; 
    endShape();

  }

The current site takes about 30% of my gpu's capacity to run smoothly. However, that is on a 2080ti with a 10700 processor. When demoing for my friend the grid lags his laptop so much the sound does not play properly.

Solutions that I've tried implementing locally are to reduce the grid density and to only render the squares visible on the computer screen, but that only reduces the gpu usage by about 4%.

about 4 years ago · Juan Pablo Isaza
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