{"size": 1985, "ext": "js", "max_stars_repo_path": "server/dve/Propagation/Illumanation/IlluminationManager.js", "max_stars_repo_name": "codingwatching/DivineVoxelEngine", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server/dve/Propagation/Illumanation/IlluminationManager.js", "max_issues_repo_name": "codingwatching/DivineVoxelEngine", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server/dve/Propagation/Illumanation/IlluminationManager.js", "max_forks_repo_name": "codingwatching/DivineVoxelEngine", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 40.5102040816, "max_line_length": 123, "alphanum_fraction": 0.6206549118}
//objects
import { Util } from "../../Global/Util.helper.js";
//functions
import { runRGBFloodFillAt, runRGBFloodRemove, runRGBFloodRemoveAt, runRGBFloodFill, } from "./Functions/RGBFloodLight.js";
import { runSunLightRemove, runSunLightRemoveAt, runSunLightUpdate, runSunLightUpdateAt, } from "./Functions/SunLight.js";
export const IlluminationManager = {
    lightByte: Util.getLightByte(),
    voxelByte: Util.getVoxelByte(),
    _3dArray: Util.getFlat3DArray(),
    air: [-1, 0],
    runSunLightUpdateAt: runSunLightUpdateAt,
    runSunLightUpdate: runSunLightUpdate,
    runSunLightRemove: runSunLightRemove,
    runSunLightRemoveAt: runSunLightRemoveAt,
    runRGBFloodFillAt: runRGBFloodFillAt,
    runRGBFloodFill: runRGBFloodFill,
    runRGBFloodRemoveAt: runRGBFloodRemoveAt,
    runRGBFloodRemove: runRGBFloodRemove,
    _RGBlightUpdateQue: [],
    _RGBlightRemovalQue: [],
    _sunLightUpdateQue: [],
    _sunLightRemoveQue: [],
    addChunkToSunLightUpdate(chunk, chunkX, chunkY, chunkZ) {
        const heightMap = chunk.heightMap;
        const voxels = chunk.voxels;
        for (let x = 0; x < 16; x++) {
            for (let z = 0; z < 16; z++) {
                this._sunLightUpdateQue.push([chunkX + x, chunkY + 127, chunkZ + z]);
            }
        }
    },
    populateChunkAirWithInitlSunLight(chunk) {
        const heightMap = chunk.heightMap;
        const voxels = chunk.voxels;
        for (let x = 0; x < 16; x++) {
            for (let z = 0; z < 16; z++) {
                const y = heightMap[x][z];
                const voxel = this._3dArray.getValue(x, y, z, voxels);
                const voxelId = this.voxelByte.getId(voxel);
                if (voxelId == 0) {
                    const nl = this.lightByte.getFullSunLight(voxel);
                    const newVoxel = this.voxelByte.encodeLightIntoVoxelData(voxel, nl);
                    this._3dArray.setValue(x, y, z, voxels, newVoxel);
                }
            }
        }
    },
};
