Readonlystepshow many whole-angle positions a full turn has: 4 for a square grid, 6 for a hex one
Readonlyworldput the map and everything in it here
centre of the view, in world units
the view's rotation, in radians, positive turning the world counter-clockwise
the rotation step this view is turned to, always in 0 .. stepsPerTurn - 1
The angle that cancels rotation: draw a label, health bar or damage number into world
with this and it stays upright however the view is turned. A half turn would otherwise put
every label upside down.
The visible region, in world units, as an axis-aligned box: use it to cull.
With the view turned, the visible region is the viewport rectangle rotated in world space, so this is the box around its four corners instead of the rectangle itself - over-inclusive rather than clipping tiles that are actually on screen. Unturned, it is the rectangle, at its exact numbers.
Eases the view towards an arbitrary angle, taking whichever way around the turn is
shorter - so animating from a hex view's fifth step back to its first sweeps the one
60-degree gap between them rather than the long way around. intensity behaves like
follow's: the remaining angle closes by that fraction each second.
eases towards something that keeps moving, such as the player
eases towards a fixed point
turns the view by whole steps; rotate(1) is the next position, rotate(-1) the last
Turns the view to an arbitrary angle immediately, no animation - free rotation, not
confined to a grid's whole steps. rotationSteps is left as it was: it names where
setRotationStep/rotate last put the view, not this angle, so the two APIs are best
used one at a time rather than interleaved.
stops the camera leaving the map; pass null to allow it again
turns the view to a whole step, wrapping around a full turn
The framework calls this on resize; sizes are in screen pixels. screenX/screenY
default to 0 (an ordinary camera starting at the corner of the canvas); a Viewport
gives its camera a nonzero one so this camera's own rectangle starts partway across
the screen instead, for a split-screen layout.
world units
seconds
shake, taking intensity in screen pixels rather than world units.
shake's own magnitude is world units because the offset it produces feeds
clampedCentre alongside every other world-space camera field; a caller thinking in
screen pixels (a convention several game engines use for this exact call) otherwise
has to divide by zoom at every call site itself. This does that division once, so
the shake still reads as intensity pixels on screen at whatever zoom is current when
it starts, matching what a caller asked for rather than what world-space asked for.
jumps to a point with no easing, for a teleport or a scene change
world point to screen pixels, through the current rotation
screen pixels to world point, for turning a click into a tile; the inverse of toScreen
Example