disfigure

Disfigure: API Reference

Classes

Disfigure classes are used to define figures.

new Man( )
new Man( height )

Class. Creates a man figure. The Optional parameter defines figure height in meters. Default height 1.80.

new Woman( )
new Woman( height )

Class. Creates a woman figure. The optional parameter defines figure height in meters. Default height 1.70.

new Child( )
new Child( height )

Class. Creates a child figure. The optional parameter defines figure height in meters. Default height 1.35.

Figures

Disfigure figures have the same structure independent on their appearance.

figure.position

Vector3 property. Gets or sets the position of a figure in 3D space.

figure.position.x
figure.position.y
figure.position.z

Numeric properties. Get or set the x, y or z coordinate of a figure in 3D space.

figure.posture

Object property. Gets or sets the posture of a figure. The posture is a JavaScript object with specific structure.

figure.postureString

String read-only property. Gets the posture of a figure as string.

figure.blend ( postureA, postureB, k )

Method. Sets the posture of a figure to be a lerp blend of postureA and postureB based on coefficient k∈[0,1].

figure.bodypart

Body part properties. The bodypart is the name of a body part, one of these:

Body parts

Each body part has the same set of properties, although some are deactivated. For example, a knee can rotate around X axis and partly around Z axis.

figure.bodypart.x

Numeric property. Gets or sets the rotation angle in degrees around the X “shoulder” axis.

figure.bodypart.y

Numeric property. Gets or sets the rotation angle in degrees around the Y “head” axis.

figure.bodypart.z

Numeric property. Gets or sets the rotation angle in degrees around the Z “chest” axis.

Functions

setAnimationLoop(callback)
callback(time)

Function. Sets animation function called once every frame. The callback function receives the time in miliseconds.

random( )
random( min, max )

Function. Generates uniformly distributed random number in interval [min,max). By default the optional parameters are min=-1 and max=1.

regular( time )
regular( time, offset )
regular( time, offset, min, max )

Function. Generates an oscilating sine sequence of numbers in interval [min,max]. By default the optional parameters are offset=0, min=-1 and max=1. Parameter offset shifts the oscillation forward or backward in time.

chaotic( time )
chaotic( time, offset )
chaotic( time, offset, min, max )

Function. Generates a chaotic oscilating sequence of numbers in interval [min,max]. By default the optional parameters are offset=0, min=-1 and max=1. Internally uses a simplex noise function. Parameter offset shifts the sequence across the time, i.e. two generators with different offsets produce different sequences.

Events

window.addEventListener(‘animate‘,callback)

Global animate event. Triggered once on every frame.

figure.addEventListener(‘animate‘,callback)

Local animate event. Triggered once on every frame for each figure.

event.time

Animate event property. Time in miliseconds in global and local animate events.

event.target

Animate event property. Figure for which a local animate event is triggered.

Variables

everybody

Global array. Contains all created figures. Usually used to traverse them and do some operation on all figures.

Home · GitHub · Legacy NPM