SparkAR Community Scripting Docs
  • Spark AR Scripting Reference
  • Audio Analyzer / Energy Meter
  • Asynchronous API Changes (v85+)
  • Custom Instructions
  • AnimationModule
    • ValueDriver
    • TimeDriver
    • SignalRecorder
    • SignalRecord
    • ScalarSampler
    • SamplerFactory
    • RotationSampler
    • Driver
    • ColorSampler
    • ArrayOfScalarSignals
    • ArrayOfScalarSamplers
  • AudioModule
    • PlaybackController
  • CameraInfoModule
    • CameraPosition
  • DeepLinkModule
  • DeviceMotionModule
  • DiagnosticsModule
  • FaceGesturesModule
  • FaceTracking2DModule
    • Face2D
  • FaceTrackingModule
    • Cheek
    • Chin
    • Eye
    • Eyebrow
    • Face
    • Forehead
    • Mouth
    • Nose
  • FontsModule
    • FontId
  • HandTrackingModule
    • Hand
  • InstructionModule
  • IrisTrackingModule
    • Eyeball
  • LightingEstimationModule
  • LiveStreamingModule
    • LiveStreamingModule.State
    • LiveStreamingReactions
    • LiveStreamingComments
  • LocaleModule
  • MaterialsModule
    • TextureTransform
    • RetouchingMaterial
    • MetallicRoughnessPbrMaterial
    • MaterialBase
    • DefaultMaterial
    • ColorPaintMaterial
    • BlendShapeToWarpMapMaterial
    • BlendedMaterial
  • NativeUIModule
    • Picker
  • NetworkingModule
  • PatchesModule
  • PersistenceModule
    • StorageScope
  • PersonSegmentationModule
  • RandomModule
  • ReactiveModule
    • AntiderivativeOverflowBehaviour
    • BoundingBoxSignal
    • ISignal
    • PixelPointSignal
    • PixelSizeSignal
    • Point2D
    • Point2DSignal
    • Point3D
    • Point4DSignal
    • PointSignal
    • PrimitiveOrShaderSignal
    • RgbaSignal
    • BoolSignal
    • Rotation
    • RotationSignal
    • ScalarSignal
    • ScalarValue
    • ScaleSignal
    • ShaderSignal
    • StringSignal
    • StringValue
    • Subscription
    • BoolValue
    • VectorSignal
    • TransformSignal
    • ColorSignal
    • EulerAnglesSignal
    • EventSource
    • HsvaSignal
    • InsetsSignal
  • SceneModule
    • AmbientLightSource
    • BrushType
    • HorizontalAlignment
    • RenderMode
    • ScalingOption
    • TextAlignment
    • TrackingMode
    • SpotLightSource
    • PointLightSource
    • DirectionalLightSource
    • HandTrackerSceneObject
    • Canvas
    • DynamicExtrusion
    • FaceAnchor
    • FaceMesh
    • VerticalTextAlignment
    • VerticalAlignment
    • FaceTracker
    • FocalPlane
    • FocalDistance
    • OutputVisibility
    • Mesh
    • Joint
    • PlaneTracker
    • Plane
    • PlanarText
    • PlanarObject
    • PlanarImage
    • PlanarFlexItem
    • PlanarDiv
    • ParticleTypeDescriptions
    • ParticleSystem
    • ParticleTypeDescription
    • PlanarFlexContainer
    • TextExtrusion
    • SvgImage
    • BlendShapesMesh
    • BlockSceneRoot
    • BoundingBox
    • Bounds2D
    • Camera
    • CameraVisibility
    • BlendShape
    • Scene
    • SceneObjectBase
    • ScreenPlane
    • Skeleton
    • segmentation
    • Speaker
    • Transform
    • TargetTracker
    • TextAlignmentWrapper
    • WorldTransform
    • SceneObject
  • ShadersModule
    • VertexAttribute
    • SdfVariant
    • PhysicallyBasedMaterialTextures
    • GradientType
    • FacePaintMaterialTextures
    • DerivativeType
    • DefaultMaterialTextures
    • ColorSpace
    • BuiltinUniform
    • BlendMode
    • BlendedMaterialTextures
  • SvgsModule
  • TexturesModule
    • State
    • SourceImageRegionTexture
    • SubTexture
    • TextureBase
    • CameraTexture
    • CanvasTexture
    • ColorTexture
    • DeepLinkTexture
    • ExternalTexture
    • ImageTexture
    • SegmentationTexture
    • SequenceTexture
  • TimeModule
  • TouchGesturesModule
    • Type
    • TouchGestureModule.Gesture.State
    • Gesture
    • LongPressGesture
    • PanGesture
    • PinchGesture
    • RawTouchGesture
    • RotateGesture
    • TapGesture
  • UnitsModule
Powered by GitBook
On this page
  • Example
  • Properties
  • Methods
  • Classes

Was this helpful?

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.

Example

//==============================================================================
// The following example demonstrates how to bind the position and rotation of
// objects to the eyeball and iris.
//
// Project setup:
// - Insert two planes
// - (Recommended) Decrease the scale of the planes and assign materials to them
//==============================================================================

// Load in the required modules
const FaceTracking = require('FaceTracking');
const IrisTracking = require('IrisTracking');
const Scene = require('Scene');

// Locate the planes in the Scene
const centerPlane = Scene.root.find('plane0');
const irisPlane = Scene.root.find('plane1');

// Store a reference to a detected face
const face = FaceTracking.face(0);

// Store a reference to the left eyeball
const leftEyeball = IrisTracking.leftEyeball(face);

// Store a reference to the center and iris plane's transform
const centerPlaneTransform = centerPlane.transform;
const irisPlaneTransform = irisPlane.transform;

// Store references to the eyeball center, iris and rotation
const leftEyeballCenter = leftEyeball.center;
const leftEyeballIris = leftEyeball.iris;
const leftEyeballRotation = leftEyeball.rotation.eulerAngles;

// Bind the position of the eyeball center to the center plane
centerPlaneTransform.x = leftEyeballCenter.x;
centerPlaneTransform.y = leftEyeballCenter.y;
centerPlaneTransform.z = leftEyeballCenter.z;

// Bind the position of the the eyeball iris to the iris plane
irisPlaneTransform.x = leftEyeballIris.x;
irisPlaneTransform.y = leftEyeballIris.y;
irisPlaneTransform.z = leftEyeballIris.z;

// Bind the rotation of both planes to the eyeball rotation
centerPlaneTransform.rotationX = leftEyeballRotation.x;
centerPlaneTransform.rotationY = leftEyeballRotation.y;
centerPlaneTransform.rotationZ = leftEyeballRotation.z;

irisPlaneTransform.rotationX = leftEyeballRotation.x;
irisPlaneTransform.rotationY = leftEyeballRotation.y;
irisPlaneTransform.rotationZ = leftEyeballRotation.z;

Properties

This module exposes no properties.

Methods

Method

Description

leftEyeball

leftEyeball(face: Face): Eyeball

Returns an Eyeball object for the given face, containing information about the 3D position of the left eyeball.

rightEyeball

rightEyeball(face: Face): Eyeball

Returns an Eyeball object for the given face, containing information about the 3D position of the right eyeball.

Classes

Class

Description

The Eyeball class exposes details of a tracked eyeball.

PreviousInstructionModuleNextEyeball

Last updated 5 years ago

Was this helpful?

Eyeball