tentone 6 years ago
parent
commit
8a45d736fa
5 changed files with 23 additions and 11 deletions
  1. 8 4
      build/escher.js
  2. 0 0
      build/escher.min.js
  3. 8 4
      build/escher.module.js
  4. 4 2
      source/Renderer.js
  5. 3 1
      source/Viewport.js

+ 8 - 4
build/escher.js

@@ -1656,7 +1656,7 @@
 	{
 	{
 		if(this.matrixNeedsUpdate)
 		if(this.matrixNeedsUpdate)
 		{
 		{
-			this.matrix.m = [1, 0, 0, 1, this.position.x, this.position.y];
+			this.matrix.m = [1, 0, 0, 1, -this.position.x, -this.position.y];
 
 
 			if(this.rotation !== 0)
 			if(this.rotation !== 0)
 			{		
 			{		
@@ -1664,12 +1664,14 @@
 				var s = Math.sin(this.rotation);
 				var s = Math.sin(this.rotation);
 				this.matrix.multiply(new Matrix([c, s, -s, c, 0, 0]));
 				this.matrix.multiply(new Matrix([c, s, -s, c, 0, 0]));
 			}
 			}
-			
+
 			if(this.scale !== 1)
 			if(this.scale !== 1)
 			{
 			{
 				this.matrix.scale(this.scale, this.scale);
 				this.matrix.scale(this.scale, this.scale);
 			}
 			}
 
 
+			this.matrix.multiply(new Matrix([1, 0, 0, 1, this.position.x - this.canvas.width / 2 * this.scale,  this.position.y - this.canvas.height / 2 * this.scale]));
+
 			this.inverseMatrix = this.matrix.getInverse();
 			this.inverseMatrix = this.matrix.getInverse();
 			this.matrixNeedsUpdate = false;
 			this.matrixNeedsUpdate = false;
 		}
 		}
@@ -1821,6 +1823,8 @@
 	 * Its also resposible for managing the canvas state.
 	 * Its also resposible for managing the canvas state.
 	 *
 	 *
 	 * @class
 	 * @class
+	 * @param {DOM} canvas Canvas to render the content.
+	 * @param {Object} options Renderer canvas options.
 	 */
 	 */
 	function Renderer(canvas, options)
 	function Renderer(canvas, options)
 	{
 	{
@@ -1894,8 +1898,8 @@
 	 *
 	 *
 	 * Should be called at a fixed rate preferably using the requestAnimationFrame() method, its also possible to use the createRenderLoop() method, that automatically creates a infinite render loop.
 	 * Should be called at a fixed rate preferably using the requestAnimationFrame() method, its also possible to use the createRenderLoop() method, that automatically creates a infinite render loop.
 	 *
 	 *
-	 * @param object Object to be updated.
-	 * @param viewport Viewport to be updated (should be the one where the objects will be rendered after).
+	 * @param object {Object2D} Object to be updated.
+	 * @param viewport {Viewport} Viewport to be updated (should be the one where the objects will be rendered after).
 	 */
 	 */
 	Renderer.prototype.update = function(object, viewport)
 	Renderer.prototype.update = function(object, viewport)
 	{
 	{

File diff suppressed because it is too large
+ 0 - 0
build/escher.min.js


+ 8 - 4
build/escher.module.js

@@ -1650,7 +1650,7 @@ Viewport.prototype.updateMatrix = function()
 {
 {
 	if(this.matrixNeedsUpdate)
 	if(this.matrixNeedsUpdate)
 	{
 	{
-		this.matrix.m = [1, 0, 0, 1, this.position.x, this.position.y];
+		this.matrix.m = [1, 0, 0, 1, -this.position.x, -this.position.y];
 
 
 		if(this.rotation !== 0)
 		if(this.rotation !== 0)
 		{		
 		{		
@@ -1658,12 +1658,14 @@ Viewport.prototype.updateMatrix = function()
 			var s = Math.sin(this.rotation);
 			var s = Math.sin(this.rotation);
 			this.matrix.multiply(new Matrix([c, s, -s, c, 0, 0]));
 			this.matrix.multiply(new Matrix([c, s, -s, c, 0, 0]));
 		}
 		}
-		
+
 		if(this.scale !== 1)
 		if(this.scale !== 1)
 		{
 		{
 			this.matrix.scale(this.scale, this.scale);
 			this.matrix.scale(this.scale, this.scale);
 		}
 		}
 
 
+		this.matrix.multiply(new Matrix([1, 0, 0, 1, this.position.x - this.canvas.width / 2 * this.scale,  this.position.y - this.canvas.height / 2 * this.scale]));
+
 		this.inverseMatrix = this.matrix.getInverse();
 		this.inverseMatrix = this.matrix.getInverse();
 		this.matrixNeedsUpdate = false;
 		this.matrixNeedsUpdate = false;
 	}
 	}
@@ -1815,6 +1817,8 @@ ViewportControls.prototype.update = function(pointer)
  * Its also resposible for managing the canvas state.
  * Its also resposible for managing the canvas state.
  *
  *
  * @class
  * @class
+ * @param {DOM} canvas Canvas to render the content.
+ * @param {Object} options Renderer canvas options.
  */
  */
 function Renderer(canvas, options)
 function Renderer(canvas, options)
 {
 {
@@ -1888,8 +1892,8 @@ Renderer.prototype.createRenderLoop = function(group, viewport, onUpdate)
  *
  *
  * Should be called at a fixed rate preferably using the requestAnimationFrame() method, its also possible to use the createRenderLoop() method, that automatically creates a infinite render loop.
  * Should be called at a fixed rate preferably using the requestAnimationFrame() method, its also possible to use the createRenderLoop() method, that automatically creates a infinite render loop.
  *
  *
- * @param object Object to be updated.
- * @param viewport Viewport to be updated (should be the one where the objects will be rendered after).
+ * @param object {Object2D} Object to be updated.
+ * @param viewport {Viewport} Viewport to be updated (should be the one where the objects will be rendered after).
  */
  */
 Renderer.prototype.update = function(object, viewport)
 Renderer.prototype.update = function(object, viewport)
 {
 {

+ 4 - 2
source/Renderer.js

@@ -9,6 +9,8 @@ import {ViewportControls} from "./controls/ViewportControls.js";
  * Its also resposible for managing the canvas state.
  * Its also resposible for managing the canvas state.
  *
  *
  * @class
  * @class
+ * @param {DOM} canvas Canvas to render the content.
+ * @param {Object} options Renderer canvas options.
  */
  */
 function Renderer(canvas, options)
 function Renderer(canvas, options)
 {
 {
@@ -82,8 +84,8 @@ Renderer.prototype.createRenderLoop = function(group, viewport, onUpdate)
  *
  *
  * Should be called at a fixed rate preferably using the requestAnimationFrame() method, its also possible to use the createRenderLoop() method, that automatically creates a infinite render loop.
  * Should be called at a fixed rate preferably using the requestAnimationFrame() method, its also possible to use the createRenderLoop() method, that automatically creates a infinite render loop.
  *
  *
- * @param object Object to be updated.
- * @param viewport Viewport to be updated (should be the one where the objects will be rendered after).
+ * @param object {Object2D} Object to be updated.
+ * @param viewport {Viewport} Viewport to be updated (should be the one where the objects will be rendered after).
  */
  */
 Renderer.prototype.update = function(object, viewport)
 Renderer.prototype.update = function(object, viewport)
 {
 {

+ 3 - 1
source/Viewport.js

@@ -85,12 +85,14 @@ Viewport.prototype.updateMatrix = function()
 			var s = Math.sin(this.rotation);
 			var s = Math.sin(this.rotation);
 			this.matrix.multiply(new Matrix([c, s, -s, c, 0, 0]));
 			this.matrix.multiply(new Matrix([c, s, -s, c, 0, 0]));
 		}
 		}
-		
+
 		if(this.scale !== 1)
 		if(this.scale !== 1)
 		{
 		{
 			this.matrix.scale(this.scale, this.scale);
 			this.matrix.scale(this.scale, this.scale);
 		}
 		}
 
 
+		//this.matrix.multiply(new Matrix([1, 0, 0, 1, this.position.x - this.canvas.width / 2 * this.scale,  this.position.y - this.canvas.height / 2 * this.scale]));
+
 		this.inverseMatrix = this.matrix.getInverse();
 		this.inverseMatrix = this.matrix.getInverse();
 		this.matrixNeedsUpdate = false;
 		this.matrixNeedsUpdate = false;
 	}
 	}

Some files were not shown because too many files changed in this diff