Skip to content

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.

new AlphaMap(data, width, height): AlphaMap

Defined in: packages/three-flatland/src/events/AlphaMap.ts:59

Uint8Array

Alpha values, row-major from the top (canvas pixel order).

number

number

AlphaMap

readonly data: Uint8Array

Defined in: packages/three-flatland/src/events/AlphaMap.ts:61

Alpha values, row-major from the top (canvas pixel order).


readonly height: number

Defined in: packages/three-flatland/src/events/AlphaMap.ts:63


readonly width: number

Defined in: packages/three-flatland/src/events/AlphaMap.ts:62

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.

number

number

number


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.width
atlasV = frame.y + localV * frame.height

This 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.

number

number

AtlasRect

number


static fromTexture(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.

Texture 

AlphaMap | null