three-d icon indicating copy to clipboard operation
three-d copied to clipboard

Apply transformations to Space

Open pedrotrschneider opened this issue 3 years ago • 1 comments

Is there a way to apply transformations to the space, such as translation, rotation and zoom? For instance, I would like to make the origin of the world the center of the screen instead of the top-left corner. Other things I would like to achieve are rotating space around the origin and zoom in each axis separately. I understand this could be achieved in 3d by using cameras, but this seems a bit overkill for 2d applications, and I didn't manage to make it work either way. Is there currently a way to do that? I'm on version 0.12.2.

pedrotrschneider avatar Jul 29 '22 19:07 pedrotrschneider

Yes! 🚀 To set the world origin to the center of the screen, set the viewport to something like this:

Viewport {
    x: -width/2,
    y: -height/2,
    width,
    height,
}

I'm not sure I understand the second part, if you want to rotate in 3D space, then, in my mind, your application is not in 2D? Also, the 2D functionality is actually in 3D and also using a camera, so there is nothing wrong with that approach you are describing.

asny avatar Aug 01 '22 07:08 asny