UNPKG

bp-cloner

Version:

More info and explanations here - https://doc.babylonjs.com/communityExtensions/clonerSystem

79 lines (78 loc) 2.96 kB
import { Cloner, CMesh } from './core'; import { Scene } from '@babylonjs/core/scene'; import { Mesh } from '@babylonjs/core/Meshes/'; export interface ICSVector3 { readonly x: number; readonly y: number; readonly z: number; } /** * The MatrixCloner clones and distributes given meshes in 3D space. If more than one mesh is provided, then the corresponding clones will be placed subsequently one after another starting in the x direction followed by y and z direction. * The MatrixCloner 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 middle position of all generated clones. Transforming this root affects all underlying clones (childs) at once. * The given input meshes will be made inactive during construction. * @param mesh The array of meshes/cloners to be cloned, meshes will be made inactive after construction. * @param scene Babylon scene. * @param mcount The number of clones in x,y and z direction. Default { x: 3, y: 3, z: 3 }. * @param size The distance from one clone to another in x,y and z direction. Default { x: 2, y: 2, z: 2 }. * @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. */ export declare class MatrixCloner extends Cloner { static instance_nr: number; private _useInstances; private _size; private _mcount; private _iModeRelative; private _instance_nr; private isPickable; constructor(mesh: Array<Mesh>, scene: Scene, { useInstances, mcount, size, iModeRelative, isPickable, }?: { useInstances?: boolean | undefined; mcount?: { x: number; y: number; z: number; } | undefined; size?: { x: number; y: number; z: number; } | undefined; iModeRelative?: boolean | undefined; isPickable?: boolean | undefined; }); createClone(parent: CMesh): Mesh | null; private createClones; /** * Sets the number of instances / clones in x, y and z directions. */ set mcount(m: ICSVector3); get mcount(): ICSVector3; get state(): { mcount: { x: number; y: number; z: number; }; size: { x: number; y: number; z: number; }; }; set size(s: ICSVector3); get size(): ICSVector3; private calcRot; private calcSize; private calcPos; /** * 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. */ get root(): Mesh | null; /** * Deletes all Cloner's children and disposes the root Node. */ delete(): void; update(): void; }