import { Asset } from "../../Asset.js";
import { Sampler2D } from "../../../graphics/texture/sampler/Sampler2D.js";

export class ImageRGBADataAsset extends Asset {
    /**
     *
     * @param {number[]|Uint8Array} data
     * @param {number} width
     * @param {number} height
     * @param {number} [itemSize]
     */
    constructor(data, width, height, itemSize = 4) {
        super();

        /**
         *
         * @type {number[]}
         */
        this.data = data;

        /**
         *
         * @type {number}
         */
        this.width = width;

        /**
         *
         * @type {number}
         */
        this.height = height;

        /**
         * Number of channels
         * @type {number}
         */
        this.itemSize = itemSize;

        this.byteSize = data.length;
    }

    create() {
        return new Sampler2D(this.data, this.itemSize, this.width, this.height);
    }
}
