LensStudio:Preview
ModuleModule 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
| Enumeration | Description |
|---|---|
| CameraView | Enum selecting which device camera the preview simulates. |
| GestureState | - |
Classes
| Class | Description |
|---|---|
| AssetNotReady | Pause 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. |
| Config | Preview 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. |
| DoubleTap | Base class for all script-accessible Lens Studio objects. |
| Gesture | Base class for all script-accessible Lens Studio objects. |
| Hover | Base class for all script-accessible Lens Studio objects. |
| Image | Frame captured from a preview by screenshot() or tryScreenshot(). |
| Input | Preview input source, made of a source path and a stream type. |
| InspectionSession | Handle 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 | - |
| IPreviewProfiling | Records performance traces of a preview. Obtain it from the preview's profiling property. |
| Pan | Base class for all script-accessible Lens Studio objects. |
| PausedByUser | Pause reason reported when the creator pauses the Preview panel or switches it to a paused or inspected stream. |
| Pinch | Base class for all script-accessible Lens Studio objects. |
| RenderFailed | Pause reason reported when rendering fails several times in a row. Fix the Lens, then reload the preview to recover. |
| StreamType | Enum representing the type of preview stream. |
| Suspended | Pause reason reported while a preview is suspended, for example after LensPreview.pause(). |
| Tap | Base class for all script-accessible Lens Studio objects. |
| Touch | Base class for all script-accessible Lens Studio objects. |
| TraceSession | Performance trace being recorded, returned by IPreviewProfiling.startTrace(). |
| Video | MP4 video recorded from a preview by recordVideo(). |
Functions
| Function | Description |
|---|---|
| allImages | Returns a promise that resolves to Input values for the sample images bundled with Lens Studio, each with the Multimedia stream type. |
| allScenes | Returns 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. |
| allVideos | Returns a promise that resolves to Input values for the sample videos bundled with Lens Studio, each with the Multimedia stream type. |