AlphaMap
Defined in: packages/three-flatland/src/events/AlphaMap.ts:58
CPU-side alpha-channel store for pixel-perfect hit testing
(hitTestMode: 'alpha'). 1 byte per pixel.
Spec §10: populated from a baked .alpha.png sidecar when present;
fromTexture is the runtime readback fallback.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AlphaMap(
data,width,height):AlphaMap
Defined in: packages/three-flatland/src/events/AlphaMap.ts:59
Parameters
Section titled “Parameters”Uint8Array
Alpha values, row-major from the top (canvas pixel order).
number
height
Section titled “height”number
Returns
Section titled “Returns”AlphaMap
Properties
Section titled “Properties”
readonlydata:Uint8Array
Defined in: packages/three-flatland/src/events/AlphaMap.ts:61
Alpha values, row-major from the top (canvas pixel order).
height
Section titled “height”
readonlyheight:number
Defined in: packages/three-flatland/src/events/AlphaMap.ts:63
readonlywidth:number
Defined in: packages/three-flatland/src/events/AlphaMap.ts:62
Methods
Section titled “Methods”sampleAtlasUV()
Section titled “sampleAtlasUV()”sampleAtlasUV(
u,v):number
Defined in: packages/three-flatland/src/events/AlphaMap.ts:67
Sample at atlas UV (0–1, bottom-left origin). Returns 0–255.
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”number
sampleFrame()
Section titled “sampleFrame()”sampleFrame(
localU,localV,frame):number
Defined in: packages/three-flatland/src/events/AlphaMap.ts:89
Sample at sprite-local UV (0–1 within the frame quad). Returns 0–255.
Maps localUV through the frame rect with the same linear transform
the renderer uses:
atlasU = frame.x + localU * frame.widthatlasV = frame.y + localV * frame.heightThis is intentionally identical to Sprite2DMaterial._buildBaseColor’s
TSL expression flippedUV.mul(instanceUV.zw).add(instanceUV.xy).
Neither the shader nor this method applies rotation or trim-offset
corrections — see the AtlasRect interface for the full rationale.
Parameters
Section titled “Parameters”localU
Section titled “localU”number
localV
Section titled “localV”number
AtlasRect
Returns
Section titled “Returns”number
fromTexture()
Section titled “fromTexture()”
staticfromTexture(texture):AlphaMap|null
Defined in: packages/three-flatland/src/events/AlphaMap.ts:99
Runtime fallback: extract the alpha channel from a loaded texture via canvas readback. Synchronous and main-thread — prefer the baked sidecar (spec §10). Returns null when the image is missing or the canvas is tainted.
Parameters
Section titled “Parameters”texture
Section titled “texture”Returns
Section titled “Returns”AlphaMap | null