import * as THREE from 'three'

export const loadExrBackground = async (game, path) => {
    let exrFilePromise = new Promise((success, fail) => {
        game.exrLoader.load(path, (data, texData) => {
            success(data, texData)
        })
    })
    let environmentMap = await exrFilePromise
    environmentMap.mapping = THREE.EquirectangularReflectionMapping
    game.scene.background = environmentMap
    game.scene.environment = environmentMap
}

export const loadRgbeBackground = async (game, path) => {
    let rgbeFilePromise = new Promise((success, fail) => {
        game.rgbeLoader.load(path, (data, texData) => {
            success(data, texData)
        })
    })
    let environmentMap = await rgbeFilePromise
    environmentMap.mapping = THREE.EquirectangularReflectionMapping
    game.scene.background = environmentMap
    game.scene.environment = environmentMap
}