Class: RectilinearView

RectilinearView(params, limiter)

A view implementing a rectilinear projection for 360° images.

Constructor

new RectilinearView(params, limiter)

Parameters:
Name Type Description
params Object

the initial view parameters.

Properties
Name Type Attributes Default Description
yaw number <optional>
0

the yaw angle, in the [-π, π] range. When params.yaw < 0, the view rotates left. When params.yaw > 0, the view rotates right.

pitch number <optional>
0

the pitch angle, in the [-π, π] range. When params.pitch < 0, the view rotates downwards. When params.pitch > 0, the view rotates upwards.

roll number <optional>
0

the roll angle, in the [-π, π] range. When params.roll < 0, the view rotates clockwise. When params.roll > 0, the view rotates counter-clockwise.

fov number <optional>
π/4

the vertical field of view, in the [0, π] range.

limiter function

the view limiting function.

Implements:

Namespaces

limit

Methods

coordinatesToPerspectiveTransform(coords, radius, extraTransforms) → {String}

Calculate the perspective transform required to position an element with perspective.

Parameters:
Name Type Description
coords Object
Properties
Name Type Description
yaw number
pitch number
radius Number

Radius of the imaginary sphere where the element is

extraTransforms String

Extra transformations to be applied at the end of the transformation. Can be used to rotate the element.

Returns:

The CSS transform to be applied on the element

Type
String

coordinatesToScreen(coords) → {Object|number|number}

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

Parameters:
Name Type Description
coords Object
Properties
Name Type Description
yaw number
pitch number
roll number
Returns:
  • result

    Type
    Object
  • result.x

    Type
    number
  • result.y

    Type
    number

destroy()

Destructor.

fov() → {number}

Get the fov value.

Returns:
Type
number

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.<vec4>
Returns:

whether the rectangle intersects the view frustum.

limiter() → {function}

Get the view limiter.

Returns:

limiter

Type
function

normalizeToClosest(coords) → {Object|number|number}

Normalize view coordinates so that they are the closest to the current view. Useful for tweening the view through the shortest path. If a result argument is supplied, the object is filled in with the result and returned. Otherwise, a fresh object is returned.

Parameters:
Name Type Description
coords Object
Properties
Name Type Description
yaw number
pitch number
Returns:
  • result

    Type
    Object
  • result.yaw

    Type
    number
  • result.pitch

    Type
    number

offsetFov(fovOffset)

Add fovOffset to the current fov value.

Parameters:
Name Type Description
fovOffset number

offsetPitch(pitchOffset)

Add pitchOffset to the current pitch value.

Parameters:
Name Type Description
pitchOffset number

offsetRoll(rollOffset)

Add rollOffset to the current roll value.

Parameters:
Name Type Description
rollOffset number

offsetYaw(yawOffset)

Add yawOffset to the current yaw value.

Parameters:
Name Type Description
yawOffset number

parameters() → {Object|number|number|number|number}

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

Returns:
  • obj

    Type
    Object
  • obj.yaw

    Type
    number
  • obj.pitch

    Type
    number
  • obj.roll

    Type
    number
  • obj.fov

    Type
    number

pitch() → {number}

Get the pitch angle.

Returns:
Type
number

projection() → {mat4}

Compute and return the projection matrix for the current view.

Returns:
Type
mat4

roll() → {number}

Get the roll angle.

Returns:
Type
number

screenToCoordinates(screen) → {Object|Object|Object}

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

Parameters:
Name Type Description
screen Object
Properties
Name Type Description
x number
y number
Returns:
  • result

    Type
    Object
  • result.x

    Type
    Object
  • result.y

    Type
    Object

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

setFov(fov)

Set the fov value.

Parameters:
Name Type Description
fov number

setLimiter(limiter)

Set the view limiter.

Parameters:
Name Type Description
limiter function

setParameters(obj)

Set the view parameters. Unspecified parameters are left unchanged.

Parameters:
Name Type Description
obj Object
Properties
Name Type Description
yaw number
pitch number
roll number
fov number

setPitch(pitch)

Set the pitch angle.

Parameters:
Name Type Description
pitch number

setRoll(roll)

Set the roll angle.

Parameters:
Name Type Description
roll number

setSize(obj)

Set the viewport dimensions.

Parameters:
Name Type Description
obj Object
Properties
Name Type Description
width number
height number

setYaw(yaw)

Set the yaw angle.

Parameters:
Name Type Description
yaw number

size() → {Object|number|number}

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

Returns:
  • obj

    Type
    Object
  • obj.width

    Type
    number
  • obj.height

    Type
    number

type() → {string}

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

See also Stage#registerRenderer.

Implements:
Returns:
Type
string

width() → {number}

Get the viewport width.

Returns:
Type
number

yaw() → {number}

Get the yaw angle.

Returns:
Type
number