diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 535f833..d140946 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -26,7 +26,7 @@ * World transform and local transform of this object. * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! * - * @member {PIXI.Transform|PIXI.TransformStatic} + * @member {PIXI.TransformBase} */ this.transform = new TransformClass(); diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 535f833..d140946 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -26,7 +26,7 @@ * World transform and local transform of this object. * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! * - * @member {PIXI.Transform|PIXI.TransformStatic} + * @member {PIXI.TransformBase} */ this.transform = new TransformClass(); diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index ce1573c..3a89102 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,28 +1,18 @@ -var math = require('../math'); +var math = require('../math'), + TransformBase = require('./TransformBase'); /** * Generic class to deal with traditional 2D matrix transforms - * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! + * local transformation is calculated from position,scale,skew and rotation * * @class + * @extends PIXI.TransformBase * @memberof PIXI */ function Transform() { - /** - * The global matrix transform. - * - * @member {PIXI.Matrix} - */ - this.worldTransform = new math.Matrix(); - - /** - * The local matrix transform. - * - * @member {PIXI.Matrix} - */ - this.localTransform = new math.Matrix(); + TransformBase.call(this); /** * The coordinate of the object relative to the local coordinates of the parent. @@ -52,7 +42,6 @@ */ this.pivot = new math.Point(0.0); - /** * The rotation value of the object, in radians * @@ -67,13 +56,9 @@ this._sy = Math.sin(0);//skewY); this._nsx = Math.sin(0);//skewX); this._cx = Math.cos(0);//skewX); - - this._dirty = false; - this.updated = true; - - this._worldID = 0; } +Transform.prototype = Object.create(TransformBase.prototype); Transform.prototype.constructor = Transform; Transform.prototype.updateSkew = function () @@ -85,6 +70,24 @@ }; /** + * Updates only local matrix + */ +Transform.prototype.updateLocalTransform = function() { + var lt = this.localTransform; + var a, b, c, d; + + a = this._cr * this.scale.x; + b = this._sr * this.scale.x; + c = -this._sr * this.scale.y; + d = this._cr * this.scale.y; + + lt.a = this._cy * a + this._sy * c; + lt.b = this._cy * b + this._sy * d; + lt.c = this._nsx * a + this._cx * c; + lt.d = this._nsx * b + this._cx * d; +}; + +/** * Updates the values of the object and applies the parent's transform. * @param parentTransform {PIXI.Transform} The transform of the parent of this object */ diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 535f833..d140946 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -26,7 +26,7 @@ * World transform and local transform of this object. * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! * - * @member {PIXI.Transform|PIXI.TransformStatic} + * @member {PIXI.TransformBase} */ this.transform = new TransformClass(); diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index ce1573c..3a89102 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,28 +1,18 @@ -var math = require('../math'); +var math = require('../math'), + TransformBase = require('./TransformBase'); /** * Generic class to deal with traditional 2D matrix transforms - * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! + * local transformation is calculated from position,scale,skew and rotation * * @class + * @extends PIXI.TransformBase * @memberof PIXI */ function Transform() { - /** - * The global matrix transform. - * - * @member {PIXI.Matrix} - */ - this.worldTransform = new math.Matrix(); - - /** - * The local matrix transform. - * - * @member {PIXI.Matrix} - */ - this.localTransform = new math.Matrix(); + TransformBase.call(this); /** * The coordinate of the object relative to the local coordinates of the parent. @@ -52,7 +42,6 @@ */ this.pivot = new math.Point(0.0); - /** * The rotation value of the object, in radians * @@ -67,13 +56,9 @@ this._sy = Math.sin(0);//skewY); this._nsx = Math.sin(0);//skewX); this._cx = Math.cos(0);//skewX); - - this._dirty = false; - this.updated = true; - - this._worldID = 0; } +Transform.prototype = Object.create(TransformBase.prototype); Transform.prototype.constructor = Transform; Transform.prototype.updateSkew = function () @@ -85,6 +70,24 @@ }; /** + * Updates only local matrix + */ +Transform.prototype.updateLocalTransform = function() { + var lt = this.localTransform; + var a, b, c, d; + + a = this._cr * this.scale.x; + b = this._sr * this.scale.x; + c = -this._sr * this.scale.y; + d = this._cr * this.scale.y; + + lt.a = this._cy * a + this._sy * c; + lt.b = this._cy * b + this._sy * d; + lt.c = this._nsx * a + this._cx * c; + lt.d = this._nsx * b + this._cx * d; +}; + +/** * Updates the values of the object and applies the parent's transform. * @param parentTransform {PIXI.Transform} The transform of the parent of this object */ diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js new file mode 100644 index 0000000..1472515 --- /dev/null +++ b/src/core/display/TransformBase.js @@ -0,0 +1,68 @@ +var math = require('../math'); + + +/** + * Generic class to deal with traditional 2D matrix transforms + * + * @class + * @memberof PIXI + */ +function TransformBase() +{ + /** + * The global matrix transform. It can be swapped temporarily by some functions like getLocalBounds() + * + * @member {PIXI.Matrix} + */ + this.worldTransform = new math.Matrix(); + /** + * The local matrix transform + * + * @member {PIXI.Matrix} + */ + this.localTransform = new math.Matrix(); + + this._worldID = 0; +} + +TransformBase.prototype.constructor = TransformBase; + +/** + * TransformBase does not have decomposition, so this function wont do anything + */ +TransformBase.prototype.updateLocalTransform = function() { // jshint unused:false + +}; + +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.TransformBase} The transform of the parent of this object + * + */ +TransformBase.prototype.updateTransform = function (parentTransform) +{ + var pt = parentTransform.worldTransform; + var wt = this.worldTransform; + var lt = this.localTransform; + + // concat the parent matrix with the objects transform. + wt.a = lt.a * pt.a + lt.b * pt.c; + wt.b = lt.a * pt.b + lt.b * pt.d; + wt.c = lt.c * pt.a + lt.d * pt.c; + wt.d = lt.c * pt.b + lt.d * pt.d; + wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; + wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; + + this._worldID ++; +}; + +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ +TransformBase.prototype.updateWorldTransform = TransformBase.prototype.updateTransform; + +TransformBase.IDENTITY = new TransformBase(); + +module.exports = TransformBase; diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 535f833..d140946 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -26,7 +26,7 @@ * World transform and local transform of this object. * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! * - * @member {PIXI.Transform|PIXI.TransformStatic} + * @member {PIXI.TransformBase} */ this.transform = new TransformClass(); diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index ce1573c..3a89102 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,28 +1,18 @@ -var math = require('../math'); +var math = require('../math'), + TransformBase = require('./TransformBase'); /** * Generic class to deal with traditional 2D matrix transforms - * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! + * local transformation is calculated from position,scale,skew and rotation * * @class + * @extends PIXI.TransformBase * @memberof PIXI */ function Transform() { - /** - * The global matrix transform. - * - * @member {PIXI.Matrix} - */ - this.worldTransform = new math.Matrix(); - - /** - * The local matrix transform. - * - * @member {PIXI.Matrix} - */ - this.localTransform = new math.Matrix(); + TransformBase.call(this); /** * The coordinate of the object relative to the local coordinates of the parent. @@ -52,7 +42,6 @@ */ this.pivot = new math.Point(0.0); - /** * The rotation value of the object, in radians * @@ -67,13 +56,9 @@ this._sy = Math.sin(0);//skewY); this._nsx = Math.sin(0);//skewX); this._cx = Math.cos(0);//skewX); - - this._dirty = false; - this.updated = true; - - this._worldID = 0; } +Transform.prototype = Object.create(TransformBase.prototype); Transform.prototype.constructor = Transform; Transform.prototype.updateSkew = function () @@ -85,6 +70,24 @@ }; /** + * Updates only local matrix + */ +Transform.prototype.updateLocalTransform = function() { + var lt = this.localTransform; + var a, b, c, d; + + a = this._cr * this.scale.x; + b = this._sr * this.scale.x; + c = -this._sr * this.scale.y; + d = this._cr * this.scale.y; + + lt.a = this._cy * a + this._sy * c; + lt.b = this._cy * b + this._sy * d; + lt.c = this._nsx * a + this._cx * c; + lt.d = this._nsx * b + this._cx * d; +}; + +/** * Updates the values of the object and applies the parent's transform. * @param parentTransform {PIXI.Transform} The transform of the parent of this object */ diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js new file mode 100644 index 0000000..1472515 --- /dev/null +++ b/src/core/display/TransformBase.js @@ -0,0 +1,68 @@ +var math = require('../math'); + + +/** + * Generic class to deal with traditional 2D matrix transforms + * + * @class + * @memberof PIXI + */ +function TransformBase() +{ + /** + * The global matrix transform. It can be swapped temporarily by some functions like getLocalBounds() + * + * @member {PIXI.Matrix} + */ + this.worldTransform = new math.Matrix(); + /** + * The local matrix transform + * + * @member {PIXI.Matrix} + */ + this.localTransform = new math.Matrix(); + + this._worldID = 0; +} + +TransformBase.prototype.constructor = TransformBase; + +/** + * TransformBase does not have decomposition, so this function wont do anything + */ +TransformBase.prototype.updateLocalTransform = function() { // jshint unused:false + +}; + +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.TransformBase} The transform of the parent of this object + * + */ +TransformBase.prototype.updateTransform = function (parentTransform) +{ + var pt = parentTransform.worldTransform; + var wt = this.worldTransform; + var lt = this.localTransform; + + // concat the parent matrix with the objects transform. + wt.a = lt.a * pt.a + lt.b * pt.c; + wt.b = lt.a * pt.b + lt.b * pt.d; + wt.c = lt.c * pt.a + lt.d * pt.c; + wt.d = lt.c * pt.b + lt.d * pt.d; + wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; + wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; + + this._worldID ++; +}; + +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ +TransformBase.prototype.updateWorldTransform = TransformBase.prototype.updateTransform; + +TransformBase.IDENTITY = new TransformBase(); + +module.exports = TransformBase; diff --git a/src/core/display/TransformManual.js b/src/core/display/TransformManual.js deleted file mode 100644 index 08f41be..0000000 --- a/src/core/display/TransformManual.js +++ /dev/null @@ -1,55 +0,0 @@ -var math = require('../math'); - - -/** - * Generic class to deal with traditional 2D matrix transforms - * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! - * - * @class - * @memberof PIXI - */ -function TransformManual() -{ - /** - * The global matrix transform. - * - * @member {PIXI.Matrix} - */ - this.worldTransform = new math.Matrix(); - - /** - * The local matrix transform. - * - * @member {PIXI.Matrix} - */ - this.localTransform = new math.Matrix(); - - this._worldID = 0; -} - -TransformManual.prototype.constructor = TransformManual; - -/** - * Updates the values of the object and applies the parent's transform. - * @param parentTransform {PIXI.Transform} The transform of the parent of this object - * - */ -TransformManual.prototype.updateTransform = function (parentTransform) -{ - - var pt = parentTransform.worldTransform; - var wt = this.worldTransform; - var lt = this.localTransform; - - // concat the parent matrix with the objects transform. - wt.a = lt.a * pt.a + lt.b * pt.c; - wt.b = lt.a * pt.b + lt.b * pt.d; - wt.c = lt.c * pt.a + lt.d * pt.c; - wt.d = lt.c * pt.b + lt.d * pt.d; - wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; - wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; - - this._worldID ++; -}; - -module.exports = TransformManual; diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 535f833..d140946 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -26,7 +26,7 @@ * World transform and local transform of this object. * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! * - * @member {PIXI.Transform|PIXI.TransformStatic} + * @member {PIXI.TransformBase} */ this.transform = new TransformClass(); diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index ce1573c..3a89102 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,28 +1,18 @@ -var math = require('../math'); +var math = require('../math'), + TransformBase = require('./TransformBase'); /** * Generic class to deal with traditional 2D matrix transforms - * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! + * local transformation is calculated from position,scale,skew and rotation * * @class + * @extends PIXI.TransformBase * @memberof PIXI */ function Transform() { - /** - * The global matrix transform. - * - * @member {PIXI.Matrix} - */ - this.worldTransform = new math.Matrix(); - - /** - * The local matrix transform. - * - * @member {PIXI.Matrix} - */ - this.localTransform = new math.Matrix(); + TransformBase.call(this); /** * The coordinate of the object relative to the local coordinates of the parent. @@ -52,7 +42,6 @@ */ this.pivot = new math.Point(0.0); - /** * The rotation value of the object, in radians * @@ -67,13 +56,9 @@ this._sy = Math.sin(0);//skewY); this._nsx = Math.sin(0);//skewX); this._cx = Math.cos(0);//skewX); - - this._dirty = false; - this.updated = true; - - this._worldID = 0; } +Transform.prototype = Object.create(TransformBase.prototype); Transform.prototype.constructor = Transform; Transform.prototype.updateSkew = function () @@ -85,6 +70,24 @@ }; /** + * Updates only local matrix + */ +Transform.prototype.updateLocalTransform = function() { + var lt = this.localTransform; + var a, b, c, d; + + a = this._cr * this.scale.x; + b = this._sr * this.scale.x; + c = -this._sr * this.scale.y; + d = this._cr * this.scale.y; + + lt.a = this._cy * a + this._sy * c; + lt.b = this._cy * b + this._sy * d; + lt.c = this._nsx * a + this._cx * c; + lt.d = this._nsx * b + this._cx * d; +}; + +/** * Updates the values of the object and applies the parent's transform. * @param parentTransform {PIXI.Transform} The transform of the parent of this object */ diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js new file mode 100644 index 0000000..1472515 --- /dev/null +++ b/src/core/display/TransformBase.js @@ -0,0 +1,68 @@ +var math = require('../math'); + + +/** + * Generic class to deal with traditional 2D matrix transforms + * + * @class + * @memberof PIXI + */ +function TransformBase() +{ + /** + * The global matrix transform. It can be swapped temporarily by some functions like getLocalBounds() + * + * @member {PIXI.Matrix} + */ + this.worldTransform = new math.Matrix(); + /** + * The local matrix transform + * + * @member {PIXI.Matrix} + */ + this.localTransform = new math.Matrix(); + + this._worldID = 0; +} + +TransformBase.prototype.constructor = TransformBase; + +/** + * TransformBase does not have decomposition, so this function wont do anything + */ +TransformBase.prototype.updateLocalTransform = function() { // jshint unused:false + +}; + +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.TransformBase} The transform of the parent of this object + * + */ +TransformBase.prototype.updateTransform = function (parentTransform) +{ + var pt = parentTransform.worldTransform; + var wt = this.worldTransform; + var lt = this.localTransform; + + // concat the parent matrix with the objects transform. + wt.a = lt.a * pt.a + lt.b * pt.c; + wt.b = lt.a * pt.b + lt.b * pt.d; + wt.c = lt.c * pt.a + lt.d * pt.c; + wt.d = lt.c * pt.b + lt.d * pt.d; + wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; + wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; + + this._worldID ++; +}; + +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ +TransformBase.prototype.updateWorldTransform = TransformBase.prototype.updateTransform; + +TransformBase.IDENTITY = new TransformBase(); + +module.exports = TransformBase; diff --git a/src/core/display/TransformManual.js b/src/core/display/TransformManual.js deleted file mode 100644 index 08f41be..0000000 --- a/src/core/display/TransformManual.js +++ /dev/null @@ -1,55 +0,0 @@ -var math = require('../math'); - - -/** - * Generic class to deal with traditional 2D matrix transforms - * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! - * - * @class - * @memberof PIXI - */ -function TransformManual() -{ - /** - * The global matrix transform. - * - * @member {PIXI.Matrix} - */ - this.worldTransform = new math.Matrix(); - - /** - * The local matrix transform. - * - * @member {PIXI.Matrix} - */ - this.localTransform = new math.Matrix(); - - this._worldID = 0; -} - -TransformManual.prototype.constructor = TransformManual; - -/** - * Updates the values of the object and applies the parent's transform. - * @param parentTransform {PIXI.Transform} The transform of the parent of this object - * - */ -TransformManual.prototype.updateTransform = function (parentTransform) -{ - - var pt = parentTransform.worldTransform; - var wt = this.worldTransform; - var lt = this.localTransform; - - // concat the parent matrix with the objects transform. - wt.a = lt.a * pt.a + lt.b * pt.c; - wt.b = lt.a * pt.b + lt.b * pt.d; - wt.c = lt.c * pt.a + lt.d * pt.c; - wt.d = lt.c * pt.b + lt.d * pt.d; - wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; - wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; - - this._worldID ++; -}; - -module.exports = TransformManual; diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index d89168f..392eff8 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,28 +1,16 @@ -var math = require('../math'); +var math = require('../math'), + TransformBase = require('./TransformBase'); /** * Transform that takes care about its versions - * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! * * @class + * @extends PIXI.TransformBase * @memberof PIXI */ function TransformStatic() { - /** - * The global matrix transform. - * - * @member {PIXI.Matrix} - */ - this.worldTransform = new math.Matrix(); - - /** - * The local matrix transform. - * - * @member {PIXI.Matrix} - */ - this.localTransform = new math.Matrix(); - + TransformBase.call(this); /** * The coordinate of the object relative to the local coordinates of the parent. * @@ -60,13 +48,10 @@ this._nsx = Math.sin(0);//skewX); this._cx = Math.cos(0);//skewX); - - this._localID = 0; this._currentLocalID = 0; - this._parentID = 0; - this._worldID = 0; } +TransformStatic.prototype = Object.create(TransformBase.prototype); TransformStatic.prototype.constructor = TransformStatic; TransformStatic.prototype.onChange = function () @@ -85,6 +70,35 @@ }; /** + * Updates only local matrix + */ +TransformStatic.prototype.updateLocalTransform = function() { + var lt = this.localTransform; + if(this._localID !== this._currentLocalID) + { + // get the matrix values of the displayobject based on its transform properties.. + var a,b,c,d; + + a = this._cr * this.scale.x; + b = this._sr * this.scale.x; + c = -this._sr * this.scale.y; + d = this._cr * this.scale.y; + + lt.a = this._cy * a + this._sy * c; + lt.b = this._cy * b + this._sy * d; + lt.c = this._nsx * a + this._cx * c; + lt.d = this._nsx * b + this._cx * d; + + 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._currentLocalID = this._localID; + + // force an update.. + this._parentID = -1; + } +}; + +/** * Updates the values of the object and applies the parent's transform. * @param parentTransform {PIXI.Transform} The transform of the parent of this object * diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 535f833..d140946 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -26,7 +26,7 @@ * World transform and local transform of this object. * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! * - * @member {PIXI.Transform|PIXI.TransformStatic} + * @member {PIXI.TransformBase} */ this.transform = new TransformClass(); diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index ce1573c..3a89102 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,28 +1,18 @@ -var math = require('../math'); +var math = require('../math'), + TransformBase = require('./TransformBase'); /** * Generic class to deal with traditional 2D matrix transforms - * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! + * local transformation is calculated from position,scale,skew and rotation * * @class + * @extends PIXI.TransformBase * @memberof PIXI */ function Transform() { - /** - * The global matrix transform. - * - * @member {PIXI.Matrix} - */ - this.worldTransform = new math.Matrix(); - - /** - * The local matrix transform. - * - * @member {PIXI.Matrix} - */ - this.localTransform = new math.Matrix(); + TransformBase.call(this); /** * The coordinate of the object relative to the local coordinates of the parent. @@ -52,7 +42,6 @@ */ this.pivot = new math.Point(0.0); - /** * The rotation value of the object, in radians * @@ -67,13 +56,9 @@ this._sy = Math.sin(0);//skewY); this._nsx = Math.sin(0);//skewX); this._cx = Math.cos(0);//skewX); - - this._dirty = false; - this.updated = true; - - this._worldID = 0; } +Transform.prototype = Object.create(TransformBase.prototype); Transform.prototype.constructor = Transform; Transform.prototype.updateSkew = function () @@ -85,6 +70,24 @@ }; /** + * Updates only local matrix + */ +Transform.prototype.updateLocalTransform = function() { + var lt = this.localTransform; + var a, b, c, d; + + a = this._cr * this.scale.x; + b = this._sr * this.scale.x; + c = -this._sr * this.scale.y; + d = this._cr * this.scale.y; + + lt.a = this._cy * a + this._sy * c; + lt.b = this._cy * b + this._sy * d; + lt.c = this._nsx * a + this._cx * c; + lt.d = this._nsx * b + this._cx * d; +}; + +/** * Updates the values of the object and applies the parent's transform. * @param parentTransform {PIXI.Transform} The transform of the parent of this object */ diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js new file mode 100644 index 0000000..1472515 --- /dev/null +++ b/src/core/display/TransformBase.js @@ -0,0 +1,68 @@ +var math = require('../math'); + + +/** + * Generic class to deal with traditional 2D matrix transforms + * + * @class + * @memberof PIXI + */ +function TransformBase() +{ + /** + * The global matrix transform. It can be swapped temporarily by some functions like getLocalBounds() + * + * @member {PIXI.Matrix} + */ + this.worldTransform = new math.Matrix(); + /** + * The local matrix transform + * + * @member {PIXI.Matrix} + */ + this.localTransform = new math.Matrix(); + + this._worldID = 0; +} + +TransformBase.prototype.constructor = TransformBase; + +/** + * TransformBase does not have decomposition, so this function wont do anything + */ +TransformBase.prototype.updateLocalTransform = function() { // jshint unused:false + +}; + +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.TransformBase} The transform of the parent of this object + * + */ +TransformBase.prototype.updateTransform = function (parentTransform) +{ + var pt = parentTransform.worldTransform; + var wt = this.worldTransform; + var lt = this.localTransform; + + // concat the parent matrix with the objects transform. + wt.a = lt.a * pt.a + lt.b * pt.c; + wt.b = lt.a * pt.b + lt.b * pt.d; + wt.c = lt.c * pt.a + lt.d * pt.c; + wt.d = lt.c * pt.b + lt.d * pt.d; + wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; + wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; + + this._worldID ++; +}; + +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ +TransformBase.prototype.updateWorldTransform = TransformBase.prototype.updateTransform; + +TransformBase.IDENTITY = new TransformBase(); + +module.exports = TransformBase; diff --git a/src/core/display/TransformManual.js b/src/core/display/TransformManual.js deleted file mode 100644 index 08f41be..0000000 --- a/src/core/display/TransformManual.js +++ /dev/null @@ -1,55 +0,0 @@ -var math = require('../math'); - - -/** - * Generic class to deal with traditional 2D matrix transforms - * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! - * - * @class - * @memberof PIXI - */ -function TransformManual() -{ - /** - * The global matrix transform. - * - * @member {PIXI.Matrix} - */ - this.worldTransform = new math.Matrix(); - - /** - * The local matrix transform. - * - * @member {PIXI.Matrix} - */ - this.localTransform = new math.Matrix(); - - this._worldID = 0; -} - -TransformManual.prototype.constructor = TransformManual; - -/** - * Updates the values of the object and applies the parent's transform. - * @param parentTransform {PIXI.Transform} The transform of the parent of this object - * - */ -TransformManual.prototype.updateTransform = function (parentTransform) -{ - - var pt = parentTransform.worldTransform; - var wt = this.worldTransform; - var lt = this.localTransform; - - // concat the parent matrix with the objects transform. - wt.a = lt.a * pt.a + lt.b * pt.c; - wt.b = lt.a * pt.b + lt.b * pt.d; - wt.c = lt.c * pt.a + lt.d * pt.c; - wt.d = lt.c * pt.b + lt.d * pt.d; - wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; - wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; - - this._worldID ++; -}; - -module.exports = TransformManual; diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index d89168f..392eff8 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,28 +1,16 @@ -var math = require('../math'); +var math = require('../math'), + TransformBase = require('./TransformBase'); /** * Transform that takes care about its versions - * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! * * @class + * @extends PIXI.TransformBase * @memberof PIXI */ function TransformStatic() { - /** - * The global matrix transform. - * - * @member {PIXI.Matrix} - */ - this.worldTransform = new math.Matrix(); - - /** - * The local matrix transform. - * - * @member {PIXI.Matrix} - */ - this.localTransform = new math.Matrix(); - + TransformBase.call(this); /** * The coordinate of the object relative to the local coordinates of the parent. * @@ -60,13 +48,10 @@ this._nsx = Math.sin(0);//skewX); this._cx = Math.cos(0);//skewX); - - this._localID = 0; this._currentLocalID = 0; - this._parentID = 0; - this._worldID = 0; } +TransformStatic.prototype = Object.create(TransformBase.prototype); TransformStatic.prototype.constructor = TransformStatic; TransformStatic.prototype.onChange = function () @@ -85,6 +70,35 @@ }; /** + * Updates only local matrix + */ +TransformStatic.prototype.updateLocalTransform = function() { + var lt = this.localTransform; + if(this._localID !== this._currentLocalID) + { + // get the matrix values of the displayobject based on its transform properties.. + var a,b,c,d; + + a = this._cr * this.scale.x; + b = this._sr * this.scale.x; + c = -this._sr * this.scale.y; + d = this._cr * this.scale.y; + + lt.a = this._cy * a + this._sy * c; + lt.b = this._cy * b + this._sy * d; + lt.c = this._nsx * a + this._cx * c; + lt.d = this._nsx * b + this._cx * d; + + 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._currentLocalID = this._localID; + + // force an update.. + this._parentID = -1; + } +}; + +/** * Updates the values of the object and applies the parent's transform. * @param parentTransform {PIXI.Transform} The transform of the parent of this object * diff --git a/src/core/index.js b/src/core/index.js index 5679e75..a8ba707 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -19,7 +19,7 @@ Container: require('./display/Container'), Transform: require('./display/Transform'), TransformStatic: require('./display/TransformStatic'), - TransformManual: require('./display/TransformManual'), + TransformBase: require('./display/TransformBase'), // sprites Sprite: require('./sprites/Sprite'), diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 535f833..d140946 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -26,7 +26,7 @@ * World transform and local transform of this object. * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! * - * @member {PIXI.Transform|PIXI.TransformStatic} + * @member {PIXI.TransformBase} */ this.transform = new TransformClass(); diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index ce1573c..3a89102 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,28 +1,18 @@ -var math = require('../math'); +var math = require('../math'), + TransformBase = require('./TransformBase'); /** * Generic class to deal with traditional 2D matrix transforms - * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! + * local transformation is calculated from position,scale,skew and rotation * * @class + * @extends PIXI.TransformBase * @memberof PIXI */ function Transform() { - /** - * The global matrix transform. - * - * @member {PIXI.Matrix} - */ - this.worldTransform = new math.Matrix(); - - /** - * The local matrix transform. - * - * @member {PIXI.Matrix} - */ - this.localTransform = new math.Matrix(); + TransformBase.call(this); /** * The coordinate of the object relative to the local coordinates of the parent. @@ -52,7 +42,6 @@ */ this.pivot = new math.Point(0.0); - /** * The rotation value of the object, in radians * @@ -67,13 +56,9 @@ this._sy = Math.sin(0);//skewY); this._nsx = Math.sin(0);//skewX); this._cx = Math.cos(0);//skewX); - - this._dirty = false; - this.updated = true; - - this._worldID = 0; } +Transform.prototype = Object.create(TransformBase.prototype); Transform.prototype.constructor = Transform; Transform.prototype.updateSkew = function () @@ -85,6 +70,24 @@ }; /** + * Updates only local matrix + */ +Transform.prototype.updateLocalTransform = function() { + var lt = this.localTransform; + var a, b, c, d; + + a = this._cr * this.scale.x; + b = this._sr * this.scale.x; + c = -this._sr * this.scale.y; + d = this._cr * this.scale.y; + + lt.a = this._cy * a + this._sy * c; + lt.b = this._cy * b + this._sy * d; + lt.c = this._nsx * a + this._cx * c; + lt.d = this._nsx * b + this._cx * d; +}; + +/** * Updates the values of the object and applies the parent's transform. * @param parentTransform {PIXI.Transform} The transform of the parent of this object */ diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js new file mode 100644 index 0000000..1472515 --- /dev/null +++ b/src/core/display/TransformBase.js @@ -0,0 +1,68 @@ +var math = require('../math'); + + +/** + * Generic class to deal with traditional 2D matrix transforms + * + * @class + * @memberof PIXI + */ +function TransformBase() +{ + /** + * The global matrix transform. It can be swapped temporarily by some functions like getLocalBounds() + * + * @member {PIXI.Matrix} + */ + this.worldTransform = new math.Matrix(); + /** + * The local matrix transform + * + * @member {PIXI.Matrix} + */ + this.localTransform = new math.Matrix(); + + this._worldID = 0; +} + +TransformBase.prototype.constructor = TransformBase; + +/** + * TransformBase does not have decomposition, so this function wont do anything + */ +TransformBase.prototype.updateLocalTransform = function() { // jshint unused:false + +}; + +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.TransformBase} The transform of the parent of this object + * + */ +TransformBase.prototype.updateTransform = function (parentTransform) +{ + var pt = parentTransform.worldTransform; + var wt = this.worldTransform; + var lt = this.localTransform; + + // concat the parent matrix with the objects transform. + wt.a = lt.a * pt.a + lt.b * pt.c; + wt.b = lt.a * pt.b + lt.b * pt.d; + wt.c = lt.c * pt.a + lt.d * pt.c; + wt.d = lt.c * pt.b + lt.d * pt.d; + wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; + wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; + + this._worldID ++; +}; + +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ +TransformBase.prototype.updateWorldTransform = TransformBase.prototype.updateTransform; + +TransformBase.IDENTITY = new TransformBase(); + +module.exports = TransformBase; diff --git a/src/core/display/TransformManual.js b/src/core/display/TransformManual.js deleted file mode 100644 index 08f41be..0000000 --- a/src/core/display/TransformManual.js +++ /dev/null @@ -1,55 +0,0 @@ -var math = require('../math'); - - -/** - * Generic class to deal with traditional 2D matrix transforms - * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! - * - * @class - * @memberof PIXI - */ -function TransformManual() -{ - /** - * The global matrix transform. - * - * @member {PIXI.Matrix} - */ - this.worldTransform = new math.Matrix(); - - /** - * The local matrix transform. - * - * @member {PIXI.Matrix} - */ - this.localTransform = new math.Matrix(); - - this._worldID = 0; -} - -TransformManual.prototype.constructor = TransformManual; - -/** - * Updates the values of the object and applies the parent's transform. - * @param parentTransform {PIXI.Transform} The transform of the parent of this object - * - */ -TransformManual.prototype.updateTransform = function (parentTransform) -{ - - var pt = parentTransform.worldTransform; - var wt = this.worldTransform; - var lt = this.localTransform; - - // concat the parent matrix with the objects transform. - wt.a = lt.a * pt.a + lt.b * pt.c; - wt.b = lt.a * pt.b + lt.b * pt.d; - wt.c = lt.c * pt.a + lt.d * pt.c; - wt.d = lt.c * pt.b + lt.d * pt.d; - wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; - wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; - - this._worldID ++; -}; - -module.exports = TransformManual; diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index d89168f..392eff8 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,28 +1,16 @@ -var math = require('../math'); +var math = require('../math'), + TransformBase = require('./TransformBase'); /** * Transform that takes care about its versions - * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! * * @class + * @extends PIXI.TransformBase * @memberof PIXI */ function TransformStatic() { - /** - * The global matrix transform. - * - * @member {PIXI.Matrix} - */ - this.worldTransform = new math.Matrix(); - - /** - * The local matrix transform. - * - * @member {PIXI.Matrix} - */ - this.localTransform = new math.Matrix(); - + TransformBase.call(this); /** * The coordinate of the object relative to the local coordinates of the parent. * @@ -60,13 +48,10 @@ this._nsx = Math.sin(0);//skewX); this._cx = Math.cos(0);//skewX); - - this._localID = 0; this._currentLocalID = 0; - this._parentID = 0; - this._worldID = 0; } +TransformStatic.prototype = Object.create(TransformBase.prototype); TransformStatic.prototype.constructor = TransformStatic; TransformStatic.prototype.onChange = function () @@ -85,6 +70,35 @@ }; /** + * Updates only local matrix + */ +TransformStatic.prototype.updateLocalTransform = function() { + var lt = this.localTransform; + if(this._localID !== this._currentLocalID) + { + // get the matrix values of the displayobject based on its transform properties.. + var a,b,c,d; + + a = this._cr * this.scale.x; + b = this._sr * this.scale.x; + c = -this._sr * this.scale.y; + d = this._cr * this.scale.y; + + lt.a = this._cy * a + this._sy * c; + lt.b = this._cy * b + this._sy * d; + lt.c = this._nsx * a + this._cx * c; + lt.d = this._nsx * b + this._cx * d; + + 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._currentLocalID = this._localID; + + // force an update.. + this._parentID = -1; + } +}; + +/** * Updates the values of the object and applies the parent's transform. * @param parentTransform {PIXI.Transform} The transform of the parent of this object * diff --git a/src/core/index.js b/src/core/index.js index 5679e75..a8ba707 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -19,7 +19,7 @@ Container: require('./display/Container'), Transform: require('./display/Transform'), TransformStatic: require('./display/TransformStatic'), - TransformManual: require('./display/TransformManual'), + TransformBase: require('./display/TransformBase'), // sprites Sprite: require('./sprites/Sprite'), diff --git a/src/core/math/Matrix.js b/src/core/math/Matrix.js index 6b84899..4b2b345 100644 --- a/src/core/math/Matrix.js +++ b/src/core/math/Matrix.js @@ -348,8 +348,8 @@ /** * Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform. - * @param transform {PIXI.Transform} the transform to apply the properties to. - * @return {PIXI.Transform} The transform with the newly applied properies + * @param transform {PIXI.Transform|PIXI.TransformStatic} the transform to apply the properties to. + * @return {PIXI.Transform|PIXI.TransformStatic} The transform with the newly applied properies */ Matrix.prototype.decompose = function(transform) { diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 535f833..d140946 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -26,7 +26,7 @@ * World transform and local transform of this object. * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! * - * @member {PIXI.Transform|PIXI.TransformStatic} + * @member {PIXI.TransformBase} */ this.transform = new TransformClass(); diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index ce1573c..3a89102 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -1,28 +1,18 @@ -var math = require('../math'); +var math = require('../math'), + TransformBase = require('./TransformBase'); /** * Generic class to deal with traditional 2D matrix transforms - * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! + * local transformation is calculated from position,scale,skew and rotation * * @class + * @extends PIXI.TransformBase * @memberof PIXI */ function Transform() { - /** - * The global matrix transform. - * - * @member {PIXI.Matrix} - */ - this.worldTransform = new math.Matrix(); - - /** - * The local matrix transform. - * - * @member {PIXI.Matrix} - */ - this.localTransform = new math.Matrix(); + TransformBase.call(this); /** * The coordinate of the object relative to the local coordinates of the parent. @@ -52,7 +42,6 @@ */ this.pivot = new math.Point(0.0); - /** * The rotation value of the object, in radians * @@ -67,13 +56,9 @@ this._sy = Math.sin(0);//skewY); this._nsx = Math.sin(0);//skewX); this._cx = Math.cos(0);//skewX); - - this._dirty = false; - this.updated = true; - - this._worldID = 0; } +Transform.prototype = Object.create(TransformBase.prototype); Transform.prototype.constructor = Transform; Transform.prototype.updateSkew = function () @@ -85,6 +70,24 @@ }; /** + * Updates only local matrix + */ +Transform.prototype.updateLocalTransform = function() { + var lt = this.localTransform; + var a, b, c, d; + + a = this._cr * this.scale.x; + b = this._sr * this.scale.x; + c = -this._sr * this.scale.y; + d = this._cr * this.scale.y; + + lt.a = this._cy * a + this._sy * c; + lt.b = this._cy * b + this._sy * d; + lt.c = this._nsx * a + this._cx * c; + lt.d = this._nsx * b + this._cx * d; +}; + +/** * Updates the values of the object and applies the parent's transform. * @param parentTransform {PIXI.Transform} The transform of the parent of this object */ diff --git a/src/core/display/TransformBase.js b/src/core/display/TransformBase.js new file mode 100644 index 0000000..1472515 --- /dev/null +++ b/src/core/display/TransformBase.js @@ -0,0 +1,68 @@ +var math = require('../math'); + + +/** + * Generic class to deal with traditional 2D matrix transforms + * + * @class + * @memberof PIXI + */ +function TransformBase() +{ + /** + * The global matrix transform. It can be swapped temporarily by some functions like getLocalBounds() + * + * @member {PIXI.Matrix} + */ + this.worldTransform = new math.Matrix(); + /** + * The local matrix transform + * + * @member {PIXI.Matrix} + */ + this.localTransform = new math.Matrix(); + + this._worldID = 0; +} + +TransformBase.prototype.constructor = TransformBase; + +/** + * TransformBase does not have decomposition, so this function wont do anything + */ +TransformBase.prototype.updateLocalTransform = function() { // jshint unused:false + +}; + +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.TransformBase} The transform of the parent of this object + * + */ +TransformBase.prototype.updateTransform = function (parentTransform) +{ + var pt = parentTransform.worldTransform; + var wt = this.worldTransform; + var lt = this.localTransform; + + // concat the parent matrix with the objects transform. + wt.a = lt.a * pt.a + lt.b * pt.c; + wt.b = lt.a * pt.b + lt.b * pt.d; + wt.c = lt.c * pt.a + lt.d * pt.c; + wt.d = lt.c * pt.b + lt.d * pt.d; + wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; + wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; + + this._worldID ++; +}; + +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ +TransformBase.prototype.updateWorldTransform = TransformBase.prototype.updateTransform; + +TransformBase.IDENTITY = new TransformBase(); + +module.exports = TransformBase; diff --git a/src/core/display/TransformManual.js b/src/core/display/TransformManual.js deleted file mode 100644 index 08f41be..0000000 --- a/src/core/display/TransformManual.js +++ /dev/null @@ -1,55 +0,0 @@ -var math = require('../math'); - - -/** - * Generic class to deal with traditional 2D matrix transforms - * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! - * - * @class - * @memberof PIXI - */ -function TransformManual() -{ - /** - * The global matrix transform. - * - * @member {PIXI.Matrix} - */ - this.worldTransform = new math.Matrix(); - - /** - * The local matrix transform. - * - * @member {PIXI.Matrix} - */ - this.localTransform = new math.Matrix(); - - this._worldID = 0; -} - -TransformManual.prototype.constructor = TransformManual; - -/** - * Updates the values of the object and applies the parent's transform. - * @param parentTransform {PIXI.Transform} The transform of the parent of this object - * - */ -TransformManual.prototype.updateTransform = function (parentTransform) -{ - - var pt = parentTransform.worldTransform; - var wt = this.worldTransform; - var lt = this.localTransform; - - // concat the parent matrix with the objects transform. - wt.a = lt.a * pt.a + lt.b * pt.c; - wt.b = lt.a * pt.b + lt.b * pt.d; - wt.c = lt.c * pt.a + lt.d * pt.c; - wt.d = lt.c * pt.b + lt.d * pt.d; - wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; - wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; - - this._worldID ++; -}; - -module.exports = TransformManual; diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index d89168f..392eff8 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -1,28 +1,16 @@ -var math = require('../math'); +var math = require('../math'), + TransformBase = require('./TransformBase'); /** * Transform that takes care about its versions - * This will be reworked in v4.1, please do not use it yet unless you know what are you doing! * * @class + * @extends PIXI.TransformBase * @memberof PIXI */ function TransformStatic() { - /** - * The global matrix transform. - * - * @member {PIXI.Matrix} - */ - this.worldTransform = new math.Matrix(); - - /** - * The local matrix transform. - * - * @member {PIXI.Matrix} - */ - this.localTransform = new math.Matrix(); - + TransformBase.call(this); /** * The coordinate of the object relative to the local coordinates of the parent. * @@ -60,13 +48,10 @@ this._nsx = Math.sin(0);//skewX); this._cx = Math.cos(0);//skewX); - - this._localID = 0; this._currentLocalID = 0; - this._parentID = 0; - this._worldID = 0; } +TransformStatic.prototype = Object.create(TransformBase.prototype); TransformStatic.prototype.constructor = TransformStatic; TransformStatic.prototype.onChange = function () @@ -85,6 +70,35 @@ }; /** + * Updates only local matrix + */ +TransformStatic.prototype.updateLocalTransform = function() { + var lt = this.localTransform; + if(this._localID !== this._currentLocalID) + { + // get the matrix values of the displayobject based on its transform properties.. + var a,b,c,d; + + a = this._cr * this.scale.x; + b = this._sr * this.scale.x; + c = -this._sr * this.scale.y; + d = this._cr * this.scale.y; + + lt.a = this._cy * a + this._sy * c; + lt.b = this._cy * b + this._sy * d; + lt.c = this._nsx * a + this._cx * c; + lt.d = this._nsx * b + this._cx * d; + + 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._currentLocalID = this._localID; + + // force an update.. + this._parentID = -1; + } +}; + +/** * Updates the values of the object and applies the parent's transform. * @param parentTransform {PIXI.Transform} The transform of the parent of this object * diff --git a/src/core/index.js b/src/core/index.js index 5679e75..a8ba707 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -19,7 +19,7 @@ Container: require('./display/Container'), Transform: require('./display/Transform'), TransformStatic: require('./display/TransformStatic'), - TransformManual: require('./display/TransformManual'), + TransformBase: require('./display/TransformBase'), // sprites Sprite: require('./sprites/Sprite'), diff --git a/src/core/math/Matrix.js b/src/core/math/Matrix.js index 6b84899..4b2b345 100644 --- a/src/core/math/Matrix.js +++ b/src/core/math/Matrix.js @@ -348,8 +348,8 @@ /** * Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform. - * @param transform {PIXI.Transform} the transform to apply the properties to. - * @return {PIXI.Transform} The transform with the newly applied properies + * @param transform {PIXI.Transform|PIXI.TransformStatic} the transform to apply the properties to. + * @return {PIXI.Transform|PIXI.TransformStatic} The transform with the newly applied properies */ Matrix.prototype.decompose = function(transform) { diff --git a/src/deprecation.js b/src/deprecation.js index 121f120..0d86a06 100644 --- a/src/deprecation.js +++ b/src/deprecation.js @@ -283,6 +283,21 @@ return core.Filter; } }, + + /** + * @class + * @private + * @name PIXI.TransformManual + * @see PIXI.TransformBase + * @deprecated since version 4.0.0 + */ + TransformManual: { + get: function() + { + warn('TransformManual has been renamed to TransformBase, please update your pixi-spine'); + return core.TransformBase; + } + } }); core.DisplayObject.prototype.generateTexture = function(renderer, scaleMode, resolution)