Skip to content

Bug: updateNeighborsOfChunk reads chunk.isEmpty (undefined) instead of chunk._isEmpty #208

@tom288

Description

@tom288

In src/lib/world.js, updateNeighborsOfChunk reads chunk.isEmpty (no underscore):

var terrainChanged = (!chunk) || (chunk && !chunk.isEmpty)

But Chunk defines the property as _isEmpty (with underscore). chunk.isEmpty is always undefined, so !chunk.isEmpty is always true, making terrainChanged unconditionally true.

This means every empty chunk arrival marks all 26 neighbours as _terrainDirty, causing unnecessary re-meshing. For typical terrain where most chunks above ground are air, this creates a large amount of redundant meshing work during world loading.

Fix:

- var terrainChanged = (!chunk) || (chunk && !chunk.isEmpty)
+ var terrainChanged = (!chunk) || (chunk && !chunk._isEmpty)

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