import { Blending, InstancedBufferGeometry, Mesh, ShaderMaterial, Side, Texture, Vector2, Vector3 } from 'three'; import { Emitter } from './Emitter'; import { IDefinesBooleanPropKeys, IEmitterOptions, IGroupOptions, IShaderAttributeKeyArray, IShaderAttributes, IUniforms } from './types'; export declare const valueOverLifetimeLength = 4; /** * An EmitterGroup instance. * @typedef {Object} EmitterGroup * @see EmitterGroup */ /** * A map of options to configure an EmitterGroup instance. * @typedef {Object} GroupOptions * * @property {Object} texture An object describing the texture used by the group. * * @property {Object} texture.value An instance of THREE.Texture. * * @property {Object=} texture.frames A THREE.Vector2 instance describing the number * of frames on the x- and y-axis of the given texture. * If not provided, the texture will NOT be treated as * a sprite-sheet and as such will NOT be animated. * * @property {Number} [texture.frameCount=texture.frames.x * texture.frames.y] The total number of frames in the sprite-sheet. * Allows for sprite-sheets that don't fill the entire * texture. * * @property {Number} texture.loop The number of loops through the sprite-sheet that should * be performed over the course of a single particle's lifetime. * * @property {Number} fixedTimeStep If no `dt` (or `deltaTime`) value is passed to this group's * `tick()` function, this number will be used to move the particle * simulation forward. Value in SECONDS. * * @property {Boolean} hasPerspective Whether the distance a particle is from the camera should affect * the particle's size. * * @property {Boolean} colorize Whether the particles in this group should be rendered with color, or * whether the only color of particles will come from the provided texture. * * @property {Number} blending One of Three.js's blending modes to apply to this group's `ShaderMaterial`. * * @property {Boolean} transparent Whether these particle's should be rendered with transparency. * * @property {Number} alphaTest Sets the alpha value to be used when running an alpha test on the `texture.value` property. Value between 0 and 1. * * @property {Boolean} depthWrite Whether rendering the group has any effect on the depth buffer. * * @property {Boolean} depthTest Whether to have depth test enabled when rendering this group. * * @property {Boolean} fog Whether this group's particles should be affected by their scene's fog. * * @property {Number} scale The scale factor to apply to this group's particle sizes. Useful for * setting particle sizes to be relative to renderer size. * * @property {Boolean} [frustumCulled=true] If set to false, the emitter mesh will be culled if outside * of the camera frustum. Default is true. * * @property {String} [billboard=undefined] If set, particles will be billobarded. Options are 'spherical' | 'directional' | 'cylindrical'; */ /** * The EmitterGroup class. Creates a new group, containing a material, geometry, and mesh. */ export declare class EmitterGroup { uuid: string; fixedTimeStep: number; worldSpace: boolean; private _texture; set texture(texture: Texture | null); get texture(): Texture | null; set alphaTest(value: number); get alphaTest(): number; set transparent(value: boolean); get transparent(): boolean; set depthWrite(value: boolean); get depthWrite(): boolean; set depthTest(value: boolean); get depthTest(): boolean; set blending(value: Blending); get blending(): Blending; set fog(value: boolean); get fog(): boolean; set side(value: Side); get side(): Side; set hasPerspective(value: boolean); get hasPerspective(): boolean; set colorize(value: boolean); get colorize(): boolean; set scale(value: number); get scale(): number; set frustumCulled(value: boolean); get frustumCulled(): boolean; textureFrames: Vector2; textureFrameCount: number; textureLoop: number; private _hasPerspective; billboard?: 'spherical' | 'directional' | 'cylindrical'; /** * @deprecated Use `rotation axisSpread` parameter setter directly on the emitters instead. */ randomParticleRotationAngle?: number; private _colorize; maxParticleCount: number | null; private _blending; private _transparent; private _alphaTest; private _depthWrite; private _depthTest; private _fog; private _side; private _scale; emitters: Emitter[]; emitterIDs: string[]; particleCount: number; uniforms: IUniforms; defines: Record & { VALUE_OVER_LIFETIME_LENGTH: number; }; attributes: IShaderAttributes; attributeKeys: IShaderAttributeKeyArray; attributeCount: number; material: ShaderMaterial; geometry: InstancedBufferGeometry; mesh: Mesh; private _pool; private _poolCreationSettings; private _createNewWhenPoolEmpty; attributesNeedRefresh: boolean; private _attributesNeedDynamicReset; constructor(options: IGroupOptions); updateDefines: () => void; private _applyAttributesToGeometry; /** * Adds an Emitter instance to this group, creating particle values and * assigning them to this group's shader attributes. * * @param {Emitter} Emitter The emitter to add to this group. */ addEmitter: (emitter: Emitter) => this | undefined; /** * Removes an Emitter instance from this group. When called, * all particle's belonging to the given emitter will be instantly * removed from the scene. * * @param {Emitter} emitter The emitter to add to this group. */ removeEmitter: (emitter: Emitter) => void; /** * Fetch a single emitter instance from the pool. * If there are no objects in the pool, a new emitter will be * created if specified. * * @return {Emitter|null} */ getFromPool: () => Emitter | null | undefined; /** * Release an emitter into the pool. * * @param {ShaderEmitter} emitter * @return {Group} This group instance. */ releaseIntoPool: (emitter: Emitter) => this | undefined; /** * Get the pool array * * @return {Array} */ getPool: () => Emitter[]; /** * Add a pool of emitters to this particle group * * @param {Number} numEmitters The number of emitters to add to the pool. * @param {EmitterOptions|Array} emitterOptions An object, or array of objects, describing the options to pass to each emitter. * @param {Boolean} createNew Should a new emitter be created if the pool runs out? * @return {Group} This group instance. */ addPool: (numEmitters: number, emitterOptions: IEmitterOptions, createNew: boolean) => this; private _triggerSingleEmitter; /** * Set a given number of emitters as alive, with an optional position * vector3 to move them to. * * @param {Number} numEmitters The number of emitters to activate * @param {Object} [position=undefined] A THREE.Vector3 instance describing the position to activate the emitter(s) at. * @return {Group} This group instance. */ triggerPoolEmitter: (numEmitters: number, position: Vector3) => this; private _updateUniforms; private _resetBufferRanges; private _updateBuffers; /** * Simulate all the emitter's belonging to this group, updating * attribute values along the way. * @param {Number} [dt=Group's `fixedTimeStep` value] The number of seconds to simulate the group's emitters for (deltaTime) */ tick: (dt?: number) => void; /** * Dipose the geometry and material for the group. * * @return {Group} Group instance. */ dispose: () => this; }