Skip to main content

LensStudio:Preview

Module

Module providing preview functionality for Lens Studio.

Example

// The LensStudio:Preview module exposes Config, CameraView, Input,
// StreamType, IPreviewPanel, and PreviewPanel for driving preview
// sessions in Lens Studio.
import { Config, CameraView, Input, StreamType } from 'LensStudio:Preview';

// Builds a Config that feeds an image or video file to the Lens through the front camera view.
export function createFileConfig(mediaFile: Editor.Path): Config {
const config = new Config();
config.cameraView = CameraView.Front;
config.upscale = 1280; // longest side of the input frame, in pixels; 0 = use the source resolution

const input = new Input();
input.type = StreamType.Multimedia;
input.sourcePath = mediaFile;
config.input = input;
return config;
}

Enumerations

EnumerationDescription
CameraViewEnum selecting which device camera the preview simulates.
GestureState-

Classes

ClassDescription
AssetNotReadyPause reason reported when some assets are not ready or a script failed to compile. It is not resumable: resume() does not clear it, so fix the project instead.
ConfigPreview input configuration: input source, camera view, simulated device, and input upscale. Read it from a preview's config property, modify it, and assign it back.
DoubleTapBase class for all script-accessible Lens Studio objects.
GestureBase class for all script-accessible Lens Studio objects.
HoverBase class for all script-accessible Lens Studio objects.
ImageFrame captured from a preview by screenshot() or tryScreenshot().
InputPreview input source, made of a source path and a stream type.
InspectionSessionHandle to the Lens's runtime scene during preview inspection, returned by startInspection(). The session becomes inactive when it is stopped, when the preview input changes, or when the preview is destroyed.
InvalidAssetConfiguration-
IPreviewProfilingRecords performance traces of a preview. Obtain it from the preview's profiling property.
PanBase class for all script-accessible Lens Studio objects.
PausedByUserPause reason reported when the creator pauses the Preview panel or switches it to a paused or inspected stream.
PinchBase class for all script-accessible Lens Studio objects.
RenderFailedPause reason reported when rendering fails several times in a row. Fix the Lens, then reload the preview to recover.
StreamTypeEnum representing the type of preview stream.
SuspendedPause reason reported while a preview is suspended, for example after LensPreview.pause().
TapBase class for all script-accessible Lens Studio objects.
TouchBase class for all script-accessible Lens Studio objects.
TraceSessionPerformance trace being recorded, returned by IPreviewProfiling.startTrace().
VideoMP4 video recorded from a preview by recordVideo().

Functions

FunctionDescription
allImagesReturns a promise that resolves to Input values for the sample images bundled with Lens Studio, each with the Multimedia stream type.
allScenesReturns a promise that resolves to Input values for the interactive sample scenes bundled with Lens Studio, each with the Interactive stream type. A headless LensPreview cannot open these inputs.
allVideosReturns a promise that resolves to Input values for the sample videos bundled with Lens Studio, each with the Multimedia stream type.