disfigure

Disfigure: API Reference

A: addEventListener and animate ankle arm attach B: bands blend C: chaotic chest Child D: dress E: elbow everybody F: foot forearm H: head I: index K: knee L: latex leg lockTo M: Man middle O: or P: pinky pointAt position postureString posture R: random regular ring S: setAnimationLoop shin slice T: target thigh thumb time torso V: velour W: waist Woman wrist X: x Y: y Z: z

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.dress( clothing )

Method. Defines the dressing of a figure. The description of the clothing is an array of range and material functions: [ defaultMaterial, slice_1, material_1, … slice_N, material_N]. Slices are function that select portion of the figure and materials are clothing materials.

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.

figure.bodypart.attach(object)

Method. Attaches 3D object to a body part. Object’s position and orientation are relative to the body part.

figure.bodypart.pointAt( localX, localY, localZ )

Method. Calculates the global coordinate of point with local point ( localX, localY, localZ ) on a body part.

figure.bodypart.lockTo( globalX, globalY, globalZ, localX, localY, localZ )

Method. Moves a figure so that local point (localX, localY, localZ) on a body part is at global point (globalX, globalY, globalZ). If the local point is not provided, then the body part origin (0,0,0) is used instead.

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.

Clothing

velour( color )

Clothing function. Defines velour (matte) clothing material using Three.js color.

latex( color )

Clothing function. Defines latex (shiny) clothing material using Three.js color.

bands( material_1, material_2, width, options )

Clothing function. Makes a composite material of alternating horizontal bands of material_1 and material_2. The width of each band is defined in meters. The optional options parameter provides additional properties for the band.

slice( from, to, options )

Clothing function. Defines a slice of a figure to be dressed in given material. Parameters from and to define the start and the end of the slice, measured in meters. The optional options parameter provides additional properties for the slice.

Additionally, slices could be curved as a wave when a non-zero wave option is provided.

slice_1.and( slice_2 )

Clothing chained method. Combines slices into more complex shapes by intersecting them. The result slice contains points common for both slide_1 and slide_2.

slice_1(…).or( slice_2 )

Clothing chained method. Combines slices into more complex shapes by uniting them. The result slice contains points from any of the slides.

Home · GitHub · Legacy NPM