Camera
ClassRenders SceneObjects to one or more Render Target textures.
- Available on all platforms
Index
Properties
- aspect
- clearColor
- colorRenderTargets
- depthBufferMode
- depthStencilRenderTarget
- devicePropertiesSource
- devicePropertyUsage
- enableClearDepth
- enabled
- far
- fov
- inputTexture
- isBeingDestroyed
- isEnabledInHierarchy
- maskTexture
- near
- rayTracing
- renderLayer
- renderOrder
- renderTarget
- renderTargetCubemapFace
- renderTargetMipmapLevel
- renderTargetSlice
- sceneObject
- size
- type
- uniqueIdentifier
Methods
- createColorRenderTarget
- createDepthStencilRenderTarget
- depthStencilRenderTargetSupported
- destroy
- getOrthographicSize
- getProjectionMatrix
- getSceneObject
- getSupportedColorRenderTargetCount
- getTransform
- getTypeName
- getViewMatrix
- getViewProjectionMatrix
- isOfType
- isSame
- isSphereVisible
- project
- screenSpaceToWorldSpace
- unproject
- worldSpaceToScreenSpace
Remarks
A Camera will only render a SceneObject if its render layer is enabled on the Camera.
Extends
Properties
aspect
aspect:
number
The aspect ratio of the camera (width/height).
Default Value
1
clearColor
clearColor:
vec4
When enableClearColor is true and inputTexture is null, this color is used to clear this Camera's renderTarget before drawing to it.
Default Value
(0, 0, 0, 1)
colorRenderTargets
colorRenderTargets:
ColorRenderTarget[]
Returns an array of Color Render Targets. The first color render target is always available.
Since
Lens Scripting Version 141
Default Value
[]
depthBufferMode
depthBufferMode:
DepthBufferMode
Determines the way depth is handled on this Camera. Changing this can help sort objects at different distance ranges.
Default Value
Camera.DepthBufferMode.Regular
depthStencilRenderTarget
depthStencilRenderTarget:
DepthStencilRenderTarget
Descriptor of depth/stencil textures and clear options.
Since
Lens Scripting Version 152
devicePropertiesSource
devicePropertiesSource:
TextureTrackingScope
The Texture this Camera will be used to render content onto, and will be used to configure device properties which are set to physical. When unset it is assumed to be the DeviceCameraTexture. Relevant for cases where TextureTrackingScope will be used with 3D content like Face Mesh which will need the save fov used for the Camera.
Since
Lens Scripting Version 309
Default Value
null
devicePropertyUsage
devicePropertyUsage:
DeviceProperty
Controls which Camera settings will be overridden by physical device properties.
For example, this can be used to override the fov property to match the device camera's actual field of view.
Default Value
Camera.DeviceProperty.All
enableClearDepth
enableClearDepth:
boolean
If enabled, this Camera will clear the depth buffer on its renderTarget before drawing to it.
Default Value
false
enabled
enabled:
boolean
If disabled, the Component will stop enacting its behavior.
Default Value
true
Inherited from
far
far:
number
The distance of the far clipping plane.
Default Value
100
fov
fov:
number
The Camera's field of view in radians.
Default Value
1
inputTexture
inputTexture:
Texture
When enableClearColor is true, this texture is used to clear this Camera's renderTarget before drawing.
If this texture is null, clearColor will be used instead.
Default Value
null
isBeingDestroyed
readonlyisBeingDestroyed:boolean
Returns true if this Component is currently being destroyed. Becomes true as soon as
destruction begins via Component#destroy or destruction of its owning SceneObject,
before any OnDestroyEvent callbacks fire.
Since
Lens Scripting Version 364
Example
if (!script.isBeingDestroyed) {
// Component is still fully alive
}
Inherited from
isEnabledInHierarchy
readonlyisEnabledInHierarchy:boolean
Returns true if this Component, its SceneObject, and all of that SceneObjects parents are enabled.
Inherited from
Component.isEnabledInHierarchy
maskTexture
maskTexture:
Texture
A texture controlling which parts of the output texture the camera will draw to. The "red" value of each pixel determines how strongly the camera will draw to that part of the image. For example, a completely black section will cause the camera to not draw there at all. A completely white (or red) section will cause the camera to draw normally. Colors in between, like gray, will be semitransparent.
Default Value
null
near
near:
number
The distance of the near clipping plane.
Default Value
1
rayTracing
rayTracing:
RayTracingSettings
Toggles ray tracing for the camera. When true, ray tracing is enabled.
Default Value
null
renderLayer
renderLayer:
LayerSet
Controls the set of layers this Camera will render.
Default Value
LayerSet.all()
renderOrder
renderOrder:
number
The sorting order the Camera renders in. Every frame, Cameras render in ascending order determined by their renderOrder properties.
Default Value
0
renderTarget
renderTarget:
Texture
The RenderTarget this Camera will draw to.
Default Value
null
renderTargetCubemapFace
renderTargetCubemapFace:
CubemapFace
Sets which face of the cubemap this camera will render to.
Since
Lens Scripting Version 194
Default Value
Camera.CubemapFace.PositiveX
renderTargetMipmapLevel
renderTargetMipmapLevel:
number
Sets the mipmap level for the camera's render target.
Since
Lens Scripting Version 340
Default Value
0
renderTargetSlice
renderTargetSlice:
number
Sets the slice index for the camera's render target.
Since
Lens Scripting Version 340
Default Value
0
sceneObject
readonlysceneObject:SceneObject
The SceneObject this component is on.
Inherited from
size
size:
number
The orthographic size of the camera.
Default Value
10
type
type:
Type
Controls which type of rendering the camera uses.
Default Value
Camera.Type.Perspective
uniqueIdentifier
readonlyuniqueIdentifier:string
Since
Lens Scripting Version 176
Inherited from
Methods
createColorRenderTarget()
staticcreateColorRenderTarget():ColorRenderTarget
Creates and returns a new Color Render Target.
Returns
Since
Lens Scripting Version 141
createDepthStencilRenderTarget()
staticcreateDepthStencilRenderTarget():DepthStencilRenderTarget
Create a depth/stencil render target descriptor for the camera.
Returns
Since
Lens Scripting Version 152
depthStencilRenderTargetSupported()
staticdepthStencilRenderTargetSupported():boolean
Return true if the device supports stencil operations and render to depth texture.
Returns
boolean
Since
Lens Scripting Version 152
destroy()
destroy():
void
Destroys the component.
Returns
void
Inherited from
getOrthographicSize()
getOrthographicSize():
vec2
For orthographic cameras, returns the camera size as (width, height).
Returns
getProjectionMatrix()
getProjectionMatrix():
mat4
Returns the projection matrix for this camera.
Returns
Since
Lens Scripting Version 340
getSceneObject()
getSceneObject():
SceneObject
Returns the SceneObject the component is attached to.
Returns
Inherited from
getSupportedColorRenderTargetCount()
staticgetSupportedColorRenderTargetCount():number
Returns the number of possible render target bindings to the camera.
Returns
number
Since
Lens Scripting Version 152
getTransform()
getTransform():
Transform
Returns the Transform this component is attached to.
Returns
Inherited from
getTypeName()
staticgetTypeName():TypeName<Camera>
Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().
Returns
TypeName<Camera>
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
getViewMatrix()
getViewMatrix():
mat4
Returns the view matrix for this camera.
Returns
Since
Lens Scripting Version 340
getViewProjectionMatrix()
getViewProjectionMatrix():
mat4
Returns the combined view and projection matrix for this camera.
Returns
Since
Lens Scripting Version 340
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
isSphereVisible()
isSphereVisible(
center,radius):boolean
Returns true if a sphere with the specified world space center position and radius is visible within the camera frustum, false otherwise.
Parameters
| Parameter | Type |
|---|---|
center | vec3 |
radius | number |
Returns
boolean
project()
project(
worldSpacePoint):vec3
Converts a world space position to a raw screen space position.
The screen space position will be returned as a vec3 with x,y representing normalized screen space,
and z representing a raw depth value not directly convertible to world units.
This returned value will mostly be useful for passing into unproject().
Parameters
| Parameter | Type |
|---|---|
worldSpacePoint | vec3 |
Returns
screenSpaceToWorldSpace()
screenSpaceToWorldSpace(
normalizedScreenSpacePoint,absoluteDepth):vec3
Converts a screen space position to a world space position, given an absolute depth.
The screen space position should be provided as a vec2 in the range ([0-1], [0-1]),
(0,0) being the top-left of the screen and (1,1) being the bottom-right.
The returned world space position will be the point absoluteDepth units away from the Camera's
near plane at the point specified in screen space.
Parameters
| Parameter | Type |
|---|---|
normalizedScreenSpacePoint | vec2 |
absoluteDepth | number |
Returns
unproject()
unproject(
clipSpacePoint):vec3
Converts a raw screen space position to a world space position.
clipSpacePoint should be a vec3 returned from a previous project() call, since the
z value represents a raw depth value not directly convertible to world units.
Parameters
| Parameter | Type |
|---|---|
clipSpacePoint | vec3 |
Returns
worldSpaceToScreenSpace()
worldSpaceToScreenSpace(
worldSpacePoint):vec2
Converts the world space position worldSpacePoint to a screen space position.
Screen positions are represented in the range ([0-1], [0-1]), (0,0) being the top-left of the screen and (1,1) being the bottom-right.
Parameters
| Parameter | Type |
|---|---|
worldSpacePoint | vec3 |
Returns
See also
Camera and Layers guide.
Nested types
Enumerations
| Enumeration | Description |
|---|---|
| CubemapFace | Different faces of the cubemap that a camera can render into. |
| DepthBufferMode | Used in Camera's depthBufferMode property. Each mode is suited for handling objects at a certain distance range. For more information on depth modes, see the Camera and Layers guide. |
| DeviceProperty | Used in Camera's devicePropertyUsage property. Specifies which camera properties should be overridden by device properties. |
| Type | Returned from Camera's type property. |
Classes
| Class | Description |
|---|---|
| BaseRenderTarget | The base class from which ColorRenderTarget and DepthStencilRenderTarget are derived from |
| ColorRenderTarget | Color based RenderTarget. |
| DepthStencilRenderTarget | This class inherits from the BaseRenderTarget class. BaseRenderTarget class is not available for creation and is used like the base class for DepthStencilRenderTarget class to provide access to targetTexture, inputTexture and maskTexture properties. |