Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

277
Vistas
How can I change the scene background color on scroll in Three JS?

I am trying to make a website where you have a background color at the start, and when I scroll to a certain part it eases into another color. I can do it to the point that it changes on scroll, but it changes right away and isn't locked to the scroll position, so it stays that way.

This is my original color:

scene.background = new THREE.Color(0x007ca9);

I want it to change when it reaches div page-2.

<body>
  <canvas id="bg"></canvas>
  <main>
    <div class="page-1" data-color="blue">
      <ul>
        <img class="logo" src="logo.png">
        <h1>whatever</h1>
      </ul>
    </div>
    <div class="page-2" data-color="grey">
      <h1>whatever</h1>
    </div>

  </main>

</body>

And here is the onscroll function I'm currently using, which doesn't get the job done obviously.

function changeColor() {
  scene.background = new THREE.Color(0x24252a)
}

document.body.onscroll = changeColor;

I'm somewhat of a beginner so any help that is as simple as possible would be much appreciated.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda