import { G as GetEnvInfo, U as UploadEnvSpherical, a as UploadEnvLevelsAsync } from './environmentTextureTools-Dymc7Tqj.js';
import './index-Bq2njFOY.js';
import './index-BeVTUo08.js';
import './dumpTools-OHI-SWuw.js';

/**
 * Implementation of the ENV Texture Loader.
 * @internal
 */
// eslint-disable-next-line @typescript-eslint/naming-convention
class _ENVTextureLoader {
    constructor() {
        /**
         * Defines whether the loader supports cascade loading the different faces.
         */
        this.supportCascades = false;
    }
    /**
     * Uploads the cube texture data to the WebGL texture. It has already been bound.
     * @param data contains the texture data
     * @param texture defines the BabylonJS internal texture
     * @param createPolynomials will be true if polynomials have been requested
     * @param onLoad defines the callback to trigger once the texture is ready
     * @param onError defines the callback to trigger in case of error
     */
    loadCubeData(data, texture, createPolynomials, onLoad, onError) {
        if (Array.isArray(data)) {
            return;
        }
        const info = GetEnvInfo(data);
        if (info) {
            texture.width = info.width;
            texture.height = info.width;
            try {
                UploadEnvSpherical(texture, info);
                // eslint-disable-next-line github/no-then
                UploadEnvLevelsAsync(texture, data, info).then(() => {
                    texture.isReady = true;
                    texture.onLoadedObservable.notifyObservers(texture);
                    texture.onLoadedObservable.clear();
                    if (onLoad) {
                        onLoad();
                    }
                }, (reason) => {
                    onError?.("Can not upload environment levels", reason);
                });
            }
            catch (e) {
                onError?.("Can not upload environment file", e);
            }
        }
        else if (onError) {
            onError("Can not parse the environment file", null);
        }
    }
    /**
     * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
     */
    loadData() {
        // eslint-disable-next-line no-throw-literal
        throw ".env not supported in 2d.";
    }
}

export { _ENVTextureLoader };
//# sourceMappingURL=envTextureLoader-CGOF2rGJ.js.map
