screenToTile

fun IsometricEngine.screenToTile(screenX: Double, screenY: Double, viewportWidth: Int, viewportHeight: Int, tileSize: Double = 1.0, elevation: Double = 0.0, originOffset: Point = Point.ORIGIN): TileCoordinate

Returns the TileCoordinate of the tile at the given screen position on the specified z-plane.

Chains screenToWorld with toTileCoordinate. The elevation parameter specifies which horizontal z-plane to intersect during inverse projection — for flat tile grids this should be 0.0 (the default). For elevated terrain, pass the surface height of the expected tile layer.

For complex terrain where elevation varies per tile, use screenToWorld directly and call toTileCoordinate with the appropriate elevation after determining the layer through other means.

Parameters

screenX

Screen x-coordinate of the tap (px)

screenY

Screen y-coordinate of the tap (px)

viewportWidth

Width of the scene viewport (px)

viewportHeight

Height of the scene viewport (px)

tileSize

World units per tile side (default 1.0)

elevation

Z-plane to intersect during inverse projection (default 0.0)

originOffset

World position of the grid's (0,0) corner (default Point.ORIGIN)