ViewComponent

Native view component.

Provides access to a native view component instance.

Static Members

Properties

Methods


Static Members

.TypeName: string



Properties

.exposure: number

1.5.2+

Get the camera exposure multiplier.

.exposure

1.5.2+

Set the camera exposure multiplier.


.extent: number

1.2.2+

Get the width of the orthographic viewing volume.

.extent

1.2.2+

Set the width of the orthographic viewing volume.

Only has an effect if projectionType is Orthographic.


.far: number

Far clipping plane value.

.far

Set far clipping plane distance for the view.

If an XR session is active, the change will apply in the following frame, otherwise the change is immediate.


.fov: number

Get the horizontal field of view for the view, in degrees.

If an XR session is active and this is the left or right eye view, this returns the field of view reported by the device, regardless of the fov that was set.

.fov

Set the horizontal field of view for the view, in degrees.

Only has an effect if projectionType is Perspective.

If an XR session is active and this is the left or right eye view, the field of view reported by the device is used and this value is ignored. After the XR session ends, the new value is applied.


.near: number

ViewComponent near clipping plane value.

.near

Set near clipping plane distance for the view.

If an XR session is active, the change will apply in the following frame, otherwise the change is immediate.


.projectionMatrix: Float32Array

Equivalent to getProjectionMatrix.

Note: Prefer to use getProjectionMatrix for performance.


.projectionType: ProjectionType

1.2.2+

Projection type of the view.

.projectionType

1.2.2+

Set the projection type of the view.


.viewport: Int32Array

1.3.0+

Get viewport of the view of the form: [x, y, width, height].



Methods

.getDirectionForScreenPosition<T>(x: number, y: number, out: T) ⇒ T

.getDirectionForScreenPosition(x: number, y: number) ⇒ Float32Array

1.5.0+

Get the view space direction towards a 2D point in HTML canvas coordinates.

Example:

// e holds a MouseEvent, e.g. from a canvas 'click' event listener
const direction = new Float32Array(3);
viewComponent.getDirectionForScreenPosition(e.clientX, e.clientY, direction);
// Get a world space direction
viewComponent.object.transformVectorWorld(direction, direction);

Note: For orthographic views, the direction is always (0, 0, -1).

Returns: The out parameter.

ParamTypeDescription
xnumberX coordinate between 0 and viewport width (exclusive), increasing values go right.
ynumberY coordinate between 0 and viewport height (exclusive), increasing values go down.
outTDestination array/vector, expected to have at least 3 elements.
Template ParamType Definition
Textends NumberArray

.getProjectionMatrix<T>(out: T) ⇒ T

.getProjectionMatrix() ⇒ Float32Array

Projection matrix.

A 4x4 matrix that transforms from view space to a WebGL-compatible clip space (-1 to 1 on all axes, near plane at -1, far plane at 1).

If an XR session is active and this is the left or right eye view, this returns the projection matrix reported by the device.

Note: This is not necessarily the final projection matrix used for rendering. You can use it for unprojecting from screen space coordinates to view space.

Returns: The out parameter.

ParamTypeDescription
outTDestination array/vector, expected to have at least 16 elements.
Template ParamType Definition
Textends NumberArray

.getViewport<T>(out: T) ⇒ T

.getViewport() ⇒ Int32Array

1.3.0+

Get viewport of the view of the form: [x, y, width, height].

Returns: The out parameter.

ParamTypeDescription
outTDestination array/vector, expected to have at least 4 elements.
Template ParamType Definition
Textends NumberArray