import VectorType from '../enum/VectorType.js'
import BgImage from '../Geometry/BgImage.js'
import { mathUtil } from '../MathUtil.js'
import { floorplanService } from './FloorplanService'
import Constant from '../Constant'

export default class BgImageService {
    constructor() { 
    }

    async createBgImage(url,center,vectorId) {
        const bgImage = new BgImage(url, center,vectorId)
        if(bgImage.url){
            const imageData = await floorplanService.loadImageData(bgImage.url)
            bgImage.setImageData(imageData)
        }

        floorplanService.addBgImage(bgImage)
        return bgImage
    }

    deleteBgImage() {
        floorplanService.deleteBgImage()
    }

    setBgImageInfo(bgImageInfo) {
        let bgImage = floorplanService.getBgImage(bgImageInfo.vectorId)
        bgImage.vectorId = bgImageInfo.vectorId
        bgImage.url = bgImageInfo.url
        bgImage.scale = bgImageInfo.scale
        bgImage.center = JSON.parse(JSON.stringify(bgImageInfo.center))
    }
}

const bgImageService = new BgImageService()
export { bgImageService }