Class: FlatView

FlatView(params, limiteropt)

A View implementing an orthogonal projection for flat images.

Constructor

new FlatView(params, limiteropt)

Parameters:
Name Type Attributes Description
params FlatViewParams

The initial view parameters. The mediaAspectRatio parameter must always be set. The other parameters default to {x: 0.5, y: 0.5, z: 1 } if unspecified.

limiter FlatViewLimiter <optional>

The view limiter. If unspecified, no view limiting is applied. See FlatView.limit for commonly used limiters.

Implements:

Namespaces

limit

Members

type

The view type, used by the Stage to determine the appropriate renderer for a given geometry and view.

Known values are "rectilinear" and "flat".

See also Stage#registerRenderer.

Properties:
Type Description
string
Implements:

Methods

coordinatesToScreen(coords, resultopt) → {Coords}

Convert view coordinates into screen coordinates. If a result argument is provided, it is filled in and returned. Otherwise, a fresh object is filled in and returned.

Parameters:
Name Type Attributes Description
coords FlatViewCoords

The view coordinates.

result Coords <optional>

The result argument for the screen coordinates.

Returns:
Type
Coords

destroy()

Destructor.

height() → {number}

Get the viewport height.

Returns:
Type
number

intersects(rectangle)

Return whether the view frustum intersects the given rectangle.

This function may return false positives, but never false negatives. It is used for frustum culling, i.e., excluding invisible tiles from the rendering process.

Parameters:
Name Type Description
rectangle Array.<vec3>

The vertices of the rectangle.

inverseProjection() → {mat4}

Returns the inverse projection matrix for the current view.

Returns:
Type
mat4

limiter() → (nullable) {FlatViewLimiter}

Get the view limiter, or null if unset.

Returns:
Type
FlatViewLimiter

mediaAspectRatio() → {number}

Get the media aspect ratio.

Returns:
Type
number

offsetX(xOffset)

Add xOffset to the x parameter.

Parameters:
Name Type Description
xOffset number

offsetY(yOffset)

Add yOffset to the y parameter.

Parameters:
Name Type Description
yOffset number

offsetZoom(zoomOffset)

Add zoomOffset to the zoom value.

Parameters:
Name Type Description
zoomOffset number

parameters(paramsopt) → {FlatViewParams}

Get the view parameters. If an argument is supplied, it is filled in with the result and returned. Otherwise, a fresh object is filled in and returned.

Parameters:
Name Type Attributes Description
params FlatViewParams <optional>
Returns:
Type
FlatViewParams

projection() → {mat4}

Returns the projection matrix for the current view.

Returns:
Type
mat4

screenToCoordinates(coords, resultopt) → {FlatViewCoords}

Convert screen coordinates into view coordinates. If a result argument is provided, it is filled in with the result and returned. Otherwise, a fresh object is filled in and returned.

Parameters:
Name Type Attributes Description
coords Coords

The screen coordinates.

result FlatViewCoords <optional>

The result argument for the view coordinates.

Returns:
Type
FlatViewCoords

selectLevel(levelList) → {Level}

Select the level that should be used to render the view.

Parameters:
Name Type Description
levelList Array.<Level>

the list of levels from which to select.

Returns:

the selected level.

Type
Level

setLimiter(limiternullable)

Set the view limiter.

Parameters:
Name Type Attributes Description
limiter FlatViewLimiter <nullable>

The new limiter, or null to unset.

setMediaAspectRatio(mediaAspectRatio)

Set the media aspect ratio.

Parameters:
Name Type Description
mediaAspectRatio number

setParameters(params)

Set the view parameters. Unspecified parameters are left unchanged.

Parameters:
Name Type Description
params FlatViewParameters

setSize(size)

Set the viewport dimensions.

Parameters:
Name Type Description
size Size

setX(x)

Set the x parameter.

Parameters:
Name Type Description
x number

setY(y)

Set the y parameter.

Parameters:
Name Type Description
y number

setZoom(zoom)

Set the zoom value.

Parameters:
Name Type Description
zoom number

size(sizeopt) → {Size}

Get the viewport dimensions. If an argument is supplied, it is filled in with the result and returned. Otherwise, a fresh object is filled in and returned.

Parameters:
Name Type Attributes Description
size Size <optional>
Returns:
Type
Size

width() → {number}

Get the viewport width.

Returns:
Type
number

x() → {number}

Get the x parameter.

Returns:
Type
number

y() → {number}

Get the y parameter.

Returns:
Type
number

zoom() → {number}

Get the zoom value.

Returns:
Type
number