import { Color, Vector2, Vector3 } from 'three'; import { MersenneTwister } from './MersenneTwister'; import ShaderAttribute from './ShaderAttribute'; export declare const mersenneGenerator: MersenneTwister; /** * A bunch of utility functions used throughout the library. * @namespace * @type {Object} */ export declare const utils: { /** * Ensures that any "value-over-lifetime" properties of an emitter are * of the correct length (as dictated by `valueOverLifetimeLength`). * * Delegates to `utils.interpolateArray` for array resizing. * * If properties aren't arrays, then property values are put into one. * * @param {Object} property The property of an ParticleEmitter instance to check compliance of. * @param {Number} minLength The minimum length of the array to create. * @param {Number} maxLength The maximum length of the array to create. */ ensureValueOverLifetimeCompliance: (property: any, minLength: number, maxLength: number) => void; /** * Performs linear interpolation (lerp) on an array. * * For example, lerping [1, 10], with a `newLength` of 10 will produce [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]. * * Delegates to `utils.lerpTypeAgnostic` to perform the actual * interpolation. * * @param {Array} srcArray The array to lerp. * @param {Number} newLength The length the array should be interpolated to. * @return {Array} The interpolated array. */ interpolateArray: (srcArray: Array, newLength: number) => any[]; /** * Clamp a number to between the given min and max values. * @param {Number} value The number to clamp. * @param {Number} min The minimum value. * @param {Number} max The maximum value. * @return {Number} The clamped number. */ clamp: (value: number, min: number, max: number) => number; /** * Linearly interpolates two values of various types. The given values * must be of the same type for the interpolation to work. * @param {(number|Object)} start The start value of the lerp. * @param {(number|object)} end The end value of the lerp. * @param {Number} delta The delta posiiton of the lerp operation. Ideally between 0 and 1 (inclusive). * @return {(number|object|undefined)} The result of the operation. Result will be undefined if * the start and end arguments aren't a supported type, or * if their types do not match. */ lerpTypeAgnostic: (start: number | Vector2 | Vector3 | Color, end: number | Vector2 | Vector3 | Color, delta: number) => number | Color | Vector3 | Vector2 | undefined; /** * Perform a linear interpolation operation on two numbers. * @param {Number} start The start value. * @param {Number} end The end value. * @param {Number} delta The position to interpolate to. * @return {Number} The result of the lerp operation. */ lerp: (start: number, end: number, delta: number) => number; /** * Rounds a number to a nearest multiple. * * @param {Number} n The number to round. * @param {Number} multiple The multiple to round to. * @return {Number} The result of the round operation. */ roundToNearestMultiple: (n: number, multiple: number) => number; /** * Check if all items in an array are equal. Uses strict equality. * * @param {Array} array The array of values to check equality of. * @return {Boolean} Whether the array's values are all equal or not. */ arrayValuesAreEqual: (array: Array) => boolean; /** * Given a start value and a spread value, create and return a random * number. * @param {Number} base The start value. * @param {Number} spread The size of the random variance to apply. * @return {Number} A randomised number. */ randomFloat: (base: number, spread: number) => number; /** * Given an ShaderAttribute instance, and various other settings, * assign values to the attribute's array in a `vec3` format. * * @param {Object} attribute The instance of ShaderAttribute to save the result to. * @param {Number} index The offset in the attribute's TypedArray to save the result from. * @param {Object} base THREE.Vector3 instance describing the start value. * @param {Object} spread THREE.Vector3 instance describing the random variance to apply to the start value. * @param {Object} spreadClamp THREE.Vector3 instance describing the multiples to clamp the randomness to. */ randomVector3: (attribute: ShaderAttribute, index: number, base: Vector3, spread: Vector3, spreadClamp?: Vector3) => void; randomColorAsHex: (attribute: ShaderAttribute, index: number, base: Color[], spread: Vector3[]) => void; /** * Given an ShaderAttribute instance, and various other settings, * assign values to the attribute's array in a `vec3` format. * * @param {Object} attribute The instance of ShaderAttribute to save the result to. * @param {Number} index The offset in the attribute's TypedArray to save the result from. * @param {Object} start THREE.Vector3 instance describing the start line position. * @param {Object} end THREE.Vector3 instance describing the end line position. */ randomVector3OnLine: (attribute: ShaderAttribute, index: number, start: Vector3, end: Vector3) => void; /** * Assigns a random vector 3 value to an ShaderAttribute instance, projecting the * given values onto a sphere. * * @param {Object} attribute The instance of ShaderAttribute to save the result to. * @param {Number} index The offset in the attribute's TypedArray to save the result from. * @param {Object} base THREE.Vector3 instance describing the origin of the transform. * @param {Number} radius The radius of the sphere to project onto. * @param {Number} radiusSpread The amount of randomness to apply to the projection result * @param {Object} radiusScale THREE.Vector3 instance describing the scale of each axis of the sphere. * @param {Number} radiusSpreadClamp What numeric multiple the projected value should be clamped to. */ randomVector3OnSphere: (attribute: ShaderAttribute, index: number, base: Vector3, radius: number, radiusSpread: number, radiusScale: Vector3, radiusSpreadClamp: number) => void; /** * Assigns a random vector 3 value to an ShaderAttribute instance, projecting the * given values onto a 2d-disc. * * @param {Object} attribute The instance of ShaderAttribute to save the result to. * @param {Number} index The offset in the attribute's TypedArray to save the result from. * @param {Object} base THREE.Vector3 instance describing the origin of the transform. * @param {Number} radius The radius of the sphere to project onto. * @param {Number} radiusSpread The amount of randomness to apply to the projection result * @param {Object} radiusScale THREE.Vector3 instance describing the scale of each axis of the disc. The z-component is ignored. * @param {Number} radiusSpreadClamp What numeric multiple the projected value should be clamped to. */ randomVector3OnDisc: (attribute: ShaderAttribute, index: number, base: Vector3, radius: number, radiusSpread: number, radiusScale: Vector3, radiusSpreadClamp: number) => void; randomDirectionVector3OnSphere: (attribute: ShaderAttribute, index: number, posX: number, posY: number, posZ: number, emitterPosition: Vector3, speed: number, speedSpread: number) => void; randomDirectionVector3OnDisc: (attribute: ShaderAttribute, index: number, posX: number, posY: number, posZ: number, emitterPosition: Vector3, speed: number, speedSpread: number) => void; getPackedRotationAxis: (axis: Vector3, axisSpread: Vector3) => number; };