Class: PoseOutfitPlugin
@geenee/bodyrenderers-three.PoseOutfitPlugin
Plugin implementing virtual try-on of avatar's outfit
PoseOutfitPlugin is extension of PoseAlignPlugin that allows to specify body meshes of the avatar's node as occluders and optionally hide some child meshes (parts). It's a good starting point for virtual try-on applications. OutfitParams defines available options of outfit. You can download any Ready Player Me avatar which outfit similar to final result, edit its outfit, re-skin model if necessary. Then simply use this plugin to build try-on app. Armature bones must follow Mixamo / RPM naming convention.
Hierarchy
↳
PoseOutfitPlugin
Constructors
constructor
• new PoseOutfitPlugin(node?
, outfit?
, tune?
)
Constructor
Parameters
Name | Type | Description |
---|---|---|
node? | Object3D <Event > | Scene node to attach |
outfit? | OutfitParams | Occluder and hidden parts |
tune | PoseTuneParams | Fine-tuning parameters |
Overrides
Properties
alignScore
• Readonly
alignScore: 0.9
Pose score threshold
Inherited from
alignVisibility
• Readonly
alignVisibility: 0.9
Keypoint visibility threshold
Inherited from
PoseAlignPlugin.alignVisibility
avatarLength
• Protected
avatarLength: number
= 1
Reference length of the model
Inherited from
loaded
• loaded: boolean
Loaded state
Inherited from
node
• Protected
Optional
node: Object3D
<Event
>
Inherited from
outfit
• Protected
Optional
outfit: OutfitParams
scene
• Protected
Optional
scene: Scene
Inherited from
skeleton
• Protected
Optional
skeleton: SkeletonRef
Bones of the model's rig
Inherited from
skeletonRef
• Protected
Optional
skeletonRef: Skeleton
Reference to model's skeleton
Inherited from
spineRef
• Protected
Optional
spineRef: Spine
Shape of spine
Inherited from
tune
• Protected
tune: PoseTuneParams
Inherited from
Methods
alignBone
▸ Protected
alignBone(transform
, bone
, scale?
): void
Set bone transformation
Transformation is in the world coordinate frame. If bone has parent we find relative transformation to follow the skeleton hierarchy. Optionally scale of parent bone can be adjusted to align head and reference (rest) position of parent's tail (they have to be the same 3D point).
Parameters
Name | Type | Default value | Description |
---|---|---|---|
transform | Bone | undefined | Global bone position and rotation |
bone | Bone | undefined | Reference to bone instance |
scale | boolean | true | Whether to scale parent bone |
Returns
void
Inherited from
dispose
▸ dispose(): void
Dispose render plugin
Returns
void
Inherited from
estimateBones
▸ Protected
estimateBones(points
, spineRef
): Skeleton
Estimate bone positions and axes
Based on detected keypoints estimates bone transformations. Position of bone if defined by 3D point itself, bone length is the distance between keypoints connected by bone. Bone's rotation is defined by its axes that are evaluated from relative positions of adjacent keypoints. Method returns only bone position and orientation axis, final transformation of any bone can be found using the next bone in hierarchy.
Parameters
Name | Type | Description |
---|---|---|
points | PosePoints | Pose keypoints |
spineRef | Spine | Shape of spine |
Returns
Bone transformations
Inherited from
load
▸ load(scene?
): Promise
<void
>
Initialize plugin
Parses and caches the rig/armature of the attached scene node (one provided to plugin's constructor). Precalculates geometrical parameters of skeleton.
Parameters
Name | Type | Description |
---|---|---|
scene? | Scene | Scene this plugin is attached to |
Returns
Promise
<void
>
Promise resolving when initialization is finished
Inherited from
setNode
▸ setNode(object?
): Promise
<void
>
Set/attach a scene node
Method setNode() is extended to make occluders from specified body meshes and optionally hide some child meshes according to parameters. Occluders are made the same way OccluderPlugin does via overriding mesh materials.
Parameters
Name | Type | Description |
---|---|---|
object? | Object3D <Event > | Scene node to attach |
Returns
Promise
<void
>
Promise resolving when initialization is finished
Overrides
setOutfit
▸ setOutfit(node?
, outfit?
): Promise
<void
>
Set outfit parameters
Parameters
Name | Type | Description |
---|---|---|
node? | Object3D <Event > | Scene node to attach |
outfit? | OutfitParams | Occluder and hidden parts |
Returns
Promise
<void
>
Promise resolving when initialization is finished
unload
▸ unload(): void
Reset plugin
Removes the attached node.
Returns
void
Inherited from
update
▸ update(result
, stream
): Promise
<void
>
Update skeleton of the scene node
Evaluates positions, rotations and scales of node bones
based on estimation of 3D keypoints, then applies these
transformations to bones following hierarchy of armature.
Optionally fine-tunes the basic
alignment to improve model fitting or make it more natural.
You can override this method to further tune model's rig
using provided estimations of bones as starting point.
Simply call await super.update(result, stream);
and use
skeletonRef member storing refs
to all bones of the skeleton to access transformations.
Parameters
Name | Type | Description |
---|---|---|
result | PoseResult | Pose estimation results |
stream | HTMLCanvasElement | Captured video frame |
Returns
Promise
<void
>
Promise resolving when update is finished
Inherited from
updateHandL
▸ Protected
updateHandL(anchors
, points
): void
Update left hand skeleton
Parameters
Name | Type | Description |
---|---|---|
anchors | Skeleton | Positions and axes of bones |
points | PosePoints | Pose keypoints |
Returns
void
Inherited from
updateHandR
▸ Protected
updateHandR(anchors
, points
): void
Update right hand skeleton
Parameters
Name | Type | Description |
---|---|---|
anchors | Skeleton | Positions and axes of bones |
points | PosePoints | Pose keypoints |
Returns
void
Inherited from
updateLegL
▸ Protected
updateLegL(anchors
, points
): void
Update left leg skeleton
Parameters
Name | Type | Description |
---|---|---|
anchors | Skeleton | Positions and axes of bones |
points | PosePoints | Pose keypoints |
Returns
void
Inherited from
updateLegR
▸ Protected
updateLegR(anchors
, points
): void
Update right leg skeleton
Parameters
Name | Type | Description |
---|---|---|
anchors | Skeleton | Positions and axes of bones |
points | PosePoints | Pose keypoints |
Returns
void
Inherited from
updateSpine
▸ Protected
updateSpine(anchors
): void
Update spine skeleton
Parameters
Name | Type | Description |
---|---|---|
anchors | Skeleton | Positions and axes of bones |
Returns
void