Skip to content

Оптимизация #4

@EnterNameOfUser

Description

@EnterNameOfUser

function init_lighting() {

for (let i = 0; i < 500; i++) {
    const x = Math.floor(Math.random() * 32 * 16);
    const y = Math.floor(Math.random() * 32 * 16);
    const z = Math.floor(Math.random() * 32 * 16);
    chunks.set(x, y, z, 3);
    solverR.add(x, y, z, 15);
}

for (let i = 0; i < 10000000; i++) {
    const x = Math.floor(Math.random() * 32 * 16);
    const y = Math.floor(Math.random() * 32 * 16);
    const z = Math.floor(Math.random() * 32 * 16);
    if (chunks.get(x, y, z) === 0 && chunks.get(x, y - 1, z) === 1) {
        chunks.set(x, y, z, 4);
    }
}

for (let z = 0; z < chunks.h * CD; z++) {
    for (let x = 0; x < chunks.w * CW; x++) {
        for (let y = CH - 1; y >= 0; y--) {
            const voxel = chunks.get(x, y, z);
            if (!bricks[voxel].lightInside) {
                if (y + 1 < CH) {
                    solverS.add(x, y + 1, z, 15);
                }
                break;
            }
            solverS.add(x, y + 1, z, 15);
        }
    }
    solverS.solve();
    console.log('day-light: ', z, ' of ', chunks.h * CD, '(' + Math.ceil(z / (chunks.h * CD) * 100.0) + '%)');
}

solverR.solve();

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions