Svrf API Docs

ARKit and Scenekit Utilities

generateNode()

Generates a SCNNode for a SvrfMedia with a type _3d. This method can used to generate the whole 3D model, but is not recommended for face filters.

Face Filters

If you want to generate face filters for ARKit, use the generateFaceFilter() method.

Declaration

func generateNode(for media: SvrfMedia,
onSuccess success: @escaping (_ node: SCNNode) -> Void,
onFailure failure: Optional<((_ error: SvrfError) -> Void)> = nil)

Parameters

ParameterDescription
mediaThe SvrfMedia to generate the SCNNode from. The type must be _3d.
successSuccess closure.
-- nodeThe SCNNode generated from the SvrfMedia.
failureError closure.
-- errorA SvrfError.

Return Value

On success, it generates and returns a SCNNode from the SvrfMedia provided. The SCNNode can then be added to a SCNView.

generateFaceFilter()

The Svrf API allows you to access all of Svrf's ARKit compatible face filters and stream them directly to your app. Use the generateFaceFilter method to stream a face filter to your app and convert it into a SCNNode in runtime. You can then add the face filter to SceneKit.

Declaration

func generateFaceFilter(for media: SvrfMedia,
useOccluder: bool = true,
onSuccess success: @escaping (_ faceFilter: SvrfFaceFilter) -> Void,
onFailure failure: Optional<((_ error: SvrfError) -> Void)> = nil)

Parameters

ParameterDescription
mediaThe SvrfMedia to generate the face filter from. The type must be _3d.
useOccluderUse the occluder provided with the 3D model, otherwise it will be removed.
successSuccess closure.
-- faceFilterA class that contains the face filter SCNNode, ability to manage face filter animations, and optional scene overlays. See SvrfFaceFilter.

failure | Error closure. -- error | A SvrfError.

Return Value

On success, it generates and returns a SvrfFaceFilter.

SvrfFaceFilter

The class SvrfFaceFilter contains the face filter SCNNode, ability to manage face filter animations, and optional scene overlays.

Blend Shapes

The 3D animation terms "blend shapes", "morph targets", and "pose morphs" are often used interchangeably.

setBlendShapes()

This function enumerates through the node's hierarchy. Any children nodes with morph targets that follow the ARKit blend shape naming conventions will be affected.

Declaration

class SvrfMedia {
var looping: Bool = true
var sceneOverlay: SvrfSceneOverlay?
var node: SCNNode?
var animations: [(CAAnimation, SCNNode)] = []
func setBlendShapes(blendShapes: [ARFaceAnchor.BlendShapeLocation: NSNumber]): void
func animationDidStop(_ animation: CAAnimation, finished flag: Bool): void
func addAnimation(_ animation: CAAnimation, node: SCNNode): void
}

Properties

PropertyDescription
loopingWhen set to true (default), face filter animations are repeated indefinitely. Note: If set to false while an animation is playing, animation will play through to completion.
animatingWhether animations should play. Set to false to pause the animation.
sceneOverlay2D face filter overlay included with this SvrfFaceFilter. Some filters provide a 2D component to be overlaid on the SCNScene. Set this as your scene's overlaySKScene.
nodeThe root node for the face filter.
animations
setBlendShapesBlend shape mapping allows Svrf's ARKit compatible face filters to have animations that are activated by your user's facial expressions.
animationDidStop
addAnimation