Repository navigation
feat: Use devicePixelRatio for level of detail computation in tile traversal - #513
Merged
Merged
Conversation
`dev-docs/README.md` clarifies the four-folder layout (top-level living docs, specs/, ideas/, plans/) and when to write what. `dev-docs/lod-and-pixel-matching.md` documents how tile LOD selection ties source raster pixels to screen pixels via ground meters, names the four threads that contribute to or are missing from the criterion (devicePixelRatio, camera distance/tilt, lat-varying source mpp, the unifying viewport-project alternative), and explains why per-tile LOD already varies by latitude today. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds an optional `pixelRatio` parameter to `getTileIndices` and `RasterTileNode.update()`, replaces the LOD comparison with the dimensionless `devicePixelsPerSourcePixel <= 1` form. Default pixelRatio=1 preserves existing CSS-pixel behavior; the layer wire-up in the next commit changes the user-visible default. Background: dev-docs/lod-and-pixel-matching.md § (A). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Threads the layer's effective device-pixel ratio (drawing-buffer / CSS size, computed manually since `cssToDeviceRatio()` is deprecated and `devicePixelRatio`/`getDevicePixelRatio()` ignore Deck's `useDevicePixels`) into `RasterTileset2D` as `getPixelRatio`. The LOD criterion now matches source pixels to *device* pixels rather than CSS pixels. Closes #64. Behavior change: on a 2× display the layer fetches ~4× more tiles per view (one finer overview level over the same area). This is correct under the device-pixel framing — the display can resolve that detail. See dev-docs/lod-and-pixel-matching.md § (A). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
devicePixelRatio for tile LOD selection (#64)
The implementation reads `drawingBufferWidth / cssWidth`, not luma's deprecated `cssToDeviceRatio()` and not the system DPR. Document this explicitly: list the cases where the drawing-buffer ratio diverges from `window.devicePixelRatio` (useDevicePixels: false, numeric override, explicit setDrawingBufferSize, maxDrawingBufferSize cap), and note that deck.gl's convention (which our variable names follow) uses "device pixel" colloquially to mean "rendered framebuffer pixel." Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
devicePixelRatio for tile LOD selection (#64)devicePixelRatio for level of detail computation in tile traversal
The `RasterTileset2DOptions.getPixelRatio` JSDoc described the layer as wiring this to the deprecated `cssToDeviceRatio()`. The actual implementation reads `drawingBufferWidth / cssWidth` per call, for the reasons documented in dev-docs/lod-and-pixel-matching.md § (A) (the luma deprecation conflated drawing-buffer ratio with system DPR). Update the docstring to match. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced May 7, 2026
Closed
kylebarron
added a commit
that referenced
this pull request
May 11, 2026
…525) * docs(specs): add traversal bounding-volume cache design Memoizes per-tile bounding volumes (proj4 reprojection + OBB construction) across getTileIndices calls on the RasterTileset2D, eliminating the per-animation-frame recomputation that #513's device-pixel LOD change exposed (#523). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * feat(raster-tileset): add BoundingVolumeCache (LRU, soft-capped) Standalone cache for tile bounding volumes keyed by "z/x/y", with LRU recency and a swept soft cap. Not wired into the traversal yet. Refs #523. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * feat(raster-tileset): thread BoundingVolumeCache through the traversal getBoundingVolume consults an optional BoundingVolumeCache (passed via the RasterTileNode ctor / createRootTiles / getTileIndices opts) before doing the proj4 reprojections + OBB fit. Omitting the cache preserves the previous per-node-only behavior. getTileIndices sweeps the cache once at the top of each traversal. Refs #523. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * feat(raster-tileset): RasterTileset2D memoizes tile bounding volumes Each RasterTileset2D now owns a BoundingVolumeCache and passes it into getTileIndices, so animation-frame traversals reuse the proj4 reprojections + OBB fit instead of recomputing them every frame. New RasterTileset2DOptions.maxBoundingVolumeCacheSize tunes the cap. Fixes the per-frame getTileIndices regression in #523. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * refactor(raster-tileset): make BoundingVolumeCache non-optional in traversal Per PR review: - The cache is a property of the traversal, not of a node — thread it through `update()`'s params (which already propagate down the recursion) instead of the `RasterTileNode` constructor / `children` getter / `createRootTiles`. - It always exists: `getTileIndices` uses a caller-supplied cache or a throwaway one. That lets `getBoundingVolume` drop its if/else and the now-redundant per-node `_boundingVolume` field (which never actually hit — `update` calls `getBoundingVolume` once per node). - Write `DEFAULT_MAX_ENTRIES` as `65_536`. Refs #523. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * refactor(raster-tileset): split getBoundingVolume / computeBoundingVolume Per PR review: getBoundingVolume is now just the cache wrapper (lookup -> hit? return : compute, store, return); the case dispatch (Globe assert, future mercator fast paths, generic Case 4) moves into a lower-level private computeBoundingVolume. Refs #523. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
4 of 6 tasks
3 tasks
4 tasks
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.
Closes #64
Summary
Deck.useDevicePixels.useDevicePixelsthat you pass toDecktileMetersPerPixel <= metersPerScreenPixelto a dimensionlessdevicePixelsPerSourcePixel <= 1. The pixel ratio is threaded throughgetTileIndices→RasterTileNode.update()and read lazily from the layer's drawing buffer (drawingBufferWidth / cssWidth) so window-drag-between-displays takes effect on the next traversal.dev-docs/lod-and-pixel-matching.mddocumenting the LOD criterion, why per-tile LOD already varies by latitude, and three named gaps that remain (camera distance/tilt, source-side latitude variation ShouldmetersPerUnit/scaleDenominatorbe scaled by the center latitude of each tile for degree-based CRSes? #89, and a sketch of a unifiedviewport.project-based criterion).dev-docs/README.mdclarifying the four-folder layout (top-level living docs,specs/,ideas/,plans/).Behavior change: on a 2× display, ~4× more tiles fetched per view (one finer overview level over the same area). Correct under the device-pixel framing — the display can resolve that detail.