HeadFitPlugin
Plugin assigning head pose to a scene node
Plugin attaches provided scene node to the head. Pose of the node (translation + rotation + scale) continuously updates according to pose estimation by @geenee/bodyprocessors!FaceProcessor. Children nodes inherently include this transform. The node can be seen as a virtual placeholder for real object. It’s recommended to attach top-level nodes that don’t include transforms relative to parent, otherwise head transform that is a pose in the world frame will be applied on top of them (will be treated as relative instead of absolute). Optionally anisotropic fine-tuning of the scale can be applied. In this case model will additionally adapt to shape of the face. If face isn’t detected by FaceProcessor plugin recursively hides the node. One of approaches to accurately align meshes with a face/head when modeling a scene is to make them children of one node at the origin and set their relative transforms using face/head base mesh as the reference, then instantiate HeadFitPlugin for this scene node. You can also apply relative transforms of children of the head-attached parent node programmatically. It’s useful to add occluder model (base mesh of a head) as a child of the node. Another possible but less scalable approach is to have all meshes be built relative to the origin and aligned with the base mesh of face/head, in this case you can create HeadFitPlugin for each mesh. This can be handy when parts are stored separately.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new HeadFitPlugin(
shapeScale
):HeadFitPlugin
Constructor
Parameters
Section titled “Parameters”shapeScale
Section titled “shapeScale”boolean
= false
Tune scale according to shape of the face
Returns
Section titled “Returns”HeadFitPlugin
Overrides
Section titled “Overrides”Properties
Section titled “Properties”loaded
Section titled “loaded”loaded:
boolean
Loaded state
Inherited from
Section titled “Inherited from”
protected
optional
node:TransformNode
Attached scene node
ordinal
Section titled “ordinal”ordinal:
number
Ordinal number
Inherited from
Section titled “Inherited from”renderer?
Section titled “renderer?”
protected
optional
renderer:Renderer
<FaceResult
>
Renderer loaded the plugin
Inherited from
Section titled “Inherited from”scene?
Section titled “scene?”
protected
optional
scene:Scene
Reference to a scene instance
Inherited from
Section titled “Inherited from”shapeScale
Section titled “shapeScale”
protected
shapeScale:boolean
=false
Tune scale according to shape of the face
Methods
Section titled “Methods”dispose()
Section titled “dispose()”dispose():
void
Dispose video plugin
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”load()
Section titled “load()”load(
renderer
):Promise
<void
>
Initialize plugin
Prepares or modifies the attached node if required. Reference to the scene object is cached and used by plugin on update() and unload(). You need to reload plugin if you want to change scene it’s attached to.
Parameters
Section titled “Parameters”renderer
Section titled “renderer”Renderer this plugin is attached to
Returns
Section titled “Returns”Promise
<void
>
Promise resolving when initialization is finished
Inherited from
Section titled “Inherited from”setNode()
Section titled “setNode()”setNode(
node?
):void
Set/attach a scene node
Parameters
Section titled “Parameters”TransformNode
Scene node to attach
Returns
Section titled “Returns”void
setupCamera()
Section titled “setupCamera()”setupCamera(
ratio
,angle
):void
Set camera parameters
Could be overridden to adjust plugin’s pipeline.
Parameters
Section titled “Parameters”number
Aspect ration of input video
number
Vertical field of view in radians
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setupVideo()
Section titled “setupVideo()”setupVideo(
size
):void
Set video size
Could be overridden to adjust plugin’s pipeline.
Parameters
Section titled “Parameters”Resolution of input video
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”unload()
Section titled “unload()”unload():
void
Reset plugin
Releases all resources allocated in load(). Deletes cached reference to the scene object.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”update()
Section titled “update()”update(
result
,stream
):Promise
<void
>
Update pose of the node
Updates node’s transform (translation+rotation+scale) according to the pose estimated by @geenee/bodyprocessors!FaceProcessor. If face isn’t detected plugin recursively hides the attached node.
Parameters
Section titled “Parameters”result
Section titled “result”Results of video processing
stream
Section titled “stream”HTMLCanvasElement
Captured video frame
Returns
Section titled “Returns”Promise
<void
>
Promise resolving when update is finished