Render negative-Y sections on 1.18+ worlds - #485
Closed
u9g wants to merge 1 commit into
Closed
Conversation
Sections below y=0 were never meshed: worldrenderer's dirty-section loops hardcoded the pre-1.18 0..256 range, and the worker's section-presence guard indexed chunk.sections by y/16 even though ChunkColumn indexes sections from minY (-64 since 1.18), so negative sections resolved to undefined and were skipped. Any camera below y=0 saw only the clear color. Derive minY/worldHeight from the version's chunk implementation, index worker sections by (y - minY) / 16, and gate models.js face culling on world.minY instead of 0.
u9g
added a commit
to u9g/prismarine-viewer
that referenced
this pull request
Sep 6, 2026
A camera below y=0 renders nothing but the clear color: a bot standing on the surface of any 1.18+ world (surface ~y=-60 in the overworld's lower range, or anywhere in a deepslate cave) shows a uniform sky-blue frame with the surrounding chunks fully loaded. Three spots hardcode the pre-1.18 world range [0, 256): - worldrenderer.js dirty-section loops in addColumn/removeColumn iterate y=0..240, so sections below y=0 are never queued for meshing - worker.js indexes chunk.sections[floor(y/16)], but 1.18+ ChunkColumn indexes from minY (-64): sections[(y - minY) >> 4]; y<0 resolves to sections[-1] = undefined and the section is skipped - models.js culls faces against a hardcoded y<0 instead of the world's minY Derive minY/worldHeight from the version's chunk implementation (defaults 0/256, so pre-1.18 is unchanged), iterate the real range, index worker sections by (y - minY)/16, and gate models.js culling on world.minY. Revives PrismarineJS#485 (closed); no longer stacked on the 26.1 PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #484 — merge that first, after which this PR's diff collapses to just the last commit.
Problem
Any camera below y=0 renders nothing but the clear color — e.g. a mineflayer bot standing in a deepslate cave shows a uniform sky-blue frame, even with the surrounding chunks fully loaded.
Cause
worldrenderer.jshardcodes the pre-1.18 world range: the dirty-section loops inaddColumn/removeColumniteratey = 0..240, so sections below y=0 are never queued for meshing.worker.js's section-presence guard indexeschunk.sections[Math.floor(y / 16)], butChunkColumn(1.18+) indexes sections fromminY(-64):sections[(pos.y - this.minY) >> 4]. For y < 16 sections this resolves to the wrong index, and for y < 0 tosections[-1]= undefined, so those sections are skipped. (Above ground it is accidentally harmless — sections are dense and geometry is read via absolute coordinates — but the guard checks the wrong slot.)models.jsculls faces against a hardcodedy < 0instead of the world'sminY.Fix
minY/worldHeightfrom the version's chunk implementation insetVersion(defaults0/256, so pre-1.18 behavior is unchanged) and iterate the real range inaddColumn/removeColumn.(y - (chunk.minY ?? 0)) / 16.minYon the worker'sWorldwrapper and gatemodels.jsface culling onworld.minY ?? 0.Verification
setVersion('26.1')→{ minY: -64, worldHeight: 384 };1.16.5/1.12.2→{ 0, 256 }(new Chunk()constructs fine on old versions)World.addColumn(fromJson): the y=-16 section resolves and the block reads back throughworld.getBlockaddColumnon 26.1 now queues 20 negative-Y section jobs per column (previously 0)