"use strict"; /** * Base 2D object class, implements all the object positioning and scalling features. * * @class */ function Object2D() { /** * UUID of the object. */ this.uuid = UUID.generate(); /** * List of children objects attached to the object. */ this.children = []; /** * Parent object, the object position is affected by its parent position. */ this.parent = null; /** * Position of the object. */ this.position = new Vector2(0, 0); /** * Scale of the object. */ this.scale = new Vector2(1, 1); /** * Rotation of the object relative to its center. */ this.rotation = 0.0; /** * Local transformation matrix applied to the object. */ this.matrix = new Matrix3(); /** * Global transformation matrix used to project the object to screen space. */ this.globalMatrix = new Matrix3(); } /** * Attach a children to the object. */ Object2D.prototype.add = function(object) { object.parent = this; this.children.push(object); };