Table of contents


Mannequin.js is a simple library of an articulated mannequin figure. The shape of the figure and its movements are done purely in JavaScript. The graphics is implemented in Three.js. Click on an image to open a live demo.

This is the fourth incarnation of the mannequin figure. The first one was implemented in Elica. The second one was implemented in C/C++ and OpenGL. The third one was implemented in JS/Three.js and is a direct predecessor of the current mannequin.js. Since its first incarnation, mannequin.js is used in the course Fundamentals of Computer Graphics for Computer Sciences undergraduate students from the Faculty of Mathematics and Informatics at Sofia University.

Mannequin.js is licensed under GPL-3.0.

Three.js is included in this repository to safeguard against incompatibilities with future versions. Three.js is not a part of mannequin.js.


The mannequin.js library is provided as a JavaScript file that has to be include along with three.js.

Minimal program

Here is a minimal program that creates a male figure in the browser (live example):

<!DOCTYPE html>
    <script src="three.min.js"></script>
    <script src="mannequin.min.js"></script>
      var man = new Male();

The helper function createScene() provides a default set-up of the scene and its elements, like lighting, camera, ground, etc. Another helper function, animate(t) is responsible for defining figures’ postures at moment t. If the set-up is done with a custom function, then it should also manage the animation loop by itself.

Figure types

Mannequin figures are created as instances of classes Male(), Female() or Child() (live example):

var man = new Male();
var woman = new Female();
var kid = new Child();
    kid.position.y = -8;

These three classes have a common predecessor – the class Mannequin(feminine,height), where feminine is boolean and defines whether the shape is feminine or masculine, and the second parameter is a number for relative height (adults have height 1).

Body parts

All types of figures have the same structure of joints. For example, the right arm of a figure is accessed by r_arm. Left and right body parts are in respect to the figure, not to the viewer (live example):

Each body part has rotation methods that turn it around a pivot point. The first parameter angle of the methods is the angle of rotation in degrees, so 180 is half turn and 360 is full turn. Negative angles are allowed and they represent turning in the opposite direction. Some methods have an optional second parameter for direction of motion, which could be the constant LEFT or RIGHT.

Central body parts

The central body parts are the ones which have single instances - head, neck, torso, pelvis and the body as a whole. To move the whole body use methods bend, turn and tilt of the figure (live example):

The head supports similar methods: nod, turn and tilt (live example):

The torso has the same methods as the whole body: bend, turn and tilt (live example):

Although the neck is a separate part of the body, it is not controlled individually. Instead, a part of the head motion is distributed over the neck. Similarly, the pelvis is not controlled individually. Instead, the whole body is controlled by bending, turning and tilting.

Upper limbs

The upper limbs are symmetrical body parts: arm, elbow, wrist and fingers.

Both arms support methods raise, straddle and turn (live example). The following list refers to the right arm, however, the same methods are available for the right hand:

If the direction parameter is omitted, then the default motions of straddle and turn are symmetrical. For example, the left arm is straddled to the left, while the right arm is straddled to the right (live example).

The motion of the elbow is only bend (live example). Negative values for angle result in unnatural elbow position.

The wrists have the same methods as the torso: bend, turn and tilt (live example), but similar to the arms, the directions are symmetrical, if direction is not set:

The last body parts of the upper limbs are the fingers. They can only bend (live example), however, they are composed of two segments and the bending angle is distributed over both of them.

Lower limbs

The lower limbs are symmetrical body parts: leg, knee and ankle.

Both legs support methods raise, straddle and turn (live example). Straddling and turning are symmetrical if direction is not set.

The motion of the knee is only bend (live example). Negative values for angle result in unnatural knee position.

The ankles have the same methods as the wrists: bend, turn and tilt (live example), but similar to the legs, the directions are symmetrical, if direction is not set:

Body posture

The posture of a figure is defined by a setting the rotations of body parts. The order of rotations is fixed independent on the order of rotations in the user program (live example). For example:


produces the same posture as:


Sometimes this might lead to unexpected results, especially if the user assumes an order of rotations that is different from what mannequin.js uses. This might happen when a body part is rotated around 3 or 2 axes.

Static posture

The static posture defines the position of body part that do not change. By default, when a figure is created, its body parts are set to the default posture. This version of mannequin.js does not provide posture editor, so all rotations has to be defined programmatically.

Sometimes it is better to define the figure step by step. Tai Chi Chuan posture (live example) could start by defining the whole body position:

// overall body position
man.position.y = -7.7;

// torso and head

Then the orientation of the legs can be set:

// right leg

// left leg

Finally, the arms are fixed:

// left arm

// right arm

Dynamic posture

The dynamic posture – i.e. a posture that changes over time – is set with the same methods that are used for static posture. Mannequin.js defines an empty function animate(t), which is called in the animation loop once for each frame. All changes of a posture should be defined inside this function (live example). The parameter t is the time, measured in tenths of seconds. This function is set up in createScene(). If createScene and animate are not used, then the animation loop should be managed manually.

function animate(t)
    var time1 = (sin(2*t)+cos(3*t)+cos(5*t))/3,
        time2 = (sin(2*t-60)+cos(3*t-90)+cos(5*t-120))/3;

    ball.position.x = -3*time1;

    child.position.x = -3*time1;
    child.position.y = 4+cos(90*time1);

    scene.rotation.y = rad(30*time1);

To make the animation loop faster, all constant rotations should be defined outside animate. Also, if a rotation changing in the loop, there is no need to set it up outside the loop.

Working with postures

A posture could be extracted from a figure with the getPosture() method. It returns an object with fields version for the posture data format version, and data – a nested array for joint angles. The setPosture(posture) method is used to push a posture to a figure.

Postures could be blended via Euler interpolation (i.e. linear interpolation of Euler angels). The class method blend(posture0,posture1,k), mixes the initial posture0 and the final posture1 with a coefficient k&in;[0,1]. When k=0 the result is posture0, when k=1 the result is posture1, when k is between 0 and 1 the result is a posture between posture0 and posture1. The following example blends the posture of one figure and copies it to another figure (live example):

// two figures
man = new Male();
woman = new Female();

// two postures
A = {"version":1,"data":[...]};
B = {"version":1,"data":[...]};

// set an intermediate posture
man.setPosture( Mannequin.blend(A,B,0.5) );

// copy the posture to another figure
woman.setPosture( man.getPosture() );

Converting the posture to and from a string could be done with JSON.stringify and JSON.parse.

Other functions

Apart for moving body parts, the current version of mannequin.js provides basic functionality for additional modification or accessing the figure.

Custom colors

By default, all figures use a predefined set of global colors for body parts. Global colors are stored in Mannequin.colors array as six Three.js colors or lowercase HTML/CSS color names in specific order – head, shoes, pelvis, joints, limbs and torso:

Mannequin.colors = [
    'antiquewhite',	// head
    'gray',		// shoes
    'antiquewhite',	// pelvis
    'burlywood',	// joints
    'antiquewhite',	// limbs
    'bisque'		// torso

The global color of joints and limbs refers to all joints and all limbs. Modification of the global colors in Mannequin.colors has effect if it is done before the creation of figure instances. Individual colors of body parts are set via the recolor method of joints (live example):

// global colors
Mannequin.colors = [ 'lightgreen', 'black', 'black', 'white', 'darkolivegreen', 'darkslategray'];

var man = new Male();
// individual colors
man.l_elbow.recolor( 'yellow', 'black' );
man.l_wrist.recolor( 'orange' );
man.l_fingers.recolor( 'coral' ); 'maroon' );
man.r_knee.recolor( 'antiquewhite', 'black' );

The first parameter of recolor is the color of the main section of the joint. The second parameter is the color of the spherical section of the body part.

The tips of the fingers are accessed via

Hiding body parts

Each body part could be hidden. This does not remove the body part and its graphical object from the figure, instead it is just not rendered in the frame. The method to hide a joint from a figure is:


where joint is the name of the body part to hide. Hidden body parts can still be rotated and this affects the other body parts attached to them. The following example hides both arms and both legs, but they are still preserved internally and used by elbows and knees (live example):


Custom body parts

Body parts are descendants of THREE.Object3D and supports its properties and methods. However, due to the skeletal dependency and joint attachment, scaling of a body part should be congruent along all axes, otherwise positions need to be adjusted (live example):

man = new Male();




Any custom THREE.Object3D could be attached to a body part. The attached object is included in the body and is subject to any motion the body is doing:


Objects can be attached to hidden body parts, but they are not automatically hidden. This approach is used to replace a body part with entirely custom user object (live example):

man = new Male();

// adding bracelets
bracelet = new THREE.Mesh(
    new THREE.CylinderGeometry(3,3,1,16),	
    new THREE.MeshPhongMaterial({color:'crimson',shininess:200})
bracelet.castShadow = true;
bracelet.position.y = 6;

bracelet = bracelet.clone();

// replacing the leg with other objects

material = new THREE.MeshPhongMaterial({color:'crimson',shininess:200});

obj = new THREE.Mesh(new THREE.CylinderGeometry(3,2,3,32), material);
obj.castShadow = true;
obj.position.y = 2;

Global position

Not all interaction between figures and other objects can be implemented by attaching. Mannequin.js provides method point(x,y,z) for each body part. This method calculates the global coordinates of the point (x,y,z), defined in the local coordinate system of the body part.

The following example creates a thread going through 5 points relative to body parts of a figure (live example):

loop.geometry.vertices[0] = man.r_fingers.point(0,0,0);
loop.geometry.vertices[1] = man.head.point(2.5,0,0);
loop.geometry.vertices[2] = man.l_fingers.point(0,0,0);
loop.geometry.vertices[3] = man.l_ankle.point(-1.5,5.5,0);
loop.geometry.vertices[4] = man.r_ankle.point(-1.5,5.5,0);

loop.geometry.verticesNeedUpdate = true;

Global positions could be used to ground figures – this is to put them down on the ground. However, mannequin.js does not contain any collision functionality, thus the user should pick collision points and test their global position.

The following example uses four contact points on each shoe (i.e. man.r_ankle and man.l_ankle). The minimal vertical position of the eight contact points is used to adjust the vertical position of the figure (live example):

// get minimal vertical position of contact points
var bottom = Math.min(


man.position.y += (-29.5-bottom);

Future plans

Currently mannequin.js is used to support one of the homework assignments in the course Fundamentals of Computer Graphics. Apparently, the library could be used for other activities. This provides ideas for further improvements in the functionalities.

This is unordered list of possible future improvements:

January, 2021