import { IShapeBaseSettings, IShapeBounding, TVertexCallback, ISceneChildProps, IStreamArguments, IBufferIndex, IBaseRepetition, IRepetition, IPropArguments, EBoundingType } from '../types'; import { SceneChild } from '../SceneChild'; /** * Main class for shape generation * * @category Scene * @abstract * @class ShapeBase * @order 4 * @extends {SceneChild} */ declare abstract class ShapeBase = ISceneChildProps> extends SceneChild { /** * Empty buffer * * @internal * @ignore */ static readonly EMPTY_BUFFER: Float32Array; /** * Empty BaseRepetition * * @internal * @ignore */ static getEmptySimpleRepetition: () => IBaseRepetition; /** * Empty Repetition * * @internal * @ignore */ static getEmptyRepetition: () => IRepetition; /** * Props */ protected props: Props; /** * A final array of vertices to draw * * @internal * @ignore */ protected buffer?: Float32Array; /** * Determine if shape are static and doon't need generate at eachtime * * @internal * @ignore */ protected bStatic: boolean; /** * Determine if shape have static indexed buffer * * @internal * @ignore */ protected bStaticIndexed: boolean; /** * Flag used to determine if indexedBuffer has been generated * * @internal * @ignore */ protected bIndexed: boolean; /** * Array used for index a vertex buffer * only for first level scene children * * @internal * @ignore */ protected indexedBuffer: Array; /** * Callback to apply transform at any vertex * * @example * ```javascript * // vertexCallback example * // Generate lines with noise * * const line = new Urpflanze.Line({ * repetitions: [1, 50], * distance: [0, 4], * sideLength: ({ context, shape }) => context.percW(40, shape), // <- make the shape non-static * vertexCallback: (vertex, { repetition, context, time }, vertex_repetition) => { * const noise = context.noise('seed', vertex_repetition.offset * 2, repetition.row.offset * 2, time / 1000) * vertex[0] += noise * 10 * vertex[1] += noise * 10 * }, * }) * * line.subdivide(5) * ``` */ vertexCallback?: TVertexCallback; /** * Anchor point for draw shape, default center */ anchor: [number, number]; /** * Used for apply transformation * * @type {EBoundingType} */ boundingType?: EBoundingType; /** * The bounding inside the scene * * @type {IShapeBounding} */ bounding: IShapeBounding; /** * Creates an instance of ShapeBase * * @param {ISceneChildSettings} [settings={}] */ constructor(settings?: IShapeBaseSettings); /** * Check if the shape should be generated every time * * @returns {boolean} */ isStatic(): boolean; /** * Check if the indexedBuffer array needs to be recreated every time, * this can happen when a shape generates an array of vertices different in length at each repetition * * @returns {boolean} */ isStaticIndexed(): boolean; /** * Return a prop value * * @param {keyof ISceneChildProps} key * @param {PropArguments} [propArguments] * @param {*} [defaultValue] * @returns {*} */ getProp(key: G, propArguments?: PropArguments, defaultValue?: number | [number, number]): any; /** * Set a single or multiple props * * @param {(keyof ISceneChildProps | ISceneChildProps)} key * @param {*} [value] * @param {boolean} [bClearIndexed=false] */ setProp(key: keyof Props | Partial, value?: any, bClearIndexed?: boolean): void; /** * Unset buffer * * @param {boolean} [bClearIndexed=false] * @param {boolean} [bPropagateToParents=false] * @param {boolean} [bPropagateToChildren=false] */ clearBuffer(bClearIndexed?: boolean, bPropagateToParents?: boolean): void; /** * Update the vertex array if the shape is not static and update the indexedBuffer if it is also not static * * @param {number} generateId generation id * @param {boolean} [bDirectSceneChild=false] adjust shape of center of scene * @param {PropArguments} [parentPropArguments] */ generate(generateId?: number, bDirectSceneChild?: boolean, parentPropArguments?: PropArguments): void; /** * * * @param {number} generateId * @return {*} {boolean} */ isGenerated(generateId: number): boolean; /** * Return current shape (whit repetions) bounding * * @return {*} {IShapeBounding} */ getBounding(): IShapeBounding; /** * Return a single shape bounding * * @abstract * @return {*} {IShapeBounding} */ abstract getShapeBounding(): IShapeBounding; /** * Add into indexedBuffer * * @protected * @abstract * @param {number} frameLength * @param {IRepetition} currentRepetition * @param {IShapeBounding} singleRepetitionBounding * @returns {number} nextIndex */ protected abstract addIndex(frameLength: number, currentRepetition: IRepetition, singleRepetitionBounding: IShapeBounding): void; /** * Get number of repetitions * * @returns {number} */ getRepetitionCount(): number; /** * Return a buffer of children shape or loop generated buffer * * @protected * @param {number} generateId * @param {PropArguments} propArguments * @returns {Float32Array} */ protected abstract generateBuffer(generateId: number, propArguments: PropArguments): Float32Array; /** * * * @abstract * @param {(any)} shapeOrLoopOrBuffer */ abstract setShape(shapeOrLoopOrBuffer: any): void; /** * Return buffer * * @returns {(Float32Array | undefined)} */ getBuffer(): Float32Array | undefined; /** * Return indexed buffer * * @returns {(Array> | undefined)} */ getIndexedBuffer(): Array; /** * Return number of encapsulation * * @param {IBufferIndex} index * @returns {number} */ static getIndexParentLevel(index: IBufferIndex): number; /** * Stream buffer * * @param {(TStreamCallback} callback */ stream(callback: (streamArguments: IStreamArguments) => void): void; /** * Return empty propArguments * * @static * @param {ShapeBase} shape * @return {*} {PropArguments} */ static getEmptyPropArguments(shape: ShapeBase, parentPropArguments?: IPropArguments): IPropArguments; } export { ShapeBase }; //# sourceMappingURL=ShapeBase.d.ts.map