import { Sampler2D } from "../../../../graphics/texture/sampler/Sampler2D.js";
import sampler2D2Canvas from "../../../../graphics/texture/sampler/sampler2d_to_html_canvas.js";
import { AssetRequestScope } from "../../../AssetRequestScope.js";
import { ArrayBufferLoader } from "../../ArrayBufferLoader.js";
import { PNGReader } from "./PNGReader.js";

const array_loader = new ArrayBufferLoader();


// const path = 'moicon/ISO 7010 - Safety Signs (3)/ISO 7010 - Safety Signs/Emergency/400px/E001 – Emergency exit (left hand).png';
// const path = 'data/textures/utility/vt/uv_map_reference/5-2-1.png';
// const path = 'data/textures/utility/vt/uv_map_reference/6-62-60.png';
// const path = 'data/textures/utility/vt/uv_map_reference/5-11-5.png';
// const path = 'data/textures/utility/vt/uv_map_reference/1-0-0.png';
// const path = 'data/textures/utility/vt/uv_map_reference/5-3-0.png';
// const path = 'data/textures/utility/vt/uv_map_reference/5-21-14.png';
const path = 'data/textures/utility/vt/uv_map_reference/6-39-33.png';

array_loader.load(new AssetRequestScope(), path, (asset) => {

    const array = asset.create();

    const reader = new PNGReader(array);

    const png = reader.parse();

    console.log(png);

    const uint8Data = png.getUint8Data();

    const sampler = new Sampler2D(uint8Data.data, uint8Data.itemSize, png.getWidth(), png.getHeight());

    const canvas = sampler2D2Canvas(sampler, 1, 0);

    document.body.appendChild(canvas);

});
