Browse Source

Playing withh css3d transforms

tentone 6 years ago
parent
commit
7af57da694
5 changed files with 30 additions and 0 deletions
  1. 5 0
      build/diagram.js
  2. 0 0
      build/diagram.min.js
  3. 5 0
      build/diagram.module.js
  4. 14 0
      examples/diagram.html
  5. 6 0
      source/math/Matrix.js

+ 5 - 0
build/diagram.js

@@ -553,6 +553,11 @@
 		context.transform(this.m[0], this.m[1], this.m[2], this.m[3], this.m[4], this.m[5]);
 		context.transform(this.m[0], this.m[1], this.m[2], this.m[3], this.m[4], this.m[5]);
 	};
 	};
 
 
+	Matrix.prototype.cssTransform = function()
+	{
+		return "matrix3d(" + this.m[0] + "," + this.m[2] + "," + this.m[4] + ",0," + this.m[1] + "," + this.m[3] + "," + this.m[5] + ",0,0,0,1,0,0,0,0,1)";
+	};
+
 	/**
 	/**
 	 * Implements all UUID related methods.
 	 * Implements all UUID related methods.
 	 *
 	 *

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


+ 5 - 0
build/diagram.module.js

@@ -547,6 +547,11 @@ Matrix.prototype.tranformContext = function(context)
 	context.transform(this.m[0], this.m[1], this.m[2], this.m[3], this.m[4], this.m[5]);
 	context.transform(this.m[0], this.m[1], this.m[2], this.m[3], this.m[4], this.m[5]);
 };
 };
 
 
+Matrix.prototype.cssTransform = function()
+{
+	return "matrix3d(" + this.m[0] + "," + this.m[2] + "," + this.m[4] + ",0," + this.m[1] + "," + this.m[3] + "," + this.m[5] + ",0,0,0,1,0,0,0,0,1)";
+};
+
 /**
 /**
  * Implements all UUID related methods.
  * Implements all UUID related methods.
  *
  *

+ 14 - 0
examples/diagram.html

@@ -32,6 +32,16 @@
 			canvas.height = window.innerHeight;
 			canvas.height = window.innerHeight;
 		};
 		};
 
 
+		var div = document.createElement("div");
+		div.style.position = "absolute";
+		div.style.transformOrigin = "0px 0px 0px";
+		div.style.width = "100px";
+		div.style.height = "100px";
+		div.style.backgroundColor = "#FF0000";
+		div.style.WebkitTransformStyle = "preserve-3d";
+		div.style.transformStyle = "preserve-3d";
+		document.body.appendChild(div);
+
 		// Create the diagram
 		// Create the diagram
 		var group = new Diagram.Object2D();
 		var group = new Diagram.Object2D();
 
 
@@ -94,6 +104,10 @@
 			renderer.update(group, viewport);
 			renderer.update(group, viewport);
 			renderer.render(group, viewport);
 			renderer.render(group, viewport);
 
 
+			var projection = group.globalMatrix.clone();
+			projection.multiply(viewport.matrix);
+			div.style.transform = projection.cssTransform();
+
 			requestAnimationFrame(loop);
 			requestAnimationFrame(loop);
 		}
 		}
 
 

+ 6 - 0
source/math/Matrix.js

@@ -210,4 +210,10 @@ Matrix.prototype.tranformContext = function(context)
 	context.transform(this.m[0], this.m[1], this.m[2], this.m[3], this.m[4], this.m[5]);
 	context.transform(this.m[0], this.m[1], this.m[2], this.m[3], this.m[4], this.m[5]);
 };
 };
 
 
+Matrix.prototype.cssTransform = function()
+{
+	return "matrix3d(" + this.m[0] + "," + this.m[2] + "," + this.m[4] + ",0," + this.m[1] + "," + this.m[3] + "," + this.m[5] + ",0,0,0,1,0,0,0,0,1)";
+};
+
+
 export {Matrix};
 export {Matrix};

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