Particle layer
Extended version of Intensity layer, which does particle-based animation on top the data. The standard raster visualization of Intensity layer can be used simultanously over the same data.
Constructor
Extends: Intesity layer
Parameters
options.decodeChannels
default:
"rg" |
Channels to read the UV values from. |
---|---|
options.decodeAsWaves
default: false
|
Decode the channels as "direction + period" rather than "UV".
If true , the first channel is assumed to be direction (0-360deg) and the second to be the period (1/speed).
|
options.decodeMin
default: 0
|
Minimum encoded value. |
options.decodeMax
default: 1
|
Maximum encoded value. |
options.maxAmount
default: 128
|
Quantity of particles to be created.
Has to be a power of 2 and at least 4 .
The actual exact number will be particles * particles .
Try to keep this value as low as possible to optimize performance.
The number of actually visible particles is determined by density.
|
options.color
RgbaColor
default:
[255, 255, 255, 192] |
Color of the particle. RGB[A] - Array of 3-4 numbers. 0-255 per channel. |
options.fastColor
RgbaColor
default: same as color
|
Color of the particle when moving "fast". RGB[A] - Array of 3-4 numbers. 0-255 per channel. |
options.fastSpeed | What is considered "fast" (in px/sec) for coloring purposes. Only makes sense when fastColor is used. |
options.density
default: 2
|
Number of particles visible per 1000 px^2. |
options.drawAsLines
default: false
|
Draw the particles as lines (size is length). |
options.pixelRatio
default: 2 for normal displays and 1 for HiDPI displays
|
Use more pixels to make particles more smooth (especially when tilted). |
options.size
default: 1.5
|
Size of the particle. |
options.speed
default: 0.001
|
Speed factor of the particles. |
options.refreshInterval
default: 800
|
Time interval (in milliseconds) how often the particles are refreshed to avoid degradation.
Random 1/16 of the particles is always randomly reset.
|
options.fadeFactor
default: 0.1
|
How much the particles fade over time. |
options.useAlphaAsMask
default: false
|
If true , the particles will only be displayed where the alpha channel is 255.
This is to be set to true for tilesets that do not cover the entire globe. |
options.angleDirectionShiftSkip
default: 90
|
This angle respresents the change of direction of a particle between a render call and the next.
If a particle changes direction abruptly with an angle greater than angleDirectionShiftSkip , then it is no longer rendered.
A value of 30 (degrees) is a good compromise to reduce the "splashing" effect particle can have on the side of hurricanes at semi-global-scale zoom level.
Default: 90 (no skipping unless the particle changes direction to go backward between two render calls, which is unlikely)
|
options.uniformSpeed
default: false
|
When true , the speed of particles (and trail length) will be the same in number of pixel traveled per second, regardless of the
size of the screen, which is convenient to provide a comparable experience on mobile/desktop.
If disabled, the particles will be slower and with a shorter trail on smalled screen such as mobile.
|
options.fastIsLarger
default: false
|
If this is true , the particles gets slighly larger as they become faster.
|
null
, the same data will also be displayed as raster.
Methods
Check out the Layers method reference
This function is called in the constructor if it receives the options.
This function is useful for initializing a layer with data that comes from an asynchronous function.
For example: used in the onAdd
function of the layer after fetching the data from the MapTiler cloud.
TileLayerOptions
)
: Options specific to the intensity visualization. Same as the layer constructor
ParticleLayerOptions
)
: Options specific to the particle visualization. Same as the layer constructor
ColoringFragmentBase[]
)
: If not null, the same data will also be displayed as raster. Same as the layer constructor
Returns the ratio between the number of actually visible particle (to statisfy the specified density) and the maximum amount (maxAmount).
Value >1 mean that more particles would be utilized if availabe.
Useful for debugging and fine-tuning client application.
number
: ratio between the number of actually visible particle and the maximum amount.