feat: Ensure stone layer chunks always render and remain visible
This commit is contained in:
parent
883c3d9a08
commit
d87105baad
@ -78,6 +78,15 @@ function simulationLoop(timestamp) {
|
|||||||
// Update physics with timestamp for rate limiting
|
// Update physics with timestamp for rate limiting
|
||||||
updatePhysics(timestamp);
|
updatePhysics(timestamp);
|
||||||
|
|
||||||
|
// Force stone layer chunks to be rendered every frame
|
||||||
|
const visibleChunks = getVisibleChunks();
|
||||||
|
for (const { chunkX, chunkY, isVisible } of visibleChunks) {
|
||||||
|
if (isVisible && chunkY === 1) {
|
||||||
|
// Mark stone layer chunks as dirty to ensure they're always rendered
|
||||||
|
dirtyChunks.add(getChunkKey(chunkX, chunkY));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Render
|
// Render
|
||||||
render();
|
render();
|
||||||
|
|
||||||
|
@ -13,8 +13,9 @@ function render() {
|
|||||||
|
|
||||||
const key = getChunkKey(chunkX, chunkY);
|
const key = getChunkKey(chunkX, chunkY);
|
||||||
|
|
||||||
// Skip rendering if the chunk hasn't changed and isn't marked as dirty
|
// Always render stone layer (chunkY = 1) chunks, even if they're not dirty
|
||||||
if (!dirtyChunks.has(key) && !worldMoved) {
|
// For other chunks, only render if they're dirty or the world moved
|
||||||
|
if (chunkY !== 1 && !dirtyChunks.has(key) && !worldMoved) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,9 +527,14 @@ function generateChunksAroundPlayer() {
|
|||||||
const chunkY = 1; // The chunk at y = 1 (moved from y = -1)
|
const chunkY = 1; // The chunk at y = 1 (moved from y = -1)
|
||||||
const key = getChunkKey(chunkX, chunkY);
|
const key = getChunkKey(chunkX, chunkY);
|
||||||
|
|
||||||
// Always generate and mark as dirty to ensure rendering
|
// Always generate stone layer chunks
|
||||||
getOrCreateChunk(chunkX, chunkY);
|
getOrCreateChunk(chunkX, chunkY);
|
||||||
dirtyChunks.add(key);
|
|
||||||
|
// Mark as dirty only if it's a new chunk or if it's visible
|
||||||
|
if (!chunks.has(key) || visibleChunks.some(chunk =>
|
||||||
|
chunk.chunkX === chunkX && chunk.chunkY === chunkY && chunk.isVisible)) {
|
||||||
|
dirtyChunks.add(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate visible chunks first
|
// Generate visible chunks first
|
||||||
|
Loading…
x
Reference in New Issue
Block a user