mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[ts][pixi] Use pixi coordinate transformation functions
This commit is contained in:
parent
96797adeb5
commit
8e20a5e02b
@ -400,32 +400,12 @@ export class Spine extends Container {
|
|||||||
|
|
||||||
/** Converts a point from the skeleton coordinate system to the Pixi world coordinate system. */
|
/** Converts a point from the skeleton coordinate system to the Pixi world coordinate system. */
|
||||||
skeletonToPixiWorldCoordinates (point: { x: number; y: number }) {
|
skeletonToPixiWorldCoordinates (point: { x: number; y: number }) {
|
||||||
let transform = this.worldTransform;
|
this.worldTransform.apply(point, point);
|
||||||
let a = transform.a,
|
|
||||||
b = transform.b,
|
|
||||||
c = transform.c,
|
|
||||||
d = transform.d,
|
|
||||||
tx = transform.tx,
|
|
||||||
ty = transform.ty;
|
|
||||||
let x = point.x;
|
|
||||||
let y = point.y;
|
|
||||||
point.x = x * a + y * c + tx;
|
|
||||||
point.y = x * b + y * d + ty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Converts a point from the Pixi world coordinate system to the skeleton coordinate system. */
|
/** Converts a point from the Pixi world coordinate system to the skeleton coordinate system. */
|
||||||
pixiWorldCoordinatesToSkeleton (point: { x: number; y: number }) {
|
pixiWorldCoordinatesToSkeleton (point: { x: number; y: number }) {
|
||||||
let transform = this.worldTransform.clone().invert();
|
this.worldTransform.applyInverse(point, point);
|
||||||
let a = transform.a,
|
|
||||||
b = transform.b,
|
|
||||||
c = transform.c,
|
|
||||||
d = transform.d,
|
|
||||||
tx = transform.tx,
|
|
||||||
ty = transform.ty;
|
|
||||||
let x = point.x;
|
|
||||||
let y = point.y;
|
|
||||||
point.x = x * a + y * c + tx;
|
|
||||||
point.y = x * b + y * d + ty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Converts a point from the Pixi world coordinate system to the bone's local coordinate system. */
|
/** Converts a point from the Pixi world coordinate system to the bone's local coordinate system. */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user