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

222
Visualizações
Three js hdr turns off but never back on

I'm trying to turn on and off a hdr map in three js.

This is how I create it

//HDRI LOADER
var envmaploader = new THREE.PMREMGenerator(renderer);
const loadhdri = new THREE.RGBELoader()
.load("myhdr.hdr", function (texture){
 texture.mapping = THREE.EquirectangularReflectionMapping;
scene.background = texture;
scene.environment = texture;

})

So far so good.

I then add it to the gui:

var gui = new dat.gui.GUI();
  var params = {switch: true}
  const lightsFolder = gui.addFolder('Customize lights')
  lightsFolder.add(params, "switch").name('hdrenv').onChange(updateHdr)

Finally, I try to specify the on/off logic, but when I read the console logs, it's always printing 'false'

function updateHdr() {
if (params2==true)
   {
   scene.environment = texture
   console.log("true")}
    else
   {scene.environment = null
   console.log ("else switch false")
   }
}
        

Note that the hdr loads correctly, turns off correctly when I click the switch button, but never turns on again.

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

Try to write your updateHdr function like so:

function updateHdr( value ) {

    if ( value === true ) {

        scene.environment = texture;
        console.log( 'true' );

    } else {

        scene.environment = null;
        console.log( 'else switch false' );

    }

}
about 4 years ago · Santiago Gelvez 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