Skip to main content

ScriptScene

Class

Represents the Lens scene.

  • Available on all platforms
Platform details: Snapchat, SPECS, Camera Kit Web, Camera Kit Mobile fully supported.

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

Represents the Lens scene. Accessible through global.scene.

Index

Example

if(global.scene.getCameraType() == "front")
{
print("the front camera is active");
}
else if(global.scene.getCameraType() == "back")
{
print("the back camera is active");
}
var newObject = global.scene.createSceneObject("newObject");

Extends

Properties

captureTarget

captureTarget: Texture

The output Render Target of the actual recorded video.

Default Value

null

Mobile Only


hiddenInCapture

hiddenInCapture: LayerSet

SPECS only

Layers excluded from capture output (visible on display only). Only available on Wearable (Spectacles).

Default Value

LayerSet.none()
@wearableOnly

hiddenInDisplay

hiddenInDisplay: LayerSet

SPECS only

Layers excluded from the display (visible in capture output only). Only available on Wearable (Spectacles).

Default Value

LayerSet.none()
@wearableOnly

isRayTracingSupported

readonly isRayTracingSupported: boolean

Returns true if the device supports Ray Tracing and Advanced Graphics Features is enabled in the project settings.


liveOverlayTarget

liveOverlayTarget: Texture

Similar to liveTarget, but this RenderTarget will not have predictive motion adjustments applied to it (only applicable on supported devices). Learn more

Default Value

null

liveTarget

liveTarget: Texture

The output Render Target that users will see in the live camera and during recording.

Default Value

null

Methods

createDepthStencilRenderTargetTexture()

createDepthStencilRenderTargetTexture(): Texture

Create a texture containing the DepthStencilRenderTargetProvider.

Returns

Texture

Since

Lens Scripting Version 152


createRenderTargetTexture()

createRenderTargetTexture(): Texture

Creates a new Render Target texture with a RenderTargetProvider as its control property.

Returns

Texture


createSceneObject()

createSceneObject(name): SceneObject

Adds a new SceneObject named name to the scene.

Parameters

ParameterType
namestring

Returns

SceneObject


getActivityPhase()

getActivityPhase(): SceneActivityPhase

SPECS

Returns the current activity phase of the Scene.

Use the returned SceneActivityPhase to inspect whether the Scene is in a resting phase, such as SceneActivityPhase.Foreground, or in a transition phase, such as SceneActivityPhase.Foregrounding.

Returns

SceneActivityPhase

Since

Lens Scripting Version 367

Example

const phase = global.scene.getActivityPhase();
if (phase === SceneActivityPhase.Foreground) {
print("Scene is in the Foreground phase");
}

getCameraType()

getCameraType(): string

Returns a string describing the currently active device camera.

Returns "back" if the rear-facing (aka World) camera is active.

Returns "front" if the front-facing (aka Selfie) camera is active.

Otherwise, the camera is not initialized.

Returns

string


getRecordingState()

getRecordingState(): RecordingState

Returns the current recording state of the Lens (e.g. preview, photo, or video).

Returns

RecordingState

Since

Lens Scripting Version 354


getRootObject()

getRootObject(index): SceneObject

Returns the root SceneObject at index index in the current scene.

Parameters

ParameterType
indexnumber

Returns

SceneObject


getRootObjectsCount()

getRootObjectsCount(): number

Returns the number of SceneObject in the current scene.

Returns

number


getTypeName()

static getTypeName(): TypeName<ScriptScene>

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<ScriptScene>

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isEditorViewport()

isEditorViewport(): boolean

Returns true when scripts run in the Lens Studio Scene Editor viewport. False in Preview, on device, and in exported Lenses. Not the same as DeviceInfoSystem.isEditor, which indicates the Lens Studio application.

Returns

boolean

Since

Lens Scripting Version 378

Example

if (global.scene.isEditorViewport()) {
print("Running in the Scene Editor viewport");
}

isFullScreen()

isFullScreen(): boolean

Camera Kit

Returns true if the Lens is currently in full-screen mode.

This is useful for detecting the current viewport state, particularly for Venue AR and gaming use cases where UI layout and interaction models change based on the viewport state.

Returns

boolean

Since

Lens Scripting Version 375

Example

// Checking state for late-initialized components or prefabs
script.createEvent("OnStartEvent").bind(function() {
if (global.scene.isFullScreen()) {
setupFullScreenUI();
}
});

isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


isRecording()

isRecording(): boolean

Returns whether or not the scene is currently being recorded.

Returns

boolean


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

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame