Browse Source

allow easier creation of centered cube

ncannasse 7 năm trước cách đây
mục cha
commit
fefd97b2a8
1 tập tin đã thay đổi với 2 bổ sung1 xóa
  1. 2 1
      h3d/prim/Cube.hx

+ 2 - 1
h3d/prim/Cube.hx

@@ -7,7 +7,7 @@ class Cube extends Polygon {
 	@:s var sizeY : Float;
 	@:s var sizeZ : Float;
 
-	public function new( x = 1., y = 1., z = 1. )
+	public function new( x = 1., y = 1., z = 1., centered = false )
 	{
 		this.sizeX = x;
 		this.sizeY = y;
@@ -36,6 +36,7 @@ class Cube extends Polygon {
 		idx.push(0); idx.push(4); idx.push(1);
 		idx.push(0); idx.push(2); idx.push(4);
 		super(p, idx);
+		if( centered ) translate( -x * 0.5, -y * 0.5, -z * 0.5);
 	}
 
 	override function addUVs() {