The LinearCloner instances/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. Input meshes may be other Cloners as well.

Param: mesh

The array of meshes/cloners to be cloned, meshes will be made inactive after construction.

Param: scene

Babylon scene.

Param: count

The number of instances/clones. Default 3.

Param: offset

The offset in world units in the direction of the transform position vector. Default 0.

Param: growth

The weight factor for all transform parameters in percent/100. Default 1.

Param: P

The position transform vector. Default { x: 0, y: 2, z: 0 }.

Param: S

The scaling transform vector. Default { x: 1, y: 1, z: 1}.

Param: R

The rotation transform vector. Default { x: 0, y: 0, z: 0 }.

Param: iModeRelative

The interpolation mode. Default false (absolute).

Param: useInstances

Flag if clones should be technical "clones" or "instances". Default true.

Hierarchy

  • Cloner
    • LinearCloner

Constructors

  • Parameters

    • mesh: Mesh[]
    • scene: Scene
    • __namedParameters: {
          P: undefined | {
              x: number;
              y: number;
              z: number;
          };
          R: undefined | {
              x: number;
              y: number;
              z: number;
          };
          S: undefined | {
              x: number;
              y: number;
              z: number;
          };
          count: undefined | number;
          growth: undefined | number;
          iModeRelative: undefined | boolean;
          isPickable: undefined | boolean;
          offset: undefined | number;
          useInstances: undefined | boolean;
      } = {}
      • P: undefined | {
            x: number;
            y: number;
            z: number;
        }
      • R: undefined | {
            x: number;
            y: number;
            z: number;
        }
      • S: undefined | {
            x: number;
            y: number;
            z: number;
        }
      • count: undefined | number
      • growth: undefined | number
      • iModeRelative: undefined | boolean
      • isPickable: undefined | boolean
      • offset: undefined | number
      • useInstances: undefined | boolean

    Returns LinearCloner

Properties

_P: Vector3
_R: Vector3
_S: Vector3
_clones: CMesh[]
_count: undefined | number
_countNumberGen: null | number = null
_effectors: IEffector[] = []
_frame: number
_growth: number
_iModeRelative: boolean
_index: number
_instance_nr: number
_mesh: Mesh[] = []
_offset: number
_rootNode: null | Mesh = null
_scene: Scene
_useInstances: boolean
isPickable: boolean
instance_nr: number
vOne: Vector3 = ...
vZero: Vector3 = ...

Accessors

  • get effectors(): IEffector[]
  • Returns IEffector[]

  • get meshes(): Mesh[]
  • Gets the array of source meshes used in Cloner.

    Returns Mesh[]

  • get position(): {
        x: number;
        y: number;
        z: number;
    }
  • Returns {
        x: number;
        y: number;
        z: number;
    }

    • x: number
    • y: number
    • z: number
  • set position(pos): void
  • Parameters

    • pos: {
          x: number;
          y: number;
          z: number;
      }
      • x: number
      • y: number
      • z: number

    Returns void

  • get root(): null | Mesh
  • Gets Cloner's root - an invisible mesh, the anchor and parent of all generated instances/clones. Transforming this root affects all underlying clones (childs) at once.

    Returns null | Mesh

  • get rotation(): {
        x: number;
        y: number;
        z: number;
    }
  • Returns {
        x: number;
        y: number;
        z: number;
    }

    • x: number
    • y: number
    • z: number
  • set rotation(r): void
  • Parameters

    • r: {
          x: number;
          y: number;
          z: number;
      }
      • x: number
      • y: number
      • z: number

    Returns void

  • get scale(): {
        x: number;
        y: number;
        z: number;
    }
  • Returns {
        x: number;
        y: number;
        z: number;
    }

    • x: number
    • y: number
    • z: number
  • set scale(s): void
  • Parameters

    • s: {
          x: number;
          y: number;
          z: number;
      }
      • x: number
      • y: number
      • z: number

    Returns void

Methods

  • Adds an effector to this Cloner and sets the sensitivity (1=full sensitivity, 0=no sensitivity ==ignore effector)

    Parameters

    Returns void

  • Parameters

    • parent: CMesh

    Returns null | Mesh

  • Parameters

    • start: number = 0

    Returns void

  • Deletes all Cloner's children and disposes the root Node.

    Returns void

  • Parameters

    • vec: Vector3

    Returns Vector3

  • Returns void

  • Parameters

    • vec: Vector3

    Returns Vector3

  • Parameters

    • vec: Vector3

    Returns Vector3

  • Returns Scene

  • set the cloner's root node to the state of the flag (true=enabled)

    Parameters

    • enabled: boolean

    Returns void

  • Returns an array of matrices (scaling, rotation, position) of the Cloner meshes.

    Returns Matrix[]

  • Converts the Cloner to thin instances, then deletes this Cloner and returns an array of Cloner meshes. The source meshes are cloned, their clones set enabled. To display them use addSelf = true. All cloned source meshes get the new parent with the rootName. Be aware that the original Cloner will be disposed, so Cloner methods will not work anymore. Use the root node and its individual child meshes for further processing.

    Parameters

    • Optional addSelf: boolean

      If true, adds the source mesh to the matrix. Default false.

    • Optional rootName: string

      Allow to define the name of the root mesh which will be the parent of cloned source meshes and all thin instances. If empty, Cloner class name will be used for the name.

    Returns Mesh[]

  • Converts all Cloner meshes to thin instances from the original meshes, then deletes this Cloner and returns an array of Cloner meshes. Be aware that instances of all those original meshes become disabled as well, so if they are used in other Cloners one may want to use toThin() method instead. If you don't need animations and so on you may convert Cloner to thin instances. It greatly reduces the number of objects iterating in the render loop.

    Parameters

    • Optional addSelf: boolean

      If true, adds the source mesh to the matrix. Default false.

    Returns Mesh[]

    The array of original meshes: Mesh[]