Viewport.js 1020 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. "use strict";
  2. /**
  3. * Used to indicate how the user views the content inside of the canvas.
  4. *
  5. * @class
  6. */
  7. function Viewport()
  8. {
  9. /**
  10. * UUID of the object.
  11. */
  12. this.uuid = UUID.generate();
  13. /**
  14. * Position of the object.
  15. */
  16. this.position = new Vector2(0, 0);
  17. /**
  18. * Scale of the object.
  19. */
  20. this.scale = 1.0
  21. /**
  22. * Rotation of the object relative to its center.
  23. */
  24. this.rotation = 0.0;
  25. /**
  26. * Local transformation matrix applied to the object.
  27. */
  28. this.matrix = new Matrix();
  29. /**
  30. * If true the matrix is updated before rendering the object.
  31. */
  32. this.matrixNeedsUpdate = true;
  33. }
  34. /**
  35. * Set the transformation of the canvas context.
  36. *
  37. * @param context Canvas 2d drawing context.
  38. * @param canvas The canvas DOM element where its being drawn.
  39. */
  40. Viewport.prototype.updateMatrix = function(context, canvas)
  41. {
  42. if(true) //this.matrixNeedsUpdate)
  43. {
  44. this.matrix.compose(this.position.x, this.position.y, this.scale, this.scale, this.rotation);
  45. this.matrixNeedsUpdate = false;
  46. }
  47. };