import { DataTexture, UnsignedByteType } from "three";

/**
 *
 * @param {ArrayLike<number>|number[]|Uint8Array} contents
 * @param {Signal} [cleanup_signal] can be called to dispose of the texture
 * @returns {DataTexture}
 */
export function makeOnePixelTexture(contents, cleanup_signal) {
    const t = new DataTexture(new Uint8Array(contents), 1, 1);

    t.generateMipmaps = false;
    t.needsUpdate = true;
    t.type = UnsignedByteType;

    if (cleanup_signal !== undefined) {
        cleanup_signal.addOne(t.dispose, t);
    }

    return t;
}