name: pixijs-math description: "Use for PixiJS v8 math: Point, ObservablePoint, Matrix, Rectangle, Circle, Ellipse, Polygon, Triangle, hit testing, bounds, toGlobal/toLocal, math-extras." license: MIT
Use this for coordinates, affine transforms, geometry shapes, hit tests, and layout rectangles.
Fast Path
import { Point, Rectangle } from 'pixi.js';
const local = container.toLocal(event.global);
const hit = new Rectangle(0, 0, 120, 80).contains(local.x, local.y);
Rules
- Import math classes from
pixi.js, not@pixi/math. - Use
Container.toGlobal/toLocalfor scene coordinates; useMatrix.apply/applyInversefor raw affine transforms. ObservablePointnotifies owners onset,copyFrom, and property mutation; avoid bypassing its setters.Rectangle,Circle,Ellipse,Polygon,RoundedRectangle, andTriangleare useful forhitArea, culling, bounds, and layout.- Import
pixi.js/math-extrasbefore using extended vector/rectangle helpers. - Treat reused temporary objects as mutable; copy values if you need stable snapshots.
Deep Reads
- Full examples for
Point,Matrix, shapes, constants, and math-extras: references/details.md - Transform model:
pixijs-scene-core-concepts/references/transforms.md - Event hit areas:
pixijs-events
Common Fixes
- Wrong package: replace
@pixi/mathimports withpixi.js. - Extended method missing: add
import 'pixi.js/math-extras';once before use. - Hit test in wrong space: convert event global coordinates into the object's local space first.