Sampler
The Sampler Filter Controller.
This controller manages a sampler.
It doesn't actually render anything, and leaves the image unaltered.
It is used to sample a region of the camera view, and pass the results to a callback.
This is useful for extracting data from the camera view.
This operation is expensive, so use sparingly.
A Sampler is added to a Camera via the FilterList component:
const camera = this.cameras.main;
camera.filters.internal.addSampler(callback, region);
camera.filters.external.addSampler(callback, region);
Constructor
new Sampler(camera, callback, [region])
Parameters
| name | type | optional | default | description |
|---|---|---|---|---|
| camera | Phaser.Cameras.Scene2D.Camera | No | The Camera that owns this filter. | |
| callback | Phaser.Types.Renderer.Snapshot.SnapshotCallback | No | The callback to call with the results of the sampler. | |
| region | null | Phaser.Types.Math.Vector2Like | Phaser.Geom.Rectangle | Yes | null |
Scope: static
Extends
Source: src/filters/Sampler.js#L10
Since: 4.0.0
Inherited Members
From Phaser.Filters.Controller:
Public Members
callback
callback: Phaser.Types.Renderer.Snapshot.SnapshotCallback
Description:
The callback to call with the results of the sampler.
Source: src/filters/Sampler.js#L50
Since: 4.0.0
region
region: null, Phaser.Types.Math.Vector2Like, Phaser.Geom.Rectangle
Description:
The region to sample. If null, the entire camera view is sampled.
If a Phaser.Types.Math.Vector2Like, a point is sampled.
If a Phaser.Geom.Rectangle, the region is sampled.
Source: src/filters/Sampler.js#L59
Inherited Methods
From Phaser.Filters.Controller: