Skip to content

Instantly share code, notes, and snippets.

@JacobMuchow
Forked from dosterz97/AvatarView.js
Created June 27, 2022 20:26
Show Gist options
  • Save JacobMuchow/48cd2b1f0e0e519c4568f395ca697665 to your computer and use it in GitHub Desktop.
Save JacobMuchow/48cd2b1f0e0e519c4568f395ca697665 to your computer and use it in GitHub Desktop.
Add a loader function to help us get the file added to our environment.
import { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader.js'
loadBackground(url, renderer) {
return new Promise((resolve) => {
const loader = new RGBELoader()
const generator = new THREE.PMREMGenerator(renderer)
loader.load(url, (texture) => {
const envMap = generator.fromEquirectangular(texture).texture
generator.dispose()
texture.dispose()
resolve(envMap)
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment