RadialCloner
The RadialCloner distributes given meshes in a radial manner. If more than one meshes are provided, then the clones will be placed alternatively. Several parameters controls the position, angle, type and orientation of the clones. The RadialCloner returns an object with one important property: root. It is an invisible mesh, it's the anchor, center and parent of all generated clones. Transforming this root (position/scale/rotation) affects all underlying clones (childs) at once. 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 RadialCloner with a count of 24 clones (12 cubes cube1/cube2) distributed aligned with a radius of 6 units in the plane XZ:
var rc = new BABYLONX.RadialCloner([cube1, cube2], demo.scene, {count:24,radius:6});
Transforming of all clones can be done as you would do with a single mesh:
rc.root.scaling.y = 2;
rc.root.rotation.x = Math.PI / 4;
Animation can be done via properties:
BABYLON.Animation.CreateAndStartAnimation('radanimation', rc, 'startangle', 30, 120, 0, 90);
Parameters
BABYLONX.RadialCloner( meshes, scene[, {optional parameters}])
Mandatory Parameter | Description |
---|---|
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 Parameter | Description | Default Value |
---|---|---|
Optional Parameter count | Description the nuber of clones | Default Value 3 |
Optional Parameter radius | Description radius in world units | Default Value 3 |
Optional Parameter align | Description flag if clones are aligned against the middle position of the cloner | Default Value true |
Optional Parameter startangle | Description angle in degrees | Default Value 0 |
Optional Parameter endangle | Description angle in degrees | Default Value 360 |
Optional Parameter offset | Description angle in degrees | Default Value 0 |
Optional Parameter useInstances | Description flag if clones should be technical "clones" or "instances" | Default Value true |
Optional Parameter plane | Description object {x,y,z} describing the cloners orientation | Default Value { x: 1, y: 0, z: 1 } |
Properties | Description |
---|---|
Properties count | Description @see Optional Parameter |
Properties radius | Description @see Optional Parameter |
Properties align | Description @see Optional Parameter |
Properties startangle | Description @see Optional Parameter |
Properties endangle | Description @see Optional Parameter |
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 |
Methods | Description |
---|---|
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) |