import { ClampToEdgeWrapping, DataTexture3D, NearestFilter, RedIntegerFormat, UnsignedIntType } from "three";

/**
 * Uint32
 * @param {number} resolution
 * @returns {DataTexture3D}
 */
export function makeLookupTexture3D(resolution) {

    const lookup = new DataTexture3D(
        new Uint32Array(resolution * resolution * resolution),
        resolution,
        resolution,
        resolution
    );

    lookup.name = "Tetrahedron Lookup";

    lookup.flipY = false;
    lookup.generateMipmaps = false;
    lookup.magFilter = NearestFilter;
    lookup.minFilter = NearestFilter;

    lookup.wrapT = ClampToEdgeWrapping;
    lookup.wrapS = ClampToEdgeWrapping;
    lookup.wrapR = ClampToEdgeWrapping;

    lookup.type = UnsignedIntType;
    lookup.format = RedIntegerFormat;
    lookup.internalFormat = "R32UI";

    lookup.unpackAlignment = 4;

    lookup.needsUpdate = true;

    return lookup;
}