Class: NavigatorState

NavigatorState(modelViewMatrix, projectionMatrix, viewport, heading, tilt)

Represents the state of a navigator.

Properties of NavigatorState objects are read-only because they are values captured from a Navigator. Setting the properties on a NavigatorState instance has no effect on the Navigator from which they came.

Constructor

Constructs a navigator state. This constructor is meant to be called by navigators when their current state is requested.
Parameters:
Name Type Description
modelViewMatrix Matrix The navigator's model-view matrix.
projectionMatrix Matrix The navigator's projection matrix.
viewport Rectangle The navigator's viewport.
heading Number The navigator's heading.
tilt Number The navigator's tilt.
Source:

Members

(readonly) eyePoint :Vec3

The navigator's eye point in model coordinates, relative to the globe's center.
Type:
Source:

(readonly) frustumInModelCoordinates :Frustum

The navigator's viewing frustum in model coordinates. The frustum originates at the eyePoint and extends outward along the forward vector. The navigator's near distance and far distance identify the minimum and maximum distance, respectively, at which an object in the scene is visible.
Type:
Source:

(readonly) heading :Number

Indicates the number of degrees clockwise from north to which the view is directed.
Type:
  • Number
Source:

(readonly) modelview :Matrix

The navigator's model-view matrix. The model-view matrix transforms points from model coordinates to eye coordinates.
Type:
Source:

(readonly) modelviewNormalTransform :Matrix

The matrix that transforms normal vectors in model coordinates to normal vectors in eye coordinates. Typically used to transform a shape's normal vectors during lighting calculations.
Type:
Source:

(readonly) modelviewProjection :Matrix

The concatenation of the navigator's model-view and projection matrices. This matrix transforms points from model coordinates to clip coordinates.
Type:
Source:

(readonly) projection :Matrix

The navigator's projection matrix. The projection matrix transforms points from eye coordinates to clip coordinates.
Type:
Source:

(readonly) tilt :Number

The number of degrees the globe is tilted relative to its surface being parallel to the screen. Values are typically in the range 0 to 90 but may vary from that depending on the navigator in use.
Type:
  • Number
Source:

(readonly) viewport :Rectangle

The navigator's viewport, in WebGL screen coordinates. The viewport places the origin in the bottom-left corner and has axes that extend up and to the right from the origin.
Type:
Source:

Methods

convertPointToViewport(point, result) → {Vec2}

Converts a window-coordinate point to WebGL screen coordinates.

The specified point is understood to be in the window coordinate system of the WorldWindow, with the origin in the top-left corner and axes that extend down and to the right from the origin point.

The returned point is in WebGL screen coordinates, with the origin in the bottom-left corner and axes that extend up and to the right from the origin point.

Parameters:
Name Type Description
point Vec2 The window-coordinate point to convert.
result Vec2 A pre-allocated Vec2 in which to return the computed point.
Source:
Throws:
If either argument is null or undefined.
Type
ArgumentError
Returns:
The specified result argument set to the computed point.
Type
Vec2

convertPointToWindow(screenPoint, result) → {Vec2}

Converts a WebGL screen point to window coordinates.

The specified point is understood to be in WebGL screen coordinates, with the origin in the bottom-left corner and axes that extend up and to the right from the origin point.

The returned point is in the window coordinate system of the WorldWindow, with the origin in the top-left corner and axes that extend down and to the right from the origin point.

Parameters:
Name Type Description
screenPoint Vec2 The screen point to convert.
result Vec2 A pre-allocated Vec2 in which to return the computed point.
Source:
Throws:
If either argument is null or undefined.
Type
ArgumentError
Returns:
The specified result argument set to the computed point.
Type
Vec2

pixelSizeAtDistance(distance) → {Number}

Computes the approximate size of a pixel at a specified distance from the navigator's eye point.

This method assumes rectangular pixels, where pixel coordinates denote infinitely thin spaces between pixels. The units of the returned size are in model coordinates per pixel (usually meters per pixel). This returns 0 if the specified distance is zero. The returned size is undefined if the distance is less than zero.

Parameters:
Name Type Description
distance Number The distance from the eye point at which to determine pixel size, in model coordinates.
Source:
Returns:
The approximate pixel size at the specified distance from the eye point, in model coordinates per pixel.
Type
Number

project(modelPoint, result) → {boolean}

Transforms the specified model point from model coordinates to WebGL screen coordinates.

The resultant screen point is in WebGL screen coordinates, with the origin in the bottom-left corner and axes that extend up and to the right from the origin.

This function stores the transformed point in the result argument, and returns true or false to indicate whether or not the transformation is successful. It returns false if this navigator state's modelview or projection matrices are malformed, or if the specified model point is clipped by the near clipping plane or the far clipping plane.

Parameters:
Name Type Description
modelPoint Vec3 The model coordinate point to project.
result Vec3 A pre-allocated vector in which to return the projected point.
Source:
Throws:
If either the specified point or result argument is null or undefined.
Type
ArgumentError
Returns:
true if the transformation is successful, otherwise false.
Type
boolean

projectWithDepth(modelPoint, depthOffset, result) → {boolean}

Transforms the specified model point from model coordinates to WebGL screen coordinates, applying an offset to the modelPoint's projected depth value.

The resultant screen point is in WebGL screen coordinates, with the origin in the bottom-left corner and axes that extend up and to the right from the origin.

This function stores the transformed point in the result argument, and returns true or false to indicate whether or not the transformation is successful. It returns false if this navigator state's modelview or projection matrices are malformed, or if the modelPoint is clipped by the near clipping plane or the far clipping plane, ignoring the depth offset.

The depth offset may be any real number and is typically used to move the screenPoint slightly closer to the user's eye in order to give it visual priority over nearby objects or terrain. An offset of zero has no effect. An offset less than zero brings the screenPoint closer to the eye, while an offset greater than zero pushes the projected screen point away from the eye.

Applying a non-zero depth offset has no effect on whether the model point is clipped by this method or by WebGL. Clipping is performed on the original model point, ignoring the depth offset. The final depth value after applying the offset is clamped to the range [0,1].

Parameters:
Name Type Description
modelPoint Vec3 The model coordinate point to project.
depthOffset Number The amount of offset to apply.
result Vec3 A pre-allocated vector in which to return the projected point.
Source:
Throws:
If either the specified point or result argument is null or undefined.
Type
ArgumentError
Returns:
true if the transformation is successful, otherwise false.
Type
boolean

rayFromScreenPoint(point) → {Line}

Computes a ray originating at the navigator's eyePoint and extending through the specified point in window coordinates.

The specified point is understood to be in the window coordinate system of the WorldWindow, with the origin in the top-left corner and axes that extend down and to the right from the origin point.

The results of this method are undefined if the specified point is outside of the WorldWindow's bounds.

Parameters:
Name Type Description
point Vec2 The window coordinates point to compute a ray for.
Source:
Returns:
A new Line initialized to the origin and direction of the computed ray, or null if the ray could not be computed.
Type
Line

unProject(screenPoint, result) → {boolean}

Transforms the specified screen point from WebGL screen coordinates to model coordinates.

The screen point is understood to be in WebGL screen coordinates, with the origin in the bottom-left corner and axes that extend up and to the right from the origin.

This function stores the transformed point in the result argument, and returns true or false to indicate whether the transformation is successful. It returns false if this navigator state's modelview or projection matrices are malformed, or if the screenPoint is clipped by the near clipping plane or the far clipping plane.

Parameters:
Name Type Description
screenPoint Vec3 The screen coordinate point to un-project.
result Vec3 A pre-allocated vector in which to return the unprojected point.
Source:
Throws:
If either the specified point or result argument is null or undefined.
Type
ArgumentError
Returns:
true if the transformation is successful, otherwise false.
Type
boolean