The ObjectCloner clones and distributes the array of given meshes to the facet position of another input mesh which acts as a template. If more than one mesh is provided, then the corresponding clones will be placed subsequently one after another starting in the order as the facets of the template mesh is defined.

Param: mesh

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

Param: template

The mesh acting as template.

Param: useInstances

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

Param: isPickable

Flag true if Cloner meshes should be pickable. Default false.

Hierarchy

  • Cloner
    • ObjectCloner

Constructors

  • Parameters

    • mesh: Mesh[]
    • template: Mesh
    • scene: Scene
    • __namedParameters: {
          isPickable: undefined | boolean;
          useInstances: undefined | boolean;
      } = {}
      • isPickable: undefined | boolean
      • useInstances: undefined | boolean

    Returns ObjectCloner

Properties

_clones: CMesh[]
_count: undefined | number
_effectors: IEffector[] = []
_frame: number
_index: number
_instance_nr: number
_mesh: Mesh[] = []
_normals: Vector3[]
_positions: Vector3[]
_rootNode: null | Mesh = null
_scene: Scene
_template: Mesh
_useInstances: boolean = true
isPickable: boolean
instance_nr: number
vOne: Vector3 = ...
vZero: Vector3 = ...

Accessors

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

  • 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

Methods

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

    Parameters

    Returns void

  • Parameters

    • _parent: Mesh

    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[]