62 lines
2.3 KiB
JavaScript
62 lines
2.3 KiB
JavaScript
shadow$provide.module$node_modules$pixi_DOT_js$lib$utils$misc$Transform = function(global, require, module, exports) {
|
|
var Matrix = require("module$node_modules$pixi_DOT_js$lib$maths$matrix$Matrix"), ObservablePoint = require("module$node_modules$pixi_DOT_js$lib$maths$point$ObservablePoint");
|
|
"use strict";
|
|
class Transform {
|
|
constructor({matrix, observer} = {}) {
|
|
this.dirty = !0;
|
|
this._matrix = matrix ?? new Matrix.Matrix();
|
|
this.observer = observer;
|
|
this.position = new ObservablePoint.ObservablePoint(this, 0, 0);
|
|
this.scale = new ObservablePoint.ObservablePoint(this, 1, 1);
|
|
this.pivot = new ObservablePoint.ObservablePoint(this, 0, 0);
|
|
this.skew = new ObservablePoint.ObservablePoint(this, 0, 0);
|
|
this._rotation = 0;
|
|
this._cx = 1;
|
|
this._cy = this._sx = 0;
|
|
this._sy = 1;
|
|
}
|
|
get matrix() {
|
|
const lt = this._matrix;
|
|
if (!this.dirty) {
|
|
return lt;
|
|
}
|
|
lt.a = this._cx * this.scale.x;
|
|
lt.b = this._sx * this.scale.x;
|
|
lt.c = this._cy * this.scale.y;
|
|
lt.d = this._sy * this.scale.y;
|
|
lt.tx = this.position.x - (this.pivot.x * lt.a + this.pivot.y * lt.c);
|
|
lt.ty = this.position.y - (this.pivot.x * lt.b + this.pivot.y * lt.d);
|
|
this.dirty = !1;
|
|
return lt;
|
|
}
|
|
_onUpdate(point) {
|
|
this.dirty = !0;
|
|
point === this.skew && this.updateSkew();
|
|
this.observer?._onUpdate(this);
|
|
}
|
|
updateSkew() {
|
|
this._cx = Math.cos(this._rotation + this.skew.y);
|
|
this._sx = Math.sin(this._rotation + this.skew.y);
|
|
this._cy = -Math.sin(this._rotation - this.skew.x);
|
|
this._sy = Math.cos(this._rotation - this.skew.x);
|
|
this.dirty = !0;
|
|
}
|
|
toString() {
|
|
return `[pixi.js/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`;
|
|
}
|
|
setFromMatrix(matrix) {
|
|
matrix.decompose(this);
|
|
this.dirty = !0;
|
|
}
|
|
get rotation() {
|
|
return this._rotation;
|
|
}
|
|
set rotation(value) {
|
|
this._rotation !== value && (this._rotation = value, this._onUpdate(this.skew));
|
|
}
|
|
}
|
|
exports.Transform = Transform;
|
|
};
|
|
|
|
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$utils$misc$Transform.js.map
|