import { v4 as uuid } from "uuid";
import assert from 'assert';

export default class SkyBox {
    constructor(map) {
        this.map = map;
    }

    init(options) {
        this.options = options;
        assert(options.textures.length >= 6, '请上传6张天空盒贴图！')
        let textureIDs = [];
        for (const texture of options.textures) {
            const id = `skyTexture_${uuid()}`;
            this.map.addImage(id, texture);
            textureIDs.push(id);
        }

        this.map.addLayer({
            id: "sky",
            type: "sky",
            paint: {
                "sky-type": "texture",
                "sky-map": textureIDs,
                "sky-gradient-center": [0, 0],
            },
        });
    }
}
