UNPKG

bp-cloner

Version:

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

118 lines (117 loc) 4.34 kB
import { Cloner, CMesh } from './core'; import { Scene } from '@babylonjs/core/scene'; import { Mesh } from '@babylonjs/core/Meshes/'; /** * 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. */ export declare class LinearCloner extends Cloner { static instance_nr: number; private _useInstances; private _offset; private _P; private _R; private _S; private _iModeRelative; private _growth; private _instance_nr; private _countNumberGen; private isPickable; constructor(mesh: Array<Mesh>, scene: Scene, { count, offset, growth, useInstances, P, S, R, iModeRelative, isPickable, }?: { count?: number | undefined; offset?: number | undefined; growth?: number | undefined; useInstances?: boolean | undefined; P?: { x: number; y: number; z: number; } | undefined; S?: { x: number; y: number; z: number; } | undefined; R?: { x: number; y: number; z: number; } | undefined; iModeRelative?: boolean | undefined; isPickable?: boolean | undefined; }); createClone(parent: CMesh): Mesh | null; private createClones; private calcSize; private calcPos; private calcRot; update(): void; recalc(): void; get growth(): number; set growth(g: number); /** * Deletes all Cloner's children and disposes the root Node. */ delete(): void; set count(scnt: number | undefined); get count(): number | undefined; set iModeRel(mode: boolean); set position(pos: { x: number; y: number; z: number; }); get position(): { x: number; y: number; z: number; }; set scale(s: { x: number; y: number; z: number; }); get scale(): { x: number; y: number; z: number; }; set rotation(r: { x: number; y: number; z: number; }); get rotation(): { x: number; y: number; z: number; }; set offset(o: number); get offset(): number; /** * 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; /** * Gets the array of source meshes used in Cloner. */ get meshes(): Mesh[]; }