# `class WMChain`

Available on all platforms

A Chain; a chain consists of control points and 3D objects such as RIBBONs and COILs

A chain is a smooth line generated by Catmull-Rom method.

## Instance Fields

### `var chain:WMSmoothChain`

container of the smooth line

### `var coils:Array<WMRibbon>`

arrays of COILs belonging to this instance

### `var genCompleted:Bool`

status variable used when reading xml background

### `var ribbons:Array<WMRibbon>`

array of RIBBONs belonging to this instance

### `function new():Void`

Constructor. Do nothing.

### `function absmax():Point3D`

absolute max of position: max(abs(x),abs(y),abs(z))

### `function dispose():Void`

dispose shader instance

### `function draw(c:Context3D, mpos:Matrix3D, proj:Matrix3D, voffset:Vector3D, light:Vector3D, cpos:Vector3D, dcActive:Bool, dcCoeff:Float, dcLength:Float):Bool`

draw `_polygon` on Stage3D

- light: direction of light
- cpos: position of camera
- dcActive: is depth cueing is active (false)
- dcCoeff: depth cueing coefficient (0.0)
- dcLength: depth cueing characteristic length (0.0)

### `function dump():String`

dump xml string of RIBBONs and COILs of this instance

### `function gen(c:Context3D, is_dc_active:Bool):Void`

generate polygon and set corresponding shaders; this function calls `pregen` and `gen2`.

### `function gen2(c:Context3D, is_dc_active:Bool):Void`

generate polygon and shader. Call `pregen` function before. This function should not be called explicitly unless you are using multiple Workers.

### `function getDataSize():Int`

predefined cost for drawing; return number of control points

### `function getPositions():Array<Point3D>`

get array of control points of this chain

### `function get_chain():WMSmoothChain`

getter of `chain`

### `function get_coils():Array<WMRibbon>`

getter of `coils`

### `function get_genCompleted():Bool`

getter for `genCompleted`

### `function get_ribbons():Array<WMRibbon>`

getter of `ribbons`

### `function num():Int`

number of elements inside; return the number of control points. Both of given and automatically inserted points are considered.

### `function pregen():Void`

preparation for generating polygon. This function is explicitly used in non-primordial Worker, where Context3D of the primordial Worker is not available. If Worker is not used, this function should not be called explicitly.

### `function register(r:WMRibbon):Void`

register a RIBBON or COIL given by `r`. The type of object can be determined by isRibbon variable of `r`.

### `function scaleCoord(scale:Float):Void`

scale position by `scale`

### `function setPositions(pos:Array<Dynamic>, ni:Int):Void`

Read a set of control point by array `pos`. If `ni` is given, number of points automatiaclly inserted between given points can be assigned. Default value of `ni` is 2.

### `function sumPos():Point3D`

sum of positions

### `function translate(p:Point3D):Void`

translate coordinate by `p`