UNPKG

2.75 kBTypeScriptView Raw
1import { Matrix } from '@pixi/math';
2import type { Texture } from './Texture';
3/**
4 * Class controls uv mapping from Texture normal space to BaseTexture normal space.
5 *
6 * Takes `trim` and `rotate` into account. May contain clamp settings for Meshes and TilingSprite.
7 *
8 * Can be used in Texture `uvMatrix` field, or separately, you can use different clamp settings on the same texture.
9 * If you want to add support for texture region of certain feature or filter, that's what you're looking for.
10 *
11 * Takes track of Texture changes through `_lastTextureID` private field.
12 * Use `update()` method call to track it from outside.
13 * @see PIXI.Texture
14 * @see PIXI.Mesh
15 * @see PIXI.TilingSprite
16 * @memberof PIXI
17 */
18export declare class TextureMatrix {
19 /**
20 * Matrix operation that converts texture region coords to texture coords
21 * @readonly
22 */
23 mapCoord: Matrix;
24 /**
25 * Changes frame clamping
26 * Works with TilingSprite and Mesh
27 * Change to 1.5 if you texture has repeated right and bottom lines, that leads to smoother borders
28 * @default 0
29 */
30 clampOffset: number;
31 /**
32 * Changes frame clamping
33 * Works with TilingSprite and Mesh
34 * Change to -0.5 to add a pixel to the edge, recommended for transparent trimmed textures in atlas
35 * @default 0.5
36 */
37 clampMargin: number;
38 /**
39 * Clamp region for normalized coords, left-top pixel center in xy , bottom-right in zw.
40 * Calculated based on clampOffset.
41 */
42 readonly uClampFrame: Float32Array;
43 /** Normalized clamp offset. Calculated based on clampOffset. */
44 readonly uClampOffset: Float32Array;
45 /**
46 * Tracks Texture frame changes.
47 * @protected
48 */
49 _textureID: number;
50 /**
51 * Tracks Texture frame changes.
52 * @protected
53 */
54 _updateID: number;
55 _texture: Texture;
56 /**
57 * If texture size is the same as baseTexture.
58 * @default false
59 * @readonly
60 */
61 isSimple: boolean;
62 /**
63 * @param texture - observed texture
64 * @param clampMargin - Changes frame clamping, 0.5 by default. Use -0.5 for extra border.
65 */
66 constructor(texture: Texture, clampMargin?: number);
67 /** Texture property. */
68 get texture(): Texture;
69 set texture(value: Texture);
70 /**
71 * Multiplies uvs array to transform
72 * @param uvs - mesh uvs
73 * @param [out=uvs] - output
74 * @returns - output
75 */
76 multiplyUvs(uvs: Float32Array, out?: Float32Array): Float32Array;
77 /**
78 * Updates matrices if texture was changed.
79 * @param [forceUpdate=false] - if true, matrices will be updated any case
80 * @returns - Whether or not it was updated
81 */
82 update(forceUpdate?: boolean): boolean;
83}