Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/pixi-augmentations.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'pixi.js';

/**
* `ExtendedSprite` caches a texture's alpha channel on the texture source itself,
* so a pixel-perfect hit test does not have to re-read the pixels on every mouse
* move: `hitMap` holds the bytes, `hitMapDirty` says they need regenerating, and
* `hitMapTime` throttles how often that happens. `GraphicAssetPalette` fills the
* same fields when it bakes a recoloured texture, and `TexturePool` deletes them
* when it recycles or destroys one.
*
* None of the three belongs to PixiJS, so every one of those reads and writes
* used to sit behind a `@ts-ignore`. That silences the whole line rather than the
* one unknown property, which is why they were removed - declaring the fields
* here does the same job without hiding anything else on those lines.
*
* All three are optional because `TexturePool` `delete`s them and `ExtendedSprite`
* reads `hitMapTime` through `?? 0`.
*
* This file must stay a module - it imports 'pixi.js' for exactly that reason.
* In a global script `declare module 'pixi.js'` would declare an ambient module
* and shadow the real types instead of adding to them. The type parameter list
* has to match the class declaration exactly, or the merge is rejected.
*/
declare module 'pixi.js'
{
interface TextureSource<T extends Record<string, any> = any>
{
hitMap?: Uint8Array | Uint8ClampedArray;
hitMapDirty?: boolean;
hitMapTime?: number;
}
}