Skip to content
This repository has been archived by the owner on May 7, 2022. It is now read-only.

Handle zoom? #141

Open
mattdm opened this issue Mar 14, 2021 · 8 comments
Open

Handle zoom? #141

mattdm opened this issue Mar 14, 2021 · 8 comments
Labels
enhancement New feature or request

Comments

@mattdm
Copy link

mattdm commented Mar 14, 2021

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. :)

@mattdm mattdm added the enhancement New feature or request label Mar 14, 2021
@mattdm
Copy link
Author

mattdm commented Mar 14, 2021

Also, related #95 — the "what was clicked" code could/should be zoom aware.

@tim-blackbird
Copy link

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.

@joshuajbouw
Copy link
Owner

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

@mattdm
Copy link
Author

mattdm commented Mar 20, 2021

@joshuajbouw Just checking that the rendering / chunking functions don't make assumptions based on camera zoom. If that is all handled, then cool. :)

@joshuajbouw
Copy link
Owner

Hm, that I would need to double check.

@joshuajbouw joshuajbouw reopened this Mar 21, 2021
@StarArawn
Copy link
Contributor

StarArawn commented Apr 10, 2021

I attempted to use the OrthographicPorjection's scale property to zoom in/out, but you get weird lines. Example:
island

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

@StarArawn
Copy link
Contributor

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;

island2

@StarArawn
Copy link
Contributor

I have a PR open that fixes the line issue:
#153

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants