Camera
Lens Studio v1.0.0+
Scripting Name: Component.Camera
Inherits from Component
Inner Classes: Camera.DepthBufferMode
, Camera.DeviceProperty
, Camera.Type
Description
Renders the scene to a Render Target texture. A Camera will only render a SceneObject if the SceneObject’s render layer is enabled on the Camera. For more information, see the Camera and Layers guide.
Methods
getOrthographicSize()
: vec2
For orthographic cameras, returns the camera size as (width, height).
isSphereVisible(vec3 center, Number radius)
: Boolean
Returns true if a sphere with the specified world space center position and radius is visible within the camera frustum, false otherwise.
project(vec3 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()
.
screenSpaceToWorldSpace(vec2 normalizedScreenSpacePoint, Number 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.
unproject(vec3 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.
worldSpaceToScreenSpace(vec3 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.
static createColorRenderTarget()
: Camera.ColorRenderTarget
Creates and returns a new Color Render Target.
Properties
aspect
: Number
The aspect ratio of the camera (width/height).
clearColor
: vec4
When enableClearColor
is true and inputTexture
is null, this color is used to clear this Camera’s renderTarget
before drawing to it.
depthBufferMode
: Camera.DepthBufferMode
Determines the way depth is handled on this Camera. Changing this can help sort objects at different distance ranges.
devicePropertyUsage
: Camera.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.
enableClearColor
: Boolean
If enabled, this Camera will clear the color on its renderTarget
before drawing to it.
inputTexture
will be used to clear it unless it is null, in which case clearColor
is used instead.
enableClearDepth
: Boolean
If enabled, this Camera will clear the depth buffer on its renderTarget
before drawing to it.
far
: Number
The distance of the far clipping plane.
fov
: Number
The Camera’s field of view in radians.
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.
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.
near
: Number
The distance of the near clipping plane.
renderLayer
: LayerSet
Controls the set of layers this Camera will render.
renderOrder
: Number
The sorting order the Camera renders in. Every frame, Cameras render in ascending order determined by their renderOrder
properties.
renderTarget
: Texture
The RenderTarget this Camera will draw to.
size
: Number
The orthographic size of the camera.
type
: Camera.Type
Read-only property describing which type of rendering the camera uses.
Inherited Methods
destroy()
: void
Destroys the component.
getSceneObject()
: SceneObject
Returns the SceneObject the component is attached to.
getTransform()
: Transform
Returns the Transform this component is attached to.
isSame(SerializableWithUID other)
: Boolean
Returns true if this object is the same as other
. Useful for checking if two references point to the same thing.
getTypeName()
: String
Returns the name of this object’s type.
isOfType(String type)
: Boolean
Returns true if the object matches or derives from the passed in type.
Inherited Properties
enabled
: Boolean
If disabled, the Component will stop enacting its behavior.
Still Looking for help?
Visit Support