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
Parameter | Description |
---|---|
media | The SvrfMedia to generate the SCNNode from. The type must be _3d . |
success | Success closure. |
-- node | The SCNNode generated from the SvrfMedia . |
failure | Error closure. |
-- error | A 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
Parameter | Description |
---|---|
media | The SvrfMedia to generate the face filter from. The type must be _3d . |
useOccluder | Use the occluder provided with the 3D model, otherwise it will be removed. |
success | Success closure. |
-- faceFilter | A 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 = truevar sceneOverlay: SvrfSceneOverlay?var node: SCNNode?var animations: [(CAAnimation, SCNNode)] = []func setBlendShapes(blendShapes: [ARFaceAnchor.BlendShapeLocation: NSNumber]): voidfunc animationDidStop(_ animation: CAAnimation, finished flag: Bool): voidfunc addAnimation(_ animation: CAAnimation, node: SCNNode): void}
Properties
Property | Description |
---|---|
looping | When 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. |
animating | Whether animations should play. Set to false to pause the animation. |
sceneOverlay | 2D 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 . |
node | The root node for the face filter. |
animations | |
setBlendShapes | Blend shape mapping allows Svrf's ARKit compatible face filters to have animations that are activated by your user's facial expressions. |
animationDidStop | |
addAnimation |