Skip to main content

Interface: View

Encompasses all the state needed for rendering a Scene.

Renderer#render operates on View objects. These View objects specify important parameters such as:

  • The Scene
  • The Camera
  • The Viewport
  • Some rendering parameters

View instances are heavy objects that internally cache a lot of data needed for rendering. It is not advised for an application to use many View objects.

For example, in a game, a View could be used for the main scene and another one for the game's user interface. More View instances could be used for creating special effects (e.g. a View is akin to a rendering pass).

Extends

  • PointerHolder

Properties

antiAliasing

antiAliasing: "none" | "FXAA"

Enables or disables anti-aliasing in the post-processing stage. Enabled by default. MSAA can be enabled in addition, see setSampleCount().

Param

FXAA for enabling, NONE for disabling anti-aliasing.

Note

For MSAA anti-aliasing, see setSamplerCount().

Default

'FXAA'

Defined in

src/types/View.ts:95


camera

camera: RNFCamera

Defined in

src/types/View.ts:34


dithering

dithering: "none" | "temporal"

Enables or disables dithering in the post-processing stage. Enabled by default.

Default

'temporal'

Defined in

src/types/View.ts:102


isValid

readonly isValid: boolean

Get if the refernce to the native pointer is still valid and strong.

If this is false, this object has been manually released with release() and all other methods on this object will throw an Error.

Inherited from

PointerHolder.isValid

Defined in

src/types/PointerHolder.ts:37


postProcessing

postProcessing: boolean

Enables or disables post processing. Enabled by default.

Post-processing includes:

  • Depth-of-field
  • Bloom
  • Vignetting
  • Temporal Anti-aliasing (TAA)
  • Color grading & gamma encoding
  • Dithering
  • FXAA
  • Dynamic scaling

Disabling post-processing forgoes color correctness as well as some anti-aliasing techniques and should only be used for debugging, UI overlays or when using custom render targets (see RenderTarget).

Default

true

See

setBloomOptions, setColorGrading, setAntiAliasing, setDithering, setSampleCount

Defined in

src/types/View.ts:71


scene

scene: Scene

Defined in

src/types/View.ts:35


screenSpaceRefraction

screenSpaceRefraction: boolean

Enables or disables screen space refraction.

Default

true

Defined in

src/types/View.ts:48


shadowing

shadowing: boolean

Enables or disables shadow mapping. Enabled by default.

See

LightManager::Builder::castShadows(), RenderableManager::Builder::receiveShadows(), RenderableManager::Builder::castShadows(),

Default

true

Defined in

src/types/View.ts:83


temporalAntiAliasingOptions

temporalAntiAliasingOptions: Record<string, number>

This type is the raw expected valeu for JSI. The type is encoded in TemporalAntiAliasingOptions

Defined in

src/types/View.ts:123

Methods

createAmbientOcclusionOptions()

createAmbientOcclusionOptions(): AmbientOcclusionOptions

Returns

AmbientOcclusionOptions

Defined in

src/types/View.ts:105


createDynamicResolutionOptions()

createDynamicResolutionOptions(): DynamicResolutionOptions

Returns

DynamicResolutionOptions

Defined in

src/types/View.ts:106


getAmbientOcclusionOptions()

getAmbientOcclusionOptions(): AmbientOcclusionOptions

Returns

AmbientOcclusionOptions

Defined in

src/types/View.ts:40


getAspectRatio()

getAspectRatio(): number

Returns

number

Defined in

src/types/View.ts:37


getDynamicResolutionOptions()

getDynamicResolutionOptions(): DynamicResolutionOptions

Returns

DynamicResolutionOptions

Defined in

src/types/View.ts:42


getViewport()

getViewport(): Viewport

Returns

Viewport

Defined in

src/types/View.ts:38


pickEntity()

pickEntity(x, y): Promise<null | Entity>

Given 2D screen coordinates, returns the entity at that position. Returns undefined if no entity is found.

Parameters

x: number

y: number

Returns

Promise<null | Entity>

Defined in

src/types/View.ts:117


projectWorldToScreen()

projectWorldToScreen(worldPosition): [number, number]

Given a world position, returns the 2D screen coordinates.

Parameters

worldPosition: Float3

Returns

[number, number]

Defined in

src/types/View.ts:111


release()

release(): void

Manually release this reference to the native pointer. This will ensure that JS will no longer hold a strong reference, and memory can be safely cleaned up.

If the native pointer is still referenced elsewhere in native code, the underlying memory will not be deleted unless the other references are also released.

If this is not called, the memory will only be cleaned once the JS gabage collector decides to delete this object, which might be at any point in the future.

Calling release() is not required as the GC will destroy this object eventually anyways, but it is recommended to optimize memory usage.

After manually releasing a pointer, all future methods on this object will throw an Error.

Returns

void

Inherited from

PointerHolder.release

Defined in

src/types/PointerHolder.ts:30


setAmbientOcclusionOptions()

setAmbientOcclusionOptions(options): void

Parameters

options: AmbientOcclusionOptions

Returns

void

Defined in

src/types/View.ts:39


setDynamicResolutionOptions()

setDynamicResolutionOptions(options): void

Parameters

options: DynamicResolutionOptions

Returns

void

Defined in

src/types/View.ts:41