loadbackground.js 888 B

12345678910111213141516171819202122232425
  1. import * as THREE from 'three'
  2. export const loadExrBackground = async (game, path) => {
  3. let exrFilePromise = new Promise((success, fail) => {
  4. game.exrLoader.load(path, (data, texData) => {
  5. success(data, texData)
  6. })
  7. })
  8. let environmentMap = await exrFilePromise
  9. environmentMap.mapping = THREE.EquirectangularReflectionMapping
  10. game.scene.background = environmentMap
  11. game.scene.environment = environmentMap
  12. }
  13. export const loadRgbeBackground = async (game, path) => {
  14. let rgbeFilePromise = new Promise((success, fail) => {
  15. game.rgbeLoader.load(path, (data, texData) => {
  16. success(data, texData)
  17. })
  18. })
  19. let environmentMap = await rgbeFilePromise
  20. environmentMap.mapping = THREE.EquirectangularReflectionMapping
  21. game.scene.background = environmentMap
  22. game.scene.environment = environmentMap
  23. }