Skip to content

PoseBFitPlugin

Pose plugin aligning node’s rig with keypoints

Universal plugin aligning node’s rig and pose estimated by @geenee/bodyprocessors!PoseProcessor. It’s a base of try-on, twin, and other plugins. You can use this class as a starting point and customize alignment method or add features. Basically, PoseBFitPlugin evaluates positions and rotations of armature bones based on 3D pose keypoints, then applies these transforms to bones following the armature hierarchy. Plugin supports rigs compatible with Mixamo, for example any Ready Player Me avatar. This is the most common standard of rigs for human-like models supported by many game engines. Provided node must contain an armature among its children. Armature bones must follow Mixamo / RPM naming convention. Models rigged and skinned manually or using Mixamo tool can variate depending on anthropomorphous topology of the model. PoseBFitPlugin can apply number of fine-tuning adjustments to basic alignment improving model fitting or making it look more natural. PoseTuneParams explains tuning options. By default the plugin is fine-tuned for RPM avatars so you can simply replace person with the avatar model in the scene.

new PoseBFitPlugin(tune): PoseBFitPlugin

Constructor

PoseTuneParams = ...

Fine-tuning parameters

PoseBFitPlugin

PosePlugin.constructor

readonly alignScore: 0.9 = 0.90

Pose score threshold


readonly alignVisibility: 0.9 = 0.90

Keypoint visibility threshold


protected cameraAngle: number

Camera vertical angle in radians


protected cameraRatio: number

Camera aspect ratio


loaded: boolean

Loaded state

PosePlugin.loaded


protected optional node: TransformNode

Attached scene node


protected nodeOrigin: BoneTransform

Origin of node relative to the root bone


ordinal: number

Ordinal number

PosePlugin.ordinal


protected optional renderer: Renderer<PoseResult>

Renderer loaded the plugin

PosePlugin.renderer


protected optional scene: Scene

Reference to a scene instance

PosePlugin.scene


protected optional skeleton: Skeleton

Reference to model’s skeleton


protected optional skeletonNodes: SkeletonNodes

Bones of the model’s rig


protected optional skeletonSizes: SkeletonSizes

Reference sizes of skeleton


protected optional spineCurve: SpineCurve

Shape of spine


protected tune: PoseTuneParams

Fine-tuning parameters

dispose(): void

Dispose video plugin

void

PosePlugin.dispose


protected estimateBones(pose, spineCurve, skeletonSizes): SkeletonTransforms

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.

PosePoints

Pose keypoints

SpineCurve

Shape of spine

SkeletonSizes

SkeletonTransforms

Bone transformations


load(renderer): 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.

Renderer<PoseResult>

Renderer this plugin is attached to

Promise<void>

Promise resolving when initialization is finished

PosePlugin.load


setNode(node?): void

Set/attach a scene node

Parses and caches the rig/armature of the node. Precalculates geometrical parameters of skeleton.

TransformNode

Scene node to attach

void


setupCamera(ratio, angle): void

Set camera parameters

number

Aspect ration of input video

number

Vertical field of view in radians

void

PosePlugin.setupCamera


setupVideo(size): void

Set video size

Could be overridden to adjust plugin’s pipeline.

Size

Resolution of input video

void

PosePlugin.setupVideo


unload(): void

Reset plugin

Clears internal state and frees all resources allocated in load().

void

PosePlugin.unload


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 a starting point. Simply call await super.update(result, stream); and use PoseBFitPlugin#skeletonNodes member storing refs to all bones of the skeleton to access transformations.

PoseResult

Pose estimation results

HTMLCanvasElement

Captured video frame

Promise<void>

Promise resolving when update is finished

PosePlugin.update


protected updateArm(bones, points): void

Update arm rig (see update)

Arm bones and transforms

{ bone: TransformNode; transform: BoneTransform; }

TransformNode

BoneTransform

{ bone: TransformNode; transform: BoneTransform; }

TransformNode

BoneTransform

{ bone: TransformNode; transform: BoneTransform; }

TransformNode

BoneTransform

Arm keypoints

PosePoint

PosePoint

void


protected updateLeg(bones, points): void

Update leg rig (see update)

Leg bones and transforms

{ bone: TransformNode; transform: BoneTransform; }

TransformNode

BoneTransform

{ bone: TransformNode; transform: BoneTransform; }

TransformNode

BoneTransform

{ bone: TransformNode; transform: BoneTransform; }

TransformNode

BoneTransform

{ bone: TransformNode; transform: BoneTransform; }

TransformNode

BoneTransform

Leg keypoints

PosePoint

PosePoint

PosePoint

void


protected updateSpine(transforms, bones): void

Update spine rig (see update)

SkeletonTransforms

Estimated transformations

SkeletonNodes

Spine bones

void