IsometricEngine
Core isometric rendering engine. Platform-agnostic — outputs PreparedScene that can be rendered by any platform.
This class is a thin facade that delegates to focused collaborators:
SceneGraph — mutable scene state accumulation
IsometricProjection — 3D-to-2D projection, lighting, culling
DepthSorter — intersection-based depth sorting with broad-phase acceleration
HitTester — hit testing with point-in-polygon and touch radius
Coordinate System
The engine uses a standard isometric projection with configurable angle (default 30°) and scale (default 70 pixels per unit).
z (up)
|
|
/ \
/ \
y x
(left-down) (right-down)x-axis: points right-and-down on screen
y-axis: points left-and-down on screen
z-axis: points straight up on screen
Projection formulas
The 3D-to-2D projection is:
screenX = originX + x * scale * cos(angle) + y * scale * cos(PI - angle)
screenY = originY - x * scale * sin(angle) - y * scale * sin(PI - angle) - z * scaleDepth sorting
Faces are sorted back-to-front using Point.depth: x + y - 2 * z. Higher depth values are farther from the viewer and drawn first.
Constructors
Properties
Monotonically increasing version counter, incremented whenever mutable engine parameters (angle, scale) change. Signals caches that projected output may be stale. Volatile to ensure visibility when read by the renderer on a different thread (e.g. Canvas draw vs main-thread mutation).
Functions
Finds the RenderCommand at the given screen coordinates in the prepared scene.
Projects the 3D scene to 2D screen space for the given viewport size.
Returns the TileCoordinate of the tile at the given screen position on the specified z-plane.
Project a 3D world point to 2D screen coordinates.