Hi everyone.
I know there is a lot of resource with a lot of answers about this question, but there is something that i still don’t understand.
I am creating a 2D tile system. It’s a grid (x,y) and the resolution is defined by the level. Like google map for example or any tile system. Level is here to choose the resolution.
So, I have a scene, an orthographic camera, and one geometry (it’s a quad mesh) that i move to (0,0) to display the first tile, then to (512,0) for the second tile and so on. (My tiles are 512*512 pixels)
Everything works great ! And i can convert pixel to world coordinate and world coordinate easily (by normalizing between -1 and 1 and then unproject the vector to the camera)
But now, if i want to initialize my world (in world coordinate) with zoom = 2.
I do :
camera.zoom = 2
camera.position.set(worldX, worldY)
and i update the camera matrix.
The problem is this only works well if camera.zoom = 1. So, i need to compute the worldX, worldY which will work if my camera is at zoom = 2
And, for some reason, i also need to scale my whole scene, and apply transformations like shear.
If i do. that, when i compute pixel to worldCoordinate, it doesnt works at all
Is there something i am missing ?
I hope my message is understandable. If not, i will make some illustration about my problem
Thank you for your help.