Repository navigation
Conversation
…loses BlueMap-Minecraft#328 Adds a webapp.conf setting "zoom-to-cursor" (default: true) to switch back to zooming towards the center of the screen. The zoom-buttons, keyboard-zoom and zooming while following a player still zoom towards the center.
…e mouse While the camera is rotated or tilted with the mouse (including the movement that continues after releasing the button), the mouse-wheel zoom goes towards the center of the screen.
Close up in the perspective view (below a distance of 500, where the target height follows the terrain), the point to zoom towards is now found at the height of the terrain under the cursor, instead of on the plane at the height of the camera-target. With the cursor on e.g. a mountain, that point was behind the mountain, so the zoom headed past it. The hires-tiles are ray-traced and the lowres-tiles are sampled along the ray, only when the zoom starts or the cursor moves.
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.
Summary
Closes #328.
Scroll-wheel zoom (including trackpad scroll) and pinch zoom keep the point under the cursor, or between the fingers, in place. This works for zooming in and out, in the 3D and flat views. Leaflet (OpenStreetMap, Dynmap), Mapbox GL and MapLibre all do this by default.
These still zoom to the centre: the +/- buttons, keyboard zoom, zooming while following a player, and wheel zoom while the camera is rotated or tilted with the mouse (right-drag, or Alt/Ctrl+left-drag).
Moving the target this way scales the camera around the point under the cursor without changing its orientation, so that point stays under the cursor.
New
webapp.confoption, following the same path asmin-zoom-distance:Set it to
falsefor the old centred zoom.Docs: BlueMap-Minecraft/BlueMapWiki#187
Changes after the feedback on Discord
The second and third commits answer the two points from Discord:
Map.raycastTerrain()raytraces the hires tiles.lowresTerrainHeightAt(), which is split out ofterrainHeightAt()unchanged.Evidence
Before: scrolling with the cursor on a landmark near a corner zooms toward the screen centre, so the landmark moves toward the edge and off screen.
After: the landmark stays under the cursor while zooming in and out.
Before (first commit): with the cursor on a mountain face, the zoom headed for the ground behind the mountain.
After: it heads for the mountain face.
Tested in a browser over several rounds on a server with existing 5.29 maps, using this branch's CLI build, side by side with the earlier builds:
zoom-to-cursor: false, which gives the old behaviourA numeric check with the real
CombinedCameraand the pose code fromControlsManager.updateCamera(): on flat terrain, the point under the cursor stays fixed (error < 1e-6 NDC) in perspective at several tilts and in the flat view.A frame-by-frame simulation with a mountain, using the real
MapHeightControls(terrain following and distance fade) andMap.raycastTerrain(). It covers far and close zooms, flat ground, near and on a mountain, and zooming out. The table shows the worst drift of the point under the cursor on screen (NDC; 2 = the full screen width):npm run build, eslint,spotlessCheckand:cli:releasepass.Merge Danger
Door: two-way
The change only touches the web app's map controls and
Map(one new method, plus one split out ofterrainHeightAt()), and adds one config option that defaults on. Reverting restores centred zoom.Blast Radius: small
zoom-to-cursor: falseto keep the old behaviour.I wrote this with help from an AI coding assistant. I reviewed and tested it myself.