troisjs / trois

✨ ThreeJS + VueJS 3 + ViteJS ⚡
https://troisjs.github.io
MIT License
4.23k stars 302 forks source link

Is There a way to add an HDRI image as sky for better light? #177

Open LUK3D opened 1 year ago

damonsong commented 1 year ago

I'm learning troisjs now and can't find the HDRI image API so far. I'm using the JS function to create the HDR env for the scene.

` function createHDRenvMap(scene, renderer, hdrFile) { const pmremGenerator = new PMREMGenerator(renderer) pmremGenerator.compileEquirectangularShader()

const rgbeLoader = new RGBELoader()

rgbeLoader.load(hdrFile, (texture) => {
    const envMap = pmremGenerator.fromEquirectangular(texture).texture
    pmremGenerator.dispose()

    scene.environment =  envMap
})
// return envMap

}

`

scene and renderer is the parameters, hdrFile is the entire path and file name.