bevy_tilemap
bevy_tilemap copied to clipboard
Handle zoom?
What problem does this solve or what need does it fill?
It'd be very nice for tilemap to handle (arbitrary, smooth) map zoom in addition to panning.
Describe the solution would you like?
As I see in the examples, panning is accomplished by manipulating the 2d camera translation directly. It happens that zoom in 2d works by scaling everything rather than moving the camera. It would be nice (but not essential) for this to all be accomplished in one interface.
(Super awesome bonus: smooth pan/zoom where you give target values and a system updates them over a number of frames.)
Describe the alternative(s) you've considered?
Coding it all myself rather than working on my actual game stuff. :)
Also, related #95 — the "what was clicked" code could/should be zoom aware.
Bevy's main
branch now has a scale
property on OrthographicProjection
so you can zoom in using the camera.
I believe that should solve both problems.
Awesome, yeah, I was certain it was related to Bevy itself, not the Tilemap. Can only do as much as the base lib can do. Thanks for the heads up @Devil-Ira
@joshuajbouw Just checking that the rendering / chunking functions don't make assumptions based on camera zoom. If that is all handled, then cool. :)
Hm, that I would need to double check.
I attempted to use the OrthographicPorjection
's scale property to zoom in/out, but you get weird lines. Example:
Its possibly related to having precision errors, or some sort of filtering issue. Camera code found here: https://github.com/StarArawn/bevy_roguelike_prototype/blob/main/src/game/camera/input.rs
Using the following code helps a little bit however I still get lines:
let atlas_texture = textures.get_mut(tilemap_atlas_handle.clone()).unwrap();
atlas_texture.sampler.min_filter = bevy::render::texture::FilterMode::Nearest;
I have a PR open that fixes the line issue: https://github.com/joshuajbouw/bevy_tilemap/pull/153