Scripting API
Scripting API Overview

Scripting API

The following is a description of all scripting modules.

AnimationModule

The AnimationModule class implements object animation.

Classes

ClassDescription
ArrayOfScalarSamplersThe ArrayOfScalarSamplers class describes an array of scalar samplers.
It extends the implementation of Array<ScalarSampler> type in JavaScript,
and adds a single additional method to get a sampler at a particular index - get().
ArrayOfScalarSignalsThe ArrayOfScalarSignals class describes an array of scalar signals.
It extends the implementation of Array<ScalarSignal> type in JavaScript,
and adds a single additional method to get a sampler at a particular index - get().
ColorSamplerThe ColorSampler class encapsulates a color sampler.
DriverThe Driver class encapsulates an animation driver.
RotationSamplerThe RotationSampler class is an animation sampler for object rotation.
SamplerFactoryThe SamplerFactory class creates different types of animation samplers.
ScalarSamplerThe ScalarSampler class encapsulates a scalar value sampler.
TimeDriverThe TimeDriver class allows driving an animation sampler using time.
ValueDriverThe ValueDriver class allows driving an animation sampler using raw values.

AudioModule

The AudioModule class enables sound effects.

Classes

ClassDescription
PlaybackControllerThe PlaybackController class enables control of audio playback.

BlocksModule

The BlocksModule class provides methods for interacting with the Blocks in your effect.

CameraInfoModule

The CameraInfoModule class provides access to details about the device camera.

Enums

EnumDescription
CameraPositionThe CameraPosition enum describes the direction the camera is facing.

DeepLinkModule

The DeepLinkModule class exposes methods and properties to read the values that an external app sent to an effect.

DeviceMotionModule

The DeviceMotionModule class enables device movement detection.

DiagnosticsModule

The DiagnosticsModule class enables diagnostic logging.

Classes

ClassDescription
TypeSystemMetadataThe TypeSystemMetadata class contains type system metadata.

FaceGesturesModule

The FaceGesturesModule class enables face orientation detection.

FaceTracking2DModule

The FaceTracking2DModule class enables tracking faces in 2D.

Classes

ClassDescription
Face2DThe Face2D class exposes details of a tracked face.

FaceTrackingModule

The FaceTrackingModule class enables tracking faces in 3D.

Classes

ClassDescription
CheekThe Cheek class exposes the details of a detected cheek.
ChinThe Chin class exposes the details of a detected chin.
EyeThe Eye class exposes the details of a detected eye.
EyebrowThe Eyebrow class exposes the details of a detected eyebrow.
FaceThe Face class exposes details of a tracked face.
ForeheadThe Forehead class exposes the details of a detected forehead.
MouthThe Mouth class exposes the details of a detected mouth.
NoseThe Nose class exposes the details of a detected nose.

FontsModule

The FontsModule class is used for working with custom fonts in effects.

Classes

ClassDescription
FontIdThe FontsId class identifies a font in an effect.

HandTrackingModule

The HandTrackingModule class enables hand tracking.

Classes

ClassDescription
HandThe Hand class describes a hand detected in a scene.

InstantGamingModule

The InstantGamingModule class.

InstructionModule

The InstructionModule class enables effects to provide instructions to the user.

IrisTrackingModule

The IrisTrackingModule class allows you to track the location of people's irises in your effect, to create effects such as eye color replacement.

Classes

ClassDescription
EyeballThe Eyeball class exposes details of a tracked eyeball.

LightingEstimationModule

The LightingEstimation module encapsulates access to estimations of lighting in the scene.

LiveStreamingModule

The LiveStreamingModule class enables to retrieve information from a live stream from within the effect, such as reactions and comments.

Classes

ClassDescription
LiveStreamingCommentsThe LiveStreamingComments class provides access to the Facebook Live comments stream.
LiveStreamingReactions

Enums

EnumDescription
StateThe LiveStreamingModule.State enum describes the state of a live stream.
@

LocaleModule

The LocaleModule class encapsulates access to the locale identifier of the device.

MaterialsModule

The Materials module provides access to the materials in an effect.

Classes

ClassDescription
BlendedMaterialThe BlendedMaterial class encapsulates materials blended from multiple textures.
BlendShapeToWarpMapMaterialThe BlendShapeToWarpMapMaterial class is the JS-side representation of the "Face Warp Material" in Spark AR Studio, used to create face warp effects.
ColorPaintMaterialThe ColorPaintMaterial class encapsulates a face-paint material.
ComposedMaterialThe ComposedMaterial class encapsulates patch asset materials.
DefaultMaterialThe DefaultMaterial class encapsulates an image-based material.
MaterialBaseThe MaterialBase class exposes properties common to all material types.
MetallicRoughnessPbrMaterialThe MetallicRoughnessPbrMaterial class encapsulates physically based materials.
RetouchingMaterialThe RetouchingMaterial class encapsulates parameters which define the extend of certain beautification techniques.
TextureTransformThe TextureTransform class encapsulates scaling and translation transforms about a textures UV axis.

Enums

EnumDescription
BlendModeThe BlendMode enum describes how material is blended.
CullModeThe CullMode enum describes how material is culled.

NativeUIModule

The NativeUI module exposes editable text.

Classes

ClassDescription
PickerThe Picker class describes an object controlling native picker behavior.
SliderThe Slider class describes an object controlling native slider behavior.

PatchesModule

The PatchesModule module allows interop between JS scripting and the AR Studio patches visual scripting system.

Classes

ClassDescription
PatchesInputsThe PatchesInputs class encapsulates methods for setting inputs to the Patch Editor.
PatchesOutputsThe PatchesOutputs class encapsulates methods for getting outputs of the Patch Editor.

PersistenceModule

The Persistence class encapsulates persistent objects.

Classes

ClassDescription
StorageScopeThe StorageScope class encapsulates different methods of storage for persistent objects.

PersonSegmentationModule

The PersonSegmentationModule class enables the separation of a person from a scene.

RandomModule

The RandomModule class enables random number generation.

ReactiveModule

The ReactiveModule class exposes methods for reactive programming.

Classes

ClassDescription
BoolSignalThe BoolSignal class monitors a boolean value.
BoolSignalHistoryThe BoolSignalHistory encapsulates methods for accessing values of BoolSignal from previous frames.
BoundingBoxSignalThe BoundingBoxSignal class monitors bounding box values.
BoundingBoxSignalHistoryThe BoundingBoxSignalHistory encapsulates methods for accessing values of BoundingBoxSignal from previous frames.
ColorSignalThe ColorSignal class monitors a color.
EventSourceThe EventSource class provides methods for monitoring signals.
EventSourceHistoryThe EventSourceHistory encapsulates methods for accessing values of EventSource from previous frames.
HsvaSignalThe HsvaSignal class monitors a HSVA color value.
ISignalThe ISignal interface. The base class for ScalarSignal, PointSignal, VectorSignal, BoolSignal, and StringSignal
Point2DThe Point2D class contains a 2D coordinate.
Point2DSignalThe Point2DSignal class monitors a 2D coordinate.
Point2DSignalHistoryThe Point2DSignalHistory encapsulates methods for accessing values of Point2DSignal from previous frames.
Point3DThe Point3D class contains a 3D coordinate.
Point4DSignalThe Point4DSignal class monitors a 4D coordinate.
Point4DSignalHistoryThe Point4DSignalHistory encapsulates methods for accessing values of Point4DSignal from previous frames.
PointSignalThe PointSignal class monitors a 3D coordinate.
PointSignalHistoryThe PointSignalHistory encapsulates methods for accessing values of PointSignal from previous frames.
PrimitiveOrShaderSignalThe PrimitiveOrShader represents a primitive or shader signal.
PrimitiveOrShaderSignalHistoryThe PrimitiveOrShaderSignalHistory encapsulates methods for accessing values of PrimitiveOrShaderSignal from previous frames.
QuaternionSignalThe QuaternionSignal class monitors rotation in a quaternion representation.
QuaternionSignalHistoryThe QuaternionSignalHistory encapsulates methods for accessing values of QuaternionSignal from previous frames.
RgbaSignalThe RgbaSignal class monitors a RGBA color value.
RotationThe Rotation class encapsulates an object's rotation in a quaternion representation.
ScalarSignalThe ScalarSignal class monitors a numerical value.
ScalarSignalHistoryThe ScalarSignalHistory encapsulates methods for accessing values of ScalarSignal from previous frames.
ShaderSignalThe ShaderSignal represents a shader signal. Scalar and Vector signals can automatically be converted to a ShaderSignal.
ShaderSignalHistoryThe ShaderSignalHistory encapsulates methods for accessing values of ShaderSignal from previous frames.
StringSignalThe StringSignal class monitors a string value.
StringSignalHistoryThe StringSignalHistory encapsulates methods for accessing values of StringSignal from previous frames.
SubscriptionThe Subscription class implements object value monitoring.
TransformSignalThe TransformSignal class monitors a scene transform.
TransformSignalHistoryThe TransformSignalHistory encapsulates methods for accessing values of TransformSignal from previous frames.
VectorSignalThe VectorSignal class monitors a vector.
VectorSignalHistoryThe VectorSignalHistory encapsulates methods for accessing values of VectorSignal from previous frames.

Enums

EnumDescription
AntiderivativeOverflowBehaviourThe AntiderivativeOverflowBehaviour enum describes the recovery technique used when an antiderivative overflows.

SceneModule

The SceneModule class exposes properties and methods to access the objects in a scene.

Classes

ClassDescription
AmbientLightSourceThe AmbientLightSource class describes an ambient lighting source.
BlendShapeThe BlendShape class describes a shape attached to a mesh or face mesh which can be used to change the shape of that mesh.
BlockInstanceInputsThe BlockInstanceInputs class encapsulates methods for setting inputs to the block instance.
BlockInstanceOutputsThe BlockInstanceOutputs class encapsulates methods for getting outputs of the block instance.
BlockSceneRootThe BlockSceneRoot class describes the root scene object of a block.
BoundingBoxThe BoundingBox class describes the bounds of a scene element in the local coordinate system.
Bounds2DThe Bounds2D class describes the bounds of a scene element.
CameraThe Camera class exposes details about the device camera focal area.
CameraVisibilityThe CameraVisibility class describes whether or not an object is visible from various camera views.
CanvasThe Canvas class describes a scene canvas.
DirectionalLightSourceThe DirectionalLightSource class describes a directional light source.
DynamicExtrusionThe DynamicExtrusion class provides functionality for creating extruded 3D objects using a brush.
FaceMeshThe FaceMesh class describes a face mesh.
FaceTracker"The FaceTracker class propagates details of detected faces to the scene."
FocalDistanceThe FocalDistance class describes a focal distance.
FocalPlaneThe FocalPlane class exposes details about the focal plane of the device camera.
HandTrackerThis class represents the hand tracker scene object, used to track the position of hands in the scene.
JointThe Joint class encapsulates a joint scene object.
MeshThe Mesh class describes a scene mesh.
MeshSurfaceThe MeshSurface class describes a surface in a mesh.
OutputVisibilityThe OutputVisibility class describes whether or not an object is visible from various outputs.
ParticleSystemThe ParticleSystem class implements the particle management system for the scene.
ParticleTypeDescriptionThe ParticleTypeDescription class provides functionality for setting particle sprite densities in the scene.
ParticleTypeDescriptionsThe ParticleTypeDescriptions class provides a container for particle type descriptions.
PlanarDivThe PlanarDiv class describes a div on a plane.
PlanarFlexContainerThe PlanarFlexContainer class describes a flex container on a plane.
PlanarFlexItemThe PlanarFlexItem class describes a flex item on a plane.
PlanarImageThe PlanarImage class describes an image rendered on a plane.
PlanarObjectThe PlanarObject class describes an object on a plane.
PlanarStackThe PlanarImage class describes an image rendered on a plane.
PlanarTextThe PlanarText class describes text on a plane.
PlaneThe Plane class describes a plane.
PlaneTrackerThe PlaneTracker class provides functionality for locating a 3D plane based on 2D screen coordinates.
PointLightSourceThe PointLightSource class describes a point light source.
SceneThe Scene class implements properties and methods to access the objects in a scene.
SceneObjectThe SceneObject class describes an object in a scene.
SceneObjectBase
ScreenPlaneThe ScreenPlane class describes a screen plane.
SkeletonThe Skeleton class describes a skeleton object.
SpeakerThe Speaker class encapsulates an speaker for a scene. Old class name is AudioSource.
SpotLightSourceThe SpotLightSource class describes a spot light source.
SvgImageThe SvgImage class describes an SVG asset for a scene.
TargetTrackerThe TargetTracker encapsulates a tracker for some target.
TextAlignmentWrapperThe TextAlignmentWrapper class contains text alignment details.
TextExtrusion"The TextExtrusion class describes a 3D text scene object.
TransformThe Transform class describes an object transform for a scene.
WorldTransformThe WorldTransform class describes an object tranform for a sceneObject in world space.

Enums

EnumDescription
DirectionThe Direction enum describes the stack layout's direction.
BrushTypeThe BrushType enum describes what kind of brush is used for dynamic extrusion.
HorizontalAlignmentThe HorizontalAlignment enum describes how an element is aligned horizontally.
RenderModeThe RenderMode enum describes how to render a scene object.
ScalingOptionThe ScalingOption enum describes how an element is scaled.
StackAlignThe StackAlign enum describes the stack children's alignment.
StackDistributeThe StackDistribute enum describes the stack children's distribution.
TextAlignmentThe TextAlignment enum describes how a text element is aligned horizontally.
TrackingModeThe TrackingMode enum describes how a PlaneTracker is tracking an object.
VerticalAlignmentThe VerticalAlignment enum describes how an element is aligned vertically.
VerticalTextAlignmentThe VerticalTextAlignment enum describes how a text element is aligned vertically.

SegmentationModule

The SegmentationModule class enables the separation of a person or hair or skin from a scene.

Classes

ClassDescription
HairSegmentationThe HairSegmentation class exposes the information about a person's hair.

ShadersModule

The ShadersModule exposes APIs to create Visual Shaders using JavaScript.
The following is an explanation of the unique types and concepts specific to the ShadersModule.

PrimitiveOrShaderSignal is a union type of Point2DSignal, PointSignal, Point4DSignal, VectorSignal, TransformSignal, or ShaderSignal.
ShaderSignal is a graphics shader output that produces one of the types defined in the above union. As ShaderSignal is GPU bound, it can only be used in a GPU context.

ShaderSignal can also be of a function type, used for function mapping from one type to another.
For example, a shader with the signature function(Point2DSignal): Point4DSignal is a type of a function that maps a Point2DSignal to a Point4DSignal.

Enums

EnumDescription
BlendedMaterialTexturesThe BlendedMaterialTextures enum describes the different texture slots for a flat material.
BlendModeThe BlendMode enum describes the blending mode.
BuiltinUniformThe BuiltinUniform enum describes the bultin shader uniforms.
ColorSpaceThe ColorSpace enum describes the color space.
DefaultMaterialTexturesThe DefaultMaterialTextures enum describes the different texture slots for a default material.
DerivativeTypeThe DerivativeType enum describes the shader derivative type.
FacePaintMaterialTexturesThe FacePaintMaterialTextures enum describes the different texture slots for a face paint
material.
GradientTypeThe GradientType enum describes the type of the shader gradient.
PhysicallyBasedMaterialTexturesThe PhysicallyBasedMaterialTextures enum describes the different texture slots for a
physically based material.
SdfVariantThe SdfVariant enum describes the SDF variant.
VertexAttributeThe VertexAttribute enum describes the bultin vertex attributes.

SvgsModule

The SvgsModule module enables working with SVGs.

Classes

ClassDescription
SvgThe Svg class describes an SVG in an effect.

TexturesModule

The TexturesModule class enables images, animation sequences, videos, colors, and other visual artifacts to be combined to form materials.

Classes

ClassDescription
CameraTextureThe CameraTexture class represents a texture type that contains image data coming in from system camera, or captured photo/video in case of using the effect with "Media Library".
CanvasTextureThe CanvasTexture class enables painting with a brush to a texture.
ColorTextureThe ColorTexture class encapsulates a texture that has a color (including alpha channel).
DeepLinkTextureThe DeepLinkTexture class represents an image texture passed in via the sharing SDK.
GalleryTextureThe GalleryTexture class encapsulates a texture that was picked from the gallery.
ImageTextureThe ImageTexture class encapsulates an image that may be used to form materials for rendering in the scene.
SegmentationTextureThe SegmentationTexture class encapsulates a texture that will be used for image segmentation.
SequenceTextureThe SequenceTexture class is a collection of still images that form an animation.
SourceImageRegionTextureThe SourceImageRegionTexture class.
SubTextureThe SubTexture class exposes details of a texture in UV coordinates.
TextureBaseThe TextureBase class describes a texture.

Enums

EnumDescription
StateThe State enum describes the state of a GalleryTexture.

TimeModule

The TimeModule class enables time-based events.

TouchGesturesModule

The TouchGesturesModule class enables touch gesture detection.

Classes

ClassDescription
GestureThe SamplerFactory class creates different types of animation samplers.
LongPressGestureThe LongPressGesture class contains the details of a detected long-press gesture.
PanGestureThe PanGesture class contains the details of a detected pan gesture.
PinchGestureThe PinchGesture class contains the details of a detected pinch gesture.
RotateGestureThe RotateGesture class contains the details of a detected Rotate gesture.
TapGestureThe TapGesture class contains the details of a detected tap gesture.

Enums

EnumDescription
StateThe State enum describes the state of a Gesture.
GestureTypeThe GestureType enum describes the type of a given Gesture.

UnitsModule

The UnitsModule class provides functionality for converting values into world-space units.

WeatherModule

The WeatherModule class provides information about the current weather.

Was this article helpful?