LinearCloner

Cloner Source Code
The maintenance of the Cloner System extension is the responsibility of the author.

idpic1

The LinearCloner clones and distributes given meshes in a linear manner. If more than one mesh is provided, then the corresponding clones will be placed subsequently one after another. The LinearCloner can instantiated in two different interpolation-modes: absolute and relative. In the first mode the values of the input parameters (scale/rotation/position) can be seen as the difference from the first to the last clone, whereas in the relative mode those values are the difference from clone to clone. The LinearCloner returns an object with an important property: root. It is an invisible mesh, it's the anchor and parent of all generated clones, its position is the position of the first clone. Transforming this root affects all underlying clones (childs) at once but independently of the interpolation mode. Most of the input parameters are also available as properties and they are very suitable for animation (tweening). The given input meshes will be made inactive during construction, so after construction there will be only one of two possible mesh types: BABYLON clones or instances.
Note: Input meshes can be BABYLON meshes but other Cloners as well!

Example

Example of a LinearCloner with a count of 10 clones (5 x cube1, 5 x cube2) with an increment vector of {x:2,y:0,z:-1} :

var lc = new BABYLONX.LinearCloner([cube1, cube2], demo.scene, { iModeRelative:true,count:10,P:{x:2,y:0,z:-1} });

Transforming of all clones can be done as you would do with a single mesh:

lc.root.scaling.y = 2; lc.root.rotation.x = Math.PI / 4;

Animation can be done via properties:

BABYLON.Animation.CreateAndStartAnimation('ani', lc, 'offset', 30, 120, 0, 10);

Parameters

BABYLONX.LinearCloner( meshes, scene[, {optional parameters}])

Mandatory ParameterDescription
Mandatory Parameter
meshes
Description
array of meshes/cloners to be cloned, meshes will be made inactive after construction
Mandatory Parameter
scene
Description
BABYLON scene
Optional ParameterDescriptionDefault Value
Optional Parameter
count
Description
the nuber of clones
Default Value
3
Optional Parameter
offset
Description
offset in world units in the direction of the transform position vector
Default Value
0
Optional Parameter
growth
Description
weight factor for all transform parameters in percent/100
Default Value
1
Optional Parameter
P
Description
transform position vector
Default Value
{ x: 0, y: 2, z: 0 }
Optional Parameter
S
Description
scale transformation
Default Value
{ x: 1, y: 1, z: 1}
Optional Parameter
R
Description
rotation values in degrees
Default Value
{ x: 0, y: 0, z: 0 }
Optional Parameter
iModeRelative
Description
interpolation mode,
Default Value
false (absolute)
Optional Parameter
useInstances
Description
flag if clones should be technical "clones" or "instances"
Default Value
true
PropertiesDescription
Properties
count
Description
@see Optional Parameter
Properties
offset
Description
@see Optional Parameter
Properties
growth
Description
@see Optional Parameter
Properties
position
Description
@see Optional Parameter P
Properties
scale
Description
@see Optional Parameter S
Properties
rotation
Description
@see Optional Parameter R
Properties
rotation3
Description
rotation values in radians {x,y,z}
Properties
offset
Description
@see Optional Parameter
Properties
root
Description
READONLY, getting an invisibe mesh representing the anchor of the cloner (root node)
Properties
effectors
Description
READONLY, gets a list of Effectors assigned to this Cloner
MethodsDescription
Methods
addEffector(effector, sensitivity)
Description
adds an effector to this Cloner and sets the sensitivity (1=full sensitivity, 0=no sensitivity ==ignore effector)
Methods
setEnabled(flag)
Description
set the cloner's root node to the state of the flag (true=enabled)