Nicolas Cannasse 11 年之前
父节点
当前提交
a2c5c5ddee
共有 100 个文件被更改,包括 1092 次插入1092 次删除
  1. 10 10
      h2d/CachedBitmap.hx
  2. 19 19
      h2d/Console.hx
  3. 18 18
      h2d/Drawable.hx
  4. 11 11
      h2d/Font.hx
  5. 1 1
      h2d/HtmlText.hx
  6. 9 9
      h2d/Layers.hx
  7. 12 12
      h2d/RenderContext.hx
  8. 14 14
      h2d/ScaleGrid.hx
  9. 4 4
      h2d/Scene3D.hx
  10. 4 4
      h2d/SpriteBatch.hx
  11. 4 4
      h2d/TileGroup.hx
  12. 4 4
      h2d/col/Circle.hx
  13. 0 0
      h2d/col/Delaunay.hx
  14. 6 6
      h2d/col/Line.hx
  15. 7 7
      h2d/col/Point.hx
  16. 8 8
      h2d/col/Poly.hx
  17. 13 13
      h2d/col/Polynomial.hx
  18. 3 3
      h2d/col/RoundRect.hx
  19. 5 5
      h2d/col/Seg.hx
  20. 7 7
      h2d/col/Triangle.hx
  21. 17 17
      h2d/col/Voronoi.hx
  22. 5 5
      h2d/comp/Box.hx
  23. 6 6
      h2d/comp/Button.hx
  24. 7 7
      h2d/comp/Checkbox.hx
  25. 7 7
      h2d/comp/Color.hx
  26. 61 61
      h2d/comp/ColorPicker.hx
  27. 9 9
      h2d/comp/Context.hx
  28. 76 76
      h2d/comp/GradientEditor.hx
  29. 9 9
      h2d/comp/Input.hx
  30. 8 8
      h2d/comp/Interactive.hx
  31. 7 7
      h2d/comp/ItemList.hx
  32. 18 18
      h2d/comp/JQuery.hx
  33. 6 6
      h2d/comp/Label.hx
  34. 7 7
      h2d/comp/Parser.hx
  35. 12 12
      h2d/comp/Select.hx
  36. 6 6
      h2d/comp/Slider.hx
  37. 2 2
      h2d/css/Fill.hx
  38. 5 5
      h2d/css/Parser.hx
  39. 6 6
      h2d/css/Style.hx
  40. 10 10
      h3d/Buffer.hx
  41. 26 26
      h3d/Camera.hx
  42. 5 5
      h3d/Indexes.hx
  43. 20 20
      h3d/Matrix.hx
  44. 23 23
      h3d/Quat.hx
  45. 9 9
      h3d/anim/FrameAnimation.hx
  46. 5 5
      h3d/anim/SimpleBlend.hx
  47. 16 16
      h3d/anim/Skin.hx
  48. 8 8
      h3d/anim/SmoothTransition.hx
  49. 8 8
      h3d/anim/Transition.hx
  50. 26 26
      h3d/col/Bounds.hx
  51. 17 17
      h3d/col/Plane.hx
  52. 12 12
      h3d/col/Point.hx
  53. 10 10
      h3d/col/Ray.hx
  54. 5 5
      h3d/col/Seg.hx
  55. 29 29
      h3d/impl/Driver.hx
  56. 8 8
      h3d/impl/ManagedBuffer.hx
  57. 9 9
      h3d/mat/Material.hx
  58. 4 4
      h3d/mat/MeshMaterial.hx
  59. 10 10
      h3d/mat/Pass.hx
  60. 20 20
      h3d/parts/Data.hx
  61. 70 70
      h3d/parts/Editor.hx
  62. 35 35
      h3d/parts/Emitter.hx
  63. 7 7
      h3d/parts/Material.hx
  64. 9 9
      h3d/parts/Particle.hx
  65. 9 9
      h3d/pass/Base.hx
  66. 12 12
      h3d/pass/Blur.hx
  67. 3 3
      h3d/pass/Distance.hx
  68. 4 4
      h3d/pass/LightSystem.hx
  69. 1 1
      h3d/pass/Params.hx
  70. 7 7
      h3d/pass/ShadowMap.hx
  71. 4 4
      h3d/prim/Cube.hx
  72. 7 7
      h3d/prim/Cylinder.hx
  73. 17 17
      h3d/prim/FBXModel.hx
  74. 4 4
      h3d/prim/GeoSphere.hx
  75. 6 6
      h3d/prim/MeshPrimitive.hx
  76. 5 5
      h3d/prim/Plan2D.hx
  77. 12 12
      h3d/prim/Plan3D.hx
  78. 9 9
      h3d/prim/Polygon.hx
  79. 7 7
      h3d/prim/Primitive.hx
  80. 8 8
      h3d/prim/Quads.hx
  81. 4 4
      h3d/prim/Sphere.hx
  82. 3 3
      h3d/prim/UV.hx
  83. 8 8
      h3d/scene/Box.hx
  84. 2 2
      h3d/scene/DirLight.hx
  85. 8 8
      h3d/scene/Graphics.hx
  86. 3 3
      h3d/scene/Light.hx
  87. 5 5
      h3d/scene/Mesh.hx
  88. 4 4
      h3d/scene/MultiMaterial.hx
  89. 46 46
      h3d/scene/Object.hx
  90. 4 4
      h3d/scene/PointLight.hx
  91. 10 10
      h3d/scene/RenderContext.hx
  92. 11 11
      h3d/scene/Scene.hx
  93. 13 13
      h3d/scene/Skin.hx
  94. 1 1
      h3d/shader/AlphaMap.hx
  95. 8 8
      h3d/shader/AmbientLight.hx
  96. 3 3
      h3d/shader/BlurShader.hx
  97. 1 1
      h3d/shader/Buffers.hx
  98. 3 3
      h3d/shader/ColorAdd.hx
  99. 3 3
      h3d/shader/ColorKey.hx
  100. 3 3
      h3d/shader/ColorMatrix.hx

+ 10 - 10
h2d/CachedBitmap.hx

@@ -5,10 +5,10 @@ class CachedBitmap extends Drawable {
 	public var width(default, set) : Int;
 	public var width(default, set) : Int;
 	public var height(default, set) : Int;
 	public var height(default, set) : Int;
 	public var freezed : Bool;
 	public var freezed : Bool;
-	
+
 	var renderDone : Bool;
 	var renderDone : Bool;
 	var tile : Tile;
 	var tile : Tile;
-	
+
 	public function new( ?parent, width = -1, height = -1 ) {
 	public function new( ?parent, width = -1, height = -1 ) {
 		super(parent);
 		super(parent);
 		this.width = width;
 		this.width = width;
@@ -26,7 +26,7 @@ class CachedBitmap extends Drawable {
 		clean();
 		clean();
 		super.onDelete();
 		super.onDelete();
 	}
 	}
-	
+
 	function set_width(w) {
 	function set_width(w) {
 		clean();
 		clean();
 		width = w;
 		width = w;
@@ -38,7 +38,7 @@ class CachedBitmap extends Drawable {
 		height = h;
 		height = h;
 		return h;
 		return h;
 	}
 	}
-	
+
 	public function getTile() {
 	public function getTile() {
 		if( tile == null ) {
 		if( tile == null ) {
 			var scene = getScene();
 			var scene = getScene();
@@ -55,7 +55,7 @@ class CachedBitmap extends Drawable {
 	override function drawRec( ctx : RenderContext ) {
 	override function drawRec( ctx : RenderContext ) {
 		emitTile(ctx, tile);
 		emitTile(ctx, tile);
 	}
 	}
-	
+
 	override function sync( ctx : RenderContext ) {
 	override function sync( ctx : RenderContext ) {
 		if( posChanged ) {
 		if( posChanged ) {
 			calcAbsPos();
 			calcAbsPos();
@@ -69,7 +69,7 @@ class CachedBitmap extends Drawable {
 		var tile = getTile();
 		var tile = getTile();
 		if( !freezed || !renderDone ) {
 		if( !freezed || !renderDone ) {
 			var oldA = matA, oldB = matB, oldC = matC, oldD = matD, oldX = absX, oldY = absY;
 			var oldA = matA, oldB = matB, oldC = matC, oldD = matD, oldX = absX, oldY = absY;
-			
+
 			// init matrix without rotation
 			// init matrix without rotation
 			matA = 1;
 			matA = 1;
 			matB = 0;
 			matB = 0;
@@ -77,7 +77,7 @@ class CachedBitmap extends Drawable {
 			matD = 1;
 			matD = 1;
 			absX = 0;
 			absX = 0;
 			absY = 0;
 			absY = 0;
-			
+
 			// adds a pixels-to-viewport transform
 			// adds a pixels-to-viewport transform
 			var w = 2 / tile.width;
 			var w = 2 / tile.width;
 			var h = -2 / tile.height;
 			var h = -2 / tile.height;
@@ -99,7 +99,7 @@ class CachedBitmap extends Drawable {
 			for( c in childs )
 			for( c in childs )
 				c.drawRec(ctx);
 				c.drawRec(ctx);
 			ctx.engine.setTarget(null);
 			ctx.engine.setTarget(null);
-			
+
 			// restore
 			// restore
 			matA = oldA;
 			matA = oldA;
 			matB = oldB;
 			matB = oldB;
@@ -107,11 +107,11 @@ class CachedBitmap extends Drawable {
 			matD = oldD;
 			matD = oldD;
 			absX = oldX;
 			absX = oldX;
 			absY = oldY;
 			absY = oldY;
-			
+
 			renderDone = true;
 			renderDone = true;
 		}
 		}
 
 
 		super.sync(ctx);
 		super.sync(ctx);
 	}
 	}
-	
+
 }
 }

+ 19 - 19
h2d/Console.hx

@@ -13,7 +13,7 @@ enum ConsoleArg {
 class Console extends h2d.Sprite {
 class Console extends h2d.Sprite {
 
 
 	public static var HIDE_LOG_TIMEOUT = 3.;
 	public static var HIDE_LOG_TIMEOUT = 3.;
-	
+
 	var width : Int;
 	var width : Int;
 	var height : Int;
 	var height : Int;
 	var bg : h2d.Bitmap;
 	var bg : h2d.Bitmap;
@@ -28,9 +28,9 @@ class Console extends h2d.Sprite {
 	var logs : Array<String>;
 	var logs : Array<String>;
 	var logIndex:Int;
 	var logIndex:Int;
 	var curCmd:String;
 	var curCmd:String;
-	
+
 	public var shortKeyChar : Int = "/".code;
 	public var shortKeyChar : Int = "/".code;
-	
+
 	public function new(font:h2d.Font,parent) {
 	public function new(font:h2d.Font,parent) {
 		super(parent);
 		super(parent);
 		height = font.lineHeight + 2;
 		height = font.lineHeight + 2;
@@ -51,29 +51,29 @@ class Console extends h2d.Sprite {
 		addCommand("help", "Show help", [ { name : "command", t : AString, opt : true } ], showHelp);
 		addCommand("help", "Show help", [ { name : "command", t : AString, opt : true } ], showHelp);
 		addAlias("?", "help");
 		addAlias("?", "help");
 	}
 	}
-	
+
 	public function addCommand( name, help, args, callb : Dynamic ) {
 	public function addCommand( name, help, args, callb : Dynamic ) {
 		commands.set(name, { help : help, args:args, callb:callb } );
 		commands.set(name, { help : help, args:args, callb:callb } );
 	}
 	}
-	
+
 	public function addAlias( name, command ) {
 	public function addAlias( name, command ) {
 		aliases.set(name, command);
 		aliases.set(name, command);
 	}
 	}
-	
+
 	public function runCommand( commandLine : String ) {
 	public function runCommand( commandLine : String ) {
 		handleCommand(commandLine);
 		handleCommand(commandLine);
 	}
 	}
-	
+
 	override function onAlloc() {
 	override function onAlloc() {
 		super.onAlloc();
 		super.onAlloc();
 		getScene().addEventListener(onEvent);
 		getScene().addEventListener(onEvent);
 	}
 	}
-	
+
 	override function onDelete() {
 	override function onDelete() {
 		getScene().removeEventListener(onEvent);
 		getScene().removeEventListener(onEvent);
 		super.onDelete();
 		super.onDelete();
 	}
 	}
-	
+
 	function onEvent( e : hxd.Event ) {
 	function onEvent( e : hxd.Event ) {
 		switch( e.kind ) {
 		switch( e.kind ) {
 		case EWheel:
 		case EWheel:
@@ -89,7 +89,7 @@ class Console extends h2d.Sprite {
 		default:
 		default:
 		}
 		}
 	}
 	}
-	
+
 	function showHelp( ?command : String ) {
 	function showHelp( ?command : String ) {
 		var all;
 		var all;
 		if( command == null ) {
 		if( command == null ) {
@@ -128,16 +128,16 @@ class Console extends h2d.Sprite {
 			log(str);
 			log(str);
 		}
 		}
 	}
 	}
-	
+
 	public function isActive() {
 	public function isActive() {
 		return bg.visible;
 		return bg.visible;
 	}
 	}
-	
+
 	function set_cursorPos(v:Int) {
 	function set_cursorPos(v:Int) {
 		cursor.x = tf.calcTextWidth(tf.text.substr(0, v));
 		cursor.x = tf.calcTextWidth(tf.text.substr(0, v));
 		return cursorPos = v;
 		return cursorPos = v;
 	}
 	}
-	
+
 	function handleKey( e : hxd.Event ) {
 	function handleKey( e : hxd.Event ) {
 		if( e.charCode == shortKeyChar && !bg.visible ) {
 		if( e.charCode == shortKeyChar && !bg.visible ) {
 			bg.visible = true;
 			bg.visible = true;
@@ -201,12 +201,12 @@ class Console extends h2d.Sprite {
 			cursorPos++;
 			cursorPos++;
 		}
 		}
 	}
 	}
-	
+
 	function hide() {
 	function hide() {
 		bg.visible = false;
 		bg.visible = false;
 		tf.text = "";
 		tf.text = "";
 	}
 	}
-	
+
 	function handleCommand( command : String ) {
 	function handleCommand( command : String ) {
 		command = StringTools.trim(command);
 		command = StringTools.trim(command);
 		if( command.charCodeAt(0) == "/".code ) command = command.substr(1);
 		if( command.charCodeAt(0) == "/".code ) command = command.substr(1);
@@ -216,7 +216,7 @@ class Console extends h2d.Sprite {
 		}
 		}
 		logs.push(command);
 		logs.push(command);
 		logIndex = -1;
 		logIndex = -1;
-		
+
 		var args = ~/[ \t]+/g.split(command);
 		var args = ~/[ \t]+/g.split(command);
 		var cmdName = args[0];
 		var cmdName = args[0];
 		if( aliases.exists(cmdName) ) cmdName = aliases.get(cmdName);
 		if( aliases.exists(cmdName) ) cmdName = aliases.get(cmdName);
@@ -282,7 +282,7 @@ class Console extends h2d.Sprite {
 			log('ERROR $e', errorColor);
 			log('ERROR $e', errorColor);
 		}
 		}
 	}
 	}
-	
+
 	public function log( text : String, ?color ) {
 	public function log( text : String, ?color ) {
 		if( color == null ) color = tf.textColor;
 		if( color == null ) color = tf.textColor;
 		var oldH = logTxt.textHeight;
 		var oldH = logTxt.textHeight;
@@ -292,7 +292,7 @@ class Console extends h2d.Sprite {
 		logTxt.visible = true;
 		logTxt.visible = true;
 		lastLogTime = haxe.Timer.stamp();
 		lastLogTime = haxe.Timer.stamp();
 	}
 	}
-	
+
 	override function sync(ctx:h2d.RenderContext) {
 	override function sync(ctx:h2d.RenderContext) {
 		var scene = getScene();
 		var scene = getScene();
 		if( scene != null ) {
 		if( scene != null ) {
@@ -313,5 +313,5 @@ class Console extends h2d.Sprite {
 		}
 		}
 		super.sync(ctx);
 		super.sync(ctx);
 	}
 	}
-	
+
 }
 }

+ 18 - 18
h2d/Drawable.hx

@@ -1,22 +1,22 @@
 package h2d;
 package h2d;
 
 
 class Drawable extends Sprite {
 class Drawable extends Sprite {
-	
+
 	public var color(default,null) : h3d.Vector;
 	public var color(default,null) : h3d.Vector;
 	public var alpha(get, set) : Float;
 	public var alpha(get, set) : Float;
 	public var blendMode : BlendMode;
 	public var blendMode : BlendMode;
 	public var filter : Bool;
 	public var filter : Bool;
 	public var colorKey(default, set) : Null<Int>;
 	public var colorKey(default, set) : Null<Int>;
-	
+
 	var shaders : Array<hxsl.Shader>;
 	var shaders : Array<hxsl.Shader>;
-	
+
 	function new(parent) {
 	function new(parent) {
 		super(parent);
 		super(parent);
 		blendMode = Normal;
 		blendMode = Normal;
 		color = new h3d.Vector(1, 1, 1, 1);
 		color = new h3d.Vector(1, 1, 1, 1);
 		shaders = [];
 		shaders = [];
 	}
 	}
-	
+
 	function set_colorKey(v:Null<Int>) {
 	function set_colorKey(v:Null<Int>) {
 		if( shaders != null ) {
 		if( shaders != null ) {
 			var s = getShader(h3d.shader.ColorKey);
 			var s = getShader(h3d.shader.ColorKey);
@@ -32,7 +32,7 @@ class Drawable extends Sprite {
 		}
 		}
 		return colorKey = v;
 		return colorKey = v;
 	}
 	}
-	
+
 	inline function get_alpha() {
 	inline function get_alpha() {
 		return color.a;
 		return color.a;
 	}
 	}
@@ -40,7 +40,7 @@ class Drawable extends Sprite {
 	inline function set_alpha(v) {
 	inline function set_alpha(v) {
 		return color.a = v;
 		return color.a = v;
 	}
 	}
-	
+
 	public function getDebugShaderCode( toHxsl = true ) {
 	public function getDebugShaderCode( toHxsl = true ) {
 		var shader = @:privateAccess {
 		var shader = @:privateAccess {
 			var ctx = getScene().ctx;
 			var ctx = getScene().ctx;
@@ -51,27 +51,27 @@ class Drawable extends Sprite {
 		var toString = toHxsl ? function(d) return hxsl.Printer.shaderToString(d,true) : hxsl.GlslOut.toGlsl;
 		var toString = toHxsl ? function(d) return hxsl.Printer.shaderToString(d,true) : hxsl.GlslOut.toGlsl;
 		return "VERTEX=\n" + toString(shader.vertex.data) + "\n\nFRAGMENT=\n" + toString(shader.fragment.data);
 		return "VERTEX=\n" + toString(shader.vertex.data) + "\n\nFRAGMENT=\n" + toString(shader.fragment.data);
 	}
 	}
-	
+
 	public function getShader< T:hxsl.Shader >( stype : Class<T> ) : T {
 	public function getShader< T:hxsl.Shader >( stype : Class<T> ) : T {
 		for( s in shaders )
 		for( s in shaders )
 			if( Std.is(s, stype) )
 			if( Std.is(s, stype) )
 				return cast s;
 				return cast s;
 		return null;
 		return null;
 	}
 	}
-	
+
 	public inline function getShaders() {
 	public inline function getShaders() {
 		return new hxd.impl.ArrayIterator<hxsl.Shader>(shaders);
 		return new hxd.impl.ArrayIterator<hxsl.Shader>(shaders);
 	}
 	}
-	
+
 	public function addShader<T:hxsl.Shader>( s : T ) : T {
 	public function addShader<T:hxsl.Shader>( s : T ) : T {
 		this.shaders.push(s);
 		this.shaders.push(s);
 		return s;
 		return s;
 	}
 	}
-	
+
 	public function removeShader( s : hxsl.Shader ) {
 	public function removeShader( s : hxsl.Shader ) {
 		return this.shaders.remove(s);
 		return this.shaders.remove(s);
 	}
 	}
-	
+
 	function emitTile( ctx : RenderContext, tile : Tile ) {
 	function emitTile( ctx : RenderContext, tile : Tile ) {
 		if( tile == null )
 		if( tile == null )
 			tile = new Tile(null, 0, 0, 5, 5);
 			tile = new Tile(null, 0, 0, 5, 5);
@@ -82,9 +82,9 @@ class Drawable extends Sprite {
 		var buf = ctx.buffer;
 		var buf = ctx.buffer;
 		var pos = ctx.bufPos;
 		var pos = ctx.bufPos;
 		buf.grow(pos + 4 * 8);
 		buf.grow(pos + 4 * 8);
-		
+
 		inline function emit(v:Float) buf[pos++] = v;
 		inline function emit(v:Float) buf[pos++] = v;
-		
+
 		emit(ax);
 		emit(ax);
 		emit(ay);
 		emit(ay);
 		emit(tile.u);
 		emit(tile.u);
@@ -93,15 +93,15 @@ class Drawable extends Sprite {
 		emit(color.g);
 		emit(color.g);
 		emit(color.b);
 		emit(color.b);
 		emit(color.a);
 		emit(color.a);
-		
-		
+
+
 		var tw = tile.width;
 		var tw = tile.width;
 		var th = tile.height;
 		var th = tile.height;
 		var dx1 = tw * matA;
 		var dx1 = tw * matA;
 		var dy1 = tw * matB;
 		var dy1 = tw * matB;
 		var dx2 = th * matC;
 		var dx2 = th * matC;
 		var dy2 = th * matD;
 		var dy2 = th * matD;
-		
+
 		emit(ax + dx1);
 		emit(ax + dx1);
 		emit(ay + dy1);
 		emit(ay + dy1);
 		emit(tile.u2);
 		emit(tile.u2);
@@ -110,7 +110,7 @@ class Drawable extends Sprite {
 		emit(color.g);
 		emit(color.g);
 		emit(color.b);
 		emit(color.b);
 		emit(color.a);
 		emit(color.a);
-		
+
 		emit(ax + dx2);
 		emit(ax + dx2);
 		emit(ay + dy2);
 		emit(ay + dy2);
 		emit(tile.u);
 		emit(tile.u);
@@ -131,5 +131,5 @@ class Drawable extends Sprite {
 
 
 		ctx.bufPos = pos;
 		ctx.bufPos = pos;
 	}
 	}
-	
+
 }
 }

+ 11 - 11
h2d/Font.hx

@@ -11,22 +11,22 @@ class Kerning {
 }
 }
 
 
 class FontChar {
 class FontChar {
-	
+
 	public var t : h2d.Tile;
 	public var t : h2d.Tile;
 	public var width : Int;
 	public var width : Int;
 	var kerning : Null<Kerning>;
 	var kerning : Null<Kerning>;
-	
+
 	public function new(t,w) {
 	public function new(t,w) {
 		this.t = t;
 		this.t = t;
 		this.width = w;
 		this.width = w;
 	}
 	}
-	
+
 	public function addKerning( prevChar : Int, offset : Int ) {
 	public function addKerning( prevChar : Int, offset : Int ) {
 		var k = new Kerning(prevChar, offset);
 		var k = new Kerning(prevChar, offset);
 		k.next = kerning;
 		k.next = kerning;
 		kerning = k;
 		kerning = k;
 	}
 	}
-	
+
 	public function getKerningOffset( prevChar : Int ) {
 	public function getKerningOffset( prevChar : Int ) {
 		var k = kerning;
 		var k = kerning;
 		while( k != null ) {
 		while( k != null ) {
@@ -40,7 +40,7 @@ class FontChar {
 }
 }
 
 
 class Font {
 class Font {
-	
+
 	public var name(default, null) : String;
 	public var name(default, null) : String;
 	public var size(default, null) : Int;
 	public var size(default, null) : Int;
 	public var lineHeight(default, null) : Int;
 	public var lineHeight(default, null) : Int;
@@ -48,7 +48,7 @@ class Font {
 	public var charset : hxd.Charset;
 	public var charset : hxd.Charset;
 	var glyphs : Map<Int,FontChar>;
 	var glyphs : Map<Int,FontChar>;
 	var defaultChar : FontChar;
 	var defaultChar : FontChar;
-	
+
 	function new(name,size) {
 	function new(name,size) {
 		this.name = name;
 		this.name = name;
 		this.size = size;
 		this.size = size;
@@ -56,7 +56,7 @@ class Font {
 		defaultChar = new FontChar(new Tile(null, 0, 0, 0, 0),0);
 		defaultChar = new FontChar(new Tile(null, 0, 0, 0, 0),0);
 		charset = hxd.Charset.getDefault();
 		charset = hxd.Charset.getDefault();
 	}
 	}
-	
+
 	public inline function getChar( code : Int ) {
 	public inline function getChar( code : Int ) {
 		var c = glyphs.get(code);
 		var c = glyphs.get(code);
 		if( c == null ) {
 		if( c == null ) {
@@ -65,7 +65,7 @@ class Font {
 		}
 		}
 		return c;
 		return c;
 	}
 	}
-	
+
 	/**
 	/**
 		This is meant to create smoother fonts by creating them with double size while still keeping the original glyph size.
 		This is meant to create smoother fonts by creating them with double size while still keeping the original glyph size.
 	**/
 	**/
@@ -78,13 +78,13 @@ class Font {
 		lineHeight = Std.int(lineHeight * ratio);
 		lineHeight = Std.int(lineHeight * ratio);
 		this.size = size;
 		this.size = size;
 	}
 	}
-	
+
 	public function hasChar( code : Int ) {
 	public function hasChar( code : Int ) {
 		return glyphs.get(code) != null;
 		return glyphs.get(code) != null;
 	}
 	}
-	
+
 	public function dispose() {
 	public function dispose() {
 		tile.dispose();
 		tile.dispose();
 	}
 	}
-	
+
 }
 }

+ 1 - 1
h2d/HtmlText.hx

@@ -1,7 +1,7 @@
 package h2d;
 package h2d;
 
 
 class HtmlText extends Text {
 class HtmlText extends Text {
-	
+
 	override function initGlyphs( text : String, rebuild = true, ?lines : Array<Int> ) {
 	override function initGlyphs( text : String, rebuild = true, ?lines : Array<Int> ) {
 		if( rebuild ) glyphs.reset();
 		if( rebuild ) glyphs.reset();
 		glyphs.setDefaultColor(textColor);
 		glyphs.setDefaultColor(textColor);

+ 9 - 9
h2d/Layers.hx

@@ -1,25 +1,25 @@
 package h2d;
 package h2d;
 
 
 class Layers extends Sprite {
 class Layers extends Sprite {
-	
+
 	// the per-layer insert position
 	// the per-layer insert position
 	var layers : Array<Int>;
 	var layers : Array<Int>;
 	var layerCount : Int;
 	var layerCount : Int;
-	
+
 	public function new(?parent) {
 	public function new(?parent) {
 		super(parent);
 		super(parent);
 		layers = [];
 		layers = [];
 		layerCount = 0;
 		layerCount = 0;
 	}
 	}
-	
+
 	override function addChild(s) {
 	override function addChild(s) {
 		addChildAt(s, 0);
 		addChildAt(s, 0);
 	}
 	}
-	
+
 	public inline function add(s, layer) {
 	public inline function add(s, layer) {
 		return addChildAt(s, layer);
 		return addChildAt(s, layer);
 	}
 	}
-	
+
 	override function addChildAt( s : Sprite, layer : Int ) {
 	override function addChildAt( s : Sprite, layer : Int ) {
 		if( s.parent == this ) {
 		if( s.parent == this ) {
 			var old = s.allocated;
 			var old = s.allocated;
@@ -34,7 +34,7 @@ class Layers extends Sprite {
 		for( i in layer...layerCount )
 		for( i in layer...layerCount )
 			layers[i]++;
 			layers[i]++;
 	}
 	}
-	
+
 	override function removeChild( s : Sprite ) {
 	override function removeChild( s : Sprite ) {
 		for( i in 0...childs.length ) {
 		for( i in 0...childs.length ) {
 			if( childs[i] == s ) {
 			if( childs[i] == s ) {
@@ -50,7 +50,7 @@ class Layers extends Sprite {
 			}
 			}
 		}
 		}
 	}
 	}
-	
+
 	public function under( s : Sprite ) {
 	public function under( s : Sprite ) {
 		for( i in 0...childs.length )
 		for( i in 0...childs.length )
 			if( childs[i] == s ) {
 			if( childs[i] == s ) {
@@ -83,7 +83,7 @@ class Layers extends Sprite {
 				break;
 				break;
 			}
 			}
 	}
 	}
-	
+
 	public function ysort( layer : Int ) {
 	public function ysort( layer : Int ) {
 		if( layer >= layerCount ) return;
 		if( layer >= layerCount ) return;
 		var start = layer == 0 ? 0 : layers[layer - 1];
 		var start = layer == 0 ? 0 : layers[layer - 1];
@@ -109,5 +109,5 @@ class Layers extends Sprite {
 		}
 		}
 	}
 	}
 
 
-	
+
 }
 }

+ 12 - 12
h2d/RenderContext.hx

@@ -1,7 +1,7 @@
 package h2d;
 package h2d;
 
 
 class RenderContext {
 class RenderContext {
-	
+
 	public var engine : h3d.Engine;
 	public var engine : h3d.Engine;
 	public var time : Float;
 	public var time : Float;
 	public var elapsedTime : Float;
 	public var elapsedTime : Float;
@@ -9,7 +9,7 @@ class RenderContext {
 
 
 	public var buffer : hxd.FloatBuffer;
 	public var buffer : hxd.FloatBuffer;
 	public var bufPos : Int;
 	public var bufPos : Int;
-	
+
 	var texture : h3d.mat.Texture;
 	var texture : h3d.mat.Texture;
 	var baseShader : h3d.shader.Base2d;
 	var baseShader : h3d.shader.Base2d;
 	var manager : h3d.shader.Manager;
 	var manager : h3d.shader.Manager;
@@ -19,7 +19,7 @@ class RenderContext {
 	var currentShaders : Array<hxsl.Shader>;
 	var currentShaders : Array<hxsl.Shader>;
 	var currentObj : Drawable;
 	var currentObj : Drawable;
 	var stride : Int;
 	var stride : Int;
-	
+
 	public function new() {
 	public function new() {
 		frame = 0;
 		frame = 0;
 		time = 0.;
 		time = 0.;
@@ -33,7 +33,7 @@ class RenderContext {
 		baseShader = new h3d.shader.Base2d();
 		baseShader = new h3d.shader.Base2d();
 		baseShader.zValue = 0.;
 		baseShader.zValue = 0.;
 	}
 	}
-	
+
 	public function begin() {
 	public function begin() {
 		texture = null;
 		texture = null;
 		currentObj = null;
 		currentObj = null;
@@ -45,20 +45,20 @@ class RenderContext {
 		engine.selectMaterial(pass);
 		engine.selectMaterial(pass);
 		engine.uploadShaderBuffers(buffers, Globals);
 		engine.uploadShaderBuffers(buffers, Globals);
 	}
 	}
-	
+
 	function initShaders( shaders ) {
 	function initShaders( shaders ) {
 		currentShaders = shaders;
 		currentShaders = shaders;
 		compiledShader = manager.compileShaders(shaders);
 		compiledShader = manager.compileShaders(shaders);
 		buffers = new h3d.shader.Buffers(compiledShader);
 		buffers = new h3d.shader.Buffers(compiledShader);
 		manager.fillGlobals(buffers, compiledShader);
 		manager.fillGlobals(buffers, compiledShader);
 	}
 	}
-	
+
 	public function end() {
 	public function end() {
 		flush();
 		flush();
 		texture = null;
 		texture = null;
 		currentObj = null;
 		currentObj = null;
 	}
 	}
-	
+
 	public function flush(force=false) {
 	public function flush(force=false) {
 		if( bufPos == 0 ) return;
 		if( bufPos == 0 ) return;
 		beforeDraw();
 		beforeDraw();
@@ -70,7 +70,7 @@ class RenderContext {
 		bufPos = 0;
 		bufPos = 0;
 		texture = null;
 		texture = null;
 	}
 	}
-	
+
 	public function beforeDraw() {
 	public function beforeDraw() {
 		baseShader.texture = texture;
 		baseShader.texture = texture;
 		texture.filter = currentObj.filter ? Linear : Nearest;
 		texture.filter = currentObj.filter ? Linear : Nearest;
@@ -93,7 +93,7 @@ class RenderContext {
 		engine.uploadShaderBuffers(buffers, Params);
 		engine.uploadShaderBuffers(buffers, Params);
 		engine.uploadShaderBuffers(buffers, Textures);
 		engine.uploadShaderBuffers(buffers, Textures);
 	}
 	}
-	
+
 	@:access(h2d.Drawable)
 	@:access(h2d.Drawable)
 	public function beginDrawObject( obj : h2d.Drawable, texture : h3d.mat.Texture ) {
 	public function beginDrawObject( obj : h2d.Drawable, texture : h3d.mat.Texture ) {
 		beginDraw(obj, texture, true);
 		beginDraw(obj, texture, true);
@@ -102,12 +102,12 @@ class RenderContext {
 		baseShader.absoluteMatrixB.set(obj.matB, obj.matD, obj.absY);
 		baseShader.absoluteMatrixB.set(obj.matB, obj.matD, obj.absY);
 		beforeDraw();
 		beforeDraw();
 	}
 	}
-	
+
 	@:access(h2d.Drawable)
 	@:access(h2d.Drawable)
 	public function beginDrawBatch( obj : h2d.Drawable, texture : h3d.mat.Texture ) {
 	public function beginDrawBatch( obj : h2d.Drawable, texture : h3d.mat.Texture ) {
 		beginDraw(obj, texture, false);
 		beginDraw(obj, texture, false);
 	}
 	}
-	
+
 	@:access(h2d.Drawable)
 	@:access(h2d.Drawable)
 	function beginDraw(	obj : h2d.Drawable, texture : h3d.mat.Texture, isRelative : Bool ) {
 	function beginDraw(	obj : h2d.Drawable, texture : h3d.mat.Texture, isRelative : Bool ) {
 		var stride = 8;
 		var stride = 8;
@@ -144,7 +144,7 @@ class RenderContext {
 			for( i in 0...obj.shaders.length )
 			for( i in 0...obj.shaders.length )
 				currentShaders[i+1] = obj.shaders[i];
 				currentShaders[i+1] = obj.shaders[i];
 		}
 		}
-			
+
 		this.texture = texture;
 		this.texture = texture;
 		this.stride = stride;
 		this.stride = stride;
 		this.currentObj = obj;
 		this.currentObj = obj;

+ 14 - 14
h2d/ScaleGrid.hx

@@ -1,16 +1,16 @@
 package h2d;
 package h2d;
 
 
 class ScaleGrid extends h2d.TileGroup {
 class ScaleGrid extends h2d.TileGroup {
-	
+
 
 
 	public var borderWidth : Int;
 	public var borderWidth : Int;
 	public var borderHeight : Int;
 	public var borderHeight : Int;
-	
+
 	public var width(default,set) : Int;
 	public var width(default,set) : Int;
 	public var height(default,set) : Int;
 	public var height(default,set) : Int;
-	
+
 	public var tileBorders(default,set) : Bool;
 	public var tileBorders(default,set) : Bool;
-	
+
 	public function new( tile, borderW, borderH, ?parent ) {
 	public function new( tile, borderW, borderH, ?parent ) {
 		super(tile,parent);
 		super(tile,parent);
 		borderWidth = borderW;
 		borderWidth = borderW;
@@ -24,7 +24,7 @@ class ScaleGrid extends h2d.TileGroup {
 		reset();
 		reset();
 		return b;
 		return b;
 	}
 	}
-	
+
 	function set_width(w) {
 	function set_width(w) {
 		this.width = w;
 		this.width = w;
 		reset();
 		reset();
@@ -36,11 +36,11 @@ class ScaleGrid extends h2d.TileGroup {
 		reset();
 		reset();
 		return h;
 		return h;
 	}
 	}
-	
+
 	override function draw( ctx : RenderContext ) {
 	override function draw( ctx : RenderContext ) {
 		if( content.isEmpty() ) {
 		if( content.isEmpty() ) {
 			var bw = borderWidth, bh = borderHeight;
 			var bw = borderWidth, bh = borderHeight;
-			
+
 			// 4 corners
 			// 4 corners
 			content.addColor(0, 0, curColor, tile.sub(0, 0, bw, bh));
 			content.addColor(0, 0, curColor, tile.sub(0, 0, bw, bh));
 			content.addColor(width - bw, 0, curColor, tile.sub(tile.width - bw, 0, bw, bh));
 			content.addColor(width - bw, 0, curColor, tile.sub(tile.width - bw, 0, bw, bh));
@@ -49,12 +49,12 @@ class ScaleGrid extends h2d.TileGroup {
 
 
 			var sizeX = tile.width - bw * 2;
 			var sizeX = tile.width - bw * 2;
 			var sizeY = tile.height - bh * 2;
 			var sizeY = tile.height - bh * 2;
-			
+
 			if( !tileBorders ) {
 			if( !tileBorders ) {
-				
+
 				var w = width - bw * 2;
 				var w = width - bw * 2;
 				var h = height - bh * 2;
 				var h = height - bh * 2;
-				
+
 				var t = tile.sub(bw, 0, sizeX, bh);
 				var t = tile.sub(bw, 0, sizeX, bh);
 				t.scaleToSize(w, bh);
 				t.scaleToSize(w, bh);
 				content.addColor(bw, 0, curColor, t);
 				content.addColor(bw, 0, curColor, t);
@@ -70,9 +70,9 @@ class ScaleGrid extends h2d.TileGroup {
 				var t = tile.sub(tile.width - bw, bh, bw, sizeY);
 				var t = tile.sub(tile.width - bw, bh, bw, sizeY);
 				t.scaleToSize(bw, h);
 				t.scaleToSize(bw, h);
 				content.addColor(w + bw, bh, curColor, t);
 				content.addColor(w + bw, bh, curColor, t);
-				
+
 			} else {
 			} else {
-				
+
 				var rw = Std.int((width - bw * 2) / sizeX);
 				var rw = Std.int((width - bw * 2) / sizeX);
 				for( x in 0...rw ) {
 				for( x in 0...rw ) {
 					content.addColor(bw + x * sizeX, 0, curColor, tile.sub(bw, 0, sizeX, bh));
 					content.addColor(bw + x * sizeX, 0, curColor, tile.sub(bw, 0, sizeX, bh));
@@ -95,12 +95,12 @@ class ScaleGrid extends h2d.TileGroup {
 					content.addColor(width - bw, bh + rh * sizeY, curColor, tile.sub(tile.width - bw, bh, bw, dy));
 					content.addColor(width - bw, bh + rh * sizeY, curColor, tile.sub(tile.width - bw, bh, bw, dy));
 				}
 				}
 			}
 			}
-			
+
 			var t = tile.sub(bw, bh, sizeX, sizeY);
 			var t = tile.sub(bw, bh, sizeX, sizeY);
 			t.scaleToSize(width - bw * 2,height - bh * 2);
 			t.scaleToSize(width - bw * 2,height - bh * 2);
 			content.addColor(bw, bh, curColor, t);
 			content.addColor(bw, bh, curColor, t);
 		}
 		}
 		super.draw(ctx);
 		super.draw(ctx);
 	}
 	}
-	
+
 }
 }

+ 4 - 4
h2d/Scene3D.hx

@@ -1,16 +1,16 @@
 package h2d;
 package h2d;
 
 
 class Scene3D extends Sprite {
 class Scene3D extends Sprite {
-	
+
 	public var scene : h3d.scene.Scene;
 	public var scene : h3d.scene.Scene;
-	
+
 	public function new( scene, ?parent ) {
 	public function new( scene, ?parent ) {
 		super(parent);
 		super(parent);
 		this.scene = scene;
 		this.scene = scene;
 	}
 	}
-	
+
 	override function draw( ctx : RenderContext ) {
 	override function draw( ctx : RenderContext ) {
 		scene.render(ctx.engine);
 		scene.render(ctx.engine);
 	}
 	}
-	
+
 }
 }

+ 4 - 4
h2d/SpriteBatch.hx

@@ -37,15 +37,15 @@ class BatchElement {
 		rotation = 0; scale = 1;
 		rotation = 0; scale = 1;
 		this.t = t;
 		this.t = t;
 	}
 	}
-	
+
 	inline function get_alpha() {
 	inline function get_alpha() {
 		return a;
 		return a;
 	}
 	}
-	
+
 	inline function set_alpha(v) {
 	inline function set_alpha(v) {
 		return a = v;
 		return a = v;
 	}
 	}
-	
+
 	function update(et:Float) {
 	function update(et:Float) {
 		return true;
 		return true;
 	}
 	}
@@ -242,7 +242,7 @@ class SpriteBatch extends Drawable {
 	public inline function isEmpty() {
 	public inline function isEmpty() {
 		return first == null;
 		return first == null;
 	}
 	}
-	
+
 	public inline function getElements() {
 	public inline function getElements() {
 		return new ElementsIterator(first);
 		return new ElementsIterator(first);
 	}
 	}

+ 4 - 4
h2d/TileGroup.hx

@@ -21,7 +21,7 @@ private class TileLayerContent extends h3d.prim.Primitive {
 		xMax = hxd.Math.NEGATIVE_INFINITY;
 		xMax = hxd.Math.NEGATIVE_INFINITY;
 		yMax = hxd.Math.NEGATIVE_INFINITY;
 		yMax = hxd.Math.NEGATIVE_INFINITY;
 	}
 	}
-	
+
 	public function isEmpty() {
 	public function isEmpty() {
 		return triCount() == 0;
 		return triCount() == 0;
 	}
 	}
@@ -70,7 +70,7 @@ private class TileLayerContent extends h3d.prim.Primitive {
 		tmp.push(b);
 		tmp.push(b);
 		tmp.push(a);
 		tmp.push(a);
 	}
 	}
-	
+
 	public function addPoint( x : Float, y : Float, color : Int ) {
 	public function addPoint( x : Float, y : Float, color : Int ) {
 		tmp.push(x);
 		tmp.push(x);
 		tmp.push(y);
 		tmp.push(y);
@@ -82,7 +82,7 @@ private class TileLayerContent extends h3d.prim.Primitive {
 		if( x > xMax ) xMax = x;
 		if( x > xMax ) xMax = x;
 		if( y > yMax ) yMax = y;
 		if( y > yMax ) yMax = y;
 	}
 	}
-	
+
 	inline function insertColor( c : Int ) {
 	inline function insertColor( c : Int ) {
 		tmp.push(((c >> 16) & 0xFF) / 255.);
 		tmp.push(((c >> 16) & 0xFF) / 255.);
 		tmp.push(((c >> 8) & 0xFF) / 255.);
 		tmp.push(((c >> 8) & 0xFF) / 255.);
@@ -204,7 +204,7 @@ class TileGroup extends Drawable {
 	override function draw(ctx:RenderContext) {
 	override function draw(ctx:RenderContext) {
 		drawWith(ctx,this);
 		drawWith(ctx,this);
 	}
 	}
-	
+
 	@:allow(h2d)
 	@:allow(h2d)
 	function drawWith( ctx:RenderContext, obj : Drawable ) {
 	function drawWith( ctx:RenderContext, obj : Drawable ) {
 		ctx.beginDrawObject(obj, tile.getTexture());
 		ctx.beginDrawObject(obj, tile.getTexture());

+ 4 - 4
h2d/col/Circle.hx

@@ -6,13 +6,13 @@ class Circle {
 	public var x : Float;
 	public var x : Float;
 	public var y : Float;
 	public var y : Float;
 	public var ray : Float;
 	public var ray : Float;
-	
+
 	public inline function new( x : Float, y : Float, ray : Float ) {
 	public inline function new( x : Float, y : Float, ray : Float ) {
 		this.x = x;
 		this.x = x;
 		this.y = y;
 		this.y = y;
 		this.ray = ray;
 		this.ray = ray;
 	}
 	}
-	
+
 	public inline function distanceSq( p : Point ) {
 	public inline function distanceSq( p : Point ) {
 		var dx = p.x - x;
 		var dx = p.x - x;
 		var dy = p.y - y;
 		var dy = p.y - y;
@@ -25,7 +25,7 @@ class Circle {
 		var dy = p.y - y;
 		var dy = p.y - y;
 		return ray * ray - (dx * dx + dy * dy);
 		return ray * ray - (dx * dx + dy * dy);
 	}
 	}
-	
+
 	public inline function collideCircle( c : Circle ) {
 	public inline function collideCircle( c : Circle ) {
 		var dx = x - c.x;
 		var dx = x - c.x;
 		var dy = y - c.y;
 		var dy = y - c.y;
@@ -35,5 +35,5 @@ class Circle {
 	public function toString() {
 	public function toString() {
 		return '{${Math.fmt(x)},${Math.fmt(y)},${Math.fmt(ray)}}';
 		return '{${Math.fmt(x)},${Math.fmt(y)},${Math.fmt(ray)}}';
 	}
 	}
-	
+
 }
 }

文件差异内容过多而无法显示
+ 0 - 0
h2d/col/Delaunay.hx


+ 6 - 6
h2d/col/Line.hx

@@ -9,18 +9,18 @@ class Line {
 		this.p1 = p1;
 		this.p1 = p1;
 		this.p2 = p2;
 		this.p2 = p2;
 	}
 	}
-	
+
 	public inline function side( p : Point ) {
 	public inline function side( p : Point ) {
 		return (p2.x - p1.x) * (p.y - p1.y) - (p2.y - p1.y) * (p.x - p1.x);
 		return (p2.x - p1.x) * (p.y - p1.y) - (p2.y - p1.y) * (p.x - p1.x);
 	}
 	}
-	
+
 	public inline function project( p : Point ) {
 	public inline function project( p : Point ) {
 		var dx = p2.x - p1.x;
 		var dx = p2.x - p1.x;
 		var dy = p2.y - p1.y;
 		var dy = p2.y - p1.y;
 		var k = ((p.x - p1.x) * dx + (p.y - p1.y) * dy) / (dx * dx + dy * dy);
 		var k = ((p.x - p1.x) * dx + (p.y - p1.y) * dy) / (dx * dx + dy * dy);
 		return new Point(dx * k + p1.x, dy * k + p1.y);
 		return new Point(dx * k + p1.x, dy * k + p1.y);
 	}
 	}
-	
+
 	public inline function intersect( l : Line ) {
 	public inline function intersect( l : Line ) {
 		var d = (p1.x - p2.x) * (l.p1.y - l.p2.y) - (p1.y - p2.y) * (l.p1.x - l.p2.x);
 		var d = (p1.x - p2.x) * (l.p1.y - l.p2.y) - (p1.y - p2.y) * (l.p1.x - l.p2.x);
 		if( hxd.Math.abs(d) < hxd.Math.EPSILON )
 		if( hxd.Math.abs(d) < hxd.Math.EPSILON )
@@ -40,7 +40,7 @@ class Line {
 		pt.y = (a * (l.p1.y - l.p2.y) - (p1.y - p2.y) * b) / d;
 		pt.y = (a * (l.p1.y - l.p2.y) - (p1.y - p2.y) * b) / d;
 		return true;
 		return true;
 	}
 	}
-	
+
 	public inline function distanceSq( p : Point ) {
 	public inline function distanceSq( p : Point ) {
 		var dx = p2.x - p1.x;
 		var dx = p2.x - p1.x;
 		var dy = p2.y - p1.y;
 		var dy = p2.y - p1.y;
@@ -49,9 +49,9 @@ class Line {
 		var my = dy * k + p1.y - p.y;
 		var my = dy * k + p1.y - p.y;
 		return mx * mx + my * my;
 		return mx * mx + my * my;
 	}
 	}
-	
+
 	public inline function distance( p : Point ) {
 	public inline function distance( p : Point ) {
 		return hxd.Math.sqrt(distanceSq(p));
 		return hxd.Math.sqrt(distanceSq(p));
 	}
 	}
-	
+
 }
 }

+ 7 - 7
h2d/col/Point.hx

@@ -2,29 +2,29 @@ package h2d.col;
 import hxd.Math;
 import hxd.Math;
 
 
 class Point {
 class Point {
-	
+
 	public var x : Float;
 	public var x : Float;
 	public var y : Float;
 	public var y : Float;
-	
+
 	public inline function new(x = 0., y = 0.) {
 	public inline function new(x = 0., y = 0.) {
 		this.x = x;
 		this.x = x;
 		this.y = y;
 		this.y = y;
 	}
 	}
-	
+
 	public inline function distanceSq( p : Point ) {
 	public inline function distanceSq( p : Point ) {
 		var dx = x - p.x;
 		var dx = x - p.x;
 		var dy = y - p.y;
 		var dy = y - p.y;
 		return dx * dx + dy * dy;
 		return dx * dx + dy * dy;
 	}
 	}
-	
+
 	public inline function distance( p : Point ) {
 	public inline function distance( p : Point ) {
 		return Math.sqrt(distanceSq(p));
 		return Math.sqrt(distanceSq(p));
 	}
 	}
-	
+
 	public function toString() {
 	public function toString() {
 		return "{" + Math.fmt(x) + "," + Math.fmt(y) + "}";
 		return "{" + Math.fmt(x) + "," + Math.fmt(y) + "}";
 	}
 	}
-		
+
 	public inline function sub( p : Point ) {
 	public inline function sub( p : Point ) {
 		return new Point(x - p.x, y - p.y);
 		return new Point(x - p.x, y - p.y);
 	}
 	}
@@ -61,5 +61,5 @@ class Point {
 		x *= f;
 		x *= f;
 		y *= f;
 		y *= f;
 	}
 	}
-	
+
 }
 }

+ 8 - 8
h2d/col/Poly.hx

@@ -5,11 +5,11 @@ class Poly {
 
 
 	public var points : Array<Point>;
 	public var points : Array<Point>;
 	var segments : Array<Seg>;
 	var segments : Array<Seg>;
-	
+
 	public function new( points ) {
 	public function new( points ) {
 		this.points = points;
 		this.points = points;
 	}
 	}
-		
+
 	public function isConvex() {
 	public function isConvex() {
 		for( i in 0...points.length ) {
 		for( i in 0...points.length ) {
 			var p1 = points[i];
 			var p1 = points[i];
@@ -20,7 +20,7 @@ class Poly {
 		}
 		}
 		return true;
 		return true;
 	}
 	}
-	
+
 	public function calculateArea() {
 	public function calculateArea() {
 		var s = 0.;
 		var s = 0.;
 		for( i in 0...points.length ) {
 		for( i in 0...points.length ) {
@@ -41,14 +41,14 @@ class Poly {
 		}
 		}
 		return segments;
 		return segments;
 	}
 	}
-	
+
 	public function hasPoint( p : Point ) {
 	public function hasPoint( p : Point ) {
 		for( s in getSegments() )
 		for( s in getSegments() )
 			if( s.side(p) < 0 )
 			if( s.side(p) < 0 )
 				return false;
 				return false;
 		return true;
 		return true;
 	}
 	}
-	
+
 	public function project( p : Point ) : Point {
 	public function project( p : Point ) : Point {
 		var dmin = 1e20, smin = null;
 		var dmin = 1e20, smin = null;
 		for( s in getSegments() ) {
 		for( s in getSegments() ) {
@@ -60,7 +60,7 @@ class Poly {
 		}
 		}
 		return smin.project(p);
 		return smin.project(p);
 	}
 	}
-	
+
 	public function distanceSq( p : Point ) {
 	public function distanceSq( p : Point ) {
 		var dmin = 1e20;
 		var dmin = 1e20;
 		for( s in getSegments() ) {
 		for( s in getSegments() ) {
@@ -69,9 +69,9 @@ class Poly {
 		}
 		}
 		return dmin;
 		return dmin;
 	}
 	}
-	
+
 	public inline function distance( p : Point ) {
 	public inline function distance( p : Point ) {
 		return Math.sqrt(distanceSq(p));
 		return Math.sqrt(distanceSq(p));
 	}
 	}
-	
+
 }
 }

+ 13 - 13
h2d/col/Polynomial.hx

@@ -4,7 +4,7 @@ private class Matrix {
 	public var data : haxe.ds.Vector<haxe.ds.Vector<Float>>;
 	public var data : haxe.ds.Vector<haxe.ds.Vector<Float>>;
 	public var m : Int;
 	public var m : Int;
 	public var n : Int;
 	public var n : Int;
-	
+
 	public function new(m, n) {
 	public function new(m, n) {
 		this.m = m;
 		this.m = m;
 		this.n = n;
 		this.n = n;
@@ -12,7 +12,7 @@ private class Matrix {
 		for( i in 0...m )
 		for( i in 0...m )
 			data[i] = new haxe.ds.Vector(n);
 			data[i] = new haxe.ds.Vector(n);
 	}
 	}
-	
+
 	public function clone() {
 	public function clone() {
 		var m2 = new Matrix(m, n);
 		var m2 = new Matrix(m, n);
 		for( i in 0...m )
 		for( i in 0...m )
@@ -20,25 +20,25 @@ private class Matrix {
 				m2.data[i][j] = data[i][j];
 				m2.data[i][j] = data[i][j];
 		return m2;
 		return m2;
 	}
 	}
-	
+
 	function toString() {
 	function toString() {
 		return "[" + [for( k in data ) "\n" + Std.string(k)].join("") + "\n]";
 		return "[" + [for( k in data ) "\n" + Std.string(k)].join("") + "\n]";
 	}
 	}
 }
 }
 
 
 private class QR {
 private class QR {
-	
+
 	var qr : haxe.ds.Vector<haxe.ds.Vector<Float>>;
 	var qr : haxe.ds.Vector<haxe.ds.Vector<Float>>;
 	var rDiag : haxe.ds.Vector<Float>;
 	var rDiag : haxe.ds.Vector<Float>;
 	var m : Int;
 	var m : Int;
 	var n : Int;
 	var n : Int;
-	
+
 	public function new( mat : Matrix ) {
 	public function new( mat : Matrix ) {
 		this.m = mat.m;
 		this.m = mat.m;
 		this.n = mat.n;
 		this.n = mat.n;
 		qr = mat.clone().data;
 		qr = mat.clone().data;
 		rDiag = new haxe.ds.Vector(n);
 		rDiag = new haxe.ds.Vector(n);
-		
+
 		for( k in 0...n ) {
 		for( k in 0...n ) {
 			var nrm = 0.;
 			var nrm = 0.;
 			for( i in k...m )
 			for( i in k...m )
@@ -60,14 +60,14 @@ private class QR {
 			rDiag[k] = -nrm;
 			rDiag[k] = -nrm;
 		}
 		}
 	}
 	}
-	
+
 	function isFullRank() {
 	function isFullRank() {
 		for( j in 0...n )
 		for( j in 0...n )
 			if( rDiag[j] == 0 )
 			if( rDiag[j] == 0 )
 				return false;
 				return false;
 		return true;
 		return true;
 	}
 	}
-	
+
 	public function solve( b : Matrix ) {
 	public function solve( b : Matrix ) {
 		if( b.m != m ) throw "Invalid matrix size";
 		if( b.m != m ) throw "Invalid matrix size";
 		if( !isFullRank() ) return null;
 		if( !isFullRank() ) return null;
@@ -96,7 +96,7 @@ private class QR {
 			beta.push(X[i][0]);
 			beta.push(X[i][0]);
 		return beta;
 		return beta;
 	}
 	}
-	
+
 	function hypot( x : Float, y : Float ) {
 	function hypot( x : Float, y : Float ) {
 		if( x < 0 ) x = -x;
 		if( x < 0 ) x = -x;
 		if( y < 0 ) y = -y;
 		if( y < 0 ) y = -y;
@@ -109,7 +109,7 @@ private class QR {
 		t = t/x;
 		t = t/x;
 		return x * Math.sqrt(1+t*t);
 		return x * Math.sqrt(1+t*t);
 	}
 	}
-	
+
 }
 }
 
 
 class Polynomial {
 class Polynomial {
@@ -129,11 +129,11 @@ class Polynomial {
 		for( i in 0...n )
 		for( i in 0...n )
 			for( j in 0...degree+1 )
 			for( j in 0...degree+1 )
 				x.data[i][j] = Math.pow(xVals[i], j);
 				x.data[i][j] = Math.pow(xVals[i], j);
-				
+
 		var y = new Matrix(yVals.length, n);
 		var y = new Matrix(yVals.length, n);
 		for( i in 0...yVals.length )
 		for( i in 0...yVals.length )
 			y.data[i][0] = yVals[i];
 			y.data[i][0] = yVals[i];
-		
+
 		var qr = new QR(x);
 		var qr = new QR(x);
 		var beta = qr.solve(y);
 		var beta = qr.solve(y);
 		if( beta == null ) {
 		if( beta == null ) {
@@ -142,5 +142,5 @@ class Polynomial {
 		}
 		}
 		return beta;
 		return beta;
 	}
 	}
-	
+
 }
 }

+ 3 - 3
h2d/col/RoundRect.hx

@@ -9,7 +9,7 @@ class RoundRect {
 	var dy : Float;
 	var dy : Float;
 	var lenSq : Float;
 	var lenSq : Float;
 	var invLenSq : Float;
 	var invLenSq : Float;
-	
+
 	public inline function new(x:Float,y:Float,w:Float,h:Float,rotation:Float) {
 	public inline function new(x:Float,y:Float,w:Float,h:Float,rotation:Float) {
 		if( w < h ) {
 		if( w < h ) {
 			var tmp = w;
 			var tmp = w;
@@ -47,7 +47,7 @@ class RoundRect {
 			pdx * pdx + pdy * pdy;
 			pdx * pdx + pdy * pdy;
 		}
 		}
 	}
 	}
-	
+
 	public inline function inside( p : Point ) {
 	public inline function inside( p : Point ) {
 		return distanceCenterSq(p) - ray * ray < 0;
 		return distanceCenterSq(p) - ray * ray < 0;
 	}
 	}
@@ -55,7 +55,7 @@ class RoundRect {
 	public inline function distance( p : Point ) {
 	public inline function distance( p : Point ) {
 		return Math.sqrt(distanceCenterSq(p)) - ray;
 		return Math.sqrt(distanceCenterSq(p)) - ray;
 	}
 	}
-	
+
 	public inline function getNormalAt( p : Point ) {
 	public inline function getNormalAt( p : Point ) {
 		var px = p.x - x;
 		var px = p.x - x;
 		var py = p.y - y;
 		var py = p.y - y;

+ 5 - 5
h2d/col/Seg.hx

@@ -9,11 +9,11 @@ class Seg {
 	public var dy : Float;
 	public var dy : Float;
 	public var lenSq : Float;
 	public var lenSq : Float;
 	public var invLenSq : Float;
 	public var invLenSq : Float;
-	
+
 	public inline function new( p1 : Point, p2 : Point ) {
 	public inline function new( p1 : Point, p2 : Point ) {
 		setPoints(p1, p2);
 		setPoints(p1, p2);
 	}
 	}
-	
+
 	public inline function setPoints( p1 : Point, p2 : Point ) {
 	public inline function setPoints( p1 : Point, p2 : Point ) {
 		x = p1.x;
 		x = p1.x;
 		y = p1.y;
 		y = p1.y;
@@ -22,11 +22,11 @@ class Seg {
 		lenSq = dx * dx + dy * dy;
 		lenSq = dx * dx + dy * dy;
 		invLenSq = 1 / lenSq;
 		invLenSq = 1 / lenSq;
 	}
 	}
-	
+
 	public inline function side( p : Point ) {
 	public inline function side( p : Point ) {
 		return dx * (p.y - y) - dy * (p.x - x);
 		return dx * (p.y - y) - dy * (p.x - x);
 	}
 	}
-	
+
 	public inline function distanceSq( p : Point ) {
 	public inline function distanceSq( p : Point ) {
 		var px = p.x - x;
 		var px = p.x - x;
 		var py = p.y - y;
 		var py = p.y - y;
@@ -48,7 +48,7 @@ class Seg {
 	public inline function distance( p : Point ) {
 	public inline function distance( p : Point ) {
 		return Math.sqrt(distanceSq(p));
 		return Math.sqrt(distanceSq(p));
 	}
 	}
-	
+
 	public inline function project( p : Point ) : Point {
 	public inline function project( p : Point ) : Point {
 		var px = p.x - x;
 		var px = p.x - x;
 		var py = p.y - y;
 		var py = p.y - y;

+ 7 - 7
h2d/col/Triangle.hx

@@ -1,26 +1,26 @@
 package h2d.col;
 package h2d.col;
 
 
 class Triangle {
 class Triangle {
-	
+
 	static inline var UNDEF = 1.1315e-17;
 	static inline var UNDEF = 1.1315e-17;
-	
+
 	public var a : Point;
 	public var a : Point;
 	public var b : Point;
 	public var b : Point;
 	public var c : Point;
 	public var c : Point;
 	var area : Float;
 	var area : Float;
 	var invArea : Float;
 	var invArea : Float;
-	
+
 	public inline function new( a : Point, b : Point, c : Point ) {
 	public inline function new( a : Point, b : Point, c : Point ) {
 		this.a = a;
 		this.a = a;
 		this.b = b;
 		this.b = b;
 		this.c = c;
 		this.c = c;
 		area = UNDEF;
 		area = UNDEF;
 	}
 	}
-	
+
 	public inline function getCenter() {
 	public inline function getCenter() {
 		return new Point((a.x + b.x + c.x) / 3, (a.y + b.y + c.y) / 3);
 		return new Point((a.x + b.x + c.x) / 3, (a.y + b.y + c.y) / 3);
 	}
 	}
-	
+
 	public function getArea() {
 	public function getArea() {
 		if( area == UNDEF ) {
 		if( area == UNDEF ) {
 			area = ((a.y * b.x - a.x * b.y) + (b.y * c.x - b.x * c.y) + (c.y * a.x - c.x * a.y)) * -0.5;
 			area = ((a.y * b.x - a.x * b.y) + (b.y * c.x - b.x * c.y) + (c.y * a.x - c.x * a.y)) * -0.5;
@@ -33,7 +33,7 @@ class Triangle {
 		getArea();
 		getArea();
 		return invArea;
 		return invArea;
 	}
 	}
-	
+
 	/**
 	/**
 		Calculate barycentric coordinates for the point p
 		Calculate barycentric coordinates for the point p
 	**/
 	**/
@@ -43,5 +43,5 @@ class Triangle {
 		var t = area * (a.x * b.y - a.y * b.x + (a.y - b.y) * p.x + (b.x - a.x) * p.y);
 		var t = area * (a.x * b.y - a.y * b.x + (a.y - b.y) * p.x + (b.x - a.x) * p.y);
 		return new h3d.col.Point(1 - s - t, s, t);
 		return new h3d.col.Point(1 - s - t, s, t);
 	}
 	}
-	
+
 }
 }

+ 17 - 17
h2d/col/Voronoi.hx

@@ -32,9 +32,9 @@ private class RBNode<T:RBNode<T>> {
 }
 }
 
 
 @:generic private class RBTree<T:RBNode<T>> {
 @:generic private class RBTree<T:RBNode<T>> {
-	
+
 	public var root : T;
 	public var root : T;
-	
+
 	public function new() {
 	public function new() {
 		this.root = null;
 		this.root = null;
     }
     }
@@ -320,17 +320,17 @@ private class RBNode<T:RBNode<T>> {
 }
 }
 
 
 class Cell {
 class Cell {
-	
+
 	public var id : Int;
 	public var id : Int;
 	public var point : Point;
 	public var point : Point;
 	public var halfedges : Array<Halfedge>;
 	public var halfedges : Array<Halfedge>;
-	
+
 	public function new(id, point) {
 	public function new(id, point) {
 		this.id = id;
 		this.id = id;
 		this.point = point;
 		this.point = point;
 		this.halfedges = [];
 		this.halfedges = [];
     }
     }
-	
+
 	public function getCircle() {
 	public function getCircle() {
 		// still not the best enclosing circle
 		// still not the best enclosing circle
 		// would require implementing http://www.personal.kent.edu/~rmuhamma/Compgeometry/MyCG/CG-Applets/Center/centercli.htm for complete solution
 		// would require implementing http://www.personal.kent.edu/~rmuhamma/Compgeometry/MyCG/CG-Applets/Center/centercli.htm for complete solution
@@ -371,7 +371,7 @@ class Cell {
 		halfedges.sort(sortByAngle);
 		halfedges.sort(sortByAngle);
 		return halfedges.length;
 		return halfedges.length;
 	}
 	}
-	
+
 	static function sortByAngle(a:Halfedge, b:Halfedge) {
 	static function sortByAngle(a:Halfedge, b:Halfedge) {
 		return b.angle > a.angle ? 1 : (b.angle < a.angle ? -1 : 0);
 		return b.angle > a.angle ? 1 : (b.angle < a.angle ? -1 : 0);
 	}
 	}
@@ -455,7 +455,7 @@ class Cell {
 			}
 			}
 		return 1;
 		return 1;
 	}
 	}
-	
+
 }
 }
 
 
 class Edge {
 class Edge {
@@ -467,7 +467,7 @@ class Edge {
 	public var rCell : Null<Cell>;
 	public var rCell : Null<Cell>;
 	public var va : Null<Point>;
 	public var va : Null<Point>;
 	public var vb : Null<Point>;
 	public var vb : Null<Point>;
-	
+
 	public function new(lPoint, rPoint) {
 	public function new(lPoint, rPoint) {
 		this.lPoint = lPoint;
 		this.lPoint = lPoint;
 		this.rPoint = rPoint;
 		this.rPoint = rPoint;
@@ -477,11 +477,11 @@ class Edge {
 
 
 
 
 class Halfedge {
 class Halfedge {
-	
+
 	public var point : Point;
 	public var point : Point;
 	public var edge : Edge;
 	public var edge : Edge;
 	public var angle : Float;
 	public var angle : Float;
-	
+
 	public function new(edge, lPoint:Point, rPoint:Point) {
 	public function new(edge, lPoint:Point, rPoint:Point) {
 		this.point = lPoint;
 		this.point = lPoint;
 		this.edge = edge;
 		this.edge = edge;
@@ -504,7 +504,7 @@ class Halfedge {
 				: Math.atan2(va.x-vb.x, vb.y-va.y);
 				: Math.atan2(va.x-vb.x, vb.y-va.y);
 		}
 		}
 	}
 	}
-	
+
 	public inline function getStartpoint() {
 	public inline function getStartpoint() {
 		return this.edge.lPoint == this.point ? this.edge.va : this.edge.vb;
 		return this.edge.lPoint == this.point ? this.edge.va : this.edge.vb;
     }
     }
@@ -512,7 +512,7 @@ class Halfedge {
 	public inline function getEndpoint() {
 	public inline function getEndpoint() {
 		return this.edge.lPoint == this.point ? this.edge.vb : this.edge.va;
 		return this.edge.lPoint == this.point ? this.edge.vb : this.edge.va;
     }
     }
-	
+
 	public inline function getTarget() {
 	public inline function getTarget() {
 		return this.edge.lCell != null && this.edge.lCell.point != point ? this.edge.lCell : this.edge.rCell;
 		return this.edge.lCell != null && this.edge.lCell.point != point ? this.edge.lCell : this.edge.rCell;
 	}
 	}
@@ -547,7 +547,7 @@ private class CircleEvent extends RBNode<CircleEvent> {
 }
 }
 
 
 class Voronoi {
 class Voronoi {
-	
+
 	var epsilon : Float;
 	var epsilon : Float;
 	var beachline : RBTree<Beachsection>;
 	var beachline : RBTree<Beachsection>;
 	var vertices : Array<Point>;
 	var vertices : Array<Point>;
@@ -646,7 +646,7 @@ class Voronoi {
 	function setEdgeEndpoint(edge, lPoint, rPoint, vertex) {
 	function setEdgeEndpoint(edge, lPoint, rPoint, vertex) {
 		this.setEdgeStartpoint(edge, rPoint, lPoint, vertex);
 		this.setEdgeStartpoint(edge, rPoint, lPoint, vertex);
     }
     }
-	
+
 
 
 	// rhill 2011-06-02: A lot of Beachsection instanciations
 	// rhill 2011-06-02: A lot of Beachsection instanciations
 	// occur during the computation of the Voronoi diagram,
 	// occur during the computation of the Voronoi diagram,
@@ -1406,7 +1406,7 @@ class Voronoi {
 		var r = b.y - a.y;
 		var r = b.y - a.y;
 		return r < 0 ? -1 : (r > 0 ? 1 : (b.x > a.x ? 1 : b.x < a.x ? -1 : 0));
 		return r < 0 ? -1 : (r > 0 ? 1 : (b.x > a.x ? 1 : b.x < a.x ? -1 : 0));
 	}
 	}
-	
+
 	// rhill 2011-05-19:
 	// rhill 2011-05-19:
 	//   Voronoi points are kept client-side now, to allow
 	//   Voronoi points are kept client-side now, to allow
 	//   user to freely modify content. At compute time,
 	//   user to freely modify content. At compute time,
@@ -1463,7 +1463,7 @@ class Voronoi {
 			// all done, quit
 			// all done, quit
 			else
 			else
 				break;
 				break;
-				
+
 		}
 		}
 
 
 		// wrapping-up:
 		// wrapping-up:
@@ -1475,7 +1475,7 @@ class Voronoi {
 
 
 		//   add missing edges in order to close opened cells
 		//   add missing edges in order to close opened cells
 		this.closeCells(bbox);
 		this.closeCells(bbox);
-		
+
 		var eid = 0;
 		var eid = 0;
 		for( e in edges ) {
 		for( e in edges ) {
 			e.id = eid++;
 			e.id = eid++;

+ 5 - 5
h2d/comp/Box.hx

@@ -1,17 +1,17 @@
 package h2d.comp;
 package h2d.comp;
 
 
 class Box extends Component {
 class Box extends Component {
-	
+
 	var input : h2d.Interactive;
 	var input : h2d.Interactive;
 	var scrollX : Float = 0.;
 	var scrollX : Float = 0.;
 	var scrollY : Float = 0.;
 	var scrollY : Float = 0.;
-	
+
 	public function new(?layout,?parent) {
 	public function new(?layout,?parent) {
 		super("box", parent);
 		super("box", parent);
 		if( layout == null ) layout = h2d.css.Defs.Layout.Inline;
 		if( layout == null ) layout = h2d.css.Defs.Layout.Inline;
 		addClass(":"+layout.getName().toLowerCase());
 		addClass(":"+layout.getName().toLowerCase());
 	}
 	}
-	
+
 	override function resizeRec( ctx : Context ) {
 	override function resizeRec( ctx : Context ) {
 		var extX = extLeft();
 		var extX = extLeft();
 		var extY = extTop();
 		var extY = extTop();
@@ -213,6 +213,6 @@ class Box extends Component {
 			}
 			}
 		}
 		}
 	}
 	}
-	
-	
+
+
 }
 }

+ 6 - 6
h2d/comp/Button.hx

@@ -1,11 +1,11 @@
 package h2d.comp;
 package h2d.comp;
 
 
 class Button extends Interactive {
 class Button extends Interactive {
-	
+
 	var tf : h2d.Text;
 	var tf : h2d.Text;
-	
+
 	public var text(default, set) : String;
 	public var text(default, set) : String;
-	
+
 	public function new(text, ?parent) {
 	public function new(text, ?parent) {
 		super("button",parent);
 		super("button",parent);
 		tf = new h2d.Text(null, this);
 		tf = new h2d.Text(null, this);
@@ -15,12 +15,12 @@ class Button extends Interactive {
 	function get_text() {
 	function get_text() {
 		return tf.text;
 		return tf.text;
 	}
 	}
-	
+
 	function set_text(t) {
 	function set_text(t) {
 		needRebuild = true;
 		needRebuild = true;
 		return text = t;
 		return text = t;
 	}
 	}
-	
+
 	override function resize( ctx : Context ) {
 	override function resize( ctx : Context ) {
 		if( ctx.measure ) {
 		if( ctx.measure ) {
 			tf.font = getFont();
 			tf.font = getFont();
@@ -32,5 +32,5 @@ class Button extends Interactive {
 		}
 		}
 		super.resize(ctx);
 		super.resize(ctx);
 	}
 	}
-	
+
 }
 }

+ 7 - 7
h2d/comp/Checkbox.hx

@@ -1,19 +1,19 @@
 package h2d.comp;
 package h2d.comp;
 
 
 class Checkbox extends Interactive {
 class Checkbox extends Interactive {
-	
+
 	public var checked(default, set) : Bool;
 	public var checked(default, set) : Bool;
-	
+
 	public function new(?parent) {
 	public function new(?parent) {
 		super("checkbox", parent);
 		super("checkbox", parent);
 		checked = false;
 		checked = false;
 	}
 	}
-	
+
 	function set_checked(b) {
 	function set_checked(b) {
 		toggleClass(":checked", b);
 		toggleClass(":checked", b);
 		return checked = b;
 		return checked = b;
 	}
 	}
-	
+
 	override function resize( ctx : Context ) {
 	override function resize( ctx : Context ) {
 		super.resize(ctx);
 		super.resize(ctx);
 		if( !ctx.measure ) {
 		if( !ctx.measure ) {
@@ -25,13 +25,13 @@ class Checkbox extends Interactive {
 			}
 			}
 		}
 		}
 	}
 	}
-	
+
 	override function onClick() {
 	override function onClick() {
 		checked = !checked;
 		checked = !checked;
 		onChange(checked);
 		onChange(checked);
 	}
 	}
-	
+
 	public dynamic function onChange( checked : Bool ) {
 	public dynamic function onChange( checked : Bool ) {
 	}
 	}
-	
+
 }
 }

+ 7 - 7
h2d/comp/Color.hx

@@ -1,10 +1,10 @@
 package h2d.comp;
 package h2d.comp;
 
 
 class Color extends Component {
 class Color extends Component {
-	
+
 	var input : h2d.Interactive;
 	var input : h2d.Interactive;
 	public var value(default, set) : Int;
 	public var value(default, set) : Int;
-	
+
 	public function new(?parent) {
 	public function new(?parent) {
 		super("color", parent);
 		super("color", parent);
 		input = new h2d.Interactive(0, 0, bg);
 		input = new h2d.Interactive(0, 0, bg);
@@ -24,12 +24,12 @@ class Color extends Component {
 		};
 		};
 		value = 0;
 		value = 0;
 	}
 	}
-	
+
 	function set_value(v) {
 	function set_value(v) {
 		needRebuild = true;
 		needRebuild = true;
 		return value = v;
 		return value = v;
 	}
 	}
-	
+
 	override function resize( ctx : Context ) {
 	override function resize( ctx : Context ) {
 		super.resize(ctx);
 		super.resize(ctx);
 		if( !ctx.measure ) {
 		if( !ctx.measure ) {
@@ -38,7 +38,7 @@ class Color extends Component {
 			bg.fillRectColor(extLeft() - style.marginLeft, extTop() - style.marginTop, contentWidth, contentHeight, 0xFF000000 | value);
 			bg.fillRectColor(extLeft() - style.marginLeft, extTop() - style.marginTop, contentWidth, contentHeight, 0xFF000000 | value);
 		}
 		}
 	}
 	}
-	
+
 	function selectColor() {
 	function selectColor() {
 		var p : Component = this;
 		var p : Component = this;
 		while( p.parentComponent != null )
 		while( p.parentComponent != null )
@@ -56,8 +56,8 @@ class Color extends Component {
 			b.remove();
 			b.remove();
 		};
 		};
 	}
 	}
-	
+
 	public dynamic function onChange( color : Int ) {
 	public dynamic function onChange( color : Int ) {
 	}
 	}
-	
+
 }
 }

+ 61 - 61
h2d/comp/ColorPicker.hx

@@ -30,7 +30,7 @@ private enum CompStyle {
 private class Style {
 private class Style {
 	public function new () {
 	public function new () {
 	}
 	}
-	
+
 	public static function get(kind:CompStyle) {
 	public static function get(kind:CompStyle) {
 		var style = new h2d.css.Style();
 		var style = new h2d.css.Style();
 		switch(kind) {
 		switch(kind) {
@@ -62,13 +62,13 @@ private class Arrow extends h2d.css.Fill {
 
 
 private class Cross extends h2d.css.Fill {
 private class Cross extends h2d.css.Fill {
 	var size:Float;
 	var size:Float;
-	
+
 	public function new (parent, size:Float, color = 0xff000000) {
 	public function new (parent, size:Float, color = 0xff000000) {
 		super(parent);
 		super(parent);
 		this.size = size;
 		this.size = size;
 		lineRect(FillStyle.Color(color), 0, 0, size, size, 1);
 		lineRect(FillStyle.Color(color), 0, 0, size, size, 1);
 	}
 	}
-	
+
 	public function setColor(color:Int) {
 	public function setColor(color:Int) {
 		reset();
 		reset();
 		lineRect(FillStyle.Color(color), 0, 0, size, size, 1);
 		lineRect(FillStyle.Color(color), 0, 0, size, size, 1);
@@ -82,12 +82,12 @@ private class Color extends h2d.Sprite {
 	public var color(default, set):Int = 0xFFFFFFFF;
 	public var color(default, set):Int = 0xFFFFFFFF;
 	public var preview(default, set):Int = 0xFFFFFFFF;
 	public var preview(default, set):Int = 0xFFFFFFFF;
 	public var alpha(default, set):Float = 1.;
 	public var alpha(default, set):Float = 1.;
-	
+
 	var canvas:h2d.css.Fill;
 	var canvas:h2d.css.Fill;
 	var label : h2d.comp.Label;
 	var label : h2d.comp.Label;
 	var input : h2d.comp.Input;
 	var input : h2d.comp.Input;
-	
-	
+
+
 	public function new (picker,ix, iy, iw, ih, parent) {
 	public function new (picker,ix, iy, iw, ih, parent) {
 		super(parent);
 		super(parent);
 		this.picker = picker;
 		this.picker = picker;
@@ -97,7 +97,7 @@ private class Color extends h2d.Sprite {
 		height = ih;
 		height = ih;
 		init();
 		init();
 	}
 	}
-	
+
 	function set_color(v:Int) {
 	function set_color(v:Int) {
 		if(v != color) {
 		if(v != color) {
 			color = v;
 			color = v;
@@ -105,7 +105,7 @@ private class Color extends h2d.Sprite {
 		}
 		}
 		return color;
 		return color;
 	}
 	}
-	
+
 	function set_preview(v:Int) {
 	function set_preview(v:Int) {
 		if(v != preview) {
 		if(v != preview) {
 			preview = v;
 			preview = v;
@@ -113,18 +113,18 @@ private class Color extends h2d.Sprite {
 		}
 		}
 		return color;
 		return color;
 	}
 	}
-	
+
 	function set_alpha(v:Float) {
 	function set_alpha(v:Float) {
 		alpha = v;
 		alpha = v;
 		drawAll();
 		drawAll();
 		return color;
 		return color;
 	}
 	}
-	
+
 	public function updateColor(v:Int) {
 	public function updateColor(v:Int) {
 		color = v;
 		color = v;
 		input.value = StringTools.hex(preview, 6).substr(2);
 		input.value = StringTools.hex(preview, 6).substr(2);
 	}
 	}
-	
+
 	function init() {
 	function init() {
 		label = new h2d.comp.Label("#", this);
 		label = new h2d.comp.Label("#", this);
 		label.setStyle(Style.get(ColorLabel));
 		label.setStyle(Style.get(ColorLabel));
@@ -144,12 +144,12 @@ private class Color extends h2d.Sprite {
 				picker.change = SColor;
 				picker.change = SColor;
 			}
 			}
 		};
 		};
-		
+
 		canvas = new h2d.css.Fill(this);
 		canvas = new h2d.css.Fill(this);
 		canvas.y = 2 + height * 0.5;
 		canvas.y = 2 + height * 0.5;
 		drawAll();
 		drawAll();
 	}
 	}
-	
+
 	public function drawAll() {
 	public function drawAll() {
 		canvas.reset();
 		canvas.reset();
 		canvas.fillRectColor(0, 0, width, height * 0.5, preview);
 		canvas.fillRectColor(0, 0, width, height * 0.5, preview);
@@ -164,12 +164,12 @@ private class Palette extends h2d.Sprite {
 	public var width :Float;
 	public var width :Float;
 	public var height :Float;
 	public var height :Float;
 	public var color(default, set):Int;
 	public var color(default, set):Int;
-	
+
 	var picker : ColorPicker;
 	var picker : ColorPicker;
 	var canvas:h2d.css.Fill;
 	var canvas:h2d.css.Fill;
 	var interact:h2d.Interactive;
 	var interact:h2d.Interactive;
 	var cursor:h2d.Sprite;
 	var cursor:h2d.Sprite;
-	
+
 	public function new (picker, ix, iy, iw, ih, parent) {
 	public function new (picker, ix, iy, iw, ih, parent) {
 		super(parent);
 		super(parent);
 		this.picker = picker;
 		this.picker = picker;
@@ -179,7 +179,7 @@ private class Palette extends h2d.Sprite {
 		height = ih;
 		height = ih;
 		init();
 		init();
 	}
 	}
-	
+
 	function init() {
 	function init() {
 		canvas = new h2d.css.Fill(this);
 		canvas = new h2d.css.Fill(this);
 		cursor = new h2d.Sprite(this);
 		cursor = new h2d.Sprite(this);
@@ -202,7 +202,7 @@ private class Palette extends h2d.Sprite {
 		color = getColor(0);
 		color = getColor(0);
 		drawAll();
 		drawAll();
 	}
 	}
-	
+
 	function set_color(v:Int) {
 	function set_color(v:Int) {
 		color = v;
 		color = v;
 		if(!picker.change.equals(SPalette))
 		if(!picker.change.equals(SPalette))
@@ -210,12 +210,12 @@ private class Palette extends h2d.Sprite {
 		drawAll();
 		drawAll();
 		return color;
 		return color;
 	}
 	}
-	
+
 	function updateCursor() {
 	function updateCursor() {
 		var hsl = ColorPicker.INTtoHSL(color);
 		var hsl = ColorPicker.INTtoHSL(color);
 		cursor.y = Math.round(Math.max(0, Math.min(height, (1 - hsl[0]) * height)));
 		cursor.y = Math.round(Math.max(0, Math.min(height, (1 - hsl[0]) * height)));
 	}
 	}
-	
+
 	public function drawAll() {
 	public function drawAll() {
 		var s = 1;
 		var s = 1;
 		var l = 0.5;
 		var l = 0.5;
@@ -228,19 +228,19 @@ private class Palette extends h2d.Sprite {
 		}
 		}
 		canvas.lineRect(FillStyle.Color(ColorPicker.borderColor), 0, 0, width, height, 1);
 		canvas.lineRect(FillStyle.Color(ColorPicker.borderColor), 0, 0, width, height, 1);
 	}
 	}
-	
+
 	public function setCursor(dy:Float) {
 	public function setCursor(dy:Float) {
 		cursor.y = Math.round(Math.max(0, Math.min(height, dy)));
 		cursor.y = Math.round(Math.max(0, Math.min(height, dy)));
 		color = getColor(cursor.y);
 		color = getColor(cursor.y);
 	}
 	}
-	
+
 	public function getColor(py:Float) {
 	public function getColor(py:Float) {
 		var h = 1 - (py / height);
 		var h = 1 - (py / height);
 		var s = 1;
 		var s = 1;
 		var l = 0.5;
 		var l = 0.5;
 		return(ColorPicker.HSLtoINT(h, s, l));
 		return(ColorPicker.HSLtoINT(h, s, l));
 	}
 	}
-	
+
 	public function setColorFrom(newColor:Int) {
 	public function setColorFrom(newColor:Int) {
 		var rgb = ColorPicker.INTtoRGB(newColor);
 		var rgb = ColorPicker.INTtoRGB(newColor);
 		var hsl = ColorPicker.RGBtoHLS(rgb[0], rgb[1], rgb[2]);
 		var hsl = ColorPicker.RGBtoHLS(rgb[0], rgb[1], rgb[2]);
@@ -255,7 +255,7 @@ private class Chart extends h2d.Sprite{
 	public var height :Int;
 	public var height :Int;
 	public var refColor(default, set):Int = 0xffffffff;
 	public var refColor(default, set):Int = 0xffffffff;
 	public var color:Int = 0xffffffff;
 	public var color:Int = 0xffffffff;
-	
+
 	var picker : ColorPicker;
 	var picker : ColorPicker;
 	var ray :Float;
 	var ray :Float;
 	var canvas:h2d.css.Fill;
 	var canvas:h2d.css.Fill;
@@ -263,7 +263,7 @@ private class Chart extends h2d.Sprite{
 	var cursor:h2d.Sprite;
 	var cursor:h2d.Sprite;
 	var lastPos:h3d.Vector;
 	var lastPos:h3d.Vector;
 	var cross:Cross ;
 	var cross:Cross ;
-	
+
 	public function new (picker,ix, iy, iw, ih, ray, parent) {
 	public function new (picker,ix, iy, iw, ih, ray, parent) {
 		super(parent);
 		super(parent);
 		this.picker = picker;
 		this.picker = picker;
@@ -274,7 +274,7 @@ private class Chart extends h2d.Sprite{
 		this.ray = ray;
 		this.ray = ray;
 		init();
 		init();
 	}
 	}
-	
+
 	function init() {
 	function init() {
 		canvas = new h2d.css.Fill(this);
 		canvas = new h2d.css.Fill(this);
 		cursor = new h2d.Sprite(this);
 		cursor = new h2d.Sprite(this);
@@ -296,7 +296,7 @@ private class Chart extends h2d.Sprite{
 		drawAll();
 		drawAll();
 		setCursor(0, 0);
 		setCursor(0, 0);
 	}
 	}
-	
+
 	public function setCursor(dx:Float, dy:Float) {
 	public function setCursor(dx:Float, dy:Float) {
 		cursor.x = Math.max(ray + 1, Math.min(width - ray - 1, dx));
 		cursor.x = Math.max(ray + 1, Math.min(width - ray - 1, dx));
 		cursor.y = Math.max(ray + 1, Math.min(height - ray - 1, dy));
 		cursor.y = Math.max(ray + 1, Math.min(height - ray - 1, dy));
@@ -304,7 +304,7 @@ private class Chart extends h2d.Sprite{
 		color = getColor(lastPos.x, lastPos.y);
 		color = getColor(lastPos.x, lastPos.y);
 		cross.setColor(ColorPicker.complementaryColor(color));
 		cross.setColor(ColorPicker.complementaryColor(color));
 	}
 	}
-	
+
 	function set_refColor(v:Int) {
 	function set_refColor(v:Int) {
 		refColor = v;
 		refColor = v;
 		color = getColor(lastPos.x, lastPos.y);
 		color = getColor(lastPos.x, lastPos.y);
@@ -312,13 +312,13 @@ private class Chart extends h2d.Sprite{
 		drawAll();
 		drawAll();
 		return refColor;
 		return refColor;
 	}
 	}
-	
+
 	function normalizePos(dx:Float, dy:Float) {
 	function normalizePos(dx:Float, dy:Float) {
 		var px = 1 - Math.min(width, Math.max(0, dx)) / width;
 		var px = 1 - Math.min(width, Math.max(0, dx)) / width;
 		var py = 1 - Math.min(height, Math.max(0, dy)) / height;
 		var py = 1 - Math.min(height, Math.max(0, dy)) / height;
 		return new h3d.Vector(px, py);
 		return new h3d.Vector(px, py);
 	}
 	}
-	
+
 	public function drawAll() {
 	public function drawAll() {
 		canvas.reset();
 		canvas.reset();
 		var rgb = [(refColor >> 16) & 0xFF, (refColor >> 8) & 0xFF,  refColor & 0xFF];
 		var rgb = [(refColor >> 16) & 0xFF, (refColor >> 8) & 0xFF,  refColor & 0xFF];
@@ -341,7 +341,7 @@ private class Chart extends h2d.Sprite{
 		}
 		}
 		canvas.lineRect(FillStyle.Color(ColorPicker.borderColor), 0, 0, width, height, 1);
 		canvas.lineRect(FillStyle.Color(ColorPicker.borderColor), 0, 0, width, height, 1);
 	}
 	}
-	
+
 	function getColor(dw:Float, dh:Float) {
 	function getColor(dw:Float, dh:Float) {
 		var rgb = [(refColor >> 16) & 0xFF, (refColor >> 8) & 0xFF,  refColor & 0xFF];
 		var rgb = [(refColor >> 16) & 0xFF, (refColor >> 8) & 0xFF,  refColor & 0xFF];
 		var r = Math.round(rgb[0] * dh);
 		var r = Math.round(rgb[0] * dh);
@@ -353,14 +353,14 @@ private class Chart extends h2d.Sprite{
 		b = Math.round(b + (max - b) * dw);
 		b = Math.round(b + (max - b) * dw);
 		return ColorPicker.RGBtoINT(r, g, b);
 		return ColorPicker.RGBtoINT(r, g, b);
 	}
 	}
-	
+
 	public function setColorFrom(newColor:Int) {
 	public function setColorFrom(newColor:Int) {
 		var rgb = ColorPicker.INTtoRGB(newColor);
 		var rgb = ColorPicker.INTtoRGB(newColor);
 		var hsl = ColorPicker.RGBtoHLS(rgb[0], rgb[1], rgb[2]);
 		var hsl = ColorPicker.RGBtoHLS(rgb[0], rgb[1], rgb[2]);
 		hsl[1] = 1; hsl[2] = 0.5;
 		hsl[1] = 1; hsl[2] = 0.5;
 		rgb = ColorPicker.HSLtoRGB(hsl[0], hsl[1], hsl[2]);
 		rgb = ColorPicker.HSLtoRGB(hsl[0], hsl[1], hsl[2]);
 		refColor = ColorPicker.RGBtoINT(rgb[0], rgb[1], rgb[2]);
 		refColor = ColorPicker.RGBtoINT(rgb[0], rgb[1], rgb[2]);
-		
+
 		var rgb = ColorPicker.INTtoRGB(newColor);
 		var rgb = ColorPicker.INTtoRGB(newColor);
 		var min = Math.min(rgb[0], Math.min(rgb[1], rgb[2]));
 		var min = Math.min(rgb[0], Math.min(rgb[1], rgb[2]));
 		var max = Math.max(rgb[0], Math.max(rgb[1], rgb[2]));
 		var max = Math.max(rgb[0], Math.max(rgb[1], rgb[2]));
@@ -375,7 +375,7 @@ private class ColorGauge extends h2d.Sprite{
 	public var height :Int;
 	public var height :Int;
 	public var color(default, set):Int = 0xffffffff;
 	public var color(default, set):Int = 0xffffffff;
 	public var ratio(get, null):Float;
 	public var ratio(get, null):Float;
-	
+
 	var picker : ColorPicker;
 	var picker : ColorPicker;
 	var canvas:h2d.css.Fill;
 	var canvas:h2d.css.Fill;
 	var interact:h2d.Interactive;
 	var interact:h2d.Interactive;
@@ -394,7 +394,7 @@ private class ColorGauge extends h2d.Sprite{
 		bindTo = rgba;
 		bindTo = rgba;
 		init();
 		init();
 	}
 	}
-	
+
 	function init() {
 	function init() {
 		label = new h2d.comp.Label(bindTo.getName(), this);
 		label = new h2d.comp.Label(bindTo.getName(), this);
 		label.setStyle(Style.get(GaugeLabel));
 		label.setStyle(Style.get(GaugeLabel));
@@ -407,7 +407,7 @@ private class ColorGauge extends h2d.Sprite{
 		input.onChange = function(e) {
 		input.onChange = function(e) {
 			setCursor(cursor.x);
 			setCursor(cursor.x);
 		};
 		};
-		
+
 		canvas = new h2d.css.Fill(this);
 		canvas = new h2d.css.Fill(this);
 		cursor = new h2d.Sprite(this);
 		cursor = new h2d.Sprite(this);
 		cursor.x = width;
 		cursor.x = width;
@@ -429,7 +429,7 @@ private class ColorGauge extends h2d.Sprite{
 		}
 		}
 		drawAll();
 		drawAll();
 	}
 	}
-	
+
 	function set_color(v:Int) {
 	function set_color(v:Int) {
 		color = v;
 		color = v;
 		if(!bindTo.equals(RGBA.A))
 		if(!bindTo.equals(RGBA.A))
@@ -437,7 +437,7 @@ private class ColorGauge extends h2d.Sprite{
 		drawAll();
 		drawAll();
 		return color;
 		return color;
 	}
 	}
-	
+
 	function setState() {
 	function setState() {
 		picker.change = switch(bindTo) {
 		picker.change = switch(bindTo) {
 			case RGBA.R: SRed;
 			case RGBA.R: SRed;
@@ -446,11 +446,11 @@ private class ColorGauge extends h2d.Sprite{
 			case RGBA.A: SAlpha;
 			case RGBA.A: SAlpha;
 		}
 		}
 	}
 	}
-	
+
 	public function get_ratio() {
 	public function get_ratio() {
 		return cursor.x / width;
 		return cursor.x / width;
 	}
 	}
-	
+
 	public function updateCursor() {
 	public function updateCursor() {
 		var a = color >>> 24;
 		var a = color >>> 24;
 		var r = (color >> 16) & 0xFF;
 		var r = (color >> 16) & 0xFF;
@@ -464,7 +464,7 @@ private class ColorGauge extends h2d.Sprite{
 		});
 		});
 		input.value = Std.string(Std.int(255 * ratio));
 		input.value = Std.string(Std.int(255 * ratio));
 	}
 	}
-	
+
 	public function setCursor(dx:Float) {
 	public function setCursor(dx:Float) {
 		cursor.x = Math.round(Math.max(0, Math.min(width, dx)));
 		cursor.x = Math.round(Math.max(0, Math.min(width, dx)));
 		var r = (color >> 16) & 0xFF;
 		var r = (color >> 16) & 0xFF;
@@ -478,7 +478,7 @@ private class ColorGauge extends h2d.Sprite{
 		}
 		}
 		input.value = Std.string(Math.round(255 * ratio));
 		input.value = Std.string(Math.round(255 * ratio));
 	}
 	}
-	
+
 	public function drawAll() {
 	public function drawAll() {
 		var r = (color >> 16) & 0xFF;
 		var r = (color >> 16) & 0xFF;
 		var g =	(color >> 8) & 0xFF;
 		var g =	(color >> 8) & 0xFF;
@@ -503,9 +503,9 @@ private class ColorGauge extends h2d.Sprite{
 
 
 @:allow(h2d.comp)
 @:allow(h2d.comp)
 class ColorPicker extends h2d.comp.Component {
 class ColorPicker extends h2d.comp.Component {
-	
+
 	public static var borderColor = 0xFFaaaaaa;
 	public static var borderColor = 0xFFaaaaaa;
-	
+
 	var finalColor : Color;
 	var finalColor : Color;
 	var palette : Palette;
 	var palette : Palette;
 	var chart : Chart;
 	var chart : Chart;
@@ -515,18 +515,18 @@ class ColorPicker extends h2d.comp.Component {
 	var gaugeAlpha : ColorGauge;
 	var gaugeAlpha : ColorGauge;
 	var timer : haxe.Timer;
 	var timer : haxe.Timer;
 	var change : ChangeState;
 	var change : ChangeState;
-	
+
 	public var color(get, set) : Int;
 	public var color(get, set) : Int;
-	
+
 	public function new(?parent) {
 	public function new(?parent) {
 		super("colorpicker", parent);
 		super("colorpicker", parent);
 		init();
 		init();
 	}
 	}
-	
+
 	inline function get_color() {
 	inline function get_color() {
 		return (finalColor.color&0xFFFFFF) | Std.int(finalColor.alpha*255) << 24;
 		return (finalColor.color&0xFFFFFF) | Std.int(finalColor.alpha*255) << 24;
 	}
 	}
-	
+
 	function set_color(v) {
 	function set_color(v) {
 		finalColor.color = v;
 		finalColor.color = v;
 		finalColor.alpha = (v >>> 24) / 255;
 		finalColor.alpha = (v >>> 24) / 255;
@@ -538,7 +538,7 @@ class ColorPicker extends h2d.comp.Component {
 		gaugeAlpha.setCursor(finalColor.alpha * gaugeAlpha.width);
 		gaugeAlpha.setCursor(finalColor.alpha * gaugeAlpha.width);
 		return v;
 		return v;
 	}
 	}
-	
+
 	override function onAlloc() {
 	override function onAlloc() {
 		super.onAlloc();
 		super.onAlloc();
 		if( timer == null ) {
 		if( timer == null ) {
@@ -546,7 +546,7 @@ class ColorPicker extends h2d.comp.Component {
 			timer.run = doUpdate;
 			timer.run = doUpdate;
 		}
 		}
 	}
 	}
-	
+
 	override function onDelete() {
 	override function onDelete() {
 		super.onDelete();
 		super.onDelete();
 		if( timer != null ) {
 		if( timer != null ) {
@@ -554,7 +554,7 @@ class ColorPicker extends h2d.comp.Component {
 			timer = null;
 			timer = null;
 		}
 		}
 	}
 	}
-	
+
 	function init() {
 	function init() {
 		finalColor = new Color(this, 15, 8, 175, 45, this);
 		finalColor = new Color(this, 15, 8, 175, 45, this);
 		palette = new Palette(this, 16, 65, 20, 140, this);
 		palette = new Palette(this, 16, 65, 20, 140, this);
@@ -584,7 +584,7 @@ class ColorPicker extends h2d.comp.Component {
 			}
 			}
 			return;
 			return;
 		}
 		}
-			
+
 		switch(change) {
 		switch(change) {
 			case SColor:	palette.setColorFrom(finalColor.color);
 			case SColor:	palette.setColorFrom(finalColor.color);
 							chart.setColorFrom(finalColor.color);
 							chart.setColorFrom(finalColor.color);
@@ -601,32 +601,32 @@ class ColorPicker extends h2d.comp.Component {
 							onChange(color);
 							onChange(color);
 			default:
 			default:
 		}
 		}
-		
+
 		gaugeRed.color = chart.color;
 		gaugeRed.color = chart.color;
 		gaugeGreen.color = chart.color;
 		gaugeGreen.color = chart.color;
 		gaugeBlue.color = chart.color;
 		gaugeBlue.color = chart.color;
 	}
 	}
-	
+
 	public dynamic function onClose() {
 	public dynamic function onClose() {
 	}
 	}
-	
+
 	public dynamic function onChange( value : Int ) {
 	public dynamic function onChange( value : Int ) {
 	}
 	}
-	
+
 //////////////////
 //////////////////
 	public static function INTtoRGB(color:Int) {
 	public static function INTtoRGB(color:Int) {
 		return [(color >> 16) & 0xFF, (color >> 8) & 0xFF,  color & 0xFF];
 		return [(color >> 16) & 0xFF, (color >> 8) & 0xFF,  color & 0xFF];
 	}
 	}
-	
+
 	public static function INTtoHSL(color:Int) {
 	public static function INTtoHSL(color:Int) {
 		var rgb = INTtoRGB(color);
 		var rgb = INTtoRGB(color);
 		return RGBtoHLS(rgb[0], rgb[1], rgb[2]);
 		return RGBtoHLS(rgb[0], rgb[1], rgb[2]);
 	}
 	}
-	
+
 	public static function RGBtoINT(r:Int, g:Int, b:Int, a:Int = 255) {
 	public static function RGBtoINT(r:Int, g:Int, b:Int, a:Int = 255) {
 		return (a << 24) | (r << 16) | (g << 8) | b;
 		return (a << 24) | (r << 16) | (g << 8) | b;
 	}
 	}
-	
+
 	public static function RGBtoHLS(r:Float, g:Float, b:Float) {
 	public static function RGBtoHLS(r:Float, g:Float, b:Float) {
 		r /= 255;
 		r /= 255;
 		g /= 255;
 		g /= 255;
@@ -649,12 +649,12 @@ class ColorPicker extends h2d.comp.Component {
 		}
 		}
 		return [h, s, l];
 		return [h, s, l];
 	}
 	}
-	
+
 	public static function HSLtoINT(h:Float, s:Float, l:Float) {
 	public static function HSLtoINT(h:Float, s:Float, l:Float) {
 		var rgb = HSLtoRGB(h, s, l);
 		var rgb = HSLtoRGB(h, s, l);
 		return RGBtoINT(rgb[0], rgb[1], rgb[2]);
 		return RGBtoINT(rgb[0], rgb[1], rgb[2]);
 	}
 	}
-	
+
 	public static function HSLtoRGB(h:Float, s:Float, l:Float) {
 	public static function HSLtoRGB(h:Float, s:Float, l:Float) {
 		var r, g, b;
 		var r, g, b;
 		if(s == 0)
 		if(s == 0)
@@ -676,7 +676,7 @@ class ColorPicker extends h2d.comp.Component {
 		}
 		}
 		return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
 		return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
 	}
 	}
-	
+
 	public static function complementaryColor (color:Int) {
 	public static function complementaryColor (color:Int) {
 		var rgb = INTtoRGB(color);
 		var rgb = INTtoRGB(color);
 		var r = rgb[0] ^ 0xFF;
 		var r = rgb[0] ^ 0xFF;

+ 9 - 9
h2d/comp/Context.hx

@@ -1,7 +1,7 @@
 package h2d.comp;
 package h2d.comp;
 
 
 class Context {
 class Context {
-	
+
 	// measure props
 	// measure props
 	public var measure : Bool;
 	public var measure : Bool;
 	public var maxWidth : Float;
 	public var maxWidth : Float;
@@ -9,19 +9,19 @@ class Context {
 	// arrange props
 	// arrange props
 	public var xPos : Null<Float>;
 	public var xPos : Null<Float>;
 	public var yPos : Null<Float>;
 	public var yPos : Null<Float>;
-	
+
 	public function new(w, h) {
 	public function new(w, h) {
 		this.maxWidth = w;
 		this.maxWidth = w;
 		this.maxHeight = h;
 		this.maxHeight = h;
 		measure = true;
 		measure = true;
 	}
 	}
-	
+
 	// ------------- STATIC API ---------------------------------------
 	// ------------- STATIC API ---------------------------------------
-	
+
 	public static function getFont( name : String, size : Int ) {
 	public static function getFont( name : String, size : Int ) {
 		return hxd.res.FontBuilder.getFont(name, size);
 		return hxd.res.FontBuilder.getFont(name, size);
 	}
 	}
-	
+
 	public static function makeTileIcon( pixels : hxd.Pixels ) : h2d.Tile {
 	public static function makeTileIcon( pixels : hxd.Pixels ) : h2d.Tile {
 		var t = cachedIcons.get(pixels);
 		var t = cachedIcons.get(pixels);
 		if( t != null && !t.isDisposed() )
 		if( t != null && !t.isDisposed() )
@@ -30,11 +30,11 @@ class Context {
 		cachedIcons.set(pixels, t);
 		cachedIcons.set(pixels, t);
 		return t;
 		return t;
 	}
 	}
-	
+
 	static var cachedIcons = new Map<hxd.Pixels,h2d.Tile>();
 	static var cachedIcons = new Map<hxd.Pixels,h2d.Tile>();
-		
+
 	public static var DEFAULT_CSS = hxd.res.Embed.getFileContent("h2d/css/default.css");
 	public static var DEFAULT_CSS = hxd.res.Embed.getFileContent("h2d/css/default.css");
-	
+
 	static var DEF = null;
 	static var DEF = null;
 	public static function getDefaultCss() {
 	public static function getDefaultCss() {
 		if( DEF != null )
 		if( DEF != null )
@@ -43,5 +43,5 @@ class Context {
 		e.addRules(DEFAULT_CSS);
 		e.addRules(DEFAULT_CSS);
 		return e;
 		return e;
 	}
 	}
-	
+
 }
 }

+ 76 - 76
h2d/comp/GradientEditor.hx

@@ -18,7 +18,7 @@ private enum CompStyle {
 private class Style {
 private class Style {
 	public function new () {
 	public function new () {
 	}
 	}
-	
+
 	public static function get(kind:CompStyle) {
 	public static function get(kind:CompStyle) {
 		var style = new h2d.css.Style();
 		var style = new h2d.css.Style();
 		switch(kind) {
 		switch(kind) {
@@ -35,7 +35,7 @@ private class Style {
 }
 }
 
 
 private class CFlag extends h2d.css.Fill {
 private class CFlag extends h2d.css.Fill {
-	
+
 	public function new (parent, x:Float, y:Float, ang = 0., color = 0xff000000, border = 0xFFaaaaaa) {
 	public function new (parent, x:Float, y:Float, ang = 0., color = 0xff000000, border = 0xFFaaaaaa) {
 		super(parent);
 		super(parent);
 		var fill = this;
 		var fill = this;
@@ -43,26 +43,26 @@ private class CFlag extends h2d.css.Fill {
 		fill.x = x;
 		fill.x = x;
 		fill.y = y;
 		fill.y = y;
 		//bg
 		//bg
-		
+
 		// bgarrow
 		// bgarrow
 		fill.addPoint(-5, -4, border);
 		fill.addPoint(-5, -4, border);
 		fill.addPoint(5, -4, border);
 		fill.addPoint(5, -4, border);
 		fill.addPoint(0, 0, border);
 		fill.addPoint(0, 0, border);
 		fill.addPoint(0, 0, border);
 		fill.addPoint(0, 0, border);
-		
+
 		// bgsquare
 		// bgsquare
 		var dy = -5;
 		var dy = -5;
 		fill.addPoint(-5, -9 + dy, border);
 		fill.addPoint(-5, -9 + dy, border);
 		fill.addPoint(5, -9 + dy, border);
 		fill.addPoint(5, -9 + dy, border);
 		fill.addPoint(-5, 1 + dy, border);
 		fill.addPoint(-5, 1 + dy, border);
 		fill.addPoint(5, 1 + dy, border);
 		fill.addPoint(5, 1 + dy, border);
-		
+
 		// arrow
 		// arrow
 		fill.addPoint(-4, -5, color);
 		fill.addPoint(-4, -5, color);
 		fill.addPoint(4, -5, color);
 		fill.addPoint(4, -5, color);
 		fill.addPoint(0, 0, color);
 		fill.addPoint(0, 0, color);
 		fill.addPoint(0, 0, color);
 		fill.addPoint(0, 0, color);
-		
+
 		// square
 		// square
 		fill.addPoint(-4, -8+dy, color);
 		fill.addPoint(-4, -8+dy, color);
 		fill.addPoint(4, -8+dy, color);
 		fill.addPoint(4, -8+dy, color);
@@ -82,7 +82,7 @@ private class Cursor extends h2d.Sprite {
 	var ang:Float;
 	var ang:Float;
 	var interact:h2d.Interactive;
 	var interact:h2d.Interactive;
 	var flag:CFlag;
 	var flag:CFlag;
-	
+
 	public function new(gradient,ix, iy, kind, value, ang, parent) {
 	public function new(gradient,ix, iy, kind, value, ang, parent) {
 		super(parent);
 		super(parent);
 		this.gradient = gradient;
 		this.gradient = gradient;
@@ -93,7 +93,7 @@ private class Cursor extends h2d.Sprite {
 		this.kind = kind;
 		this.kind = kind;
 		init();
 		init();
 	}
 	}
-	
+
 	function set_value(v) {
 	function set_value(v) {
 		value = v;
 		value = v;
 		if(flag != null) {
 		if(flag != null) {
@@ -106,11 +106,11 @@ private class Cursor extends h2d.Sprite {
 		}
 		}
 		return value;
 		return value;
 	}
 	}
-	
+
 	function get_coeff() {
 	function get_coeff() {
 		return x / gradient.boxWidth;
 		return x / gradient.boxWidth;
 	}
 	}
-	
+
 	function init() {
 	function init() {
 		cursor = new h2d.Sprite(this);
 		cursor = new h2d.Sprite(this);
 		switch(kind) {
 		switch(kind) {
@@ -122,11 +122,11 @@ private class Cursor extends h2d.Sprite {
 		interact.x = -5;
 		interact.x = -5;
 		if(kind.equals(KAlpha))
 		if(kind.equals(KAlpha))
 			interact.y = -14;
 			interact.y = -14;
-			
+
 		interact.onPush = function(e) drag();
 		interact.onPush = function(e) drag();
 		interact.onRelease = function(e) stopDrag();
 		interact.onRelease = function(e) stopDrag();
 	}
 	}
-	
+
 	public function drag() {
 	public function drag() {
 		interact.startDrag(function(e) {
 		interact.startDrag(function(e) {
 			if( e.kind == EMove ){
 			if( e.kind == EMove ){
@@ -137,39 +137,39 @@ private class Cursor extends h2d.Sprite {
 			}
 			}
 			gradient.dragTarget = this ;
 			gradient.dragTarget = this ;
 		});
 		});
-			
+
 		gradient.updateTarget = this;
 		gradient.updateTarget = this;
 		this.parent.addChild(this);
 		this.parent.addChild(this);
 	}
 	}
-	
+
 	public function stopDrag() {
 	public function stopDrag() {
 		interact.stopDrag();
 		interact.stopDrag();
 		if( !visible ) remove();
 		if( !visible ) remove();
 		gradient.dragTarget = null ;
 		gradient.dragTarget = null ;
 		gradient.dragOut = false;
 		gradient.dragOut = false;
 	}
 	}
-	
+
 	public function select() {
 	public function select() {
 		bgcolor = 0xFFFF00FF;
 		bgcolor = 0xFFFF00FF;
 		flag.remove();
 		flag.remove();
 		flag = new CFlag(cursor, 0, 0, ang, color, bgcolor);
 		flag = new CFlag(cursor, 0, 0, ang, color, bgcolor);
-		
+
 		if(gradient.colorPicker.visible)
 		if(gradient.colorPicker.visible)
 			gradient.colorPicker.color = color;
 			gradient.colorPicker.color = color;
 	}
 	}
-	
+
 	public function unselect() {
 	public function unselect() {
 		bgcolor = 0xFFAAAAAA;
 		bgcolor = 0xFFAAAAAA;
 		flag.remove();
 		flag.remove();
 		flag = new CFlag(cursor, 0, 0, ang, color, bgcolor);
 		flag = new CFlag(cursor, 0, 0, ang, color, bgcolor);
 	}
 	}
-	
+
 	public function setCursor(px:Float) {
 	public function setCursor(px:Float) {
 		x = Math.max(0, Math.min(gradient.boxWidth, px));
 		x = Math.max(0, Math.min(gradient.boxWidth, px));
 	}
 	}
 }
 }
 
 
-	
+
 private class AlphaSelector extends h2d.Sprite {
 private class AlphaSelector extends h2d.Sprite {
 	public var target(default, set):Cursor;
 	public var target(default, set):Cursor;
 	var gradient : GradientEditor;
 	var gradient : GradientEditor;
@@ -178,7 +178,7 @@ private class AlphaSelector extends h2d.Sprite {
 	var alphaInput:h2d.comp.Input;
 	var alphaInput:h2d.comp.Input;
 	var locLabel:h2d.comp.Label;
 	var locLabel:h2d.comp.Label;
 	var locInput:h2d.comp.Input;
 	var locInput:h2d.comp.Input;
-	
+
 	public function new (gradient,ix, iy, parent) {
 	public function new (gradient,ix, iy, parent) {
 		super(parent);
 		super(parent);
 		this.gradient = gradient;
 		this.gradient = gradient;
@@ -186,16 +186,16 @@ private class AlphaSelector extends h2d.Sprite {
 		y = iy;
 		y = iy;
 		init();
 		init();
 	}
 	}
-	
+
 	function init() {
 	function init() {
 		title = new h2d.comp.Label("Alpha", this);
 		title = new h2d.comp.Label("Alpha", this);
 		title.addStyle(Style.get(CLabel));
 		title.addStyle(Style.get(CLabel));
-		
+
 		slider = new h2d.comp.Slider(this);
 		slider = new h2d.comp.Slider(this);
 		slider.x = 55; slider.y = 4;
 		slider.x = 55; slider.y = 4;
 		slider.onChange = function(v) { updateSlider(v); };
 		slider.onChange = function(v) { updateSlider(v); };
 		slider.value = 1;
 		slider.value = 1;
-		
+
 		alphaInput = new h2d.comp.Input(this);
 		alphaInput = new h2d.comp.Input(this);
 		alphaInput.addStyle(Style.get(CInputSmall));
 		alphaInput.addStyle(Style.get(CInputSmall));
 		alphaInput.x = 170;
 		alphaInput.x = 170;
@@ -208,7 +208,7 @@ private class AlphaSelector extends h2d.Sprite {
 				slider.value = v;
 				slider.value = v;
 			}
 			}
 		};
 		};
-		
+
 		locLabel = new h2d.comp.Label("Location             %", this);
 		locLabel = new h2d.comp.Label("Location             %", this);
 		locLabel.setStyle(Style.get(CLabel));
 		locLabel.setStyle(Style.get(CLabel));
 		locLabel.x = 255;
 		locLabel.x = 255;
@@ -224,13 +224,13 @@ private class AlphaSelector extends h2d.Sprite {
 			}
 			}
 		};
 		};
 	}
 	}
-	
+
 	public function update() {
 	public function update() {
 		if(target == null)
 		if(target == null)
 			return;
 			return;
 		locInput.value = Std.string(Math.floor(target.coeff * 100 * 100) / 100);
 		locInput.value = Std.string(Math.floor(target.coeff * 100 * 100) / 100);
 	}
 	}
-	
+
 	function set_target(cursor:Cursor) {
 	function set_target(cursor:Cursor) {
 		target = cursor;
 		target = cursor;
 		var v = target.value / 255;
 		var v = target.value / 255;
@@ -239,7 +239,7 @@ private class AlphaSelector extends h2d.Sprite {
 		updateSlider(v);
 		updateSlider(v);
 		return target;
 		return target;
 	}
 	}
-	
+
 	function updateSlider(v:Float) {
 	function updateSlider(v:Float) {
 		var alpha = Math.round(255 * v);
 		var alpha = Math.round(255 * v);
 		alphaInput.value = Std.string(alpha);
 		alphaInput.value = Std.string(alpha);
@@ -259,7 +259,7 @@ private class ColorSelector extends h2d.Sprite {
 	var canvas:h2d.css.Fill;
 	var canvas:h2d.css.Fill;
 	var color:Int = 0xFFFFFFFF;
 	var color:Int = 0xFFFFFFFF;
 	var interact : h2d.Interactive;
 	var interact : h2d.Interactive;
-	
+
 	public function new(gradient,ix, iy, parent) {
 	public function new(gradient,ix, iy, parent) {
 		super(parent);
 		super(parent);
 		this.gradient = gradient;
 		this.gradient = gradient;
@@ -267,13 +267,13 @@ private class ColorSelector extends h2d.Sprite {
 		y = iy;
 		y = iy;
 		init();
 		init();
 	}
 	}
-	
+
 	public function update() {
 	public function update() {
 		if(target == null)
 		if(target == null)
 			return;
 			return;
 		locInput.value = Std.string(Math.floor(target.coeff * 100 * 100) / 100);
 		locInput.value = Std.string(Math.floor(target.coeff * 100 * 100) / 100);
 	}
 	}
-	
+
 	function set_target(cursor:Cursor) {
 	function set_target(cursor:Cursor) {
 		target = cursor;
 		target = cursor;
 		locInput.value = Std.string(Math.floor(target.coeff * 100 * 100) / 100);
 		locInput.value = Std.string(Math.floor(target.coeff * 100 * 100) / 100);
@@ -282,11 +282,11 @@ private class ColorSelector extends h2d.Sprite {
 		redraw();
 		redraw();
 		return target;
 		return target;
 	}
 	}
-	
+
 	function init() {
 	function init() {
 		title = new h2d.comp.Label("Color                         #", this);
 		title = new h2d.comp.Label("Color                         #", this);
 		title.setStyle(Style.get(CLabel));
 		title.setStyle(Style.get(CLabel));
-		
+
 		canvas = new Fill(this);
 		canvas = new Fill(this);
 		canvas.x = 45;
 		canvas.x = 45;
 		canvas.y = -8;
 		canvas.y = -8;
@@ -296,7 +296,7 @@ private class ColorSelector extends h2d.Sprite {
 		interact.onPush = function(e) {
 		interact.onPush = function(e) {
 			if(target == null)
 			if(target == null)
 				return;
 				return;
-			
+
 			if(!gradient.colorPicker.visible) {
 			if(!gradient.colorPicker.visible) {
 				gradient.colorPicker.visible = true;
 				gradient.colorPicker.visible = true;
 				gradient.colorPicker.color = color;
 				gradient.colorPicker.color = color;
@@ -311,7 +311,7 @@ private class ColorSelector extends h2d.Sprite {
 				gradient.colorPicker.visible = false;
 				gradient.colorPicker.visible = false;
 			}
 			}
 		};
 		};
-		
+
 		colorInput = new h2d.comp.Input(this);
 		colorInput = new h2d.comp.Input(this);
 		colorInput.setStyle(Style.get(CInput));
 		colorInput.setStyle(Style.get(CInput));
 		colorInput.x = 175;
 		colorInput.x = 175;
@@ -328,11 +328,11 @@ private class ColorSelector extends h2d.Sprite {
 				redraw();
 				redraw();
 			}
 			}
 		};
 		};
-		
+
 		locLabel = new h2d.comp.Label("Location             %", this);
 		locLabel = new h2d.comp.Label("Location             %", this);
 		locLabel.setStyle(Style.get(CLabel));
 		locLabel.setStyle(Style.get(CLabel));
 		locLabel.x = 265;
 		locLabel.x = 265;
-		
+
 		locInput = new h2d.comp.Input(this);
 		locInput = new h2d.comp.Input(this);
 		locInput.setStyle(Style.get(CInput));
 		locInput.setStyle(Style.get(CInput));
 		locInput.x = 330;
 		locInput.x = 330;
@@ -345,57 +345,57 @@ private class ColorSelector extends h2d.Sprite {
 				target.setCursor( v * gradient.boxWidth / 100 );
 				target.setCursor( v * gradient.boxWidth / 100 );
 			}
 			}
 		};
 		};
-		
+
 		redraw();
 		redraw();
 	}
 	}
-	
+
 	function redraw() {
 	function redraw() {
 		canvas.reset();
 		canvas.reset();
 		canvas.fillRectColor(0, 0, 110, 25, color);
 		canvas.fillRectColor(0, 0, 110, 25, color);
 		canvas.lineRect(FillStyle.Color(gradient.borderColor), 0, 0, 110, 25, 1);
 		canvas.lineRect(FillStyle.Color(gradient.borderColor), 0, 0, 110, 25, 1);
 	}
 	}
 }
 }
-		
-		
+
+
 //////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////
 
 
 class GradientEditor extends h2d.comp.Component {
 class GradientEditor extends h2d.comp.Component {
-	
+
 	public var borderColor = 0xFF888888;
 	public var borderColor = 0xFF888888;
 	public var dragTarget:Cursor;
 	public var dragTarget:Cursor;
 	public var dragOut:Bool;
 	public var dragOut:Bool;
 	public var updateTarget:Cursor;
 	public var updateTarget:Cursor;
 	public var boxWidth = 430;
 	public var boxWidth = 430;
 	var boxHeight = 100;
 	var boxHeight = 100;
-	
+
 	var keys:Array<Key>;
 	var keys:Array<Key>;
 	var colorsKeys:Array<Cursor>;
 	var colorsKeys:Array<Cursor>;
 	var alphaKeys:Array<Cursor>;
 	var alphaKeys:Array<Cursor>;
-	
+
 	var box:h2d.Sprite;
 	var box:h2d.Sprite;
 	var gradient:Fill;
 	var gradient:Fill;
 	var hudAlpha: AlphaSelector;
 	var hudAlpha: AlphaSelector;
 	var hudColor: ColorSelector;
 	var hudColor: ColorSelector;
-	
+
 	public var colorPicker:ColorPicker;
 	public var colorPicker:ColorPicker;
-	
+
 	var interactUp:h2d.Interactive;
 	var interactUp:h2d.Interactive;
 	var interactDown:h2d.Interactive;
 	var interactDown:h2d.Interactive;
-		
+
 
 
 	var withAlpha : Bool;
 	var withAlpha : Bool;
 	var holdCursor:Cursor;
 	var holdCursor:Cursor;
-	
+
 	public function new(?withAlpha = true, ?parent) {
 	public function new(?withAlpha = true, ?parent) {
 		super("gradienteditor", parent);
 		super("gradienteditor", parent);
 		this.withAlpha = withAlpha;
 		this.withAlpha = withAlpha;
 		init();
 		init();
 	}
 	}
-	
+
 	function init() {
 	function init() {
 		colorsKeys = [];
 		colorsKeys = [];
 		alphaKeys = [];
 		alphaKeys = [];
-		
+
 		interactUp = new h2d.Interactive(boxWidth, 16, this);
 		interactUp = new h2d.Interactive(boxWidth, 16, this);
 		interactUp.x = 10;
 		interactUp.x = 10;
 		interactUp.y = 30 - 16;
 		interactUp.y = 30 - 16;
@@ -404,28 +404,28 @@ class GradientEditor extends h2d.comp.Component {
 		interactDown.x = 10;
 		interactDown.x = 10;
 		interactDown.y = 30 + boxHeight;
 		interactDown.y = 30 + boxHeight;
 		interactDown.onPush =  function(e) createColorKey(e.relX, boxHeight);
 		interactDown.onPush =  function(e) createColorKey(e.relX, boxHeight);
-		
+
 		box = new h2d.Sprite(this);
 		box = new h2d.Sprite(this);
 		box.x = 10;
 		box.x = 10;
 		box.y = 30;
 		box.y = 30;
 		drawChecker();
 		drawChecker();
-		
+
 		hudColor = new ColorSelector(this, 20, box.y + boxHeight + 30, this);
 		hudColor = new ColorSelector(this, 20, box.y + boxHeight + 30, this);
 		hudAlpha = new AlphaSelector(this, 20, box.y + boxHeight + 30, this);
 		hudAlpha = new AlphaSelector(this, 20, box.y + boxHeight + 30, this);
 		hudAlpha.visible = false;
 		hudAlpha.visible = false;
 		hudAlpha.y = 0;
 		hudAlpha.y = 0;
-		
+
 		colorPicker = new ColorPicker(this);
 		colorPicker = new ColorPicker(this);
 		colorPicker.y = 220;
 		colorPicker.y = 220;
 		colorPicker.visible = false;
 		colorPicker.visible = false;
 		colorPicker.onClose = function() colorPicker.visible = false;
 		colorPicker.onClose = function() colorPicker.visible = false;
-		
+
 		setKeys([ { x : 0, value:0xFFFFFFFF }, { x: 1, value:0xFFFFFFFF } ],null);
 		setKeys([ { x : 0, value:0xFFFFFFFF }, { x: 1, value:0xFFFFFFFF } ],null);
 	}
 	}
-	
+
 	public dynamic function onChange( keys : Array<Key> ) {
 	public dynamic function onChange( keys : Array<Key> ) {
 	}
 	}
-	
+
 	public function setKeys(keys:Array<Key>,?kalpha:Array<Key>) {
 	public function setKeys(keys:Array<Key>,?kalpha:Array<Key>) {
 		while( colorsKeys.length > 0 )
 		while( colorsKeys.length > 0 )
 			colorsKeys.shift().remove();
 			colorsKeys.shift().remove();
@@ -444,7 +444,7 @@ class GradientEditor extends h2d.comp.Component {
 		updateKeys();
 		updateKeys();
 		updateTarget = colorsKeys[0];
 		updateTarget = colorsKeys[0];
 	}
 	}
-	
+
 	override function sync(ctx) {
 	override function sync(ctx) {
 		if(dragTarget != null) {
 		if(dragTarget != null) {
 			if(dragOut) {
 			if(dragOut) {
@@ -469,23 +469,23 @@ class GradientEditor extends h2d.comp.Component {
 					case KAlpha: alphaKeys.push(dragTarget);
 					case KAlpha: alphaKeys.push(dragTarget);
 				}
 				}
 			}
 			}
-			
+
 			hudAlpha.update();
 			hudAlpha.update();
 			hudColor.update();
 			hudColor.update();
 		}
 		}
 		else holdCursor = null;
 		else holdCursor = null;
-		
+
 		if(updateTarget != null) {
 		if(updateTarget != null) {
 			changeHud(updateTarget);
 			changeHud(updateTarget);
 			updateFlags(updateTarget);
 			updateFlags(updateTarget);
 			updateTarget = null;
 			updateTarget = null;
 		}
 		}
-		
+
 		updateKeys();
 		updateKeys();
-		
+
 		super.sync(ctx);
 		super.sync(ctx);
 	}
 	}
-	
+
 	function createAlphaKey(px:Float, py:Float) {
 	function createAlphaKey(px:Float, py:Float) {
 		if( !withAlpha )
 		if( !withAlpha )
 			return;
 			return;
@@ -494,14 +494,14 @@ class GradientEditor extends h2d.comp.Component {
 		updateTarget = cursor;
 		updateTarget = cursor;
 		cursor.drag();
 		cursor.drag();
 	}
 	}
-	
+
 	function createColorKey(px:Float, py:Float) {
 	function createColorKey(px:Float, py:Float) {
 		var cursor = new Cursor(this, px, py, KColor, getColorAt(px / boxWidth), Math.PI, box);
 		var cursor = new Cursor(this, px, py, KColor, getColorAt(px / boxWidth), Math.PI, box);
 		colorsKeys.push(cursor);
 		colorsKeys.push(cursor);
 		updateTarget = cursor;
 		updateTarget = cursor;
 		cursor.drag();
 		cursor.drag();
 	}
 	}
-	
+
 	function updateKeys() {
 	function updateKeys() {
 		var keys = [];
 		var keys = [];
 		for (i in 0...colorsKeys.length) {
 		for (i in 0...colorsKeys.length) {
@@ -510,14 +510,14 @@ class GradientEditor extends h2d.comp.Component {
 			var rgb = INTtoRGB(k.value);
 			var rgb = INTtoRGB(k.value);
 			keys.push( { x:k.coeff, value:RGBtoINT(rgb[0], rgb[1], rgb[2], alpha) } );
 			keys.push( { x:k.coeff, value:RGBtoINT(rgb[0], rgb[1], rgb[2], alpha) } );
 		}
 		}
-		
+
 		for (i in 0...alphaKeys.length) {
 		for (i in 0...alphaKeys.length) {
 			var k = alphaKeys[i];
 			var k = alphaKeys[i];
 			var alpha = k.value;
 			var alpha = k.value;
 			var rgb = INTtoRGB(getColorAt(k.coeff));
 			var rgb = INTtoRGB(getColorAt(k.coeff));
 			keys.push( { x:k.coeff, value:RGBtoINT(rgb[0], rgb[1], rgb[2], alpha) } );
 			keys.push( { x:k.coeff, value:RGBtoINT(rgb[0], rgb[1], rgb[2], alpha) } );
 		}
 		}
-		
+
 		keys.sort(function(a, b) return Reflect.compare(a.x, b.x) );
 		keys.sort(function(a, b) return Reflect.compare(a.x, b.x) );
 		if(keys[0].x != 0)
 		if(keys[0].x != 0)
 			keys.insert(0, { x:0, value:keys[0].value } );
 			keys.insert(0, { x:0, value:keys[0].value } );
@@ -529,13 +529,13 @@ class GradientEditor extends h2d.comp.Component {
 			onChange(keys);
 			onChange(keys);
 		}
 		}
 	}
 	}
-	
+
 	function getARGBAt(x:Float) {
 	function getARGBAt(x:Float) {
 		var alpha = getAlphaAt(x);
 		var alpha = getAlphaAt(x);
 		var rgb = INTtoRGB(getColorAt(x));
 		var rgb = INTtoRGB(getColorAt(x));
 		return RGBtoINT(rgb[0], rgb[1], rgb[2], alpha);
 		return RGBtoINT(rgb[0], rgb[1], rgb[2], alpha);
 	}
 	}
-	
+
 	function getAlphaAt(x:Float) {
 	function getAlphaAt(x:Float) {
 		if( !withAlpha )
 		if( !withAlpha )
 			return 255;
 			return 255;
@@ -560,7 +560,7 @@ class GradientEditor extends h2d.comp.Component {
 		var d = (x - prev.coeff) / (next.coeff - prev.coeff);
 		var d = (x - prev.coeff) / (next.coeff - prev.coeff);
 		return Math.round(prev.value + (next.value - prev.value) * d);
 		return Math.round(prev.value + (next.value - prev.value) * d);
 	}
 	}
-	
+
 	function getColorAt(x:Float) {
 	function getColorAt(x:Float) {
 		colorsKeys.sort(function(a, b) return Reflect.compare(a.coeff, b.coeff) );
 		colorsKeys.sort(function(a, b) return Reflect.compare(a.coeff, b.coeff) );
 		var prev = null;
 		var prev = null;
@@ -580,7 +580,7 @@ class GradientEditor extends h2d.comp.Component {
 		}
 		}
 		if(next == null)
 		if(next == null)
 			return prev.value;
 			return prev.value;
-			
+
 		var d = (x - prev.coeff) / (next.coeff - prev.coeff);
 		var d = (x - prev.coeff) / (next.coeff - prev.coeff);
 		var pRGB = INTtoRGB(prev.value);
 		var pRGB = INTtoRGB(prev.value);
 		var nRGB = INTtoRGB(next.value);
 		var nRGB = INTtoRGB(next.value);
@@ -589,7 +589,7 @@ class GradientEditor extends h2d.comp.Component {
 			rgb.push(Math.round(pRGB[i] + (nRGB[i] - pRGB[i]) * d));
 			rgb.push(Math.round(pRGB[i] + (nRGB[i] - pRGB[i]) * d));
 		return RGBtoINT(rgb[0], rgb[1], rgb[2]);
 		return RGBtoINT(rgb[0], rgb[1], rgb[2]);
 	}
 	}
-	
+
 	function drawGradient() {
 	function drawGradient() {
 		box.removeChild(gradient);
 		box.removeChild(gradient);
 		gradient = new Fill(box);
 		gradient = new Fill(box);
@@ -600,7 +600,7 @@ class GradientEditor extends h2d.comp.Component {
 		}
 		}
 		gradient.lineRect(FillStyle.Color(borderColor), 0, 0, boxWidth, boxHeight, 2);
 		gradient.lineRect(FillStyle.Color(borderColor), 0, 0, boxWidth, boxHeight, 2);
 	}
 	}
-	
+
 	function drawChecker() {
 	function drawChecker() {
 		var checker = new Fill(box);
 		var checker = new Fill(box);
 		var nb = 90;
 		var nb = 90;
@@ -614,7 +614,7 @@ class GradientEditor extends h2d.comp.Component {
 			}
 			}
 		}
 		}
 	}
 	}
-	
+
 	function changeHud(cursor:Cursor) {
 	function changeHud(cursor:Cursor) {
 		switch(cursor.kind) {
 		switch(cursor.kind) {
 			case KAlpha: 	hudAlpha.target = cursor;
 			case KAlpha: 	hudAlpha.target = cursor;
@@ -627,7 +627,7 @@ class GradientEditor extends h2d.comp.Component {
 							hudAlpha.y =  0;
 							hudAlpha.y =  0;
 		}
 		}
 	}
 	}
-	
+
 	function updateFlags(cursor:Cursor) {
 	function updateFlags(cursor:Cursor) {
 		for (c in alphaKeys) {
 		for (c in alphaKeys) {
 			if (c == cursor)
 			if (c == cursor)
@@ -640,12 +640,12 @@ class GradientEditor extends h2d.comp.Component {
 			else c.unselect();
 			else c.unselect();
 		}
 		}
 	}
 	}
-	
-	
+
+
 	inline public static function INTtoRGB(color:Int) {
 	inline public static function INTtoRGB(color:Int) {
 		return [(color >> 16) & 0xFF, (color >> 8) & 0xFF,  color & 0xFF, color >>> 24];
 		return [(color >> 16) & 0xFF, (color >> 8) & 0xFF,  color & 0xFF, color >>> 24];
 	}
 	}
-	
+
 	inline public static function RGBtoINT(r:Int, g:Int, b:Int, a:Int = 255) {
 	inline public static function RGBtoINT(r:Int, g:Int, b:Int, a:Int = 255) {
 		return (a << 24) | (r << 16) | (g << 8) | b;
 		return (a << 24) | (r << 16) | (g << 8) | b;
 	}
 	}

+ 9 - 9
h2d/comp/Input.hx

@@ -3,13 +3,13 @@ import hxd.Key;
 
 
 @:access(h2d.comp.Input.scene)
 @:access(h2d.comp.Input.scene)
 class Input extends Interactive {
 class Input extends Interactive {
-	
+
 	var tf : h2d.Text;
 	var tf : h2d.Text;
 	var cursor : h2d.Bitmap;
 	var cursor : h2d.Bitmap;
 	var cursorPos(default,set) : Int;
 	var cursorPos(default,set) : Int;
-	
+
 	public var value(default, set) : String;
 	public var value(default, set) : String;
-	
+
 	public function new(?parent) {
 	public function new(?parent) {
 		super("input",parent);
 		super("input",parent);
 		tf = new h2d.Text(null, this);
 		tf = new h2d.Text(null, this);
@@ -64,7 +64,7 @@ class Input extends Interactive {
 		};
 		};
 		this.value = "";
 		this.value = "";
 	}
 	}
-	
+
 	function set_cursorPos(v:Int) {
 	function set_cursorPos(v:Int) {
 		textAlign(tf);
 		textAlign(tf);
 		cursor.x = tf.x + tf.calcTextWidth(value.substr(0, v)) + extLeft();
 		cursor.x = tf.x + tf.calcTextWidth(value.substr(0, v)) + extLeft();
@@ -80,16 +80,16 @@ class Input extends Interactive {
 		input.focus();
 		input.focus();
 		cursorPos = value.length;
 		cursorPos = value.length;
 	}
 	}
-	
+
 	function get_value() {
 	function get_value() {
 		return tf.text;
 		return tf.text;
 	}
 	}
-	
+
 	function set_value(t) {
 	function set_value(t) {
 		needRebuild = true;
 		needRebuild = true;
 		return value = t;
 		return value = t;
 	}
 	}
-	
+
 	override function resize( ctx : Context ) {
 	override function resize( ctx : Context ) {
 		if( ctx.measure ) {
 		if( ctx.measure ) {
 			tf.font = getFont();
 			tf.font = getFont();
@@ -119,8 +119,8 @@ class Input extends Interactive {
 
 
 	public dynamic function onFocus() {
 	public dynamic function onFocus() {
 	}
 	}
-	
+
 	public dynamic function onBlur() {
 	public dynamic function onBlur() {
 	}
 	}
-	
+
 }
 }

+ 8 - 8
h2d/comp/Interactive.hx

@@ -1,11 +1,11 @@
 package h2d.comp;
 package h2d.comp;
 
 
 class Interactive extends Component {
 class Interactive extends Component {
-	
+
 	var input : h2d.Interactive;
 	var input : h2d.Interactive;
 	var active : Bool;
 	var active : Bool;
 	var activeRight : Bool;
 	var activeRight : Bool;
-	
+
 	function new(kind,?parent) {
 	function new(kind,?parent) {
 		super(kind,parent);
 		super(kind,parent);
 		input = new h2d.Interactive(0, 0, bg);
 		input = new h2d.Interactive(0, 0, bg);
@@ -47,7 +47,7 @@ class Interactive extends Component {
 			}
 			}
 		};
 		};
 	}
 	}
-	
+
 	override function resize( ctx : Context ) {
 	override function resize( ctx : Context ) {
 		super.resize(ctx);
 		super.resize(ctx);
 		if( !ctx.measure ) {
 		if( !ctx.measure ) {
@@ -56,23 +56,23 @@ class Interactive extends Component {
 			input.visible = !hasClass(":disabled");
 			input.visible = !hasClass(":disabled");
 		}
 		}
 	}
 	}
-	
+
 	public dynamic function onMouseOver() {
 	public dynamic function onMouseOver() {
 	}
 	}
 
 
 	public dynamic function onMouseOut() {
 	public dynamic function onMouseOut() {
 	}
 	}
-	
+
 	public dynamic function onMouseDown() {
 	public dynamic function onMouseDown() {
 	}
 	}
 
 
 	public dynamic function onMouseUp() {
 	public dynamic function onMouseUp() {
 	}
 	}
-	
+
 	public dynamic function onClick() {
 	public dynamic function onClick() {
 	}
 	}
-	
+
 	public dynamic function onRightClick() {
 	public dynamic function onRightClick() {
 	}
 	}
-	
+
 }
 }

+ 7 - 7
h2d/comp/ItemList.hx

@@ -1,28 +1,28 @@
 package h2d.comp;
 package h2d.comp;
 
 
 class ItemList extends Box {
 class ItemList extends Box {
-	
+
 	public var selected(default,set) = -1;
 	public var selected(default,set) = -1;
 	var inputs : Array<h2d.Interactive>;
 	var inputs : Array<h2d.Interactive>;
-	
+
 	public function new(?parent) {
 	public function new(?parent) {
 		super(Vertical, parent);
 		super(Vertical, parent);
 		this.name = "itemlist";
 		this.name = "itemlist";
 		inputs = [];
 		inputs = [];
 	}
 	}
-	
+
 	function set_selected(v:Int) {
 	function set_selected(v:Int) {
 		needRebuild = true;
 		needRebuild = true;
 		return selected = v;
 		return selected = v;
 	}
 	}
-	
+
 	function onWheel( e : hxd.Event ) {
 	function onWheel( e : hxd.Event ) {
 		scrollY -= e.wheelDelta * (components.length == 0 ? 0 : (components[0].height + style.verticalSpacing));
 		scrollY -= e.wheelDelta * (components.length == 0 ? 0 : (components[0].height + style.verticalSpacing));
 		if( scrollY > 0 ) scrollY = 0;
 		if( scrollY > 0 ) scrollY = 0;
 		e.propagate = false;
 		e.propagate = false;
 		needRebuild = true;
 		needRebuild = true;
 	}
 	}
-	
+
 	override function resizeRec( ctx : Context ) {
 	override function resizeRec( ctx : Context ) {
 		super.resizeRec(ctx);
 		super.resizeRec(ctx);
 		if( !ctx.measure ) {
 		if( !ctx.measure ) {
@@ -85,8 +85,8 @@ class ItemList extends Box {
 
 
 	public dynamic function onItemOver( current : Int ) {
 	public dynamic function onItemOver( current : Int ) {
 	}
 	}
-	
+
 	public dynamic function onChange( selected : Int ) {
 	public dynamic function onChange( selected : Int ) {
 	}
 	}
-	
+
 }
 }

+ 18 - 18
h2d/comp/JQuery.hx

@@ -6,26 +6,26 @@ private typedef Query = Array<CssClass>;
 @:access(h2d.comp.Component)
 @:access(h2d.comp.Component)
 @:keep
 @:keep
 class JQuery {
 class JQuery {
-	
+
 	var root : Component;
 	var root : Component;
 	var select : Array<Component>;
 	var select : Array<Component>;
-	
+
 	public function new( root : Component, query : Dynamic ) {
 	public function new( root : Component, query : Dynamic ) {
 		while( root.parentComponent != null )
 		while( root.parentComponent != null )
 			root = root.parentComponent;
 			root = root.parentComponent;
 		this.root = root;
 		this.root = root;
 		select = getSet(query);
 		select = getSet(query);
 	}
 	}
-	
+
 	public function getComponents() {
 	public function getComponents() {
 		return select;
 		return select;
 	}
 	}
-	
+
 	public function toggleClass( cl : String, ?flag : Bool ) {
 	public function toggleClass( cl : String, ?flag : Bool ) {
 		for( s in select ) s.toggleClass(cl,flag);
 		for( s in select ) s.toggleClass(cl,flag);
 		return this;
 		return this;
 	}
 	}
-	
+
 	public function find( q : Dynamic ) {
 	public function find( q : Dynamic ) {
 		if( Std.is(q, Component) )
 		if( Std.is(q, Component) )
 			return new JQuery(root, Lambda.has(select, q) ? null : q);
 			return new JQuery(root, Lambda.has(select, q) ? null : q);
@@ -39,7 +39,7 @@ class JQuery {
 		throw "Invalid JQuery " + q;
 		throw "Invalid JQuery " + q;
 		return null;
 		return null;
 	}
 	}
-	
+
 	public function filter( q : Dynamic ) {
 	public function filter( q : Dynamic ) {
 		if( Std.is(q, Component) )
 		if( Std.is(q, Component) )
 			return new JQuery(root, Lambda.has(select, q) ? null : q);
 			return new JQuery(root, Lambda.has(select, q) ? null : q);
@@ -69,7 +69,7 @@ class JQuery {
 		throw "Invalid JQuery " + q;
 		throw "Invalid JQuery " + q;
 		return null;
 		return null;
 	}
 	}
-	
+
 	public function click( f : JQuery -> Void ) {
 	public function click( f : JQuery -> Void ) {
 		for( c in select ) {
 		for( c in select ) {
 			var int = Std.instance(c, Interactive);
 			var int = Std.instance(c, Interactive);
@@ -78,7 +78,7 @@ class JQuery {
 		}
 		}
 		return this;
 		return this;
 	}
 	}
-	
+
 	public function show() {
 	public function show() {
 		for( s in select )
 		for( s in select )
 			s.getStyle(true).display = true;
 			s.getStyle(true).display = true;
@@ -90,7 +90,7 @@ class JQuery {
 			s.getStyle(true).display = false;
 			s.getStyle(true).display = false;
 		return this;
 		return this;
 	}
 	}
-	
+
 	public function toggle() {
 	public function toggle() {
 		for( s in select ) {
 		for( s in select ) {
 			var s = s.getStyle(true);
 			var s = s.getStyle(true);
@@ -98,7 +98,7 @@ class JQuery {
 		}
 		}
 		return this;
 		return this;
 	}
 	}
-	
+
 	public function iterator() {
 	public function iterator() {
 		var it = select.iterator();
 		var it = select.iterator();
 		return {
 		return {
@@ -161,7 +161,7 @@ class JQuery {
 			"";
 			"";
 		}
 		}
 	}
 	}
-	
+
 	function _set_text(v:String) {
 	function _set_text(v:String) {
 		for( c in select )
 		for( c in select )
 			switch( c.name ) {
 			switch( c.name ) {
@@ -173,7 +173,7 @@ class JQuery {
 			}
 			}
 		return this;
 		return this;
 	}
 	}
-	
+
 	function _set_style(v:String) {
 	function _set_style(v:String) {
 		var s = new h2d.css.Style();
 		var s = new h2d.css.Style();
 		new h2d.css.Parser().parse(v, s);
 		new h2d.css.Parser().parse(v, s);
@@ -181,7 +181,7 @@ class JQuery {
 			c.addStyle(s);
 			c.addStyle(s);
 		return this;
 		return this;
 	}
 	}
-	
+
 	function getSet( query : Dynamic ) {
 	function getSet( query : Dynamic ) {
 		var set;
 		var set;
 		if( query == null )
 		if( query == null )
@@ -198,29 +198,29 @@ class JQuery {
 			throw "Invalid JQuery " + query;
 			throw "Invalid JQuery " + query;
 		return set;
 		return set;
 	}
 	}
-	
+
 	function lookup( root : Component, query : String ) {
 	function lookup( root : Component, query : String ) {
 		var set = [];
 		var set = [];
 		lookupRec(root, parseQuery(query), set);
 		lookupRec(root, parseQuery(query), set);
 		return set;
 		return set;
 	}
 	}
-	
+
 	function parseQuery(q) : Query {
 	function parseQuery(q) : Query {
 		return new h2d.css.Parser().parseClasses(q);
 		return new h2d.css.Parser().parseClasses(q);
 	}
 	}
-	
+
 	function matchQuery(q:Query, comp:Component) {
 	function matchQuery(q:Query, comp:Component) {
 		for( r in q )
 		for( r in q )
 			if( h2d.css.Engine.ruleMatch(r, comp) )
 			if( h2d.css.Engine.ruleMatch(r, comp) )
 				return true;
 				return true;
 		return false;
 		return false;
 	}
 	}
-	
+
 	function lookupRec(comp:Component, q, set : Array<Component> ) {
 	function lookupRec(comp:Component, q, set : Array<Component> ) {
 		if( matchQuery(q, comp) )
 		if( matchQuery(q, comp) )
 			set.push(comp);
 			set.push(comp);
 		for( s in comp.components )
 		for( s in comp.components )
 			lookupRec(s, q, set);
 			lookupRec(s, q, set);
 	}
 	}
-	
+
 }
 }

+ 6 - 6
h2d/comp/Label.hx

@@ -1,11 +1,11 @@
 package h2d.comp;
 package h2d.comp;
 
 
 class Label extends Component {
 class Label extends Component {
-	
+
 	var tf : h2d.Text;
 	var tf : h2d.Text;
-	
+
 	public var text(default, set) : String;
 	public var text(default, set) : String;
-	
+
 	public function new(text, ?parent) {
 	public function new(text, ?parent) {
 		super("label",parent);
 		super("label",parent);
 		tf = new h2d.Text(null, this);
 		tf = new h2d.Text(null, this);
@@ -15,12 +15,12 @@ class Label extends Component {
 	function get_text() {
 	function get_text() {
 		return tf.text;
 		return tf.text;
 	}
 	}
-	
+
 	function set_text(t) {
 	function set_text(t) {
 		needRebuild = true;
 		needRebuild = true;
 		return text = t;
 		return text = t;
 	}
 	}
-	
+
 	override function resize( ctx : Context ) {
 	override function resize( ctx : Context ) {
 		if( ctx.measure ) {
 		if( ctx.measure ) {
 			tf.font = getFont();
 			tf.font = getFont();
@@ -34,5 +34,5 @@ class Label extends Component {
 		if( !ctx.measure )
 		if( !ctx.measure )
 			textAlign(tf);
 			textAlign(tf);
 	}
 	}
-	
+
 }
 }

+ 7 - 7
h2d/comp/Parser.hx

@@ -16,13 +16,13 @@ private class CustomInterp extends hscript.Interp {
 #end
 #end
 
 
 class Parser {
 class Parser {
-	
+
 	var comps : Map < String, haxe.xml.Fast -> Component -> Component > ;
 	var comps : Map < String, haxe.xml.Fast -> Component -> Component > ;
 	#if hscript
 	#if hscript
 	var interp : hscript.Interp;
 	var interp : hscript.Interp;
 	#end
 	#end
 	var root : Component;
 	var root : Component;
-	
+
 	public function new(?api:{}) {
 	public function new(?api:{}) {
 		comps = new Map();
 		comps = new Map();
 		#if hscript
 		#if hscript
@@ -34,7 +34,7 @@ class Parser {
 				interp.variables.set(f, Reflect.field(api, f));
 				interp.variables.set(f, Reflect.field(api, f));
 		#end
 		#end
 	}
 	}
-	
+
 	public function build( x : haxe.xml.Fast, ?parent : Component ) {
 	public function build( x : haxe.xml.Fast, ?parent : Component ) {
 		var c : Component;
 		var c : Component;
 		switch( x.name.toLowerCase() ) {
 		switch( x.name.toLowerCase() ) {
@@ -246,11 +246,11 @@ class Parser {
 			build(e, c);
 			build(e, c);
 		return c;
 		return c;
 	}
 	}
-	
+
 	public function register(name, make) {
 	public function register(name, make) {
 		this.comps.set(name, make);
 		this.comps.set(name, make);
 	}
 	}
-	
+
 	function makeScript( c : Component, script : String ) {
 	function makeScript( c : Component, script : String ) {
 		#if hscript
 		#if hscript
 		var p = new hscript.Parser();
 		var p = new hscript.Parser();
@@ -269,7 +269,7 @@ class Parser {
 		return function() throw "Please compile with -lib hscript to get script access";
 		return function() throw "Please compile with -lib hscript to get script access";
 		#end
 		#end
 	}
 	}
-	
+
 	public static function fromHtml( html : String, ?api ) : Component {
 	public static function fromHtml( html : String, ?api ) : Component {
 		function lookupBody(x:Xml) {
 		function lookupBody(x:Xml) {
 			if( x.nodeType == Xml.Element && x.nodeName.toLowerCase() == "body" )
 			if( x.nodeType == Xml.Element && x.nodeName.toLowerCase() == "body" )
@@ -291,5 +291,5 @@ class Parser {
 		}
 		}
 		return new Parser(api).build(new haxe.xml.Fast(body),null);
 		return new Parser(api).build(new haxe.xml.Fast(body),null);
 	}
 	}
-	
+
 }
 }

+ 12 - 12
h2d/comp/Select.hx

@@ -7,7 +7,7 @@ class Select extends Interactive {
 	var list : ItemList;
 	var list : ItemList;
 	public var value(default, null) : String;
 	public var value(default, null) : String;
 	public var selectedIndex(default,set) : Int;
 	public var selectedIndex(default,set) : Int;
-	
+
 	public function new(?parent) {
 	public function new(?parent) {
 		super("select", parent);
 		super("select", parent);
 		tf = new h2d.Text(null, this);
 		tf = new h2d.Text(null, this);
@@ -18,11 +18,11 @@ class Select extends Interactive {
 	override function onClick() {
 	override function onClick() {
 		popup();
 		popup();
 	}
 	}
-	
+
 	public function getOptions() {
 	public function getOptions() {
 		return options.copy();
 		return options.copy();
 	}
 	}
-	
+
 	public function popup() {
 	public function popup() {
 		if( list != null || options.length == 0 )
 		if( list != null || options.length == 0 )
 			return;
 			return;
@@ -52,13 +52,13 @@ class Select extends Interactive {
 			}
 			}
 		},close);
 		},close);
 	}
 	}
-	
+
 	public function close() {
 	public function close() {
 		list.remove();
 		list.remove();
 		list = null;
 		list = null;
 		getScene().stopDrag();
 		getScene().stopDrag();
 	}
 	}
-	
+
 	public dynamic function onChange( value : String ) {
 	public dynamic function onChange( value : String ) {
 	}
 	}
 
 
@@ -68,7 +68,7 @@ class Select extends Interactive {
 		if( i != selectedIndex ) needRebuild = true;
 		if( i != selectedIndex ) needRebuild = true;
 		return selectedIndex = i;
 		return selectedIndex = i;
 	}
 	}
-	
+
 	public function setValue(v) {
 	public function setValue(v) {
 		var k = -1;
 		var k = -1;
 		for( i in 0...options.length )
 		for( i in 0...options.length )
@@ -86,8 +86,8 @@ class Select extends Interactive {
 		selectedIndex = k;
 		selectedIndex = k;
 		return value;
 		return value;
 	}
 	}
-	
-	
+
+
 	function updateListPos() {
 	function updateListPos() {
 		var scene = getScene();
 		var scene = getScene();
 		var s = new h2d.css.Style();
 		var s = new h2d.css.Style();
@@ -110,20 +110,20 @@ class Select extends Interactive {
 		if( list.customStyle == null || s.offsetX != list.customStyle.offsetX || s.offsetY != list.customStyle.offsetY || s.width != list.customStyle.width )
 		if( list.customStyle == null || s.offsetX != list.customStyle.offsetX || s.offsetY != list.customStyle.offsetY || s.width != list.customStyle.width )
 			list.setStyle(s);
 			list.setStyle(s);
 	}
 	}
-	
+
 	public function clear() {
 	public function clear() {
 		options = [];
 		options = [];
 		needRebuild = true;
 		needRebuild = true;
 		selectedIndex = 0;
 		selectedIndex = 0;
 	}
 	}
-	
+
 	public function addOption(label, ?value) {
 	public function addOption(label, ?value) {
 		options.push( { label : label, value : value } );
 		options.push( { label : label, value : value } );
 		needRebuild = true;
 		needRebuild = true;
 		if( selectedIndex == options.length - 1 )
 		if( selectedIndex == options.length - 1 )
 			selectedIndex = selectedIndex; // update value
 			selectedIndex = selectedIndex; // update value
 	}
 	}
-	
+
 	public dynamic function onItemOver( value : String ) {
 	public dynamic function onItemOver( value : String ) {
 	}
 	}
 
 
@@ -140,5 +140,5 @@ class Select extends Interactive {
 		if( !ctx.measure && list != null )
 		if( !ctx.measure && list != null )
 			updateListPos();
 			updateListPos();
 	}
 	}
-	
+
 }
 }

+ 6 - 6
h2d/comp/Slider.hx

@@ -1,20 +1,20 @@
 package h2d.comp;
 package h2d.comp;
 
 
 class Slider extends Component {
 class Slider extends Component {
-	
+
 	var cursor : Button;
 	var cursor : Button;
 	var input : h2d.Interactive;
 	var input : h2d.Interactive;
 	public var minValue : Float = 0.;
 	public var minValue : Float = 0.;
 	public var maxValue : Float = 1.;
 	public var maxValue : Float = 1.;
 	public var value(default, set) : Float;
 	public var value(default, set) : Float;
-	
+
 	@:access(h2d.comp.Button)
 	@:access(h2d.comp.Button)
 	public function new(?parent) {
 	public function new(?parent) {
 		super("slider", parent);
 		super("slider", parent);
 		cursor = new Button("", this);
 		cursor = new Button("", this);
 		cursor.input.cancelEvents = true;
 		cursor.input.cancelEvents = true;
 		cursor.onMouseDown = function() {
 		cursor.onMouseDown = function() {
-			
+
 		};
 		};
 		input = new h2d.Interactive(0, 0, this);
 		input = new h2d.Interactive(0, 0, this);
 		input.onPush = function(e) {
 		input.onPush = function(e) {
@@ -29,11 +29,11 @@ class Slider extends Component {
 		}
 		}
 		value = 0.;
 		value = 0.;
 	}
 	}
-	
+
 	function pixelToVal( e : hxd.Event ) {
 	function pixelToVal( e : hxd.Event ) {
 		return (Std.int(e.relX - (style.borderSize + cursor.width * 0.5) ) / (input.width - (style.borderSize * 2 + cursor.width))) * (maxValue - minValue) + minValue;
 		return (Std.int(e.relX - (style.borderSize + cursor.width * 0.5) ) / (input.width - (style.borderSize * 2 + cursor.width))) * (maxValue - minValue) + minValue;
 	}
 	}
-	
+
 	function gotoValue( v : Float ) {
 	function gotoValue( v : Float ) {
 		if( v < minValue ) v = minValue;
 		if( v < minValue ) v = minValue;
 		if( v > maxValue ) v = maxValue;
 		if( v > maxValue ) v = maxValue;
@@ -51,7 +51,7 @@ class Slider extends Component {
 			value = v;
 			value = v;
 		onChange(value);
 		onChange(value);
 	}
 	}
-	
+
 	function set_value(v:Float) {
 	function set_value(v:Float) {
 		if( v < minValue ) v = minValue;
 		if( v < minValue ) v = minValue;
 		if( v > maxValue ) v = maxValue;
 		if( v > maxValue ) v = maxValue;

+ 2 - 2
h2d/css/Fill.hx

@@ -6,7 +6,7 @@ class Fill extends h2d.TileGroup {
 	public function new(?parent) {
 	public function new(?parent) {
 		super(h2d.Tile.fromColor(0xFFFFFFFF), parent);
 		super(h2d.Tile.fromColor(0xFFFFFFFF), parent);
 	}
 	}
-	
+
 	public inline function fillRectColor(x, y, w, h, c) {
 	public inline function fillRectColor(x, y, w, h, c) {
 		content.rectColor(x, y, w, h, c);
 		content.rectColor(x, y, w, h, c);
 	}
 	}
@@ -14,7 +14,7 @@ class Fill extends h2d.TileGroup {
 	public inline function fillRectGradient(x, y, w, h, ctl, ctr, cbl, cbr) {
 	public inline function fillRectGradient(x, y, w, h, ctl, ctr, cbl, cbr) {
 		content.rectGradient(x, y, w, h, ctl, ctr, cbl, cbr);
 		content.rectGradient(x, y, w, h, ctl, ctr, cbl, cbr);
 	}
 	}
-	
+
 	public inline function addPoint(x, y, color) {
 	public inline function addPoint(x, y, color) {
 		content.addPoint(x, y, color);
 		content.addPoint(x, y, color);
 	}
 	}

+ 5 - 5
h2d/css/Parser.hx

@@ -448,7 +448,7 @@ class Parser {
 			null;
 			null;
 		};
 		};
 	}
 	}
-	
+
 	function mapIdent<T:EnumValue>( v : Value, vals : Array<T> ) : T {
 	function mapIdent<T:EnumValue>( v : Value, vals : Array<T> ) : T {
 		var i = getIdent(v);
 		var i = getIdent(v);
 		if( i == null ) return null;
 		if( i == null ) return null;
@@ -544,7 +544,7 @@ class Parser {
 		default: null;
 		default: null;
 		};
 		};
 	}
 	}
-	
+
 	function getImage( v : Value ) {
 	function getImage( v : Value ) {
 		switch( v ) {
 		switch( v ) {
 		case VCall("url", [VString(url)]):
 		case VCall("url", [VString(url)]):
@@ -654,7 +654,7 @@ class Parser {
 		}
 		}
 		return rules;
 		return rules;
 	}
 	}
-	
+
 	public function parseClasses( css : String ) {
 	public function parseClasses( css : String ) {
 		this.css = css;
 		this.css = css;
 		pos = 0;
 		pos = 0;
@@ -683,7 +683,7 @@ class Parser {
 			unexpected(readToken());
 			unexpected(readToken());
 		return classes;
 		return classes;
 	}
 	}
-	
+
 	function updateClass( c : CssClass ) {
 	function updateClass( c : CssClass ) {
 		// map html types to comp ones
 		// map html types to comp ones
 		switch( c.node ) {
 		switch( c.node ) {
@@ -695,7 +695,7 @@ class Parser {
 		}
 		}
 		if( c.parent != null ) updateClass(c.parent);
 		if( c.parent != null ) updateClass(c.parent);
 	}
 	}
-	
+
 	function readClass( parent ) : CssClass {
 	function readClass( parent ) : CssClass {
 		var c = new CssClass();
 		var c = new CssClass();
 		c.parent = parent;
 		c.parent = parent;

+ 6 - 6
h2d/css/Style.hx

@@ -2,7 +2,7 @@ package h2d.css;
 import h2d.css.Defs;
 import h2d.css.Defs;
 
 
 class Style {
 class Style {
-	
+
 	public var fontName : Null<String>;
 	public var fontName : Null<String>;
 	public var fontSize : Null<Float>;
 	public var fontSize : Null<Float>;
 	public var color : Null<Int>;
 	public var color : Null<Int>;
@@ -41,10 +41,10 @@ class Style {
 	public var iconTop : Null<Float>;
 	public var iconTop : Null<Float>;
 	public var textAlign : Null<TextAlign>;
 	public var textAlign : Null<TextAlign>;
 	public var display : Null<Bool>;
 	public var display : Null<Bool>;
-	
+
 	public function new() {
 	public function new() {
 	}
 	}
-	
+
 	public function apply( s : Style ) {
 	public function apply( s : Style ) {
 		if( s.fontName != null ) fontName = s.fontName;
 		if( s.fontName != null ) fontName = s.fontName;
 		if( s.fontSize != null ) fontSize = s.fontSize;
 		if( s.fontSize != null ) fontSize = s.fontSize;
@@ -91,7 +91,7 @@ class Style {
 		if( s.textAlign != null ) textAlign = s.textAlign;
 		if( s.textAlign != null ) textAlign = s.textAlign;
 		if( s.display != null ) display = s.display;
 		if( s.display != null ) display = s.display;
 	}
 	}
-	
+
 	public function padding( v : Float ) {
 	public function padding( v : Float ) {
 		this.paddingTop = v;
 		this.paddingTop = v;
 		this.paddingLeft = v;
 		this.paddingLeft = v;
@@ -105,7 +105,7 @@ class Style {
 		this.marginRight = v;
 		this.marginRight = v;
 		this.marginBottom = v;
 		this.marginBottom = v;
 	}
 	}
-	
+
 	public function toString() {
 	public function toString() {
 		var fields = [];
 		var fields = [];
 		for( f in Type.getInstanceFields(Style) ) {
 		for( f in Type.getInstanceFields(Style) ) {
@@ -118,5 +118,5 @@ class Style {
 		}
 		}
 		return "{" + fields.join(", ") + "}";
 		return "{" + fields.join(", ") + "}";
 	}
 	}
-		
+
 }
 }

+ 10 - 10
h3d/Buffer.hx

@@ -32,7 +32,7 @@ class Buffer {
 	public var vertices(default,null) : Int;
 	public var vertices(default,null) : Int;
 	public var next(default,null) : Buffer;
 	public var next(default,null) : Buffer;
 	public var flags(default, null) : haxe.EnumFlags<BufferFlag>;
 	public var flags(default, null) : haxe.EnumFlags<BufferFlag>;
-	
+
 	public function new(vertices, stride, ?flags : Array<BufferFlag>) {
 	public function new(vertices, stride, ?flags : Array<BufferFlag>) {
 		id = GUID++;
 		id = GUID++;
 		this.vertices = vertices;
 		this.vertices = vertices;
@@ -49,7 +49,7 @@ class Buffer {
 	public function isDisposed() {
 	public function isDisposed() {
 		return buffer == null || buffer.isDisposed();
 		return buffer == null || buffer.isDisposed();
 	}
 	}
-	
+
 	public function dispose() {
 	public function dispose() {
 		if( buffer != null ) {
 		if( buffer != null ) {
 			buffer.freeBuffer(this);
 			buffer.freeBuffer(this);
@@ -57,7 +57,7 @@ class Buffer {
 			if( next != null ) next.dispose();
 			if( next != null ) next.dispose();
 		}
 		}
 	}
 	}
-	
+
 	/**
 	/**
 		Returns the total number of vertices including the potential next buffers if it is split.
 		Returns the total number of vertices including the potential next buffers if it is split.
 	**/
 	**/
@@ -70,7 +70,7 @@ class Buffer {
 		}
 		}
 		return count;
 		return count;
 	}
 	}
-	
+
 	public function uploadVector( buf : hxd.FloatBuffer, bufPos : Int, vertices : Int ) {
 	public function uploadVector( buf : hxd.FloatBuffer, bufPos : Int, vertices : Int ) {
 		var cur = this;
 		var cur = this;
 		while( vertices > 0 ) {
 		while( vertices > 0 ) {
@@ -82,7 +82,7 @@ class Buffer {
 			cur = cur.next;
 			cur = cur.next;
 		}
 		}
 	}
 	}
-	
+
 	public function uploadBytes( data : haxe.io.Bytes, dataPos : Int, vertices : Int ) {
 	public function uploadBytes( data : haxe.io.Bytes, dataPos : Int, vertices : Int ) {
 		var cur = this;
 		var cur = this;
 		while( vertices > 0 ) {
 		while( vertices > 0 ) {
@@ -94,28 +94,28 @@ class Buffer {
 			cur = cur.next;
 			cur = cur.next;
 		}
 		}
 	}
 	}
-	
+
 	public static function ofFloats( v : hxd.FloatBuffer, stride : Int, ?flags, ?vertices ) {
 	public static function ofFloats( v : hxd.FloatBuffer, stride : Int, ?flags, ?vertices ) {
 		var nvert = vertices == null ? Std.int(v.length / stride) : vertices;
 		var nvert = vertices == null ? Std.int(v.length / stride) : vertices;
 		var b = new Buffer(nvert, stride, flags);
 		var b = new Buffer(nvert, stride, flags);
 		b.uploadVector(v, 0, nvert);
 		b.uploadVector(v, 0, nvert);
 		return b;
 		return b;
 	}
 	}
-	
+
 }
 }
 
 
 class BufferOffset {
 class BufferOffset {
 	public var id : Int;
 	public var id : Int;
 	public var buffer : Buffer;
 	public var buffer : Buffer;
 	public var offset : Int;
 	public var offset : Int;
-	
+
 	/*
 	/*
 		This is used to return a list of BufferOffset without allocating an array
 		This is used to return a list of BufferOffset without allocating an array
 	*/
 	*/
 	public var next : BufferOffset;
 	public var next : BufferOffset;
-	
+
 	static var UID = 0;
 	static var UID = 0;
-	
+
 	public function new(buffer, offset) {
 	public function new(buffer, offset) {
 		this.id = UID++;
 		this.id = UID++;
 		this.buffer = buffer;
 		this.buffer = buffer;

+ 26 - 26
h3d/Camera.hx

@@ -3,39 +3,39 @@ package h3d;
 // use left-handed coordinate system, more suitable for 2D games X=0,Y=0 at screen top-left and Z towards user
 // use left-handed coordinate system, more suitable for 2D games X=0,Y=0 at screen top-left and Z towards user
 
 
 class Camera {
 class Camera {
-	
+
 	public var zoom : Float;
 	public var zoom : Float;
-	
+
 	/**
 	/**
 		The screenRatio represents the W/H screen ratio.
 		The screenRatio represents the W/H screen ratio.
 	 **/
 	 **/
 	public var screenRatio : Float;
 	public var screenRatio : Float;
-	
+
 	/**
 	/**
 		The horizontal FieldOfView, in degrees.
 		The horizontal FieldOfView, in degrees.
 	**/
 	**/
 	public var fovX : Float;
 	public var fovX : Float;
 	public var zNear : Float;
 	public var zNear : Float;
 	public var zFar : Float;
 	public var zFar : Float;
-	
+
 	/**
 	/**
 		Set orthographic bounds.
 		Set orthographic bounds.
 	**/
 	**/
 	public var orthoBounds : h3d.col.Bounds;
 	public var orthoBounds : h3d.col.Bounds;
-	
+
 	public var rightHanded : Bool;
 	public var rightHanded : Bool;
-	
+
 	public var mproj : Matrix;
 	public var mproj : Matrix;
 	public var mcam : Matrix;
 	public var mcam : Matrix;
 	public var m : Matrix;
 	public var m : Matrix;
-	
+
 	public var pos : Vector;
 	public var pos : Vector;
 	public var up : Vector;
 	public var up : Vector;
 	public var target : Vector;
 	public var target : Vector;
-	
+
 	public var viewX : Float = 0.;
 	public var viewX : Float = 0.;
 	public var viewY : Float = 0.;
 	public var viewY : Float = 0.;
-	
+
 	var minv : Matrix;
 	var minv : Matrix;
 	var needInv : Bool;
 	var needInv : Bool;
 
 
@@ -54,14 +54,14 @@ class Camera {
 		mproj = new Matrix();
 		mproj = new Matrix();
 		update();
 		update();
 	}
 	}
-	
+
 	/**
 	/**
 		Update the fovX value based on the requested fovY value (in degrees) and current screenRatio.
 		Update the fovX value based on the requested fovY value (in degrees) and current screenRatio.
 	**/
 	**/
 	public function setFovY( value : Float ) {
 	public function setFovY( value : Float ) {
 		fovX = Math.atan( Math.tan(value * Math.PI / 180) / screenRatio ) * 180 / Math.PI;
 		fovX = Math.atan( Math.tan(value * Math.PI / 180) / screenRatio ) * 180 / Math.PI;
 	}
 	}
-	
+
 	public function clone() {
 	public function clone() {
 		var c = new Camera(fovX, zoom, screenRatio, zNear, zFar, rightHanded);
 		var c = new Camera(fovX, zoom, screenRatio, zNear, zFar, rightHanded);
 		c.pos = pos.clone();
 		c.pos = pos.clone();
@@ -95,20 +95,20 @@ class Camera {
 		p.project(getInverseViewProj());
 		p.project(getInverseViewProj());
 		return p;
 		return p;
 	}
 	}
-	
+
 	public function update() {
 	public function update() {
 		makeCameraMatrix(mcam);
 		makeCameraMatrix(mcam);
 		makeFrustumMatrix(mproj);
 		makeFrustumMatrix(mproj);
 		m.multiply(mcam, mproj);
 		m.multiply(mcam, mproj);
 		needInv = true;
 		needInv = true;
 	}
 	}
-	
+
 	public function lostUp() {
 	public function lostUp() {
 		var p2 = pos.clone();
 		var p2 = pos.clone();
 		p2.normalize();
 		p2.normalize();
 		return Math.abs(p2.dot3(up)) > 0.999;
 		return Math.abs(p2.dot3(up)) > 0.999;
 	}
 	}
-	
+
 	public function movePosAxis( dx : Float, dy : Float, dz = 0. ) {
 	public function movePosAxis( dx : Float, dy : Float, dz = 0. ) {
 		var p = new Vector(dx, dy, dz);
 		var p = new Vector(dx, dy, dz);
 		p.project(mcam);
 		p.project(mcam);
@@ -124,7 +124,7 @@ class Camera {
 		target.y += p.y;
 		target.y += p.y;
 		target.z += p.z;
 		target.z += p.z;
 	}
 	}
-	
+
 	function makeCameraMatrix( m : Matrix ) {
 	function makeCameraMatrix( m : Matrix ) {
 		// in leftHanded the z axis is positive else it's negative
 		// in leftHanded the z axis is positive else it's negative
 		// this way we make sure that our [ax,ay,-az] matrix follow the same handness as our world
 		// this way we make sure that our [ax,ay,-az] matrix follow the same handness as our world
@@ -156,26 +156,26 @@ class Camera {
 		m._43 = -az.dot3(pos);
 		m._43 = -az.dot3(pos);
 		m._44 = 1;
 		m._44 = 1;
 	}
 	}
-	
+
 	function makeFrustumMatrix( m : Matrix ) {
 	function makeFrustumMatrix( m : Matrix ) {
 		m.zero();
 		m.zero();
-		
+
 		// this will take into account the aspect ratio and normalize the z value into [0,1] once it's been divided by w
 		// this will take into account the aspect ratio and normalize the z value into [0,1] once it's been divided by w
 		// Matrixes have to solve the following formulaes :
 		// Matrixes have to solve the following formulaes :
 		//
 		//
 		// transform P by Mproj and divide everything by
 		// transform P by Mproj and divide everything by
 		//    [x,y,-zNear,1] => [sx/zNear, sy/zNear, 0, 1]
 		//    [x,y,-zNear,1] => [sx/zNear, sy/zNear, 0, 1]
 		//    [x,y,-zFar,1] => [sx/zFar, sy/zFar, 1, 1]
 		//    [x,y,-zFar,1] => [sx/zFar, sy/zFar, 1, 1]
-		
+
 		// we apply the screen ratio to the height in order to have the fov being a horizontal FOV. This way we don't have to change the FOV when the screen is enlarged
 		// we apply the screen ratio to the height in order to have the fov being a horizontal FOV. This way we don't have to change the FOV when the screen is enlarged
-		
+
 		var bounds = orthoBounds;
 		var bounds = orthoBounds;
 		if( bounds != null ) {
 		if( bounds != null ) {
-			
+
 			var w = 1 / (bounds.xMax - bounds.xMin);
 			var w = 1 / (bounds.xMax - bounds.xMin);
 			var h = 1 / (bounds.yMax - bounds.yMin);
 			var h = 1 / (bounds.yMax - bounds.yMin);
 			var d = 1 / (bounds.zMax - bounds.zMin);
 			var d = 1 / (bounds.zMax - bounds.zMin);
-			
+
 			m._11 = 2 * w;
 			m._11 = 2 * w;
 			m._22 = 2 * h;
 			m._22 = 2 * h;
 			m._33 = d;
 			m._33 = d;
@@ -183,16 +183,16 @@ class Camera {
 			m._42 = -(bounds.yMin + bounds.yMax) * h;
 			m._42 = -(bounds.yMin + bounds.yMax) * h;
 			m._43 = -bounds.zMin * d;
 			m._43 = -bounds.zMin * d;
 			m._44 = 1;
 			m._44 = 1;
-			
+
 		} else {
 		} else {
-		
+
 			var scale = zoom / Math.tan(fovX * Math.PI / 360.0);
 			var scale = zoom / Math.tan(fovX * Math.PI / 360.0);
 			m._11 = scale;
 			m._11 = scale;
 			m._22 = scale * screenRatio;
 			m._22 = scale * screenRatio;
 			m._33 = zFar / (zFar - zNear);
 			m._33 = zFar / (zFar - zNear);
 			m._34 = 1;
 			m._34 = 1;
 			m._43 = -(zNear * zFar) / (zFar - zNear);
 			m._43 = -(zNear * zFar) / (zFar - zNear);
-			
+
 		}
 		}
 
 
 		m._11 += viewX * m._14;
 		m._11 += viewX * m._14;
@@ -204,12 +204,12 @@ class Camera {
 		m._22 += viewY * m._24;
 		m._22 += viewY * m._24;
 		m._32 += viewY * m._34;
 		m._32 += viewY * m._34;
 		m._42 += viewY * m._44;
 		m._42 += viewY * m._44;
-		
+
 		// our z is negative in that case
 		// our z is negative in that case
 		if( rightHanded ) {
 		if( rightHanded ) {
 			m._33 *= -1;
 			m._33 *= -1;
 			m._34 *= -1;
 			m._34 *= -1;
 		}
 		}
 	}
 	}
-		
+
 }
 }

+ 5 - 5
h3d/Indexes.hx

@@ -7,26 +7,26 @@ class Indexes {
 	var mem : h3d.impl.MemoryManager;
 	var mem : h3d.impl.MemoryManager;
 	var ibuf : h3d.impl.Driver.IndexBuffer;
 	var ibuf : h3d.impl.Driver.IndexBuffer;
 	public var count(default,null) : Int;
 	public var count(default,null) : Int;
-	
+
 	public function new(count) {
 	public function new(count) {
 		this.mem = h3d.Engine.getCurrent().mem;
 		this.mem = h3d.Engine.getCurrent().mem;
 		this.count = count;
 		this.count = count;
 		mem.allocIndexes(this);
 		mem.allocIndexes(this);
 	}
 	}
-	
+
 	public function isDisposed() {
 	public function isDisposed() {
 		return ibuf == null;
 		return ibuf == null;
 	}
 	}
-	
+
 	public function upload( indexes : hxd.IndexBuffer, pos : Int, count : Int, bufferPos = 0 ) {
 	public function upload( indexes : hxd.IndexBuffer, pos : Int, count : Int, bufferPos = 0 ) {
 		mem.driver.uploadIndexesBuffer(this.ibuf, pos, count, indexes, bufferPos);
 		mem.driver.uploadIndexesBuffer(this.ibuf, pos, count, indexes, bufferPos);
 	}
 	}
-	
+
 	public function dispose() {
 	public function dispose() {
 		if( ibuf != null )
 		if( ibuf != null )
 			mem.deleteIndexes(this);
 			mem.deleteIndexes(this);
 	}
 	}
-	
+
 	public static function alloc( i : hxd.IndexBuffer ) {
 	public static function alloc( i : hxd.IndexBuffer ) {
 		var idx = new Indexes( i.length );
 		var idx = new Indexes( i.length );
 		idx.upload(i, 0, i.length);
 		idx.upload(i, 0, i.length);

+ 20 - 20
h3d/Matrix.hx

@@ -2,7 +2,7 @@ package h3d;
 import hxd.Math;
 import hxd.Math;
 
 
 class Matrix {
 class Matrix {
-	
+
 	static var tmp = new Matrix();
 	static var tmp = new Matrix();
 
 
 	public var _11 : Float;
 	public var _11 : Float;
@@ -104,7 +104,7 @@ class Matrix {
 		_34 = 0.;
 		_34 = 0.;
 		_41 = 0.; _42 = 0.; _43 = 0.; _44 = 1.;
 		_41 = 0.; _42 = 0.; _43 = 0.; _44 = 1.;
 	}
 	}
-	
+
 	public function initRotate( x : Float, y : Float, z : Float ) {
 	public function initRotate( x : Float, y : Float, z : Float ) {
 		var cx = Math.cos(x);
 		var cx = Math.cos(x);
 		var sx = Math.sin(x);
 		var sx = Math.sin(x);
@@ -131,7 +131,7 @@ class Matrix {
 		_43 = 0;
 		_43 = 0;
 		_44 = 1;
 		_44 = 1;
 	}
 	}
-	
+
 	public function translate( x = 0., y = 0., z = 0. ) {
 	public function translate( x = 0., y = 0., z = 0. ) {
 		_11 += x * _14;
 		_11 += x * _14;
 		_12 += y * _14;
 		_12 += y * _14;
@@ -146,7 +146,7 @@ class Matrix {
 		_42 += y * _44;
 		_42 += y * _44;
 		_43 += z * _44;
 		_43 += z * _44;
 	}
 	}
-	
+
 	public function scale( x = 1., y = 1., z = 1. ) {
 	public function scale( x = 1., y = 1., z = 1. ) {
 		_11 *= x;
 		_11 *= x;
 		_21 *= x;
 		_21 *= x;
@@ -167,13 +167,13 @@ class Matrix {
 		tmp.initRotate(x,y,z);
 		tmp.initRotate(x,y,z);
 		multiply(this, tmp);
 		multiply(this, tmp);
 	}
 	}
-	
+
 	public function rotateAxis( axis, angle ) {
 	public function rotateAxis( axis, angle ) {
 		var tmp = tmp;
 		var tmp = tmp;
 		tmp.initRotateAxis(axis, angle);
 		tmp.initRotateAxis(axis, angle);
 		multiply(this, tmp);
 		multiply(this, tmp);
 	}
 	}
-	
+
 	public inline function pos( ?v : Vector ) {
 	public inline function pos( ?v : Vector ) {
 		if( v == null )
 		if( v == null )
 			return new Vector( _41, _42 , _43 , _44 );
 			return new Vector( _41, _42 , _43 , _44 );
@@ -183,7 +183,7 @@ class Matrix {
 		v.w = _44;
 		v.w = _44;
 		return v;
 		return v;
 	}
 	}
-	
+
 	public function prependTranslate( x = 0., y = 0., z = 0. ) {
 	public function prependTranslate( x = 0., y = 0., z = 0. ) {
 		var vx = _11 * x + _21 * y + _31 * z + _41;
 		var vx = _11 * x + _21 * y + _31 * z + _41;
 		var vy = _12 * x + _22 * y + _32 * z + _42;
 		var vy = _12 * x + _22 * y + _32 * z + _42;
@@ -200,7 +200,7 @@ class Matrix {
 		tmp.initRotate(x,y,z);
 		tmp.initRotate(x,y,z);
 		multiply(tmp, this);
 		multiply(tmp, this);
 	}
 	}
-	
+
 	public function prependRotateAxis( axis, angle ) {
 	public function prependRotateAxis( axis, angle ) {
 		var tmp = tmp;
 		var tmp = tmp;
 		tmp.initRotateAxis(axis, angle);
 		tmp.initRotateAxis(axis, angle);
@@ -212,7 +212,7 @@ class Matrix {
 		tmp.initScale(sx,sy,sz);
 		tmp.initScale(sx,sy,sz);
 		multiply(tmp, this);
 		multiply(tmp, this);
 	}
 	}
-	
+
 	public function multiply3x4( a : Matrix, b : Matrix ) {
 	public function multiply3x4( a : Matrix, b : Matrix ) {
 		var m11 = a._11; var m12 = a._12; var m13 = a._13;
 		var m11 = a._11; var m12 = a._12; var m13 = a._13;
 		var m21 = a._21; var m22 = a._22; var m23 = a._23;
 		var m21 = a._21; var m22 = a._22; var m23 = a._23;
@@ -312,7 +312,7 @@ class Matrix {
 		_31 *= invDet; _32 *= invDet; _33 *= invDet;
 		_31 *= invDet; _32 *= invDet; _33 *= invDet;
 		_41 *= invDet; _42 *= invDet; _43 *= invDet;
 		_41 *= invDet; _42 *= invDet; _43 *= invDet;
 	}
 	}
-	
+
 	public function inverse( m : Matrix ) {
 	public function inverse( m : Matrix ) {
 		var m11 = m._11; var m12 = m._12; var m13 = m._13; var m14 = m._14;
 		var m11 = m._11; var m12 = m._12; var m13 = m._13; var m14 = m._14;
 		var m21 = m._21; var m22 = m._22; var m23 = m._23; var m24 = m._24;
 		var m21 = m._21; var m22 = m._22; var m23 = m._23; var m24 = m._24;
@@ -386,18 +386,18 @@ class Matrix {
 		_31 = m._31; _32 = m._32; _33 = m._33; _34 = m._34;
 		_31 = m._31; _32 = m._32; _33 = m._33; _34 = m._34;
 		_41 = m._41; _42 = m._42; _43 = m._43; _44 = m._44;
 		_41 = m._41; _42 = m._42; _43 = m._43; _44 = m._44;
 	}
 	}
-	
+
 	public function load( a : Array<Float> ) {
 	public function load( a : Array<Float> ) {
 		_11 = a[0]; _12 = a[1]; _13 = a[2]; _14 = a[3];
 		_11 = a[0]; _12 = a[1]; _13 = a[2]; _14 = a[3];
 		_21 = a[4]; _22 = a[5]; _23 = a[6]; _24 = a[7];
 		_21 = a[4]; _22 = a[5]; _23 = a[6]; _24 = a[7];
 		_31 = a[8]; _32 = a[9]; _33 = a[10]; _34 = a[11];
 		_31 = a[8]; _32 = a[9]; _33 = a[10]; _34 = a[11];
 		_41 = a[12]; _42 = a[13]; _43 = a[14]; _44 = a[15];
 		_41 = a[12]; _42 = a[13]; _43 = a[14]; _44 = a[15];
 	}
 	}
-	
+
 	public function getFloats() {
 	public function getFloats() {
 		return [_11, _12, _13, _14, _21, _22, _23, _24, _31, _32, _33, _34, _41, _42, _43, _44];
 		return [_11, _12, _13, _14, _21, _22, _23, _24, _31, _32, _33, _34, _41, _42, _43, _44];
 	}
 	}
-	
+
 	public function toString() {
 	public function toString() {
 		return "MAT=[\n" +
 		return "MAT=[\n" +
 			"  [ " + Math.fmt(_11) + ", " + Math.fmt(_12) + ", " + Math.fmt(_13) + ", " + Math.fmt(_14) + " ]\n" +
 			"  [ " + Math.fmt(_11) + ", " + Math.fmt(_12) + ", " + Math.fmt(_13) + ", " + Math.fmt(_14) + " ]\n" +
@@ -406,13 +406,13 @@ class Matrix {
 			"  [ " + Math.fmt(_41) + ", " + Math.fmt(_42) + ", " + Math.fmt(_43) + ", " + Math.fmt(_44) + " ]\n" +
 			"  [ " + Math.fmt(_41) + ", " + Math.fmt(_42) + ", " + Math.fmt(_43) + ", " + Math.fmt(_44) + " ]\n" +
 		"]";
 		"]";
 	}
 	}
-	
+
 	// ---- COLOR MATRIX FUNCTIONS -------
 	// ---- COLOR MATRIX FUNCTIONS -------
 
 
 	static inline var lumR = 0.212671;
 	static inline var lumR = 0.212671;
 	static inline var lumG = 0.71516;
 	static inline var lumG = 0.71516;
 	static inline var lumB = 0.072169;
 	static inline var lumB = 0.072169;
-	
+
 	public function colorHue( hue : Float ) {
 	public function colorHue( hue : Float ) {
 		if( hue == 0. )
 		if( hue == 0. )
 			return;
 			return;
@@ -433,7 +433,7 @@ class Matrix {
 		tmp._43 = 0;
 		tmp._43 = 0;
 		multiply3x4(this, tmp);
 		multiply3x4(this, tmp);
 	}
 	}
-	
+
 	public function colorSaturation( sat : Float ) {
 	public function colorSaturation( sat : Float ) {
 		var is = 1 - sat;
 		var is = 1 - sat;
 		var r = is * lumR;
 		var r = is * lumR;
@@ -453,7 +453,7 @@ class Matrix {
 		tmp._43 = 0;
 		tmp._43 = 0;
 		multiply3x4(this, tmp);
 		multiply3x4(this, tmp);
 	}
 	}
-	
+
 	public function colorContrast( contrast : Float ) {
 	public function colorContrast( contrast : Float ) {
 		var v = contrast + 1;
 		var v = contrast + 1;
 		tmp._11 = v;
 		tmp._11 = v;
@@ -476,9 +476,9 @@ class Matrix {
 		_42 += brightness;
 		_42 += brightness;
 		_43 += brightness;
 		_43 += brightness;
 	}
 	}
-	
+
 	// STATICS
 	// STATICS
-	
+
 	public static function I() {
 	public static function I() {
 		var m = new Matrix();
 		var m = new Matrix();
 		m.identity();
 		m.identity();
@@ -490,7 +490,7 @@ class Matrix {
 		m.load(a);
 		m.load(a);
 		return m;
 		return m;
 	}
 	}
-	
+
 	public static function T( x = 0., y = 0., z = 0. ) {
 	public static function T( x = 0., y = 0., z = 0. ) {
 		var m = new Matrix();
 		var m = new Matrix();
 		m.initTranslate(x, y, z);
 		m.initTranslate(x, y, z);

+ 23 - 23
h3d/Quat.hx

@@ -2,43 +2,43 @@ package h3d;
 using hxd.Math;
 using hxd.Math;
 
 
 class Quat {
 class Quat {
-	
+
 	public var x : Float;
 	public var x : Float;
 	public var y : Float;
 	public var y : Float;
 	public var z : Float;
 	public var z : Float;
 	public var w : Float;
 	public var w : Float;
-	
+
 	public inline function new( x = 0., y = 0., z = 0., w = 1. ) {
 	public inline function new( x = 0., y = 0., z = 0., w = 1. ) {
 		this.x = x;
 		this.x = x;
 		this.y = y;
 		this.y = y;
 		this.z = z;
 		this.z = z;
 		this.w = w;
 		this.w = w;
 	}
 	}
-	
+
 	public inline function set(x, y, z, w) {
 	public inline function set(x, y, z, w) {
 		this.x = x;
 		this.x = x;
 		this.y = y;
 		this.y = y;
 		this.z = z;
 		this.z = z;
 		this.w = w;
 		this.w = w;
 	}
 	}
-	
+
 	public inline function identity() {
 	public inline function identity() {
 		x = y = z = 0;
 		x = y = z = 0;
 		w = 1;
 		w = 1;
 	}
 	}
-	
+
 	public inline function lengthSq() {
 	public inline function lengthSq() {
 		return x * x + y * y + z * z + w * w;
 		return x * x + y * y + z * z + w * w;
 	}
 	}
-	
+
 	public inline function length() {
 	public inline function length() {
 		return lengthSq().sqrt();
 		return lengthSq().sqrt();
 	}
 	}
-	
+
 	public function clone() {
 	public function clone() {
 		return new Quat(x, y, z, w);
 		return new Quat(x, y, z, w);
 	}
 	}
-	
+
 	public function initMoveTo( from : Vector, to : Vector ) {
 	public function initMoveTo( from : Vector, to : Vector ) {
 		//		H = Normalize(From + To)
 		//		H = Normalize(From + To)
 		//		Q = (From ^ H, From . H)
 		//		Q = (From ^ H, From . H)
@@ -54,7 +54,7 @@ class Quat {
 		w = from.x * hx + from.y * hy + from.z * hz;
 		w = from.x * hx + from.y * hy + from.z * hz;
 		normalize();
 		normalize();
 	}
 	}
-	
+
 	public function initDirection( dir : Vector ) {
 	public function initDirection( dir : Vector ) {
 		// inlined version of initRotationMatrix(Matrix.lookAtX(dir))
 		// inlined version of initRotationMatrix(Matrix.lookAtX(dir))
 		var ax = dir.clone().getNormalized();
 		var ax = dir.clone().getNormalized();
@@ -96,7 +96,7 @@ class Quat {
 			w = (ax.y - ay.x) * is;
 			w = (ax.y - ay.x) * is;
 		}
 		}
 	}
 	}
-	
+
 	public function initRotateAxis( x : Float, y : Float, z : Float, a : Float ) {
 	public function initRotateAxis( x : Float, y : Float, z : Float, a : Float ) {
 		var sin = (a / 2).sin();
 		var sin = (a / 2).sin();
 		var cos = (a / 2).cos();
 		var cos = (a / 2).cos();
@@ -106,7 +106,7 @@ class Quat {
 		this.w = cos * (x * x + y * y + z * z).sqrt(); // allow not normalized axis
 		this.w = cos * (x * x + y * y + z * z).sqrt(); // allow not normalized axis
 		normalize();
 		normalize();
 	}
 	}
-	
+
 	public function initRotateMatrix( m : Matrix ) {
 	public function initRotateMatrix( m : Matrix ) {
 		var tr = m._11 + m._22 + m._33;
 		var tr = m._11 + m._22 + m._33;
 		if( tr > 0 ) {
 		if( tr > 0 ) {
@@ -139,7 +139,7 @@ class Quat {
 			w = (m._12 - m._21) * is;
 			w = (m._12 - m._21) * is;
 		}
 		}
 	}
 	}
-	
+
 	public function normalize() {
 	public function normalize() {
 		var len = x * x + y * y + z * z + w * w;
 		var len = x * x + y * y + z * z + w * w;
 		if( len < hxd.Math.EPSILON ) {
 		if( len < hxd.Math.EPSILON ) {
@@ -153,7 +153,7 @@ class Quat {
 			w *= m;
 			w *= m;
 		}
 		}
 	}
 	}
-	
+
 	public function initRotate( ax : Float, ay : Float, az : Float ) {
 	public function initRotate( ax : Float, ay : Float, az : Float ) {
 		var sinX = ( ax * 0.5 ).sin();
 		var sinX = ( ax * 0.5 ).sin();
 		var cosX = ( ax * 0.5 ).cos();
 		var cosX = ( ax * 0.5 ).cos();
@@ -168,7 +168,7 @@ class Quat {
 		z = cosX * cosY * sinZ - sinX * sinY * cosZ;
 		z = cosX * cosY * sinZ - sinX * sinY * cosZ;
 		w = cosX * cosYZ + sinX * sinYZ;
 		w = cosX * cosYZ + sinX * sinYZ;
 	}
 	}
-	
+
 	public function multiply( q1 : Quat, q2 : Quat ) {
 	public function multiply( q1 : Quat, q2 : Quat ) {
 		var x2 = q1.x * q2.w + q1.w * q2.x + q1.y * q2.z - q1.z * q2.y;
 		var x2 = q1.x * q2.w + q1.w * q2.x + q1.y * q2.z - q1.z * q2.y;
 		var y2 = q1.w * q2.y - q1.x * q2.z + q1.y * q2.w + q1.z * q2.x;
 		var y2 = q1.w * q2.y - q1.x * q2.z + q1.y * q2.w + q1.z * q2.x;
@@ -179,13 +179,13 @@ class Quat {
 		z = z2;
 		z = z2;
 		w = w2;
 		w = w2;
 	}
 	}
-	
+
 	public function toMatrix() {
 	public function toMatrix() {
 		var m = new Matrix();
 		var m = new Matrix();
 		saveToMatrix(m);
 		saveToMatrix(m);
 		return m;
 		return m;
 	}
 	}
-	
+
 	public function toEuler() {
 	public function toEuler() {
 		return new Vector(
 		return new Vector(
 			hxd.Math.atan2(2 * (x * w + y * z), 1 - 2 * (x * x + z * z)),
 			hxd.Math.atan2(2 * (x * w + y * z), 1 - 2 * (x * x + z * z)),
@@ -193,7 +193,7 @@ class Quat {
 			(2 * (x * y + z * w)).asin()
 			(2 * (x * y + z * w)).asin()
 		);
 		);
 	}
 	}
-	
+
 	public inline function lerp( q1 : Quat, q2 : Quat, v : Float, nearest = false ) {
 	public inline function lerp( q1 : Quat, q2 : Quat, v : Float, nearest = false ) {
 		var v2;
 		var v2;
 		if( nearest && q1.dot(q2) < 0 )
 		if( nearest && q1.dot(q2) < 0 )
@@ -232,13 +232,13 @@ class Quat {
 		this.z = q1.z * a + q2.z * b;
 		this.z = q1.z * a + q2.z * b;
 		this.w = q1.w * a + q2.w * b;
 		this.w = q1.w * a + q2.w * b;
 	}
 	}
-	
+
 	public inline function conjugate() {
 	public inline function conjugate() {
 		x *= -1;
 		x *= -1;
 		y *= -1;
 		y *= -1;
 		z *= -1;
 		z *= -1;
 	}
 	}
-	
+
 	/**
 	/**
 		Negate the quaternion: this will not change the actual angle, use `conjugate` for that.
 		Negate the quaternion: this will not change the actual angle, use `conjugate` for that.
 	**/
 	**/
@@ -248,11 +248,11 @@ class Quat {
 		z *= -1;
 		z *= -1;
 		w *= -1;
 		w *= -1;
 	}
 	}
-	
+
 	public inline function dot( q : Quat ) {
 	public inline function dot( q : Quat ) {
 		return x * q.x + y * q.y + z * q.z + w * q.w;
 		return x * q.x + y * q.y + z * q.z + w * q.w;
 	}
 	}
-	
+
 	/**
 	/**
 		Save to a Left-Handed matrix
 		Save to a Left-Handed matrix
 	**/
 	**/
@@ -284,9 +284,9 @@ class Quat {
 		m._44 = 1;
 		m._44 = 1;
 		return m;
 		return m;
 	}
 	}
-	
+
 	public function toString() {
 	public function toString() {
 		return '{${x.fmt()},${y.fmt()},${z.fmt()},${w.fmt()}}';
 		return '{${x.fmt()},${y.fmt()},${z.fmt()},${w.fmt()}}';
 	}
 	}
-	
+
 }
 }

+ 9 - 9
h3d/anim/FrameAnimation.hx

@@ -5,7 +5,7 @@ class FrameObject extends AnimatedObject {
 	public var frames : haxe.ds.Vector<h3d.Matrix>;
 	public var frames : haxe.ds.Vector<h3d.Matrix>;
 	public var alphas : haxe.ds.Vector<Float>;
 	public var alphas : haxe.ds.Vector<Float>;
 	public var uvs : haxe.ds.Vector<Float>;
 	public var uvs : haxe.ds.Vector<Float>;
-	
+
 	override function clone() : AnimatedObject {
 	override function clone() : AnimatedObject {
 		var o = new FrameObject(objectName);
 		var o = new FrameObject(objectName);
 		o.frames = frames;
 		o.frames = frames;
@@ -14,7 +14,7 @@ class FrameObject extends AnimatedObject {
 		return o;
 		return o;
 	}
 	}
 }
 }
-	
+
 class FrameAnimation extends Animation {
 class FrameAnimation extends Animation {
 
 
 	var syncFrame : Int;
 	var syncFrame : Int;
@@ -23,13 +23,13 @@ class FrameAnimation extends Animation {
 		super(name,frame,sampling);
 		super(name,frame,sampling);
 		syncFrame = -1;
 		syncFrame = -1;
 	}
 	}
-	
+
 	public function addCurve( objName, frames ) {
 	public function addCurve( objName, frames ) {
 		var f = new FrameObject(objName);
 		var f = new FrameObject(objName);
 		f.frames = frames;
 		f.frames = frames;
 		objects.push(f);
 		objects.push(f);
 	}
 	}
-	
+
 	public function addAlphaCurve( objName, alphas ) {
 	public function addAlphaCurve( objName, alphas ) {
 		var f = new FrameObject(objName);
 		var f = new FrameObject(objName);
 		f.alphas = alphas;
 		f.alphas = alphas;
@@ -41,25 +41,25 @@ class FrameAnimation extends Animation {
 		f.uvs = uvs;
 		f.uvs = uvs;
 		objects.push(f);
 		objects.push(f);
 	}
 	}
-	
+
 	inline function getFrames() : Array<FrameObject> {
 	inline function getFrames() : Array<FrameObject> {
 		return cast objects;
 		return cast objects;
 	}
 	}
-	
+
 	override function initInstance() {
 	override function initInstance() {
 		super.initInstance();
 		super.initInstance();
 		for( a in getFrames() )
 		for( a in getFrames() )
 			if( a.alphas != null && (a.targetObject == null || !a.targetObject.isMesh()) )
 			if( a.alphas != null && (a.targetObject == null || !a.targetObject.isMesh()) )
 				throw a.objectName + " should be a mesh";
 				throw a.objectName + " should be a mesh";
 	}
 	}
-	
+
 	override function clone(?a:Animation) {
 	override function clone(?a:Animation) {
 		if( a == null )
 		if( a == null )
 			a = new FrameAnimation(name, frameCount, sampling);
 			a = new FrameAnimation(name, frameCount, sampling);
 		super.clone(a);
 		super.clone(a);
 		return a;
 		return a;
 	}
 	}
-	
+
 	@:access(h3d.scene.Skin)
 	@:access(h3d.scene.Skin)
 	override function sync( decompose = false ) {
 	override function sync( decompose = false ) {
 		if( decompose ) throw "Decompose not supported on Frame Animation";
 		if( decompose ) throw "Decompose not supported on Frame Animation";
@@ -80,5 +80,5 @@ class FrameAnimation extends Animation {
 				o.targetObject.defaultTransform = o.frames[frame];
 				o.targetObject.defaultTransform = o.frames[frame];
 		}
 		}
 	}
 	}
-	
+
 }
 }

+ 5 - 5
h3d/anim/SimpleBlend.hx

@@ -1,14 +1,14 @@
 package h3d.anim;
 package h3d.anim;
 
 
 class SimpleBlend extends Transition {
 class SimpleBlend extends Transition {
-	
+
 	public var objectsMap : Map<String,Bool>;
 	public var objectsMap : Map<String,Bool>;
-	
+
 	public function new( anim1 : Animation, anim2 : Animation, objects : Map < String, Bool > ) {
 	public function new( anim1 : Animation, anim2 : Animation, objects : Map < String, Bool > ) {
 		super("blend", anim1, anim2);
 		super("blend", anim1, anim2);
 		this.objectsMap = objects;
 		this.objectsMap = objects;
 	}
 	}
-	
+
 	override function clone(?a : Animation) : Animation {
 	override function clone(?a : Animation) : Animation {
 		var a : SimpleBlend = cast a;
 		var a : SimpleBlend = cast a;
 		if( a == null )
 		if( a == null )
@@ -17,7 +17,7 @@ class SimpleBlend extends Transition {
 		a.objectsMap = objectsMap;
 		a.objectsMap = objectsMap;
 		return a;
 		return a;
 	}
 	}
-	
+
 	override function createInstance( base ) {
 	override function createInstance( base ) {
 		var a = new SimpleBlend(anim1, anim2, objectsMap);
 		var a = new SimpleBlend(anim1, anim2, objectsMap);
 		a.anim1 = anim1.createInstance(base);
 		a.anim1 = anim1.createInstance(base);
@@ -31,5 +31,5 @@ class SimpleBlend extends Transition {
 		a.isInstance = true;
 		a.isInstance = true;
 		return a;
 		return a;
 	}
 	}
-	
+
 }
 }

+ 16 - 16
h3d/anim/Skin.hx

@@ -10,12 +10,12 @@ class Joint {
 	public var transPos : h3d.Matrix; // inverse pose matrix
 	public var transPos : h3d.Matrix; // inverse pose matrix
 	public var parent : Joint;
 	public var parent : Joint;
 	public var subs : Array<Joint>;
 	public var subs : Array<Joint>;
-	
+
 	public function new() {
 	public function new() {
 		bindIndex = -1;
 		bindIndex = -1;
 		subs = [];
 		subs = [];
 	}
 	}
-	
+
 }
 }
 
 
 private class Influence {
 private class Influence {
@@ -28,7 +28,7 @@ private class Influence {
 }
 }
 
 
 class Skin {
 class Skin {
-	
+
 	public var vertexCount(default, null) : Int;
 	public var vertexCount(default, null) : Int;
 	public var bonesPerVertex(default,null) : Int;
 	public var bonesPerVertex(default,null) : Int;
 	public var vertexJoints : haxe.ds.Vector<Int>;
 	public var vertexJoints : haxe.ds.Vector<Int>;
@@ -38,13 +38,13 @@ class Skin {
 	public var allJoints(default,null) : Array<Joint>;
 	public var allJoints(default,null) : Array<Joint>;
 	public var boundJoints(default,null) : Array<Joint>;
 	public var boundJoints(default,null) : Array<Joint>;
 	public var primitive : h3d.prim.Primitive;
 	public var primitive : h3d.prim.Primitive;
-	
+
 	// spliting
 	// spliting
 	public var splitJoints(default, null) : Array<Array<Joint>>;
 	public var splitJoints(default, null) : Array<Array<Joint>>;
 	public var triangleGroups : haxe.ds.Vector<Int>;
 	public var triangleGroups : haxe.ds.Vector<Int>;
-	
+
 	var envelop : Array<Array<Influence>>;
 	var envelop : Array<Array<Influence>>;
-	
+
 	public function new( vertexCount, bonesPerVertex ) {
 	public function new( vertexCount, bonesPerVertex ) {
 		this.vertexCount = vertexCount;
 		this.vertexCount = vertexCount;
 		this.bonesPerVertex = bonesPerVertex;
 		this.bonesPerVertex = bonesPerVertex;
@@ -52,7 +52,7 @@ class Skin {
 		vertexWeights = new haxe.ds.Vector(vertexCount * bonesPerVertex);
 		vertexWeights = new haxe.ds.Vector(vertexCount * bonesPerVertex);
 		envelop = [];
 		envelop = [];
 	}
 	}
-	
+
 	public function setJoints( joints : Array<Joint>, roots : Array<Joint> ) {
 	public function setJoints( joints : Array<Joint>, roots : Array<Joint> ) {
 		rootJoints = roots;
 		rootJoints = roots;
 		allJoints = joints;
 		allJoints = joints;
@@ -61,7 +61,7 @@ class Skin {
 			if( j.name != null )
 			if( j.name != null )
 				namedJoints.set(j.name, j);
 				namedJoints.set(j.name, j);
 	}
 	}
-	
+
 	public inline function addInfluence( vid : Int, j : Joint, w : Float ) {
 	public inline function addInfluence( vid : Int, j : Joint, w : Float ) {
 		var il = envelop[vid];
 		var il = envelop[vid];
 		if( il == null )
 		if( il == null )
@@ -72,11 +72,11 @@ class Skin {
 	function sortInfluences( i1 : Influence, i2 : Influence ) {
 	function sortInfluences( i1 : Influence, i2 : Influence ) {
 		return i2.w > i1.w ? 1 : -1;
 		return i2.w > i1.w ? 1 : -1;
 	}
 	}
-	
+
 	public inline function isSplit() {
 	public inline function isSplit() {
 		return splitJoints != null;
 		return splitJoints != null;
 	}
 	}
-	
+
 	public function initWeights() {
 	public function initWeights() {
 		boundJoints = [];
 		boundJoints = [];
 		var pos = 0;
 		var pos = 0;
@@ -108,7 +108,7 @@ class Skin {
 		}
 		}
 		envelop = null;
 		envelop = null;
 	}
 	}
-	
+
 	public function split( maxBones : Int, index : Array<Int> ) {
 	public function split( maxBones : Int, index : Array<Int> ) {
 		if( isSplit() )
 		if( isSplit() )
 			return true;
 			return true;
@@ -117,7 +117,7 @@ class Skin {
 
 
 		splitJoints = [];
 		splitJoints = [];
 		triangleGroups = new haxe.ds.Vector(Std.int(index.length / 3));
 		triangleGroups = new haxe.ds.Vector(Std.int(index.length / 3));
-		
+
 		// collect joints groups used by triangles
 		// collect joints groups used by triangles
 		var curGroup = new Array<Joint>(), curJoints = [];
 		var curGroup = new Array<Joint>(), curJoints = [];
 		var ipos = 0, tpos = 0;
 		var ipos = 0, tpos = 0;
@@ -149,7 +149,7 @@ class Skin {
 				if( ipos == index.length ) break;
 				if( ipos == index.length ) break;
 			}
 			}
 		}
 		}
-		
+
 		// assign split indexes to joints
 		// assign split indexes to joints
 		var groups = [for( i in 0...splitJoints.length ) { id : i, reserved : [], joints : splitJoints[i] }];
 		var groups = [for( i in 0...splitJoints.length ) { id : i, reserved : [], joints : splitJoints[i] }];
 		var joints = [for( j in boundJoints ) { j : j, groups : [], index : -1 } ];
 		var joints = [for( j in boundJoints ) { j : j, groups : [], index : -1 } ];
@@ -189,13 +189,13 @@ class Skin {
 			}
 			}
 			splitJoints.push(jl);
 			splitJoints.push(jl);
 		}
 		}
-		
+
 		// rebind
 		// rebind
 		for( i in 0...vertexJoints.length )
 		for( i in 0...vertexJoints.length )
 			vertexJoints[i] = boundJoints[vertexJoints[i]].splitIndex;
 			vertexJoints[i] = boundJoints[vertexJoints[i]].splitIndex;
 
 
 		return true;
 		return true;
 	}
 	}
-	
-	
+
+
 }
 }

+ 8 - 8
h3d/anim/SmoothTransition.hx

@@ -12,17 +12,17 @@ class SmoothedObject extends Animation.AnimatedObject {
 }
 }
 
 
 class SmoothTransition extends Transition {
 class SmoothTransition extends Transition {
-	
+
 	static var MZERO = h3d.Matrix.L([
 	static var MZERO = h3d.Matrix.L([
 		1, 0, 0, 0,
 		1, 0, 0, 0,
 		0, 1, 1, 0,
 		0, 1, 1, 0,
 		0, 0, 1, 0,
 		0, 0, 1, 0,
 		0, 0, 0, 1,
 		0, 0, 0, 1,
 	]);
 	]);
-	
+
 	public var blendFactor : Float;
 	public var blendFactor : Float;
 	var tspeed : Float;
 	var tspeed : Float;
-	
+
 	public function new(current, target, speed) {
 	public function new(current, target, speed) {
 		super("smooth", current, target);
 		super("smooth", current, target);
 		blendFactor = 0.;
 		blendFactor = 0.;
@@ -32,7 +32,7 @@ class SmoothTransition extends Transition {
 		this.isInstance = true;
 		this.isInstance = true;
 		initObjects();
 		initObjects();
 	}
 	}
-	
+
 	function initObjects() {
 	function initObjects() {
 		var allObjects = new Map();
 		var allObjects = new Map();
 		var mzero = MZERO;
 		var mzero = MZERO;
@@ -59,13 +59,13 @@ class SmoothTransition extends Transition {
 			so.isAnim2 = true;
 			so.isAnim2 = true;
 		}
 		}
 	}
 	}
-	
+
 	override function bind( base ) {
 	override function bind( base ) {
 		super.bind(base);
 		super.bind(base);
 		this.objects = [];
 		this.objects = [];
 		initObjects();
 		initObjects();
 	}
 	}
-	
+
 	@:access(h3d.scene.Skin)
 	@:access(h3d.scene.Skin)
 	override function sync( decompose = false ) {
 	override function sync( decompose = false ) {
 		if( decompose ) throw "assert";
 		if( decompose ) throw "assert";
@@ -112,7 +112,7 @@ class SmoothTransition extends Transition {
 			if( o.targetSkin != null ) o.targetSkin.currentRelPose[o.targetJoint] = m else o.targetObject.defaultTransform = m;
 			if( o.targetSkin != null ) o.targetSkin.currentRelPose[o.targetJoint] = m else o.targetObject.defaultTransform = m;
 		}
 		}
 	}
 	}
-	
+
 	override function update( dt : Float ) : Float {
 	override function update( dt : Float ) : Float {
 		var rt = super.update(dt);
 		var rt = super.update(dt);
 		var st = dt - rt;
 		var st = dt - rt;
@@ -123,5 +123,5 @@ class SmoothTransition extends Transition {
 		}
 		}
 		return rt;
 		return rt;
 	}
 	}
-	
+
 }
 }

+ 8 - 8
h3d/anim/Transition.hx

@@ -1,10 +1,10 @@
 package h3d.anim;
 package h3d.anim;
 
 
 class Transition extends Animation {
 class Transition extends Animation {
-	
+
 	public var anim1 : Animation;
 	public var anim1 : Animation;
 	public var anim2 : Animation;
 	public var anim2 : Animation;
-	
+
 	public function new( transitionName : String, anim1 : Animation, anim2 : Animation ) {
 	public function new( transitionName : String, anim1 : Animation, anim2 : Animation ) {
 		var r1 = 1, r2 = 1;
 		var r1 = 1, r2 = 1;
 		while( true ) {
 		while( true ) {
@@ -16,13 +16,13 @@ class Transition extends Animation {
 		this.anim1 = anim1;
 		this.anim1 = anim1;
 		this.anim2 = anim2;
 		this.anim2 = anim2;
 	}
 	}
-	
+
 	override function setFrame( f : Float ) {
 	override function setFrame( f : Float ) {
 		super.setFrame(f);
 		super.setFrame(f);
 		anim1.setFrame(frame % anim1.frameCount);
 		anim1.setFrame(frame % anim1.frameCount);
 		anim2.setFrame(frame % anim2.frameCount);
 		anim2.setFrame(frame % anim2.frameCount);
 	}
 	}
-	
+
 	override function clone(?a : Animation) : Animation {
 	override function clone(?a : Animation) : Animation {
 		var a : Transition = cast a;
 		var a : Transition = cast a;
 		if( a == null )
 		if( a == null )
@@ -32,19 +32,19 @@ class Transition extends Animation {
 		a.anim2 = anim2.clone();
 		a.anim2 = anim2.clone();
 		return a;
 		return a;
 	}
 	}
-	
+
 	override function sync( decompose : Bool = false ) {
 	override function sync( decompose : Bool = false ) {
 		if( decompose )
 		if( decompose )
 			throw "Decompose not supported on transition";
 			throw "Decompose not supported on transition";
 		anim1.sync();
 		anim1.sync();
 		anim2.sync();
 		anim2.sync();
 	}
 	}
-	
+
 	override function bind(base) {
 	override function bind(base) {
 		anim1.bind(base);
 		anim1.bind(base);
 		anim2.bind(base);
 		anim2.bind(base);
 	}
 	}
-	
+
 	override function update(dt:Float) {
 	override function update(dt:Float) {
 		var rt = super.update(dt);
 		var rt = super.update(dt);
 		var st = dt - rt;
 		var st = dt - rt;
@@ -56,5 +56,5 @@ class Transition extends Animation {
 			tmp = anim2.update(tmp);
 			tmp = anim2.update(tmp);
 		return rt;
 		return rt;
 	}
 	}
-	
+
 }
 }

+ 26 - 26
h3d/col/Bounds.hx

@@ -2,18 +2,18 @@ package h3d.col;
 import hxd.Math;
 import hxd.Math;
 
 
 class Bounds {
 class Bounds {
-	
+
 	public var xMin : Float;
 	public var xMin : Float;
 	public var xMax : Float;
 	public var xMax : Float;
 	public var yMin : Float;
 	public var yMin : Float;
 	public var yMax : Float;
 	public var yMax : Float;
 	public var zMin : Float;
 	public var zMin : Float;
 	public var zMax : Float;
 	public var zMax : Float;
-	
+
 	public inline function new() {
 	public inline function new() {
 		empty();
 		empty();
 	}
 	}
-	
+
 	public function inFrustum( mvp : Matrix ) {
 	public function inFrustum( mvp : Matrix ) {
 		if( testPlane(Plane.frustumLeft(mvp)) < 0 )
 		if( testPlane(Plane.frustumLeft(mvp)) < 0 )
 			return false;
 			return false;
@@ -29,7 +29,7 @@ class Bounds {
 			return false;
 			return false;
 		return true;
 		return true;
 	}
 	}
-	
+
 	inline function testPlane( p : Plane ) {
 	inline function testPlane( p : Plane ) {
 		var a = p.nx;
 		var a = p.nx;
 		var b = p.ny;
 		var b = p.ny;
@@ -41,7 +41,7 @@ class Bounds {
 		var rr = a * (xMax - xMin) + b * (yMax - yMin) + c * (zMax - zMin);
 		var rr = a * (xMax - xMin) + b * (yMax - yMin) + c * (zMax - zMin);
 		return dd + rr - p.d*2;
 		return dd + rr - p.d*2;
 	}
 	}
-	
+
 	/**
 	/**
 	 * Check if the camera model-view-projection Matrix intersects with the Bounds. Returns -1 if outside, 0 if interests and 1 if fully inside.
 	 * Check if the camera model-view-projection Matrix intersects with the Bounds. Returns -1 if outside, 0 if interests and 1 if fully inside.
 	 * @param	mvp : the model-view-projection matrix to test against
 	 * @param	mvp : the model-view-projection matrix to test against
@@ -49,7 +49,7 @@ class Bounds {
 	 */
 	 */
 	public function inFrustumDetails( mvp : Matrix, checkZ = true ) {
 	public function inFrustumDetails( mvp : Matrix, checkZ = true ) {
 		var ret = 1;
 		var ret = 1;
-		
+
 		// left
 		// left
 		var p = new Plane(mvp._14 + mvp._11, mvp._24 + mvp._21 , mvp._34 + mvp._31, mvp._44 + mvp._41);
 		var p = new Plane(mvp._14 + mvp._11, mvp._24 + mvp._21 , mvp._34 + mvp._31, mvp._44 + mvp._41);
 		var m = p.nx * (p.nx > 0 ? xMax : xMin) + p.ny * (p.ny > 0 ? yMax : yMin) + p.nz * (p.nz > 0 ? zMax : zMin);
 		var m = p.nx * (p.nx > 0 ? xMax : xMin) + p.ny * (p.ny > 0 ? yMax : yMin) + p.nz * (p.nz > 0 ? zMax : zMin);
@@ -71,7 +71,7 @@ class Bounds {
 			return -1;
 			return -1;
 		var n = p.nx * (p.nx > 0 ? xMin : xMax) + p.ny * (p.ny > 0 ? yMin : yMax) + p.nz * (p.nz > 0 ? zMin : zMax);
 		var n = p.nx * (p.nx > 0 ? xMin : xMax) + p.ny * (p.ny > 0 ? yMin : yMax) + p.nz * (p.nz > 0 ? zMin : zMax);
 		if( n + p.d < 0 ) ret = 0;
 		if( n + p.d < 0 ) ret = 0;
-		
+
 		// top
 		// top
 		var p = new Plane(mvp._14 - mvp._12, mvp._24 - mvp._22 , mvp._34 - mvp._32, mvp._44 - mvp._42);
 		var p = new Plane(mvp._14 - mvp._12, mvp._24 - mvp._22 , mvp._34 - mvp._32, mvp._44 - mvp._42);
 		var m = p.nx * (p.nx > 0 ? xMax : xMin) + p.ny * (p.ny > 0 ? yMax : yMin) + p.nz * (p.nz > 0 ? zMax : zMin);
 		var m = p.nx * (p.nx > 0 ? xMax : xMin) + p.ny * (p.ny > 0 ? yMax : yMin) + p.nz * (p.nz > 0 ? zMax : zMin);
@@ -79,7 +79,7 @@ class Bounds {
 			return -1;
 			return -1;
 		var n = p.nx * (p.nx > 0 ? xMin : xMax) + p.ny * (p.ny > 0 ? yMin : yMax) + p.nz * (p.nz > 0 ? zMin : zMax);
 		var n = p.nx * (p.nx > 0 ? xMin : xMax) + p.ny * (p.ny > 0 ? yMin : yMax) + p.nz * (p.nz > 0 ? zMin : zMax);
 		if( n + p.d < 0 ) ret = 0;
 		if( n + p.d < 0 ) ret = 0;
-				
+
 		if( checkZ ) {
 		if( checkZ ) {
 			// nea
 			// nea
 			var p = new Plane(mvp._13, mvp._23, mvp._33, mvp._43);
 			var p = new Plane(mvp._13, mvp._23, mvp._33, mvp._43);
@@ -96,10 +96,10 @@ class Bounds {
 			var n = p.nx * (p.nx > 0 ? xMin : xMax) + p.ny * (p.ny > 0 ? yMin : yMax) + p.nz * (p.nz > 0 ? zMin : zMax);
 			var n = p.nx * (p.nx > 0 ? xMin : xMax) + p.ny * (p.ny > 0 ? yMin : yMax) + p.nz * (p.nz > 0 ? zMin : zMax);
 			if( n + p.d < 0 ) ret = 0;
 			if( n + p.d < 0 ) ret = 0;
 		}
 		}
-		
+
 		return ret;
 		return ret;
 	}
 	}
-	
+
 	public function transform3x4( m : Matrix ) {
 	public function transform3x4( m : Matrix ) {
 		var xMin = xMin, yMin = yMin, zMin = zMin, xMax = xMax, yMax = yMax, zMax = zMax;
 		var xMin = xMin, yMin = yMin, zMin = zMin, xMax = xMax, yMax = yMax, zMax = zMax;
 		empty();
 		empty();
@@ -129,15 +129,15 @@ class Bounds {
 		v.transform(m);
 		v.transform(m);
 		addPoint(v);
 		addPoint(v);
 	}
 	}
-	
+
 	public inline function collide( b : Bounds ) {
 	public inline function collide( b : Bounds ) {
 		return !(xMin > b.xMax || yMin > b.yMax || zMin > b.zMax || xMax < b.xMin || yMax < b.yMin || zMax < b.zMin);
 		return !(xMin > b.xMax || yMin > b.yMax || zMin > b.zMax || xMax < b.xMin || yMax < b.yMin || zMax < b.zMin);
 	}
 	}
-	
+
 	public inline function include( p : Point ) {
 	public inline function include( p : Point ) {
 		return p.x >= xMin && p.x < xMax && p.y >= yMin && p.y < yMax && p.z >= zMin && p.z < zMax;
 		return p.x >= xMin && p.x < xMax && p.y >= yMin && p.y < yMax && p.z >= zMin && p.z < zMax;
 	}
 	}
-	
+
 	public inline function add( b : Bounds ) {
 	public inline function add( b : Bounds ) {
 		if( b.xMin < xMin ) xMin = b.xMin;
 		if( b.xMin < xMin ) xMin = b.xMin;
 		if( b.xMax > xMax ) xMax = b.xMax;
 		if( b.xMax > xMax ) xMax = b.xMax;
@@ -164,7 +164,7 @@ class Bounds {
 		if( z < zMin ) zMin = z;
 		if( z < zMin ) zMin = z;
 		if( z > zMax ) zMax = z;
 		if( z > zMax ) zMax = z;
 	}
 	}
-	
+
 	public function intersection( a : Bounds, b : Bounds ) {
 	public function intersection( a : Bounds, b : Bounds ) {
 		var xMin = Math.max(a.xMin, b.xMin);
 		var xMin = Math.max(a.xMin, b.xMin);
 		var yMin = Math.max(a.yMin, b.yMin);
 		var yMin = Math.max(a.yMin, b.yMin);
@@ -179,7 +179,7 @@ class Bounds {
 		this.zMin = zMin;
 		this.zMin = zMin;
 		this.zMax = zMax;
 		this.zMax = zMax;
 	}
 	}
-	
+
 	public inline function offset( dx : Float, dy : Float, dz : Float ) {
 	public inline function offset( dx : Float, dy : Float, dz : Float ) {
 		xMin += dx;
 		xMin += dx;
 		xMax += dx;
 		xMax += dx;
@@ -188,7 +188,7 @@ class Bounds {
 		zMin += dz;
 		zMin += dz;
 		zMax += dz;
 		zMax += dz;
 	}
 	}
-	
+
 	public inline function setMin( p : Point ) {
 	public inline function setMin( p : Point ) {
 		xMin = p.x;
 		xMin = p.x;
 		yMin = p.y;
 		yMin = p.y;
@@ -200,7 +200,7 @@ class Bounds {
 		yMax = p.y;
 		yMax = p.y;
 		zMax = p.z;
 		zMax = p.z;
 	}
 	}
-	
+
 	public function load( b : Bounds ) {
 	public function load( b : Bounds ) {
 		xMin = b.xMin;
 		xMin = b.xMin;
 		xMax = b.xMax;
 		xMax = b.xMax;
@@ -209,7 +209,7 @@ class Bounds {
 		zMin = b.zMin;
 		zMin = b.zMin;
 		zMax = b.zMax;
 		zMax = b.zMax;
 	}
 	}
-	
+
 	public function scaleCenter( v : Float ) {
 	public function scaleCenter( v : Float ) {
 		var dx = (xMax - xMin) * 0.5 * v;
 		var dx = (xMax - xMin) * 0.5 * v;
 		var dy = (yMax - yMin) * 0.5 * v;
 		var dy = (yMax - yMin) * 0.5 * v;
@@ -224,11 +224,11 @@ class Bounds {
 		yMax = my + dy;
 		yMax = my + dy;
 		zMax = mz + dz;
 		zMax = mz + dz;
 	}
 	}
-	
+
 	public inline function getMin() {
 	public inline function getMin() {
 		return new Point(xMin, yMin, zMin);
 		return new Point(xMin, yMin, zMin);
 	}
 	}
-	
+
 	public inline function getCenter() {
 	public inline function getCenter() {
 		return new Point((xMin + xMax) * 0.5, (yMin + yMax) * 0.5, (zMin + zMax) * 0.5);
 		return new Point((xMin + xMax) * 0.5, (yMin + yMax) * 0.5, (zMin + zMax) * 0.5);
 	}
 	}
@@ -236,11 +236,11 @@ class Bounds {
 	public inline function getSize() {
 	public inline function getSize() {
 		return new Point(xMax - xMin, yMax - yMin, zMax - zMin);
 		return new Point(xMax - xMin, yMax - yMin, zMax - zMin);
 	}
 	}
-	
+
 	public inline function getMax() {
 	public inline function getMax() {
 		return new Point(xMax, yMax, zMax);
 		return new Point(xMax, yMax, zMax);
 	}
 	}
-	
+
 	public inline function empty() {
 	public inline function empty() {
 		xMin = 1e20;
 		xMin = 1e20;
 		xMax = -1e20;
 		xMax = -1e20;
@@ -258,7 +258,7 @@ class Bounds {
 		zMin = -1e20;
 		zMin = -1e20;
 		zMax = 1e20;
 		zMax = 1e20;
 	}
 	}
-	
+
 	public inline function clone() {
 	public inline function clone() {
 		var b = new Bounds();
 		var b = new Bounds();
 		b.xMin = xMin;
 		b.xMin = xMin;
@@ -269,11 +269,11 @@ class Bounds {
 		b.zMax = zMax;
 		b.zMax = zMax;
 		return b;
 		return b;
 	}
 	}
-	
+
 	public function toString() {
 	public function toString() {
 		return "{" + getMin() + "," + getMax() + "}";
 		return "{" + getMin() + "," + getMax() + "}";
 	}
 	}
-	
+
 	public static inline function fromPoints( min : Point, max : Point ) {
 	public static inline function fromPoints( min : Point, max : Point ) {
 		var b = new Bounds();
 		var b = new Bounds();
 		b.setMin(min);
 		b.setMin(min);
@@ -291,5 +291,5 @@ class Bounds {
 		b.zMax = z + dz;
 		b.zMax = z + dz;
 		return b;
 		return b;
 	}
 	}
-	
+
 }
 }

+ 17 - 17
h3d/col/Plane.hx

@@ -3,31 +3,31 @@ import hxd.Math;
 
 
 @:allow(h3d.col)
 @:allow(h3d.col)
 class Plane {
 class Plane {
-	
+
 	// Place equation :  nx.X + ny.Y + nz.Z - d = 0
 	// Place equation :  nx.X + ny.Y + nz.Z - d = 0
 	var nx : Float;
 	var nx : Float;
 	var ny : Float;
 	var ny : Float;
 	var nz : Float;
 	var nz : Float;
 	var d : Float;
 	var d : Float;
-	
+
 	inline function new(nx, ny, nz, d) {
 	inline function new(nx, ny, nz, d) {
 		this.nx = nx;
 		this.nx = nx;
 		this.ny = ny;
 		this.ny = ny;
 		this.nz = nz;
 		this.nz = nz;
 		this.d = d;
 		this.d = d;
 	}
 	}
-	
+
 	/**
 	/**
 		Returns the plan normal
 		Returns the plan normal
 	**/
 	**/
 	public inline function getNormal() {
 	public inline function getNormal() {
 		return new Point(nx, ny, nz);
 		return new Point(nx, ny, nz);
 	}
 	}
-	
+
 	public inline function getNormalDistance() {
 	public inline function getNormalDistance() {
 		return d;
 		return d;
 	}
 	}
-	
+
 	/**
 	/**
 		Normalize the plan, so we can use distance().
 		Normalize the plan, so we can use distance().
 	**/
 	**/
@@ -38,22 +38,22 @@ class Plane {
 		nz *= len;
 		nz *= len;
 		d *= len;
 		d *= len;
 	}
 	}
-	
+
 	public function toString() {
 	public function toString() {
 		return "{" + getNormal()+","+ d + "}";
 		return "{" + getNormal()+","+ d + "}";
 	}
 	}
-	
+
 	/**
 	/**
 		Returns the signed distance between a point an the plane. This requires the plan to be normalized. If the distance is negative it means that we are "under" the plan.
 		Returns the signed distance between a point an the plane. This requires the plan to be normalized. If the distance is negative it means that we are "under" the plan.
 	**/
 	**/
 	public inline function distance( p : Point ) {
 	public inline function distance( p : Point ) {
 		return nx * p.x + ny * p.y + nz * p.z - d;
 		return nx * p.x + ny * p.y + nz * p.z - d;
 	}
 	}
-	
+
 	public inline function side( p : Point ) {
 	public inline function side( p : Point ) {
 		return distance(p) >= 0;
 		return distance(p) >= 0;
 	}
 	}
-	
+
 	public inline function project( p : Point ) : Point {
 	public inline function project( p : Point ) : Point {
 		var d = distance(p);
 		var d = distance(p);
 		return new Point(p.x - d * nx, p.y - d * ny, p.z - d * nz);
 		return new Point(p.x - d * nx, p.y - d * ny, p.z - d * nz);
@@ -65,22 +65,22 @@ class Plane {
 		out.y = p.y - d * ny;
 		out.y = p.y - d * ny;
 		out.z = p.z - d * nz;
 		out.z = p.z - d * nz;
 	}
 	}
-	
+
 	public static inline function fromPoints( p0 : Point, p1 : Point, p2 : Point ) {
 	public static inline function fromPoints( p0 : Point, p1 : Point, p2 : Point ) {
 		var d1 = p1.sub(p0);
 		var d1 = p1.sub(p0);
 		var d2 = p2.sub(p0);
 		var d2 = p2.sub(p0);
 		var n = d1.cross(d2);
 		var n = d1.cross(d2);
 		return new Plane(n.x,n.y,n.z,n.dot(p0));
 		return new Plane(n.x,n.y,n.z,n.dot(p0));
 	}
 	}
-	
+
 	public static inline function fromNormalPoint( n : Point, p : Point ) {
 	public static inline function fromNormalPoint( n : Point, p : Point ) {
 		return new Plane(n.x,n.y,n.z,n.dot(p));
 		return new Plane(n.x,n.y,n.z,n.dot(p));
 	}
 	}
-	
+
 	public static inline function X(v:Float) {
 	public static inline function X(v:Float) {
 		return new Plane( 1, 0, 0, v );
 		return new Plane( 1, 0, 0, v );
 	}
 	}
-	
+
 	public static inline function Y(v:Float) {
 	public static inline function Y(v:Float) {
 		return new Plane( 0, 1, 0, v );
 		return new Plane( 0, 1, 0, v );
 	}
 	}
@@ -88,7 +88,7 @@ class Plane {
 	public static inline function Z(v:Float) {
 	public static inline function Z(v:Float) {
 		return new Plane( 0, 0, 1, v );
 		return new Plane( 0, 0, 1, v );
 	}
 	}
-	
+
 	public static inline function frustumLeft( mvp : Matrix ) {
 	public static inline function frustumLeft( mvp : Matrix ) {
 		return new Plane(mvp._14 + mvp._11, mvp._24 + mvp._21 , mvp._34 + mvp._31, -(mvp._44 + mvp._41));
 		return new Plane(mvp._14 + mvp._11, mvp._24 + mvp._21 , mvp._34 + mvp._31, -(mvp._44 + mvp._41));
 	}
 	}
@@ -96,7 +96,7 @@ class Plane {
 	public static inline function frustumRight( mvp : Matrix ) {
 	public static inline function frustumRight( mvp : Matrix ) {
 		return new Plane(mvp._14 - mvp._11, mvp._24 - mvp._21 , mvp._34 - mvp._31, mvp._41 - mvp._44);
 		return new Plane(mvp._14 - mvp._11, mvp._24 - mvp._21 , mvp._34 - mvp._31, mvp._41 - mvp._44);
 	}
 	}
-	
+
 	public static inline function frustumBottom( mvp : Matrix ) {
 	public static inline function frustumBottom( mvp : Matrix ) {
 		return new Plane(mvp._14 + mvp._12, mvp._24 + mvp._22 , mvp._34 + mvp._32, -(mvp._44 + mvp._42));
 		return new Plane(mvp._14 + mvp._12, mvp._24 + mvp._22 , mvp._34 + mvp._32, -(mvp._44 + mvp._42));
 	}
 	}
@@ -104,7 +104,7 @@ class Plane {
 	public static inline function frustumTop( mvp : Matrix ) {
 	public static inline function frustumTop( mvp : Matrix ) {
 		return new Plane(mvp._14 - mvp._12, mvp._24 - mvp._22 , mvp._34 - mvp._32, mvp._42 - mvp._44);
 		return new Plane(mvp._14 - mvp._12, mvp._24 - mvp._22 , mvp._34 - mvp._32, mvp._42 - mvp._44);
 	}
 	}
-	
+
 	public static inline function frustumNear( mvp : Matrix ) {
 	public static inline function frustumNear( mvp : Matrix ) {
 		return new Plane(mvp._13, mvp._23, mvp._33, -mvp._43);
 		return new Plane(mvp._13, mvp._23, mvp._33, -mvp._43);
 	}
 	}
@@ -112,5 +112,5 @@ class Plane {
 	public static inline function frustumFar( mvp : Matrix ) {
 	public static inline function frustumFar( mvp : Matrix ) {
 		return new Plane(mvp._14 - mvp._13, mvp._24 - mvp._23, mvp._34 - mvp._33, mvp._43 - mvp._44);
 		return new Plane(mvp._14 - mvp._13, mvp._24 - mvp._23, mvp._34 - mvp._33, mvp._43 - mvp._44);
 	}
 	}
-	
+
 }
 }

+ 12 - 12
h3d/col/Point.hx

@@ -6,13 +6,13 @@ class Point {
 	public var x : Float;
 	public var x : Float;
 	public var y : Float;
 	public var y : Float;
 	public var z : Float;
 	public var z : Float;
-	
+
 	public inline function new(x=0.,y=0.,z=0.) {
 	public inline function new(x=0.,y=0.,z=0.) {
 		this.x = x;
 		this.x = x;
 		this.y = y;
 		this.y = y;
 		this.z = z;
 		this.z = z;
 	}
 	}
-	
+
 	public function inFrustum( mvp : Matrix ) {
 	public function inFrustum( mvp : Matrix ) {
 		if( !Plane.frustumLeft(mvp).side(this) )
 		if( !Plane.frustumLeft(mvp).side(this) )
 			return false;
 			return false;
@@ -28,13 +28,13 @@ class Point {
 			return false;
 			return false;
 		return true;
 		return true;
 	}
 	}
-	
+
 	public inline function set(x, y, z) {
 	public inline function set(x, y, z) {
 		this.x = x;
 		this.x = x;
 		this.y = y;
 		this.y = y;
 		this.z = z;
 		this.z = z;
 	}
 	}
-	
+
 	public inline function sub( p : Point ) {
 	public inline function sub( p : Point ) {
 		return new Point(x - p.x, y - p.y, z - p.z);
 		return new Point(x - p.x, y - p.y, z - p.z);
 	}
 	}
@@ -42,15 +42,15 @@ class Point {
 	public inline function add( p : Point ) {
 	public inline function add( p : Point ) {
 		return new Point(x + p.x, y + p.y, z + p.z);
 		return new Point(x + p.x, y + p.y, z + p.z);
 	}
 	}
-	
+
 	public inline function cross( p : Point ) {
 	public inline function cross( p : Point ) {
 		return new Point(y * p.z - z * p.y, z * p.x - x * p.z,  x * p.y - y * p.x);
 		return new Point(y * p.z - z * p.y, z * p.x - x * p.z,  x * p.y - y * p.x);
 	}
 	}
-	
+
 	public inline function lengthSq() {
 	public inline function lengthSq() {
 		return x * x + y * y + z * z;
 		return x * x + y * y + z * z;
 	}
 	}
-	
+
 	public inline function length() {
 	public inline function length() {
 		return lengthSq().sqrt();
 		return lengthSq().sqrt();
 	}
 	}
@@ -58,7 +58,7 @@ class Point {
 	public inline function dot( p : Point ) {
 	public inline function dot( p : Point ) {
 		return x * p.x + y * p.y + z * p.z;
 		return x * p.x + y * p.y + z * p.z;
 	}
 	}
-	
+
 	public inline function distanceSq( p : Point ) {
 	public inline function distanceSq( p : Point ) {
 		var dx = p.x - x;
 		var dx = p.x - x;
 		var dy = p.y - y;
 		var dy = p.y - y;
@@ -70,7 +70,7 @@ class Point {
 		return distanceSq(p).sqrt();
 		return distanceSq(p).sqrt();
 	}
 	}
 
 
-	
+
 	public function normalize() {
 	public function normalize() {
 		var k = x * x + y * y + z * z;
 		var k = x * x + y * y + z * z;
 		if( k < hxd.Math.EPSILON ) k = 0 else k = k.invSqrt();
 		if( k < hxd.Math.EPSILON ) k = 0 else k = k.invSqrt();
@@ -78,7 +78,7 @@ class Point {
 		y *= k;
 		y *= k;
 		z *= k;
 		z *= k;
 	}
 	}
-	
+
 	public inline function transform( m : Matrix ) {
 	public inline function transform( m : Matrix ) {
 		var px = x * m._11 + y * m._21 + z * m._31 + m._41;
 		var px = x * m._11 + y * m._21 + z * m._31 + m._41;
 		var py = x * m._12 + y * m._22 + z * m._32 + m._42;
 		var py = x * m._12 + y * m._22 + z * m._32 + m._42;
@@ -87,7 +87,7 @@ class Point {
 		y = py;
 		y = py;
 		z = pz;
 		z = pz;
 	}
 	}
-	
+
 	public inline function toVector() {
 	public inline function toVector() {
 		return new Vector(x, y, z);
 		return new Vector(x, y, z);
 	}
 	}
@@ -99,5 +99,5 @@ class Point {
 	public function toString() {
 	public function toString() {
 		return '{${x.fmt()},${y.fmt()},${z.fmt()}}';
 		return '{${x.fmt()},${y.fmt()},${z.fmt()}}';
 	}
 	}
-	
+
 }
 }

+ 10 - 10
h3d/col/Ray.hx

@@ -3,17 +3,17 @@ import hxd.Math;
 
 
 @:allow(h3d.col)
 @:allow(h3d.col)
 class Ray {
 class Ray {
-	
+
 	var px : Float;
 	var px : Float;
 	var py : Float;
 	var py : Float;
 	var pz : Float;
 	var pz : Float;
 	var lx : Float;
 	var lx : Float;
 	var ly : Float;
 	var ly : Float;
 	var lz : Float;
 	var lz : Float;
-	
+
 	inline function new() {
 	inline function new() {
 	}
 	}
-	
+
 	public function normalize() {
 	public function normalize() {
 		var l = lx * lx + ly * ly + lz * lz;
 		var l = lx * lx + ly * ly + lz * lz;
 		if( l < Math.EPSILON ) l = 0 else l = Math.invSqrt(l);
 		if( l < Math.EPSILON ) l = 0 else l = Math.invSqrt(l);
@@ -21,7 +21,7 @@ class Ray {
 		ly *= l;
 		ly *= l;
 		lz *= l;
 		lz *= l;
 	}
 	}
-	
+
 	public inline function getPos() {
 	public inline function getPos() {
 		return new Point(px, py, pz);
 		return new Point(px, py, pz);
 	}
 	}
@@ -29,11 +29,11 @@ class Ray {
 	public inline function getDir() {
 	public inline function getDir() {
 		return new Point(lx, ly, lz);
 		return new Point(lx, ly, lz);
 	}
 	}
-	
+
 	public function toString() {
 	public function toString() {
 		return "{" + getPos() + "," + getDir() + "}";
 		return "{" + getPos() + "," + getDir() + "}";
 	}
 	}
-	
+
 	public inline function intersect( p : Plane ) : Null<Point> {
 	public inline function intersect( p : Plane ) : Null<Point> {
 		var d = lx * p.nx + ly * p.ny + lz * p.nz;
 		var d = lx * p.nx + ly * p.ny + lz * p.nz;
 		var nd = p.d - (px * p.nx + py * p.ny + pz * p.nz);
 		var nd = p.d - (px * p.nx + py * p.ny + pz * p.nz);
@@ -45,7 +45,7 @@ class Ray {
 			return new Point(px + lx * k, py + ly * k, pz + lz * k);
 			return new Point(px + lx * k, py + ly * k, pz + lz * k);
 		}
 		}
 	}
 	}
-	
+
 	public inline function collideFrustum( mvp : Matrix ) {
 	public inline function collideFrustum( mvp : Matrix ) {
 		// transform the two ray points into the normalized frustum box
 		// transform the two ray points into the normalized frustum box
 		var a = new h3d.Vector(px, py, pz);
 		var a = new h3d.Vector(px, py, pz);
@@ -56,7 +56,7 @@ class Ray {
 		var lx = b.x - a.x;
 		var lx = b.x - a.x;
 		var ly = b.y - a.y;
 		var ly = b.y - a.y;
 		var lz = b.z - a.z;
 		var lz = b.z - a.z;
-		
+
 		var dx = 1 / lx;
 		var dx = 1 / lx;
 		var dy = 1 / ly;
 		var dy = 1 / ly;
 		var dz = 1 / lz;
 		var dz = 1 / lz;
@@ -94,7 +94,7 @@ class Ray {
 			return true;
 			return true;
 		}
 		}
 	}
 	}
-	
+
 	public static inline function fromPoints( p1 : Point, p2 : Point ) {
 	public static inline function fromPoints( p1 : Point, p2 : Point ) {
 		var r = new Ray();
 		var r = new Ray();
 		r.px = p1.x;
 		r.px = p1.x;
@@ -116,5 +116,5 @@ class Ray {
 		r.lz = dz;
 		r.lz = dz;
 		return r;
 		return r;
 	}
 	}
-	
+
 }
 }

+ 5 - 5
h3d/col/Seg.hx

@@ -2,17 +2,17 @@ package h3d.col;
 import hxd.Math;
 import hxd.Math;
 
 
 class Seg {
 class Seg {
-	
+
 	public var p1 : Point;
 	public var p1 : Point;
 	public var p2 : Point;
 	public var p2 : Point;
 	public var lenSq : Float;
 	public var lenSq : Float;
-	
+
 	public inline function new( p1 : Point, p2 : Point ) {
 	public inline function new( p1 : Point, p2 : Point ) {
 		this.p1 = p1;
 		this.p1 = p1;
 		this.p2 = p2;
 		this.p2 = p2;
 		lenSq = p1.distanceSq(p2);
 		lenSq = p1.distanceSq(p2);
 	}
 	}
-	
+
 	public inline function distanceSq( p : Point ) {
 	public inline function distanceSq( p : Point ) {
 		var t = p.sub(p1).dot(p2.sub(p1)) / lenSq;
 		var t = p.sub(p1).dot(p2.sub(p1)) / lenSq;
 		return if( t < 0 )
 		return if( t < 0 )
@@ -22,9 +22,9 @@ class Seg {
 		} else
 		} else
 			p.distanceSq(new Point(p1.x + t * (p2.x - p1.x), p1.y + t * (p2.y - p1.y)));
 			p.distanceSq(new Point(p1.x + t * (p2.x - p1.x), p1.y + t * (p2.y - p1.y)));
 	}
 	}
-	
+
 	public inline function distance( p : Point ) {
 	public inline function distance( p : Point ) {
 		return Math.sqrt(distanceSq(p));
 		return Math.sqrt(distanceSq(p));
 	}
 	}
-	
+
 }
 }

+ 29 - 29
h3d/impl/Driver.hx

@@ -24,79 +24,79 @@ enum Feature {
 }
 }
 
 
 class Driver {
 class Driver {
-	
+
 	public function hasFeature( f : Feature ) {
 	public function hasFeature( f : Feature ) {
 		return false;
 		return false;
 	}
 	}
-	
+
 	public function isDisposed() {
 	public function isDisposed() {
 		return true;
 		return true;
 	}
 	}
-	
+
 	public function dispose() {
 	public function dispose() {
 	}
 	}
-	
+
 	public function begin( frame : Int ) {
 	public function begin( frame : Int ) {
 	}
 	}
-	
+
 	public function clear( r : Float, g : Float, b : Float, a : Float ) {
 	public function clear( r : Float, g : Float, b : Float, a : Float ) {
 	}
 	}
-	
+
 	public function setCapture( bmp : hxd.BitmapData, callb : Void -> Void ) {
 	public function setCapture( bmp : hxd.BitmapData, callb : Void -> Void ) {
 	}
 	}
-	
+
 	public function reset() {
 	public function reset() {
 	}
 	}
-	
+
 	public function getDriverName( details : Bool ) {
 	public function getDriverName( details : Bool ) {
 		return "Not available";
 		return "Not available";
 	}
 	}
-	
+
 	public function init( onCreate : Bool -> Void, forceSoftware = false ) {
 	public function init( onCreate : Bool -> Void, forceSoftware = false ) {
 	}
 	}
-	
+
 	public function resize( width : Int, height : Int ) {
 	public function resize( width : Int, height : Int ) {
 	}
 	}
-	
+
 	public function selectShader( shader : hxsl.RuntimeShader ) {
 	public function selectShader( shader : hxsl.RuntimeShader ) {
 		return false;
 		return false;
 	}
 	}
-	
+
 	public function selectMaterial( pass : h3d.mat.Pass ) {
 	public function selectMaterial( pass : h3d.mat.Pass ) {
 	}
 	}
-	
+
 	public function uploadShaderBuffers( buffers : h3d.shader.Buffers, which : h3d.shader.Buffers.BufferKind ) {
 	public function uploadShaderBuffers( buffers : h3d.shader.Buffers, which : h3d.shader.Buffers.BufferKind ) {
 	}
 	}
 
 
 	public function getShaderInputNames() : Array<String> {
 	public function getShaderInputNames() : Array<String> {
 		return null;
 		return null;
 	}
 	}
-	
+
 	public function selectBuffer( buffer : VertexBuffer ) {
 	public function selectBuffer( buffer : VertexBuffer ) {
 	}
 	}
-	
+
 	public function selectMultiBuffers( buffers : Buffer.BufferOffset ) {
 	public function selectMultiBuffers( buffers : Buffer.BufferOffset ) {
 	}
 	}
-	
+
 	public function draw( ibuf : IndexBuffer, startIndex : Int, ntriangles : Int ) {
 	public function draw( ibuf : IndexBuffer, startIndex : Int, ntriangles : Int ) {
 	}
 	}
-	
+
 	public function setRenderZone( x : Int, y : Int, width : Int, height : Int ) {
 	public function setRenderZone( x : Int, y : Int, width : Int, height : Int ) {
 	}
 	}
-	
+
 	public function setRenderTarget( tex : Null<h3d.mat.Texture>, clearColor : Int ) {
 	public function setRenderTarget( tex : Null<h3d.mat.Texture>, clearColor : Int ) {
 	}
 	}
-	
+
 	public function present() {
 	public function present() {
 	}
 	}
-	
+
 	public function isHardware() {
 	public function isHardware() {
 		return true;
 		return true;
 	}
 	}
-	
+
 	public function setDebug( b : Bool ) {
 	public function setDebug( b : Bool ) {
 	}
 	}
-	
+
 	public function allocTexture( t : h3d.mat.Texture ) : Texture {
 	public function allocTexture( t : h3d.mat.Texture ) : Texture {
 		return null;
 		return null;
 	}
 	}
@@ -108,32 +108,32 @@ class Driver {
 	public function allocVertex( m : ManagedBuffer ) : VertexBuffer {
 	public function allocVertex( m : ManagedBuffer ) : VertexBuffer {
 		return null;
 		return null;
 	}
 	}
-	
+
 	public function disposeTexture( t : Texture ) {
 	public function disposeTexture( t : Texture ) {
 	}
 	}
-	
+
 	public function disposeIndexes( i : IndexBuffer ) {
 	public function disposeIndexes( i : IndexBuffer ) {
 	}
 	}
-	
+
 	public function disposeVertex( v : VertexBuffer ) {
 	public function disposeVertex( v : VertexBuffer ) {
 	}
 	}
-	
+
 	public function uploadIndexesBuffer( i : IndexBuffer, startIndice : Int, indiceCount : Int, buf : hxd.IndexBuffer, bufPos : Int ) {
 	public function uploadIndexesBuffer( i : IndexBuffer, startIndice : Int, indiceCount : Int, buf : hxd.IndexBuffer, bufPos : Int ) {
 	}
 	}
 
 
 	public function uploadIndexesBytes( i : IndexBuffer, startIndice : Int, indiceCount : Int, buf : haxe.io.Bytes , bufPos : Int ) {
 	public function uploadIndexesBytes( i : IndexBuffer, startIndice : Int, indiceCount : Int, buf : haxe.io.Bytes , bufPos : Int ) {
 	}
 	}
-	
+
 	public function uploadVertexBuffer( v : VertexBuffer, startVertex : Int, vertexCount : Int, buf : hxd.FloatBuffer, bufPos : Int ) {
 	public function uploadVertexBuffer( v : VertexBuffer, startVertex : Int, vertexCount : Int, buf : hxd.FloatBuffer, bufPos : Int ) {
 	}
 	}
 
 
 	public function uploadVertexBytes( v : VertexBuffer, startVertex : Int, vertexCount : Int, buf : haxe.io.Bytes, bufPos : Int ) {
 	public function uploadVertexBytes( v : VertexBuffer, startVertex : Int, vertexCount : Int, buf : haxe.io.Bytes, bufPos : Int ) {
 	}
 	}
-	
+
 	public function uploadTextureBitmap( t : h3d.mat.Texture, bmp : hxd.BitmapData, mipLevel : Int, side : Int ) {
 	public function uploadTextureBitmap( t : h3d.mat.Texture, bmp : hxd.BitmapData, mipLevel : Int, side : Int ) {
 	}
 	}
 
 
 	public function uploadTexturePixels( t : h3d.mat.Texture, pixels : hxd.Pixels, mipLevel : Int, side : Int ) {
 	public function uploadTexturePixels( t : h3d.mat.Texture, pixels : hxd.Pixels, mipLevel : Int, side : Int ) {
 	}
 	}
-	
+
 }
 }

+ 8 - 8
h3d/impl/ManagedBuffer.hx

@@ -19,11 +19,11 @@ class ManagedBuffer {
 	public var stride(default,null) : Int;
 	public var stride(default,null) : Int;
 	public var size(default,null) : Int;
 	public var size(default,null) : Int;
 	public var flags(default, null) : haxe.EnumFlags<Buffer.BufferFlag>;
 	public var flags(default, null) : haxe.EnumFlags<Buffer.BufferFlag>;
-	
+
 	var vbuf : Driver.VertexBuffer;
 	var vbuf : Driver.VertexBuffer;
 	var freeList : FreeCell;
 	var freeList : FreeCell;
 	var next : ManagedBuffer;
 	var next : ManagedBuffer;
-	
+
 	public function new( stride, size, ?flags : Array<Buffer.BufferFlag> ) {
 	public function new( stride, size, ?flags : Array<Buffer.BufferFlag> ) {
 		this.flags = new haxe.EnumFlags();
 		this.flags = new haxe.EnumFlags();
 		if( flags != null )
 		if( flags != null )
@@ -43,7 +43,7 @@ class ManagedBuffer {
 	public function uploadVertexBytes( start : Int, vertices : Int, data : haxe.io.Bytes, dataPos = 0 ) {
 	public function uploadVertexBytes( start : Int, vertices : Int, data : haxe.io.Bytes, dataPos = 0 ) {
 		mem.driver.uploadVertexBytes(vbuf, start, vertices, data, dataPos);
 		mem.driver.uploadVertexBytes(vbuf, start, vertices, data, dataPos);
 	}
 	}
-	
+
 	public function alloc(vertices,align) {
 	public function alloc(vertices,align) {
 		var p = allocPosition(vertices, align);
 		var p = allocPosition(vertices, align);
 		if( p < 0 )
 		if( p < 0 )
@@ -55,7 +55,7 @@ class ManagedBuffer {
 		};
 		};
 		return b;
 		return b;
 	}
 	}
-	
+
 	public function getFreeVertices() {
 	public function getFreeVertices() {
 		var m = 0;
 		var m = 0;
 		var l = freeList;
 		var l = freeList;
@@ -65,7 +65,7 @@ class ManagedBuffer {
 		}
 		}
 		return m;
 		return m;
 	}
 	}
-	
+
 	function allocPosition( nvert : Int, align : Int ) {
 	function allocPosition( nvert : Int, align : Int ) {
 		var free = freeList;
 		var free = freeList;
 		while( free != null ) {
 		while( free != null ) {
@@ -90,7 +90,7 @@ class ManagedBuffer {
 		free.count -= nvert;
 		free.count -= nvert;
 		return pos;
 		return pos;
 	}
 	}
-	
+
 	function allocBuffer( b : Buffer ) {
 	function allocBuffer( b : Buffer ) {
 		var align = b.flags.has(Quads) ? 4 : (b.flags.has(Triangles) ? 3 : 1);
 		var align = b.flags.has(Quads) ? 4 : (b.flags.has(Triangles) ? 3 : 1);
 		var p = allocPosition(b.vertices, align);
 		var p = allocPosition(b.vertices, align);
@@ -101,7 +101,7 @@ class ManagedBuffer {
 		};
 		};
 		return true;
 		return true;
 	}
 	}
-	
+
 	@:allow(h3d.Buffer.dispose)
 	@:allow(h3d.Buffer.dispose)
 	function freeBuffer( b : Buffer ) {
 	function freeBuffer( b : Buffer ) {
 		var prev : FreeCell = null;
 		var prev : FreeCell = null;
@@ -141,7 +141,7 @@ class ManagedBuffer {
 	public function dispose() {
 	public function dispose() {
 		mem.freeManaged(this);
 		mem.freeManaged(this);
 	}
 	}
-	
+
 	public inline function isDisposed() {
 	public inline function isDisposed() {
 		return vbuf == null;
 		return vbuf == null;
 	}
 	}

+ 9 - 9
h3d/mat/Material.hx

@@ -3,17 +3,17 @@ import h3d.mat.Data;
 import h3d.mat.Pass;
 import h3d.mat.Pass;
 
 
 class Material {
 class Material {
-	
+
 	var passes : Pass;
 	var passes : Pass;
 	public var mainPass(get, never) : Pass;
 	public var mainPass(get, never) : Pass;
 	public var shadows(get, set) : Bool;
 	public var shadows(get, set) : Bool;
 	public var castShadows(default, set) : Bool;
 	public var castShadows(default, set) : Bool;
 	public var receiveShadows(default, set) : Bool;
 	public var receiveShadows(default, set) : Bool;
-	
+
 	public function new(passes) {
 	public function new(passes) {
 		this.passes = passes;
 		this.passes = passes;
 	}
 	}
-	
+
 	public function addPass<T:Pass>( p : T ) : T {
 	public function addPass<T:Pass>( p : T ) : T {
 		var prev = null, cur = passes;
 		var prev = null, cur = passes;
 		while( cur != null ) {
 		while( cur != null ) {
@@ -27,7 +27,7 @@ class Material {
 		p.nextPass = null;
 		p.nextPass = null;
 		return p;
 		return p;
 	}
 	}
-	
+
 	public function removePass( p : Pass ) {
 	public function removePass( p : Pass ) {
 		var prev : Pass = null, cur = passes;
 		var prev : Pass = null, cur = passes;
 		while( cur != null ) {
 		while( cur != null ) {
@@ -44,11 +44,11 @@ class Material {
 		}
 		}
 		return false;
 		return false;
 	}
 	}
-	
+
 	inline function get_mainPass() {
 	inline function get_mainPass() {
 		return passes;
 		return passes;
 	}
 	}
-	
+
 	public function getPass( name : String ) : Pass {
 	public function getPass( name : String ) : Pass {
 		var p = passes;
 		var p = passes;
 		while( p != null ) {
 		while( p != null ) {
@@ -67,7 +67,7 @@ class Material {
 		addPass(p);
 		addPass(p);
 		return p;
 		return p;
 	}
 	}
-	
+
 	public function clone() {
 	public function clone() {
 		throw "TODO";
 		throw "TODO";
 	}
 	}
@@ -75,13 +75,13 @@ class Material {
 	inline function get_shadows() {
 	inline function get_shadows() {
 		return castShadows && receiveShadows;
 		return castShadows && receiveShadows;
 	}
 	}
-	
+
 	inline function set_shadows(v) {
 	inline function set_shadows(v) {
 		castShadows = v;
 		castShadows = v;
 		receiveShadows = v;
 		receiveShadows = v;
 		return v;
 		return v;
 	}
 	}
-	
+
 	function set_castShadows(v) {
 	function set_castShadows(v) {
 		if( castShadows == v )
 		if( castShadows == v )
 			return v;
 			return v;

+ 4 - 4
h3d/mat/MeshMaterial.hx

@@ -5,7 +5,7 @@ class MeshMaterial extends Material {
 	var mshader : h3d.shader.BaseMesh;
 	var mshader : h3d.shader.BaseMesh;
 	var textureShader : h3d.shader.Texture;
 	var textureShader : h3d.shader.Texture;
 	public var texture(get,set) : h3d.mat.Texture;
 	public var texture(get,set) : h3d.mat.Texture;
-	
+
 	public var color(get, set) : Vector;
 	public var color(get, set) : Vector;
 	public var blendMode(default, set) : BlendMode;
 	public var blendMode(default, set) : BlendMode;
 
 
@@ -15,7 +15,7 @@ class MeshMaterial extends Material {
 		super(new h3d.mat.Pass("default",new hxsl.ShaderList(mshader)));
 		super(new h3d.mat.Pass("default",new hxsl.ShaderList(mshader)));
 		this.texture = texture;
 		this.texture = texture;
 	}
 	}
-	
+
 	inline function get_color() {
 	inline function get_color() {
 		return mshader.color;
 		return mshader.color;
 	}
 	}
@@ -23,7 +23,7 @@ class MeshMaterial extends Material {
 	inline function set_color(v) {
 	inline function set_color(v) {
 		return mshader.color = v;
 		return mshader.color = v;
 	}
 	}
-	
+
 	function set_blendMode(v:BlendMode) {
 	function set_blendMode(v:BlendMode) {
 		if( mainPass != null ) {
 		if( mainPass != null ) {
 			switch( v ) {
 			switch( v ) {
@@ -47,7 +47,7 @@ class MeshMaterial extends Material {
 	function get_texture() {
 	function get_texture() {
 		return textureShader == null ? null : textureShader.texture;
 		return textureShader == null ? null : textureShader.texture;
 	}
 	}
-	
+
 	function set_texture(t) {
 	function set_texture(t) {
 		if( t == null ) {
 		if( t == null ) {
 			if( textureShader != null ) {
 			if( textureShader != null ) {

+ 10 - 10
h3d/mat/Pass.hx

@@ -4,7 +4,7 @@ import h3d.mat.Data;
 @:allow(h3d.mat.Material)
 @:allow(h3d.mat.Material)
 @:build(hxd.impl.BitsBuilder.build())
 @:build(hxd.impl.BitsBuilder.build())
 class Pass {
 class Pass {
-	
+
 	public var name(default, null) : String;
 	public var name(default, null) : String;
 	var passId : Int;
 	var passId : Int;
 	var bits : Int = 0;
 	var bits : Int = 0;
@@ -12,9 +12,9 @@ class Pass {
 	var parentShaders : hxsl.ShaderList;
 	var parentShaders : hxsl.ShaderList;
 	var shaders : hxsl.ShaderList;
 	var shaders : hxsl.ShaderList;
 	var nextPass : Pass;
 	var nextPass : Pass;
-	
+
 	public var enableLights : Bool;
 	public var enableLights : Bool;
-	
+
 	@:bits public var culling : Face;
 	@:bits public var culling : Face;
 	@:bits public var depthWrite : Bool;
 	@:bits public var depthWrite : Bool;
 	@:bits public var depthTest : Compare;
 	@:bits public var depthTest : Compare;
@@ -25,7 +25,7 @@ class Pass {
 	@:bits public var blendOp : Operation;
 	@:bits public var blendOp : Operation;
 	@:bits public var blendAlphaOp : Operation;
 	@:bits public var blendAlphaOp : Operation;
 	@:bits(4) public var colorMask : Int;
 	@:bits(4) public var colorMask : Int;
-	
+
 	public function new(name, shaders, ?parent) {
 	public function new(name, shaders, ?parent) {
 		this.parentPass = parent;
 		this.parentPass = parent;
 		this.shaders = shaders;
 		this.shaders = shaders;
@@ -36,12 +36,12 @@ class Pass {
 		blendOp = blendAlphaOp = Add;
 		blendOp = blendAlphaOp = Add;
 		colorMask = 15;
 		colorMask = 15;
 	}
 	}
-	
+
 	public function setPassName( name : String ) {
 	public function setPassName( name : String ) {
 		this.name = name;
 		this.name = name;
 		passId = hxsl.Globals.allocID(name);
 		passId = hxsl.Globals.allocID(name);
 	}
 	}
-	
+
 	public inline function blend( src, dst ) {
 	public inline function blend( src, dst ) {
 		this.blendSrc = src;
 		this.blendSrc = src;
 		this.blendAlphaSrc = src;
 		this.blendAlphaSrc = src;
@@ -53,16 +53,16 @@ class Pass {
 		this.depthWrite = write;
 		this.depthWrite = write;
 		this.depthTest = test;
 		this.depthTest = test;
 	}
 	}
-	
+
 	public function setColorMask(r, g, b, a) {
 	public function setColorMask(r, g, b, a) {
 		this.colorMask = (r?1:0) | (g?2:0) | (b?4:0) | (a?8:0);
 		this.colorMask = (r?1:0) | (g?2:0) | (b?4:0) | (a?8:0);
 	}
 	}
-	
+
 	public function addShader<T:hxsl.Shader>(s:T) : T {
 	public function addShader<T:hxsl.Shader>(s:T) : T {
 		shaders = new hxsl.ShaderList(s, shaders);
 		shaders = new hxsl.ShaderList(s, shaders);
 		return s;
 		return s;
 	}
 	}
-	
+
 	public function removeShader(s) {
 	public function removeShader(s) {
 		var sl = shaders, prev = null;
 		var sl = shaders, prev = null;
 		while( sl != null ) {
 		while( sl != null ) {
@@ -78,7 +78,7 @@ class Pass {
 		}
 		}
 		return false;
 		return false;
 	}
 	}
-	
+
 	public function getShader< T:hxsl.Shader >(t:Class<T>) : T {
 	public function getShader< T:hxsl.Shader >(t:Class<T>) : T {
 		var s = shaders;
 		var s = shaders;
 		while( s != null ) {
 		while( s != null ) {

+ 20 - 20
h3d/parts/Data.hx

@@ -26,34 +26,34 @@ enum Shape {
 }
 }
 
 
 class ValueXYZ {
 class ValueXYZ {
-	
+
 	public var vx : Value;
 	public var vx : Value;
 	public var vy : Value;
 	public var vy : Value;
 	public var vz : Value;
 	public var vz : Value;
-	
+
 	public function new(x, y, z) {
 	public function new(x, y, z) {
 		this.vx = x;
 		this.vx = x;
 		this.vy = y;
 		this.vy = y;
 		this.vz = z;
 		this.vz = z;
 	}
 	}
-	
+
 }
 }
 
 
 class ColorKey {
 class ColorKey {
-	
+
 	public var time : Float;
 	public var time : Float;
 	public var r : Float;
 	public var r : Float;
 	public var g : Float;
 	public var g : Float;
 	public var b : Float;
 	public var b : Float;
 	public var next : ColorKey;
 	public var next : ColorKey;
-	
+
 	public function new(time, r, g, b) {
 	public function new(time, r, g, b) {
 		this.time = time;
 		this.time = time;
 		this.r = r;
 		this.r = r;
 		this.g = g;
 		this.g = g;
 		this.b = b;
 		this.b = b;
 	}
 	}
-	
+
 }
 }
 
 
 enum BlendMode {
 enum BlendMode {
@@ -74,7 +74,7 @@ interface Randomized {
 }
 }
 
 
 class State {
 class State {
-	
+
 	// material
 	// material
 	public var textureName : String;
 	public var textureName : String;
 	public var frames : Array<h2d.Tile>;
 	public var frames : Array<h2d.Tile>;
@@ -82,7 +82,7 @@ class State {
 	public var sortMode : SortMode;
 	public var sortMode : SortMode;
 	public var is3D : Bool;
 	public var is3D : Bool;
 	public var isAlphaMap : Bool;
 	public var isAlphaMap : Bool;
-	
+
 	// emit
 	// emit
 	public var loop	: Bool;
 	public var loop	: Bool;
 	public var emitRate : Value;
 	public var emitRate : Value;
@@ -98,7 +98,7 @@ class State {
 	public var globalLife : Float;
 	public var globalLife : Float;
 	public var globalSpeed : Value;
 	public var globalSpeed : Value;
 	public var globalSize : Value;
 	public var globalSize : Value;
-	
+
 	// particle globals
 	// particle globals
 	public var life : Value;
 	public var life : Value;
 	public var size : Value;
 	public var size : Value;
@@ -106,28 +106,28 @@ class State {
 	public var rotation : Value;
 	public var rotation : Value;
 	public var speed : Value;
 	public var speed : Value;
 	public var gravity : Value;
 	public var gravity : Value;
-	
+
 	// effects
 	// effects
 	public var force : Null<ValueXYZ>;
 	public var force : Null<ValueXYZ>;
 	public var colors : Null<Array<{ time : Float, color : Int }>>;
 	public var colors : Null<Array<{ time : Float, color : Int }>>;
 	public var light : Value;
 	public var light : Value;
 	public var alpha : Value;
 	public var alpha : Value;
-	
+
 	// collide
 	// collide
 	public var collide : Bool;
 	public var collide : Bool;
 	public var collideKill : Bool;
 	public var collideKill : Bool;
 	public var bounce : Float;
 	public var bounce : Float;
-	
+
 	// animation
 	// animation
 	public var frame : Null<Value>;
 	public var frame : Null<Value>;
-	
+
 	// extra
 	// extra
 	public var delay : Float;
 	public var delay : Float;
 	public var update : Particle -> Void;
 	public var update : Particle -> Void;
-	
+
 	public function new() {
 	public function new() {
 	}
 	}
-	
+
 	public function setDefaults() {
 	public function setDefaults() {
 		// material
 		// material
 		textureName = null;
 		textureName = null;
@@ -168,7 +168,7 @@ class State {
 		// extra
 		// extra
 		delay = 0.;
 		delay = 0.;
 	}
 	}
-	
+
 	public function scale( val : Value, v : Float ) {
 	public function scale( val : Value, v : Float ) {
 		return switch( val ) {
 		return switch( val ) {
 		case VConst(c): VConst(c * v);
 		case VConst(c): VConst(c * v);
@@ -181,7 +181,7 @@ class State {
 		case VCustom(f): VCustom(function(p) return f(p) * v);
 		case VCustom(f): VCustom(function(p) return f(p) * v);
 		}
 		}
 	}
 	}
-	
+
 	public static inline function eval( v : Value, time : Float, r : Randomized, p : Particle ) : Float {
 	public static inline function eval( v : Value, time : Float, r : Randomized, p : Particle ) : Float {
 		return switch( v ) {
 		return switch( v ) {
 		case VConst(c): c;
 		case VConst(c): c;
@@ -204,7 +204,7 @@ class State {
 
 
 	public static var defPartAlpha = hxd.res.Embed.getResource("h3d/parts/defaultAlpha.png");
 	public static var defPartAlpha = hxd.res.Embed.getResource("h3d/parts/defaultAlpha.png");
 	public static var defPart = hxd.res.Embed.getResource("h3d/parts/default.png");
 	public static var defPart = hxd.res.Embed.getResource("h3d/parts/default.png");
-	
+
 	public function initFrames() {
 	public function initFrames() {
 		if( textureName == null ) {
 		if( textureName == null ) {
 			var t = switch( blendMode ) {
 			var t = switch( blendMode ) {
@@ -227,7 +227,7 @@ class State {
 			}
 			}
 		}
 		}
 	}
 	}
-	
+
 	public static function load( b : haxe.io.Bytes, loadTexture : String -> h2d.Tile ) {
 	public static function load( b : haxe.io.Bytes, loadTexture : String -> h2d.Tile ) {
 		var state : State = haxe.Unserializer.run(b.toString());
 		var state : State = haxe.Unserializer.run(b.toString());
 		if( state.textureName != null ) {
 		if( state.textureName != null ) {
@@ -238,5 +238,5 @@ class State {
 		state.initFrames();
 		state.initFrames();
 		return state;
 		return state;
 	}
 	}
-	
+
 }
 }

+ 70 - 70
h3d/parts/Editor.hx

@@ -25,7 +25,7 @@ private typedef Curve = {
 }
 }
 
 
 class Editor extends h2d.Sprite implements Randomized {
 class Editor extends h2d.Sprite implements Randomized {
-	
+
 	var emit : Emitter;
 	var emit : Emitter;
 	var state : State;
 	var state : State;
 	var curState : String;
 	var curState : String;
@@ -53,7 +53,7 @@ class Editor extends h2d.Sprite implements Randomized {
 	public var currentFilePath : String;
 	public var currentFilePath : String;
 	public var autoLoop : Bool = true;
 	public var autoLoop : Bool = true;
 	public var moveEmitter(default,set) : Bool = false;
 	public var moveEmitter(default,set) : Bool = false;
-	
+
 	static var CURVES : Array<{ name : String, f : Curve -> Data.Value }> = [
 	static var CURVES : Array<{ name : String, f : Curve -> Data.Value }> = [
 		{ name : "Const", f : function(c) return VConst(c.min) },
 		{ name : "Const", f : function(c) return VConst(c.min) },
 		{ name : "Linear", f : function(c) return VLinear(c.min, c.max - c.min) },
 		{ name : "Linear", f : function(c) return VLinear(c.min, c.max - c.min) },
@@ -64,12 +64,12 @@ class Editor extends h2d.Sprite implements Randomized {
 		{ name : "Random", f : function(c) return VRandom(c.min, c.max - c.min, c.converge) },
 		{ name : "Random", f : function(c) return VRandom(c.min, c.max - c.min, c.converge) },
 	];
 	];
 
 
-	
+
 	static function solvePoly( c : Curve ) {
 	static function solvePoly( c : Curve ) {
 
 
 		if( c.points == null )
 		if( c.points == null )
 			c.points = [new h2d.col.Point(0, c.min/c.max), new h2d.col.Point(1, 1)];
 			c.points = [new h2d.col.Point(0, c.min/c.max), new h2d.col.Point(1, 1)];
-		
+
 		var xvals = [for( p in c.points ) p.x];
 		var xvals = [for( p in c.points ) p.x];
 		var yvals = [for( p in c.points ) p.y * c.max];
 		var yvals = [for( p in c.points ) p.y * c.max];
 		var pts = [];
 		var pts = [];
@@ -83,14 +83,14 @@ class Editor extends h2d.Sprite implements Randomized {
 			beta.pop();
 			beta.pop();
 		return VPoly(beta,pts);
 		return VPoly(beta,pts);
 	}
 	}
-	
+
 	public function new(emiter, ?parent) {
 	public function new(emiter, ?parent) {
 		super(parent);
 		super(parent);
 		this.emit = emiter;
 		this.emit = emiter;
 		init();
 		init();
 		setState(emit.state);
 		setState(emit.state);
 	}
 	}
-	
+
 	public dynamic function onTextureSelect() {
 	public dynamic function onTextureSelect() {
 		hxd.File.browse(function(sel) {
 		hxd.File.browse(function(sel) {
 			sel.load(function(bytes) {
 			sel.load(function(bytes) {
@@ -102,20 +102,20 @@ class Editor extends h2d.Sprite implements Randomized {
 			fileTypes : [{ name : "Images", extensions : ["png","jpg","jpeg","gif"] }],
 			fileTypes : [{ name : "Images", extensions : ["png","jpg","jpeg","gif"] }],
 		});
 		});
 	}
 	}
-	
+
 	public function changeTexture( name : String, t : h2d.Tile ) {
 	public function changeTexture( name : String, t : h2d.Tile ) {
 		state.textureName = name;
 		state.textureName = name;
 		curState = null; // force reload (if texture was changed)
 		curState = null; // force reload (if texture was changed)
 		setTexture(t);
 		setTexture(t);
 		buildUI();
 		buildUI();
 	}
 	}
-	
+
 	function set_moveEmitter(v) {
 	function set_moveEmitter(v) {
 		this.moveEmitter = v;
 		this.moveEmitter = v;
 		buildUI();
 		buildUI();
 		return v;
 		return v;
 	}
 	}
-	
+
 	public dynamic function loadTexture( textureName : String ) : h2d.Tile {
 	public dynamic function loadTexture( textureName : String ) : h2d.Tile {
 		var bytes = null;
 		var bytes = null;
 		try {
 		try {
@@ -128,7 +128,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		}
 		}
 		return bytes == null ? null : hxd.res.Any.fromBytes(textureName,bytes).toTile();
 		return bytes == null ? null : hxd.res.Any.fromBytes(textureName,bytes).toTile();
 	}
 	}
-	
+
 	public dynamic function onLoad() {
 	public dynamic function onLoad() {
 		hxd.File.browse(function(sel) {
 		hxd.File.browse(function(sel) {
 			currentFilePath = sel.fileName;
 			currentFilePath = sel.fileName;
@@ -151,7 +151,7 @@ class Editor extends h2d.Sprite implements Randomized {
 			fileTypes : [{ name : "Particle Effect", extensions : ["p"] }],
 			fileTypes : [{ name : "Particle Effect", extensions : ["p"] }],
 		});
 		});
 	}
 	}
-	
+
 	public dynamic function onSave( saveData ) {
 	public dynamic function onSave( saveData ) {
 		if( currentFilePath != null )
 		if( currentFilePath != null )
 			try {
 			try {
@@ -166,7 +166,7 @@ class Editor extends h2d.Sprite implements Randomized {
 			saveFileName : function(path) currentFilePath = path,
 			saveFileName : function(path) currentFilePath = path,
 		});
 		});
 	}
 	}
-	
+
 	public function setState(s) {
 	public function setState(s) {
 		undo = [];
 		undo = [];
 		redo = [];
 		redo = [];
@@ -184,7 +184,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		buildUI();
 		buildUI();
 		emit.reset();
 		emit.reset();
 	}
 	}
-	
+
 	override function onAlloc() {
 	override function onAlloc() {
 		super.onAlloc();
 		super.onAlloc();
 		getScene().addEventListener(onEvent);
 		getScene().addEventListener(onEvent);
@@ -194,7 +194,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		super.onDelete();
 		super.onDelete();
 		getScene().addEventListener(onEvent);
 		getScene().addEventListener(onEvent);
 	}
 	}
-	
+
 	var time : Float = 0.;
 	var time : Float = 0.;
 	public dynamic function onMoveEmitter(dt:Float) {
 	public dynamic function onMoveEmitter(dt:Float) {
 		time += dt * 0.03 * 60;
 		time += dt * 0.03 * 60;
@@ -203,7 +203,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		emit.y = Math.sin(time * 0.5) * r;
 		emit.y = Math.sin(time * 0.5) * r;
 		emit.z = (Math.cos(time * 1.3) * Math.sin(time * 1.5) + 1) * r;
 		emit.z = (Math.cos(time * 1.3) * Math.sin(time * 1.5) + 1) * r;
 	}
 	}
-	
+
 	function onEvent( e : hxd.Event ) {
 	function onEvent( e : hxd.Event ) {
 		function loadHistory( h : History ) {
 		function loadHistory( h : History ) {
 			curState = h.state;
 			curState = h.state;
@@ -238,7 +238,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		default:
 		default:
 		}
 		}
 	}
 	}
-	
+
 	function buildUI() {
 	function buildUI() {
 		if( ui != null ) ui.remove();
 		if( ui != null ) ui.remove();
 		ui = h2d.comp.Parser.fromHtml('
 		ui = h2d.comp.Parser.fromHtml('
@@ -247,7 +247,7 @@ class Editor extends h2d.Sprite implements Randomized {
 					* {
 					* {
 						font-size : 12px;
 						font-size : 12px;
 					}
 					}
-					
+
 					h1 {
 					h1 {
 						font-size : 10px;
 						font-size : 10px;
 						color : #BBB;
 						color : #BBB;
@@ -256,7 +256,7 @@ class Editor extends h2d.Sprite implements Randomized {
 					.body {
 					.body {
 						layout : dock;
 						layout : dock;
 					}
 					}
-					
+
 					span {
 					span {
 						padding-top : 2px;
 						padding-top : 2px;
 					}
 					}
@@ -273,7 +273,7 @@ class Editor extends h2d.Sprite implements Randomized {
 						layout : vertical;
 						layout : vertical;
 						margin-bottom : 10px;
 						margin-bottom : 10px;
 					}
 					}
-					
+
 					.sep {
 					.sep {
 						margin-top : -10px;
 						margin-top : -10px;
 						margin-bottom : -2px;
 						margin-bottom : -2px;
@@ -281,11 +281,11 @@ class Editor extends h2d.Sprite implements Randomized {
 						width : 200px;
 						width : 200px;
 						background-color : #555;
 						background-color : #555;
 					}
 					}
-					
+
 					span.label {
 					span.label {
 						width : 97px;
 						width : 97px;
 					}
 					}
-					
+
 					.buttons {
 					.buttons {
 						layout : inline;
 						layout : inline;
 					}
 					}
@@ -293,7 +293,7 @@ class Editor extends h2d.Sprite implements Randomized {
 					.line {
 					.line {
 						layout : horizontal;
 						layout : horizontal;
 					}
 					}
-					
+
 					.ic, .icol {
 					.ic, .icol {
 						icon : url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAB3RJTUUH3QsHEDot9CONhQAAABd0RVh0U29mdHdhcmUAR0xEUE5HIHZlciAzLjRxhaThAAAACHRwTkdHTEQzAAAAAEqAKR8AAAAEZ0FNQQAAsY8L/GEFAAAABmJLR0QA/wD/AP+gvaeTAAAARklEQVR4nGP4z/CfJMRAmQYIIFbDfwwGJvpPHQ249PxHdtJ/LHKkaMBtBAN+80jRgCMY8GrAFjMMBGMKI+Jor4EU1eRoAADB1BsCKErgdwAAAABJRU5ErkJggg=");
 						icon : url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAB3RJTUUH3QsHEDot9CONhQAAABd0RVh0U29mdHdhcmUAR0xEUE5HIHZlciAzLjRxhaThAAAACHRwTkdHTEQzAAAAAEqAKR8AAAAEZ0FNQQAAsY8L/GEFAAAABmJLR0QA/wD/AP+gvaeTAAAARklEQVR4nGP4z/CfJMRAmQYIIFbDfwwGJvpPHQ249PxHdtJ/LHKkaMBtBAN+80jRgCMY8GrAFjMMBGMKI+Jor4EU1eRoAADB1BsCKErgdwAAAABJRU5ErkJggg=");
 						icon-top : 1px;
 						icon-top : 1px;
@@ -301,27 +301,27 @@ class Editor extends h2d.Sprite implements Randomized {
 						icon-color : #888;
 						icon-color : #888;
 						padding-left : 20px;
 						padding-left : 20px;
 					}
 					}
-					
+
 					.ic:hover, .icol:hover {
 					.ic:hover, .icol:hover {
 						icon-top : 0px;
 						icon-top : 0px;
 					}
 					}
-					
+
 					.icol {
 					.icol {
 						icon-color : #AAA;
 						icon-color : #AAA;
 						icon : url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAB3RJTUUH3QsICwAiCSUSqgAAABd0RVh0U29mdHdhcmUAR0xEUE5HIHZlciAzLjRxhaThAAAACHRwTkdHTEQzAAAAAEqAKR8AAAAEZ0FNQQAAsY8L/GEFAAAABmJLR0QA/wD/AP+gvaeTAAAAMklEQVR4nGMwIBEwAPFJWQVMlLHvLSYayRqcdmNBD8tFMNFI1kBa4vMnETD8Z/hPEgIAvqs9dJhBcSIAAAAASUVORK5CYII==");
 						icon : url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAB3RJTUUH3QsICwAiCSUSqgAAABd0RVh0U29mdHdhcmUAR0xEUE5HIHZlciAzLjRxhaThAAAACHRwTkdHTEQzAAAAAEqAKR8AAAAEZ0FNQQAAsY8L/GEFAAAABmJLR0QA/wD/AP+gvaeTAAAAMklEQVR4nGMwIBEwAPFJWQVMlLHvLSYayRqcdmNBD8tFMNFI1kBa4vMnETD8Z/hPEgIAvqs9dJhBcSIAAAAASUVORK5CYII==");
 					}
 					}
-					
+
 					select, button, input {
 					select, button, input {
 						icon-top : 2px;
 						icon-top : 2px;
 						width : 70px;
 						width : 70px;
 						height : 11px;
 						height : 11px;
 						padding-top : 2px;
 						padding-top : 2px;
 					}
 					}
-					
+
 					.box {
 					.box {
 						width : 95px;
 						width : 95px;
 					}
 					}
-					
+
 					input {
 					input {
 						height : 13px;
 						height : 13px;
 						padding-top : 2px;
 						padding-top : 2px;
@@ -332,39 +332,39 @@ class Editor extends h2d.Sprite implements Randomized {
 						width : 310px;
 						width : 310px;
 						layout : dock;
 						layout : dock;
 					}
 					}
-					
+
 					.curve {
 					.curve {
 						dock : bottom;
 						dock : bottom;
 						layout : vertical;
 						layout : vertical;
 						padding : 5px;
 						padding : 5px;
 						height : 165px;
 						height : 165px;
 					}
 					}
-					
+
 					.curve .title {
 					.curve .title {
 						width : 180px;
 						width : 180px;
 						text-align : right;
 						text-align : right;
 						padding: 2px 10px;
 						padding: 2px 10px;
 						background-color : #202020;
 						background-color : #202020;
 					}
 					}
-					
+
 					.tname {
 					.tname {
 						width : 102px;
 						width : 102px;
 					}
 					}
-					
+
 					#curve {
 					#curve {
 						width : 300px;
 						width : 300px;
 						height : 110px;
 						height : 110px;
 						border : 1px solid #333;
 						border : 1px solid #333;
 					}
 					}
-					
+
 					button.file {
 					button.file {
 						width : 15px;
 						width : 15px;
 					}
 					}
-					
+
 					.curve .val {
 					.curve .val {
 						display : none;
 						display : none;
 					}
 					}
-					
+
 					.m_const .v_min, .m_linear .v_min, .m_pow .v_min, .m_random .v_min, .m_cos .v_min, .m_sin .v_min {
 					.m_const .v_min, .m_linear .v_min, .m_pow .v_min, .m_random .v_min, .m_cos .v_min, .m_sin .v_min {
 						display : block;
 						display : block;
 					}
 					}
@@ -372,23 +372,23 @@ class Editor extends h2d.Sprite implements Randomized {
 					.m_linear .v_max, .m_pow .v_max, .m_random .v_max, .m_cos .v_max, .m_sin .v_max, .m_curve .v_max {
 					.m_linear .v_max, .m_pow .v_max, .m_random .v_max, .m_cos .v_max, .m_sin .v_max, .m_curve .v_max {
 						display : block;
 						display : block;
 					}
 					}
-					
+
 					.m_pow .v_pow {
 					.m_pow .v_pow {
 						display : block;
 						display : block;
 					}
 					}
-					
+
 					.m_cos .v_freq, .m_sin .v_freq {
 					.m_cos .v_freq, .m_sin .v_freq {
 						display : block;
 						display : block;
 					}
 					}
-					
+
 					.m_curve .v_prec, .m_curve .v_clear {
 					.m_curve .v_prec, .m_curve .v_clear {
 						display : block;
 						display : block;
 					}
 					}
-					
+
 					.m_random .v_rnd {
 					.m_random .v_rnd {
 						display : block;
 						display : block;
 					}
 					}
-					
+
 					.v_rnd button {
 					.v_rnd button {
 						width : auto;
 						width : auto;
 					}
 					}
@@ -396,10 +396,10 @@ class Editor extends h2d.Sprite implements Randomized {
 					.v_rnd select {
 					.v_rnd select {
 						width : 40px;
 						width : 40px;
 					}
 					}
-					
+
 				</style>
 				</style>
 				<div class="main panel">
 				<div class="main panel">
-				
+
 					<h1>Global</h1>
 					<h1>Global</h1>
 					<div class="sep"></div>
 					<div class="sep"></div>
 					<div class="col">
 					<div class="col">
@@ -429,7 +429,7 @@ class Editor extends h2d.Sprite implements Randomized {
 							<button class="ic" value="Size" onclick="api.editCurve(\'globalSize\')"/>
 							<button class="ic" value="Size" onclick="api.editCurve(\'globalSize\')"/>
 						</div>
 						</div>
 					</div>
 					</div>
-					
+
 					<h1>Emit</h1>
 					<h1>Emit</h1>
 					<div class="sep"></div>
 					<div class="sep"></div>
 					<div class="col">
 					<div class="col">
@@ -473,7 +473,7 @@ class Editor extends h2d.Sprite implements Randomized {
 							<checkbox checked="${this.moveEmitter}" onchange="api.setMove(this.checked)"/> <span>Move Emitter</span>
 							<checkbox checked="${this.moveEmitter}" onchange="api.setMove(this.checked)"/> <span>Move Emitter</span>
 						</div>
 						</div>
 					</div>
 					</div>
-					
+
 					<h1>Particle</h1>
 					<h1>Particle</h1>
 					<div class="sep"></div>
 					<div class="sep"></div>
 					<div class="col">
 					<div class="col">
@@ -490,7 +490,7 @@ class Editor extends h2d.Sprite implements Randomized {
 							<button class="ic" value="Light" onclick="api.editCurve(\'light\')"/>
 							<button class="ic" value="Light" onclick="api.editCurve(\'light\')"/>
 						</div>
 						</div>
 					</div>
 					</div>
-					
+
 					<h1>Animation</h1>
 					<h1>Animation</h1>
 					<div class="sep"></div>
 					<div class="sep"></div>
 					<div class="col">
 					<div class="col">
@@ -502,7 +502,7 @@ class Editor extends h2d.Sprite implements Randomized {
 							<button disabled="${state.frames == null || state.frames.length <= 1}" class="ic" value="Frame" onclick="api.editCurve(\'frame\')"/>
 							<button disabled="${state.frames == null || state.frames.length <= 1}" class="ic" value="Frame" onclick="api.editCurve(\'frame\')"/>
 						</div>
 						</div>
 					</div>
 					</div>
-					
+
 					<h1>Collide</h1>
 					<h1>Collide</h1>
 					<div class="sep"></div>
 					<div class="sep"></div>
 					<div class="col">
 					<div class="col">
@@ -514,7 +514,7 @@ class Editor extends h2d.Sprite implements Randomized {
 							<checkbox checked="${state.collideKill}" onchange="api.s.collideKill = this.checked"/> <span>Kill</span>
 							<checkbox checked="${state.collideKill}" onchange="api.s.collideKill = this.checked"/> <span>Kill</span>
 						</div>
 						</div>
 					</div>
 					</div>
-					
+
 					<h1>Play</h1>
 					<h1>Play</h1>
 					<div class="sep"></div>
 					<div class="sep"></div>
 					<div style="layout:dock;width:200px">
 					<div style="layout:dock;width:200px">
@@ -620,7 +620,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		cedit.onKeyDown = onCurveEvent;
 		cedit.onKeyDown = onCurveEvent;
 		setCurveMode(curve.mode);
 		setCurveMode(curve.mode);
 	}
 	}
-	
+
 	function toggleSplit() {
 	function toggleSplit() {
 		if( state.frames.length == 1 ) {
 		if( state.frames.length == 1 ) {
 			state.frame = VLinear(0,1);
 			state.frame = VLinear(0,1);
@@ -633,13 +633,13 @@ class Editor extends h2d.Sprite implements Randomized {
 		}
 		}
 		buildUI();
 		buildUI();
 	}
 	}
-	
+
 	function clearCurve() {
 	function clearCurve() {
 		curve.points = [new h2d.col.Point(0, curve.min/curve.max), new h2d.col.Point(1, 1)];
 		curve.points = [new h2d.col.Point(0, curve.min/curve.max), new h2d.col.Point(1, 1)];
 		curve.freq = 2;
 		curve.freq = 2;
 		buildUI();
 		buildUI();
 	}
 	}
-	
+
 	function onCurveEvent( e : hxd.Event ) {
 	function onCurveEvent( e : hxd.Event ) {
 		if( !curve.value.match(VPoly(_)) )
 		if( !curve.value.match(VPoly(_)) )
 			return;
 			return;
@@ -688,7 +688,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		default:
 		default:
 		}
 		}
 	}
 	}
-	
+
 	function editColors() {
 	function editColors() {
 		if( grad != null ) {
 		if( grad != null ) {
 			grad.remove();
 			grad.remove();
@@ -710,7 +710,7 @@ class Editor extends h2d.Sprite implements Randomized {
 			if( !found ) state.colors = null;
 			if( !found ) state.colors = null;
 		};
 		};
 	}
 	}
-	
+
 	function editCurve( name : String, isShape : Bool = false ) {
 	function editCurve( name : String, isShape : Bool = false ) {
 		if( curve.name == name && curve.shape == isShape ) {
 		if( curve.name == name && curve.shape == isShape ) {
 			curve.name = null;
 			curve.name = null;
@@ -735,11 +735,11 @@ class Editor extends h2d.Sprite implements Randomized {
 		rebuildCurve();
 		rebuildCurve();
 		buildUI();
 		buildUI();
 	}
 	}
-	
+
 	public function rand() {
 	public function rand() {
 		return randomValue;
 		return randomValue;
 	}
 	}
-	
+
 	function init() {
 	function init() {
 		var bg = new hxd.BitmapData(300, 110);
 		var bg = new hxd.BitmapData(300, 110);
 		bg.clear(0xFF202020);
 		bg.clear(0xFF202020);
@@ -753,12 +753,12 @@ class Editor extends h2d.Sprite implements Randomized {
 		bg.dispose();
 		bg.dispose();
 		curveTexture = h2d.Tile.fromTexture(new h3d.mat.Texture(512, 512)).sub(0, 0, curveBG.width, curveBG.height);
 		curveTexture = h2d.Tile.fromTexture(new h3d.mat.Texture(512, 512)).sub(0, 0, curveBG.width, curveBG.height);
 	}
 	}
-	
+
 	function rebuildCurve() {
 	function rebuildCurve() {
 		var bmp = new hxd.BitmapData(512, 512);
 		var bmp = new hxd.BitmapData(512, 512);
 		var width = curveTexture.width, height = curveTexture.height;
 		var width = curveTexture.width, height = curveTexture.height;
 		var yMax;
 		var yMax;
-		
+
 		switch( curve.value ) {
 		switch( curve.value ) {
 		case VConst(v): yMax = Math.abs(v);
 		case VConst(v): yMax = Math.abs(v);
 		case VRandom(min, len,_), VLinear(min, len), VPow(min,len,_): yMax = Math.max(Math.abs(min), Math.abs(min + len));
 		case VRandom(min, len,_), VLinear(min, len), VPow(min,len,_): yMax = Math.max(Math.abs(min), Math.abs(min + len));
@@ -774,8 +774,8 @@ class Editor extends h2d.Sprite implements Randomized {
 		case VCustom(_):
 		case VCustom(_):
 			throw "assert";
 			throw "assert";
 		}
 		}
-		
-		
+
+
 		var sy = 1.;
 		var sy = 1.;
 		var k = 0;
 		var k = 0;
 		while( yMax > 100 * curve.incr ) {
 		while( yMax > 100 * curve.incr ) {
@@ -786,7 +786,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		}
 		}
 		sy /= (100 * curve.incr);
 		sy /= (100 * curve.incr);
 		curve.scaleY = sy;
 		curve.scaleY = sy;
-		
+
 		inline function posX(x:Float) {
 		inline function posX(x:Float) {
 			return Std.int(x * (width - 1));
 			return Std.int(x * (width - 1));
 		}
 		}
@@ -809,7 +809,7 @@ class Editor extends h2d.Sprite implements Randomized {
 			}
 			}
 			bmp.setPixel(x, iy0, 0xFFFF0000);
 			bmp.setPixel(x, iy0, 0xFFFF0000);
 		}
 		}
-		
+
 		switch( curve.value ) {
 		switch( curve.value ) {
 		case VPoly(_):
 		case VPoly(_):
 			for( p in curve.points ) {
 			for( p in curve.points ) {
@@ -822,11 +822,11 @@ class Editor extends h2d.Sprite implements Randomized {
 			}
 			}
 		default:
 		default:
 		}
 		}
-		
+
 		curveTexture.getTexture().uploadBitmap(bmp);
 		curveTexture.getTexture().uploadBitmap(bmp);
 		bmp.dispose();
 		bmp.dispose();
 	}
 	}
-	
+
 	function initCurve( v : Value ) {
 	function initCurve( v : Value ) {
 		var c : Curve = {
 		var c : Curve = {
 			value : null,
 			value : null,
@@ -878,7 +878,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		}
 		}
 		return c;
 		return c;
 	}
 	}
-	
+
 	function getShapeValue( value : String ) {
 	function getShapeValue( value : String ) {
 		return switch( [state.shape, value] ) {
 		return switch( [state.shape, value] ) {
 		case [(SLine(v) | SSphere(v) | SCone(v, _) | SDisc(v)), "size"]: v;
 		case [(SLine(v) | SSphere(v) | SCone(v, _) | SDisc(v)), "size"]: v;
@@ -886,7 +886,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		default: VConst(0);
 		default: VConst(0);
 		}
 		}
 	}
 	}
-	
+
 	function rebuildShape( mode : Int, getValue ) {
 	function rebuildShape( mode : Int, getValue ) {
 		var size = getValue("size");
 		var size = getValue("size");
 		state.shape = switch( mode ) {
 		state.shape = switch( mode ) {
@@ -897,12 +897,12 @@ class Editor extends h2d.Sprite implements Randomized {
 		default: throw "Unknown shape #" + mode;
 		default: throw "Unknown shape #" + mode;
 		}
 		}
 	}
 	}
-	
+
 	function setCurShape( mode : Int ) {
 	function setCurShape( mode : Int ) {
 		rebuildShape(mode, getShapeValue);
 		rebuildShape(mode, getShapeValue);
 		buildUI();
 		buildUI();
 	}
 	}
-	
+
 	function setCurveMode( mode : Int ) {
 	function setCurveMode( mode : Int ) {
 		var cm = ui.getElementById("curve").getParent();
 		var cm = ui.getElementById("curve").getParent();
 		cm.removeClass("m_" + CURVES[curve.mode].name.toLowerCase());
 		cm.removeClass("m_" + CURVES[curve.mode].name.toLowerCase());
@@ -915,7 +915,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		} else
 		} else
 			updateCurve();
 			updateCurve();
 	}
 	}
-	
+
 	function updateCurve() {
 	function updateCurve() {
 		curve.value = CURVES[curve.mode].f(curve);
 		curve.value = CURVES[curve.mode].f(curve);
 		if( curve.name != null ) {
 		if( curve.name != null ) {
@@ -932,7 +932,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		curTile = t;
 		curTile = t;
 		state.initFrames();
 		state.initFrames();
 	}
 	}
-	
+
 	override function sync( ctx : h2d.RenderContext ) {
 	override function sync( ctx : h2d.RenderContext ) {
 		// if resized, let's reflow our ui
 		// if resized, let's reflow our ui
 		if( ctx.engine.width != width || ctx.engine.height != height ) {
 		if( ctx.engine.width != width || ctx.engine.height != height ) {
@@ -983,15 +983,15 @@ class Editor extends h2d.Sprite implements Randomized {
 			}
 			}
 		} else
 		} else
 			lastPartSeen = null;
 			lastPartSeen = null;
-			
+
 		if( grad != null ) {
 		if( grad != null ) {
 			grad.x = width - 680;
 			grad.x = width - 680;
 			grad.y = height - 190;
 			grad.y = height - 190;
 			grad.colorPicker.x = grad.boxWidth - 180;
 			grad.colorPicker.x = grad.boxWidth - 180;
 			grad.colorPicker.y = -321;
 			grad.colorPicker.y = -321;
 		}
 		}
-			
+
 		super.sync(ctx);
 		super.sync(ctx);
 	}
 	}
-	
+
 }
 }

+ 35 - 35
h3d/parts/Emitter.hx

@@ -13,15 +13,15 @@ class Emitter extends h3d.scene.Object implements Randomized {
 	var rnd : Float;
 	var rnd : Float;
 	var emitCount : Float;
 	var emitCount : Float;
 	var colorMap : ColorKey;
 	var colorMap : ColorKey;
-		
+
 	var head : Particle;
 	var head : Particle;
 	var tail : Particle;
 	var tail : Particle;
 	var pool : Particle;
 	var pool : Particle;
-	
+
 	var tmp : h3d.Vector;
 	var tmp : h3d.Vector;
 	var tmpBuf : hxd.FloatBuffer;
 	var tmpBuf : hxd.FloatBuffer;
 	var curPart : Particle;
 	var curPart : Particle;
-	
+
 	public function new(?state,?parent) {
 	public function new(?state,?parent) {
 		super(parent);
 		super(parent);
 		material = new Material();
 		material = new Material();
@@ -35,7 +35,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 		}
 		}
 		setState(state);
 		setState(state);
 	}
 	}
-	
+
 	/**
 	/**
 		Offset all existing particles by the given values.
 		Offset all existing particles by the given values.
 	**/
 	**/
@@ -48,7 +48,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 			p = p.next;
 			p = p.next;
 		}
 		}
 	}
 	}
-	
+
 	public function reset() {
 	public function reset() {
 		while( head != null )
 		while( head != null )
 			kill(head);
 			kill(head);
@@ -56,7 +56,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 		emitCount = 0;
 		emitCount = 0;
 		rnd = Math.random();
 		rnd = Math.random();
 	}
 	}
-	
+
 	public function setState(s) {
 	public function setState(s) {
 		this.state = s;
 		this.state = s;
 		material.texture = s.frames == null || s.frames.length == 0 ? null : s.frames[0].getTexture();
 		material.texture = s.frames == null || s.frames.length == 0 ? null : s.frames[0].getTexture();
@@ -78,11 +78,11 @@ class Emitter extends h3d.scene.Object implements Randomized {
 			}
 			}
 		}
 		}
 	}
 	}
-	
+
 	inline function eval(v) {
 	inline function eval(v) {
 		return Data.State.eval(v,time, this, curPart);
 		return Data.State.eval(v,time, this, curPart);
 	}
 	}
-	
+
 	public function update(dt:Float) {
 	public function update(dt:Float) {
 		var s = state;
 		var s = state;
 		var old = time;
 		var old = time;
@@ -113,11 +113,11 @@ class Emitter extends h3d.scene.Object implements Randomized {
 		}
 		}
 		curPart = null;
 		curPart = null;
 	}
 	}
-	
+
 	public inline function rand() {
 	public inline function rand() {
 		return Math.random();
 		return Math.random();
 	}
 	}
-	
+
 	function initPosDir( p : Particle ) {
 	function initPosDir( p : Particle ) {
 		switch( state.shape ) {
 		switch( state.shape ) {
 		case SLine(size):
 		case SLine(size):
@@ -171,7 +171,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 			p.dz = Math.cos(phi);
 			p.dz = Math.cos(phi);
 		}
 		}
 	}
 	}
-	
+
 	function initPart(p:Particle) {
 	function initPart(p:Particle) {
 		initPosDir(p);
 		initPosDir(p);
 		if( !state.emitLocal ) {
 		if( !state.emitLocal ) {
@@ -190,12 +190,12 @@ class Emitter extends h3d.scene.Object implements Randomized {
 		p.time = 0;
 		p.time = 0;
 		p.lifeTimeFactor = 1 / eval(state.life);
 		p.lifeTimeFactor = 1 / eval(state.life);
 	}
 	}
-	
+
 	public function emitPart() {
 	public function emitPart() {
 		if( posChanged ) syncPos();
 		if( posChanged ) syncPos();
 		return emitParticle();
 		return emitParticle();
 	}
 	}
-	
+
 	function emitParticle() {
 	function emitParticle() {
 		var p;
 		var p;
 		if( pool == null )
 		if( pool == null )
@@ -229,7 +229,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 		}
 		}
 		return p;
 		return p;
 	}
 	}
-	
+
 	function kill(p:Particle) {
 	function kill(p:Particle) {
 		if( p.prev == null ) head = p.next else p.prev.next = p.next;
 		if( p.prev == null ) head = p.next else p.prev.next = p.next;
 		if( p.next == null ) tail = p.prev else p.next.prev = p.prev;
 		if( p.next == null ) tail = p.prev else p.next.prev = p.prev;
@@ -238,7 +238,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 		pool = p;
 		pool = p;
 		count--;
 		count--;
 	}
 	}
-	
+
 	function updateParticle( p : Particle, dt : Float ) {
 	function updateParticle( p : Particle, dt : Float ) {
 		p.time += dt * p.lifeTimeFactor;
 		p.time += dt * p.lifeTimeFactor;
 		if( p.time > 1 ) {
 		if( p.time > 1 ) {
@@ -246,7 +246,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 			return;
 			return;
 		}
 		}
 		p.randIndex = 0;
 		p.randIndex = 0;
-	
+
 		// apply forces
 		// apply forces
 		if( state.force != null ) {
 		if( state.force != null ) {
 			p.fx += p.eval(state.force.vx, time) * dt;
 			p.fx += p.eval(state.force.vx, time) * dt;
@@ -263,7 +263,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 		p.size = p.eval(state.size, p.time);
 		p.size = p.eval(state.size, p.time);
 		p.ratio = p.eval(state.ratio, p.time);
 		p.ratio = p.eval(state.ratio, p.time);
 		p.rotation = p.eval(state.rotation, p.time);
 		p.rotation = p.eval(state.rotation, p.time);
-		
+
 		// collide
 		// collide
 		if( state.collide && collider != null && collider.collidePart(p, tmp) ) {
 		if( state.collide && collider != null && collider.collidePart(p, tmp) ) {
 			if( state.collideKill ) {
 			if( state.collideKill ) {
@@ -276,8 +276,8 @@ class Emitter extends h3d.scene.Object implements Randomized {
 				p.dz = v.z * state.bounce;
 				p.dz = v.z * state.bounce;
 			}
 			}
 		}
 		}
-			
-		
+
+
 		// calc color
 		// calc color
 		var ck = colorMap;
 		var ck = colorMap;
 		var light = p.eval(state.light, p.time);
 		var light = p.eval(state.light, p.time);
@@ -314,27 +314,27 @@ class Emitter extends h3d.scene.Object implements Randomized {
 			p.cb = light;
 			p.cb = light;
 		}
 		}
 		p.ca = p.eval(state.alpha, p.time);
 		p.ca = p.eval(state.alpha, p.time);
-		
+
 		// frame
 		// frame
 		if( state.frame != null ) {
 		if( state.frame != null ) {
 			var f = p.eval(state.frame, p.time) % 1;
 			var f = p.eval(state.frame, p.time) % 1;
 			if( f < 0 ) f += 1;
 			if( f < 0 ) f += 1;
 			p.frame = Std.int(f * state.frames.length);
 			p.frame = Std.int(f * state.frames.length);
 		}
 		}
-		
+
 		if( state.update != null )
 		if( state.update != null )
 			state.update(p);
 			state.update(p);
 	}
 	}
-	
+
 	override function sync( ctx : h3d.scene.RenderContext ) {
 	override function sync( ctx : h3d.scene.RenderContext ) {
 		super.sync(ctx);
 		super.sync(ctx);
 		update(ctx.elapsedTime * speed);
 		update(ctx.elapsedTime * speed);
 	}
 	}
-	
+
 	public function isActive() {
 	public function isActive() {
 		return count != 0 || time < 1 || state.loop;
 		return count != 0 || time < 1 || state.loop;
 	}
 	}
-	
+
 	function sort( list : Particle ) {
 	function sort( list : Particle ) {
 		return haxe.ds.ListSort.sort(list, function(p1, p2) return p1.w < p2.w ? 1 : -1);
 		return haxe.ds.ListSort.sort(list, function(p1, p2) return p1.w < p2.w ? 1 : -1);
 	}
 	}
@@ -342,7 +342,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 	function sortInv( list : Particle ) {
 	function sortInv( list : Particle ) {
 		return haxe.ds.ListSort.sort(list, function(p1, p2) return p1.w < p2.w ? -1 : 1);
 		return haxe.ds.ListSort.sort(list, function(p1, p2) return p1.w < p2.w ? -1 : 1);
 	}
 	}
-	
+
 	@:access(h3d.parts.Material) @:access(h2d.Tile)
 	@:access(h3d.parts.Material) @:access(h2d.Tile)
 	override function draw( ctx : h3d.scene.RenderContext ) {
 	override function draw( ctx : h3d.scene.RenderContext ) {
 		if( head == null )
 		if( head == null )
@@ -382,7 +382,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 				var f = frames[p.frame];
 				var f = frames[p.frame];
 				if( f == null ) f = frames[0];
 				if( f == null ) f = frames[0];
 				var ratio = p.size * p.ratio * (f.height / f.width);
 				var ratio = p.size * p.ratio * (f.height / f.width);
-				
+
 				tmp[pos++] = prevX1;
 				tmp[pos++] = prevX1;
 				tmp[pos++] = prevY1;
 				tmp[pos++] = prevY1;
 				tmp[pos++] = prevZ1;
 				tmp[pos++] = prevZ1;
@@ -402,7 +402,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 					tmp[pos++] = p.cb;
 					tmp[pos++] = p.cb;
 					tmp[pos++] = p.ca;
 					tmp[pos++] = p.ca;
 				}
 				}
-				
+
 				tmp[pos++] = prevX2;
 				tmp[pos++] = prevX2;
 				tmp[pos++] = prevY2;
 				tmp[pos++] = prevY2;
 				tmp[pos++] = prevZ2;
 				tmp[pos++] = prevZ2;
@@ -431,11 +431,11 @@ class Emitter extends h3d.scene.Object implements Randomized {
 				dy *= d;
 				dy *= d;
 				dz *= d;
 				dz *= d;
 				var dir = new h3d.Vector(Math.sin(p.rotation), 0, Math.cos(p.rotation)).cross(new h3d.Vector(dx, dy, dz));
 				var dir = new h3d.Vector(Math.sin(p.rotation), 0, Math.cos(p.rotation)).cross(new h3d.Vector(dx, dy, dz));
-				
+
 				prevX1 = p.x + dir.x * p.size;
 				prevX1 = p.x + dir.x * p.size;
 				prevY1 = p.y + dir.y * p.size;
 				prevY1 = p.y + dir.y * p.size;
 				prevZ1 = p.z + dir.z * p.size;
 				prevZ1 = p.z + dir.z * p.size;
-				
+
 				prevX2 = p.x - dir.x * p.size;
 				prevX2 = p.x - dir.x * p.size;
 				prevY2 = p.y - dir.y * p.size;
 				prevY2 = p.y - dir.y * p.size;
 				prevZ2 = p.z - dir.z * p.size;
 				prevZ2 = p.z - dir.z * p.size;
@@ -473,7 +473,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 					tmp[pos++] = p.cb;
 					tmp[pos++] = p.cb;
 					tmp[pos++] = p.ca;
 					tmp[pos++] = p.ca;
 				}
 				}
-				
+
 				prev = p;
 				prev = p;
 				p = p.next;
 				p = p.next;
 			}
 			}
@@ -501,7 +501,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 					tmp[pos++] = p.cb;
 					tmp[pos++] = p.cb;
 					tmp[pos++] = p.ca;
 					tmp[pos++] = p.ca;
 				}
 				}
-				
+
 				tmp[pos++] = p.x;
 				tmp[pos++] = p.x;
 				tmp[pos++] = p.y;
 				tmp[pos++] = p.y;
 				tmp[pos++] = p.z;
 				tmp[pos++] = p.z;
@@ -552,7 +552,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 					tmp[pos++] = p.cb;
 					tmp[pos++] = p.cb;
 					tmp[pos++] = p.ca;
 					tmp[pos++] = p.ca;
 				}
 				}
-				
+
 				p = p.next;
 				p = p.next;
 			}
 			}
 		}
 		}
@@ -560,7 +560,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 		if( hasColor ) stride += 4;
 		if( hasColor ) stride += 4;
 		var buffer = h3d.Buffer.ofFloats(tmp, stride, [Quads, Dynamic], Std.int(pos/stride));
 		var buffer = h3d.Buffer.ofFloats(tmp, stride, [Quads, Dynamic], Std.int(pos/stride));
 		var size = eval(state.globalSize);
 		var size = eval(state.globalSize);
-		
+
 		/*
 		/*
 		material.pshader.mpos = state.emitLocal ? this.absPos : h3d.Matrix.I();
 		material.pshader.mpos = state.emitLocal ? this.absPos : h3d.Matrix.I();
 		material.pshader.mproj = ctx.camera.m;
 		material.pshader.mproj = ctx.camera.m;
@@ -573,12 +573,12 @@ class Emitter extends h3d.scene.Object implements Randomized {
 		}
 		}
 		material.pshader.hasColor = hasColor;
 		material.pshader.hasColor = hasColor;
 		material.pshader.isAlphaMap = state.isAlphaMap;
 		material.pshader.isAlphaMap = state.isAlphaMap;
-		
+
 		ctx.engine.selectMaterial(material);
 		ctx.engine.selectMaterial(material);
 		ctx.engine.renderQuadBuffer(buffer);
 		ctx.engine.renderQuadBuffer(buffer);
 		buffer.dispose();
 		buffer.dispose();
 		*/
 		*/
 		throw "TODO";
 		throw "TODO";
 	}
 	}
-	
+
 }
 }

+ 7 - 7
h3d/parts/Material.hx

@@ -13,14 +13,14 @@ private class PartShader extends h3d.impl.Shader {
 			uv : Float2,
 			uv : Float2,
 			color : Float4,
 			color : Float4,
 		};
 		};
-		
+
 		var tuv : Float2;
 		var tuv : Float2;
 		var tcolor : Float4;
 		var tcolor : Float4;
 		var partSize : Float2;
 		var partSize : Float2;
-		
+
 		var hasColor : Bool;
 		var hasColor : Bool;
 		var is3D : Bool;
 		var is3D : Bool;
-		
+
 		var isAlphaMap : Bool;
 		var isAlphaMap : Bool;
 
 
 		function vertex( mpos : M34, mproj : Matrix ) {
 		function vertex( mpos : M34, mproj : Matrix ) {
@@ -45,7 +45,7 @@ private class PartShader extends h3d.impl.Shader {
 			tuv = input.uv;
 			tuv = input.uv;
 			if( hasColor ) tcolor = input.color;
 			if( hasColor ) tcolor = input.color;
 		}
 		}
-		
+
 		function fragment( tex : Texture ) {
 		function fragment( tex : Texture ) {
 			var c = tex.get(tuv.xy);
 			var c = tex.get(tuv.xy);
 			if( hasColor ) c *= tcolor;
 			if( hasColor ) c *= tcolor;
@@ -55,7 +55,7 @@ private class PartShader extends h3d.impl.Shader {
 			}
 			}
 			out = c;
 			out = c;
 		}
 		}
-	
+
 	}
 	}
 #else
 #else
 	static var VERTEX = "";
 	static var VERTEX = "";
@@ -66,12 +66,12 @@ private class PartShader extends h3d.impl.Shader {
 */
 */
 
 
 class Material extends h3d.mat.MeshMaterial {
 class Material extends h3d.mat.MeshMaterial {
-	
+
 	public function new(?texture) {
 	public function new(?texture) {
 		super(texture);
 		super(texture);
 		blendMode = Alpha;
 		blendMode = Alpha;
 		mainPass.culling = None;
 		mainPass.culling = None;
 		mainPass.depthWrite = false;
 		mainPass.depthWrite = false;
 	}
 	}
-	
+
 }
 }

+ 9 - 9
h3d/parts/Particle.hx

@@ -1,12 +1,12 @@
 package h3d.parts;
 package h3d.parts;
 
 
 class Particle implements Data.Randomized {
 class Particle implements Data.Randomized {
-	
+
 	public var x : Float;
 	public var x : Float;
 	public var y : Float;
 	public var y : Float;
 	public var z : Float;
 	public var z : Float;
 	public var w : Float;
 	public var w : Float;
-	
+
 	public var time : Float;
 	public var time : Float;
 	public var lifeTimeFactor : Float;
 	public var lifeTimeFactor : Float;
 
 
@@ -22,16 +22,16 @@ class Particle implements Data.Randomized {
 	public var cg : Float;
 	public var cg : Float;
 	public var cb : Float;
 	public var cb : Float;
 	public var ca : Float;
 	public var ca : Float;
-	
+
 	public var frame : Int;
 	public var frame : Int;
-	
+
 	public var size : Float;
 	public var size : Float;
 	public var ratio : Float;
 	public var ratio : Float;
 	public var rotation : Float;
 	public var rotation : Float;
-	
+
 	public var prev : Particle;
 	public var prev : Particle;
 	public var next : Particle;
 	public var next : Particle;
-	
+
 	public var randIndex = 0;
 	public var randIndex = 0;
 	public var randValues : Array<Float>;
 	public var randValues : Array<Float>;
 
 
@@ -42,15 +42,15 @@ class Particle implements Data.Randomized {
 		ca = 1;
 		ca = 1;
 		frame = 0;
 		frame = 0;
 	}
 	}
-	
+
 	public inline function eval( v : Data.Value, time : Float ) {
 	public inline function eval( v : Data.Value, time : Float ) {
 		return Data.State.eval(v, time, this, this);
 		return Data.State.eval(v, time, this, this);
 	}
 	}
-	
+
 	public function rand() {
 	public function rand() {
 		if( randValues == null ) randValues = [];
 		if( randValues == null ) randValues = [];
 		if( randValues.length <= randIndex ) randValues.push(Math.random());
 		if( randValues.length <= randIndex ) randValues.push(Math.random());
 		return randValues[randIndex++];
 		return randValues[randIndex++];
 	}
 	}
-	
+
 }
 }

+ 9 - 9
h3d/pass/Base.hx

@@ -9,7 +9,7 @@ class Base {
 	var globals(get, never) : hxsl.Globals;
 	var globals(get, never) : hxsl.Globals;
 	var priority : Int = 0;
 	var priority : Int = 0;
 	public var lightSystem : LightSystem;
 	public var lightSystem : LightSystem;
-	
+
 	inline function get_globals() return manager.globals;
 	inline function get_globals() return manager.globals;
 
 
 	@global("camera.view") var cameraView : h3d.Matrix = ctx.camera.mcam;
 	@global("camera.view") var cameraView : h3d.Matrix = ctx.camera.mcam;
@@ -25,30 +25,30 @@ class Base {
 		var t = ctx.engine.getTarget();
 		var t = ctx.engine.getTarget();
 		t != null && !t.flags.has(TargetNoFlipY) ? -1 : 1;
 		t != null && !t.flags.has(TargetNoFlipY) ? -1 : 1;
 	}
 	}
-	
+
 	public function new() {
 	public function new() {
 		manager = new h3d.shader.Manager(getOutputs());
 		manager = new h3d.shader.Manager(getOutputs());
 		initGlobals();
 		initGlobals();
 		lightSystem = new LightSystem(globals);
 		lightSystem = new LightSystem(globals);
 	}
 	}
-	
+
 	function getOutputs() {
 	function getOutputs() {
 		return ["output.position", "output.color"];
 		return ["output.position", "output.color"];
 	}
 	}
-	
+
 	public function compileShader( p : h3d.mat.Pass ) {
 	public function compileShader( p : h3d.mat.Pass ) {
 		var out = [for( s in p.getShadersRec() ) s];
 		var out = [for( s in p.getShadersRec() ) s];
 		out.reverse();
 		out.reverse();
 		return manager.compileShaders(out);
 		return manager.compileShaders(out);
 	}
 	}
-	
+
 	function allocBuffer( s : hxsl.RuntimeShader, shaders : Array<hxsl.Shader> ) {
 	function allocBuffer( s : hxsl.RuntimeShader, shaders : Array<hxsl.Shader> ) {
 		var buf = new h3d.shader.Buffers(s);
 		var buf = new h3d.shader.Buffers(s);
 		manager.fillGlobals(buf, s);
 		manager.fillGlobals(buf, s);
 		manager.fillParams(buf, s, shaders);
 		manager.fillParams(buf, s, shaders);
 		return buf;
 		return buf;
 	}
 	}
-	
+
 	@:access(h3d.scene)
 	@:access(h3d.scene)
 	function setupShaders( passes : Object ) {
 	function setupShaders( passes : Object ) {
 		var p = passes;
 		var p = passes;
@@ -82,14 +82,14 @@ class Base {
 			p = p.next;
 			p = p.next;
 		}
 		}
 	}
 	}
-	
+
 	static inline function sortByShader( o1 : Object, o2 : Object ) {
 	static inline function sortByShader( o1 : Object, o2 : Object ) {
 		var d = o1.shader.id - o2.shader.id;
 		var d = o1.shader.id - o2.shader.id;
 		if( d != 0 ) return d;
 		if( d != 0 ) return d;
 		// TODO : sort by textures
 		// TODO : sort by textures
 		return 0;
 		return 0;
 	}
 	}
-	
+
 	@:access(h3d.scene)
 	@:access(h3d.scene)
 	public function draw( ctx : h3d.scene.RenderContext, passes : Object ) {
 	public function draw( ctx : h3d.scene.RenderContext, passes : Object ) {
 		this.ctx = ctx;
 		this.ctx = ctx;
@@ -118,5 +118,5 @@ class Base {
 		this.ctx = null;
 		this.ctx = null;
 		return passes;
 		return passes;
 	}
 	}
-	
+
 }
 }

+ 12 - 12
h3d/pass/Blur.hx

@@ -1,17 +1,17 @@
 package h3d.pass;
 package h3d.pass;
 
 
 class Blur {
 class Blur {
-	
+
 	/**
 	/**
 		Gives the blur quality : 0 for disable, 1 for 3x3, 2 for 5x5, etc.
 		Gives the blur quality : 0 for disable, 1 for 3x3, 2 for 5x5, etc.
 	**/
 	**/
 	public var quality(default, set) : Int;
 	public var quality(default, set) : Int;
-	
+
 	/**
 	/**
 		The amount of blur (gaussian blur value).
 		The amount of blur (gaussian blur value).
 	**/
 	**/
 	public var sigma(default, set) : Float;
 	public var sigma(default, set) : Float;
-		
+
 	var values : Array<Float>;
 	var values : Array<Float>;
 	var shader : h3d.shader.BlurShader;
 	var shader : h3d.shader.BlurShader;
 	var pass : h3d.mat.Pass;
 	var pass : h3d.mat.Pass;
@@ -28,7 +28,7 @@ class Blur {
 		pass.depth(false, Always);
 		pass.depth(false, Always);
 		plan = new h3d.prim.Plan2D();
 		plan = new h3d.prim.Plan2D();
 	}
 	}
-	
+
 	function set_quality(q) {
 	function set_quality(q) {
 		values = null;
 		values = null;
 		return quality = q;
 		return quality = q;
@@ -38,7 +38,7 @@ class Blur {
 		values = null;
 		values = null;
 		return sigma = s;
 		return sigma = s;
 	}
 	}
-	
+
 	function gauss( x:Int, s:Float ) : Float {
 	function gauss( x:Int, s:Float ) : Float {
 		if( s <= 0 ) return x == 0 ? 1 : 0;
 		if( s <= 0 ) return x == 0 ? 1 : 0;
 		var sq = s * s;
 		var sq = s * s;
@@ -47,13 +47,13 @@ class Blur {
 	}
 	}
 
 
 	public function apply( src : h3d.mat.Texture, ?tmp : h3d.mat.Texture, isDepth = false ) {
 	public function apply( src : h3d.mat.Texture, ?tmp : h3d.mat.Texture, isDepth = false ) {
-		
+
 		if( quality == 0 ) return;
 		if( quality == 0 ) return;
-		
+
 		var alloc = tmp == null;
 		var alloc = tmp == null;
 		if( alloc )
 		if( alloc )
 			tmp = new h3d.mat.Texture(src.width, src.height, [Target, TargetNoFlipY]);
 			tmp = new h3d.mat.Texture(src.width, src.height, [Target, TargetNoFlipY]);
-			
+
 		if( values == null ) {
 		if( values == null ) {
 			values = [];
 			values = [];
 			var tot = 0.;
 			var tot = 0.;
@@ -66,18 +66,18 @@ class Blur {
 			for( i in 0...quality + 1 )
 			for( i in 0...quality + 1 )
 				values[i] /= tot;
 				values[i] /= tot;
 		}
 		}
-			
+
 		var engine = h3d.Engine.getCurrent();
 		var engine = h3d.Engine.getCurrent();
-		
+
 		shader.Quality = quality + 1;
 		shader.Quality = quality + 1;
 		shader.texture = src;
 		shader.texture = src;
 		shader.values = values;
 		shader.values = values;
 		shader.isDepth = isDepth;
 		shader.isDepth = isDepth;
 		shader.pixel.set(1 / src.width, 0);
 		shader.pixel.set(1 / src.width, 0);
-		
+
 		var shaders : Array<hxsl.Shader> = [shader];
 		var shaders : Array<hxsl.Shader> = [shader];
 		var rts = manager.compileShaders(shaders);
 		var rts = manager.compileShaders(shaders);
-		
+
 
 
 		engine.setTarget(tmp,0xFFFF0000);
 		engine.setTarget(tmp,0xFFFF0000);
 		engine.selectMaterial(pass);
 		engine.selectMaterial(pass);

+ 3 - 3
h3d/pass/Distance.hx

@@ -1,7 +1,7 @@
 package h3d.pass;
 package h3d.pass;
 
 
 class Distance extends Base {
 class Distance extends Base {
-	
+
 	var texture : h3d.mat.Texture;
 	var texture : h3d.mat.Texture;
 
 
 	public function new() {
 	public function new() {
@@ -13,7 +13,7 @@ class Distance extends Base {
 	override function getOutputs() {
 	override function getOutputs() {
 		return ["output.position", "output.distance"];
 		return ["output.position", "output.distance"];
 	}
 	}
-	
+
 	override function draw(ctx : h3d.scene.RenderContext, passes) {
 	override function draw(ctx : h3d.scene.RenderContext, passes) {
 		if( texture == null || texture.width != ctx.engine.width || texture.height != ctx.engine.height ) {
 		if( texture == null || texture.width != ctx.engine.width || texture.height != ctx.engine.height ) {
 			if( texture != null ) texture.dispose();
 			if( texture != null ) texture.dispose();
@@ -24,5 +24,5 @@ class Distance extends Base {
 		ctx.engine.setTarget(null);
 		ctx.engine.setTarget(null);
 		return passes;
 		return passes;
 	}
 	}
-	
+
 }
 }

+ 4 - 4
h3d/pass/LightSystem.hx

@@ -20,7 +20,7 @@ class LightSystem {
 		ambientLight = new h3d.Vector(1, 1, 1);
 		ambientLight = new h3d.Vector(1, 1, 1);
 		ambientShader = new h3d.shader.AmbientLight();
 		ambientShader = new h3d.shader.AmbientLight();
 	}
 	}
-	
+
 	public function initLights( lights : h3d.scene.Light ) {
 	public function initLights( lights : h3d.scene.Light ) {
 		this.lights = lights;
 		this.lights = lights;
 		lightCount = 0;
 		lightCount = 0;
@@ -34,13 +34,13 @@ class LightSystem {
 			lights = haxe.ds.ListSort.sortSingleLinked(lights, sortLight);
 			lights = haxe.ds.ListSort.sortSingleLinked(lights, sortLight);
 		setGlobals();
 		setGlobals();
 	}
 	}
-	
+
 	function sortLight( l1 : h3d.scene.Light, l2 : h3d.scene.Light ) {
 	function sortLight( l1 : h3d.scene.Light, l2 : h3d.scene.Light ) {
 		var p = l1.priority - l2.priority;
 		var p = l1.priority - l2.priority;
 		if( p != 0 ) return -p;
 		if( p != 0 ) return -p;
 		return l1.objectDistance < l2.objectDistance ? -1 : 1;
 		return l1.objectDistance < l2.objectDistance ? -1 : 1;
 	}
 	}
-	
+
 	@:access(h3d.scene.Object.absPos)
 	@:access(h3d.scene.Object.absPos)
 	public function computeLight( obj : h3d.scene.Object, shaders : hxsl.ShaderList ) : hxsl.ShaderList {
 	public function computeLight( obj : h3d.scene.Object, shaders : hxsl.ShaderList ) : hxsl.ShaderList {
 		if( lightCount > maxLightsPerObject ) {
 		if( lightCount > maxLightsPerObject ) {
@@ -72,5 +72,5 @@ class LightSystem {
 		}
 		}
 		return shaders;
 		return shaders;
 	}
 	}
-	
+
 }
 }

+ 1 - 1
h3d/pass/Params.hx

@@ -3,5 +3,5 @@ package h3d.pass;
 class Params {
 class Params {
 
 
 	public static var shadowShader : hxsl.Shader = new h3d.shader.Shadow();
 	public static var shadowShader : hxsl.Shader = new h3d.shader.Shadow();
-	
+
 }
 }

+ 7 - 7
h3d/pass/ShadowMap.hx

@@ -33,7 +33,7 @@ class ShadowMap extends Base {
 		color = new h3d.Vector();
 		color = new h3d.Vector();
 		blur = new Blur(2, 3);
 		blur = new Blur(2, 3);
 	}
 	}
-	
+
 	public dynamic function getSceneBounds( bounds : h3d.col.Bounds ) {
 	public dynamic function getSceneBounds( bounds : h3d.col.Bounds ) {
 		bounds.xMin = -10;
 		bounds.xMin = -10;
 		bounds.yMin = -10;
 		bounds.yMin = -10;
@@ -42,11 +42,11 @@ class ShadowMap extends Base {
 		bounds.yMax = 10;
 		bounds.yMax = 10;
 		bounds.zMax = 10;
 		bounds.zMax = 10;
 	}
 	}
-	
+
 	override function getOutputs() {
 	override function getOutputs() {
 		return ["output.position", "output.distance"];
 		return ["output.position", "output.distance"];
 	}
 	}
-	
+
 	override function setGlobals() {
 	override function setGlobals() {
 		super.setGlobals();
 		super.setGlobals();
 		lightCamera.orthoBounds.empty();
 		lightCamera.orthoBounds.empty();
@@ -54,7 +54,7 @@ class ShadowMap extends Base {
 		lightCamera.update();
 		lightCamera.update();
 		cameraViewProj = lightCamera.m;
 		cameraViewProj = lightCamera.m;
 	}
 	}
-	
+
 	override function draw( ctx : h3d.scene.RenderContext, passes) {
 	override function draw( ctx : h3d.scene.RenderContext, passes) {
 		if( texture == null || texture.width != size ) {
 		if( texture == null || texture.width != size ) {
 			if( texture != null ) {
 			if( texture != null ) {
@@ -72,9 +72,9 @@ class ShadowMap extends Base {
 		ctx.engine.setTarget(texture, 0xFFFFFFFF);
 		ctx.engine.setTarget(texture, 0xFFFFFFFF);
 		passes = super.draw(ctx, passes);
 		passes = super.draw(ctx, passes);
 		ctx.engine.setTarget(null);
 		ctx.engine.setTarget(null);
-		
+
 		blur.apply(texture, blurTexture, true);
 		blur.apply(texture, blurTexture, true);
-		
+
 		ctx.sharedGlobals.set(shadowMapId, texture);
 		ctx.sharedGlobals.set(shadowMapId, texture);
 		ctx.sharedGlobals.set(shadowProjId, lightCamera.m);
 		ctx.sharedGlobals.set(shadowProjId, lightCamera.m);
 		ctx.sharedGlobals.set(shadowColorId, color);
 		ctx.sharedGlobals.set(shadowColorId, color);
@@ -83,5 +83,5 @@ class ShadowMap extends Base {
 		return passes;
 		return passes;
 	}
 	}
 
 
-	
+
 }
 }

+ 4 - 4
h3d/prim/Cube.hx

@@ -30,15 +30,15 @@ class Cube extends Polygon {
 		idx.push(0); idx.push(2); idx.push(4);
 		idx.push(0); idx.push(2); idx.push(4);
 		super(p, idx);
 		super(p, idx);
 	}
 	}
-	
+
 	override function addUVs() {
 	override function addUVs() {
 		unindex();
 		unindex();
-		
+
 		var z = new UV(0, 0);
 		var z = new UV(0, 0);
 		var x = new UV(1, 0);
 		var x = new UV(1, 0);
 		var y = new UV(0, 1);
 		var y = new UV(0, 1);
 		var o = new UV(1, 1);
 		var o = new UV(1, 1);
-		
+
 		uvs = [
 		uvs = [
 			z, x, o,
 			z, x, o,
 			z, o, y,
 			z, o, y,
@@ -54,5 +54,5 @@ class Cube extends Polygon {
 			z, y, o,
 			z, y, o,
 		];
 		];
 	}
 	}
-	
+
 }
 }

+ 7 - 7
h3d/prim/Cylinder.hx

@@ -2,9 +2,9 @@ package h3d.prim;
 import h3d.col.Point;
 import h3d.col.Point;
 
 
 class Cylinder extends Quads {
 class Cylinder extends Quads {
-	
+
 	var segs : Int;
 	var segs : Int;
-	
+
 	public function new( segs : Int, ray = 1.0, height = 1.0 ) {
 	public function new( segs : Int, ray = 1.0, height = 1.0 ) {
 		var pts = new Array();
 		var pts = new Array();
 		var ds = Math.PI * 2 / segs;
 		var ds = Math.PI * 2 / segs;
@@ -21,7 +21,7 @@ class Cylinder extends Quads {
 		}
 		}
 		super(pts);
 		super(pts);
 	}
 	}
-	
+
 	override public function addTCoords() {
 	override public function addTCoords() {
 		uvs = new Array();
 		uvs = new Array();
 		for( s in 0...segs ) {
 		for( s in 0...segs ) {
@@ -33,16 +33,16 @@ class Cylinder extends Quads {
 			uvs.push(new UV(u2, 0));
 			uvs.push(new UV(u2, 0));
 		}
 		}
 	}
 	}
-	
+
 	override public function addNormals() {
 	override public function addNormals() {
 		normals = new Array();
 		normals = new Array();
 		var ds = Math.PI * 2 / segs;
 		var ds = Math.PI * 2 / segs;
 		for( s in 0...segs ) {
 		for( s in 0...segs ) {
 			//var ac = (s + 0.5) * ds;
 			//var ac = (s + 0.5) * ds;
-			
+
 			var ac0 = (s - 0.5) * ds;
 			var ac0 = (s - 0.5) * ds;
 			var ac1 = (s+ 0.5) * ds;
 			var ac1 = (s+ 0.5) * ds;
-			
+
 			//var n = new Point(Math.cos(ac), Math.sin(ac), 0);
 			//var n = new Point(Math.cos(ac), Math.sin(ac), 0);
 			var n0 = new Point(Math.cos(ac0), Math.sin(ac0), 0);
 			var n0 = new Point(Math.cos(ac0), Math.sin(ac0), 0);
 			var n1 = new Point(Math.cos(ac1), Math.sin(ac1), 0);
 			var n1 = new Point(Math.cos(ac1), Math.sin(ac1), 0);
@@ -52,7 +52,7 @@ class Cylinder extends Quads {
 			normals.push(n);
 			normals.push(n);
 			normals.push(n);
 			normals.push(n);
 			*/
 			*/
-			
+
 			normals.push(n0);
 			normals.push(n0);
 			normals.push(n1);
 			normals.push(n1);
 			normals.push(n0);
 			normals.push(n0);

+ 17 - 17
h3d/prim/FBXModel.hx

@@ -16,11 +16,11 @@ class FBXModel extends MeshPrimitive {
 		this.geom = g;
 		this.geom = g;
 		curMaterial = -1;
 		curMaterial = -1;
 	}
 	}
-	
+
 	public function getVerticesCount() {
 	public function getVerticesCount() {
 		return Std.int(geom.getVertices().length / 3);
 		return Std.int(geom.getVertices().length / 3);
 	}
 	}
-	
+
 	override function getBounds() {
 	override function getBounds() {
 		if( bounds != null )
 		if( bounds != null )
 			return bounds;
 			return bounds;
@@ -47,7 +47,7 @@ class FBXModel extends MeshPrimitive {
 		}
 		}
 		return bounds;
 		return bounds;
 	}
 	}
-	
+
 	override function render( engine : h3d.Engine ) {
 	override function render( engine : h3d.Engine ) {
 		if( curMaterial < 0 ) {
 		if( curMaterial < 0 ) {
 			super.render(engine);
 			super.render(engine);
@@ -61,11 +61,11 @@ class FBXModel extends MeshPrimitive {
 		indexes = idx;
 		indexes = idx;
 		curMaterial = -1;
 		curMaterial = -1;
 	}
 	}
-	
+
 	override function selectMaterial( material : Int ) {
 	override function selectMaterial( material : Int ) {
 		curMaterial = material;
 		curMaterial = material;
 	}
 	}
-	
+
 	override function dispose() {
 	override function dispose() {
 		super.dispose();
 		super.dispose();
 		if( groupIndexes != null ) {
 		if( groupIndexes != null ) {
@@ -75,31 +75,31 @@ class FBXModel extends MeshPrimitive {
 			groupIndexes = null;
 			groupIndexes = null;
 		}
 		}
 	}
 	}
-	
+
 	override function alloc( engine : h3d.Engine ) {
 	override function alloc( engine : h3d.Engine ) {
 		dispose();
 		dispose();
-		
+
 		var verts = geom.getVertices();
 		var verts = geom.getVertices();
 		var norms = geom.getNormals();
 		var norms = geom.getNormals();
 		var tuvs = geom.getUVs()[0];
 		var tuvs = geom.getUVs()[0];
 		var colors = geom.getColors();
 		var colors = geom.getColors();
 		var mats = multiMaterial ? geom.getMaterials() : null;
 		var mats = multiMaterial ? geom.getMaterials() : null;
-		
+
 		var gt = geom.getGeomTranslate();
 		var gt = geom.getGeomTranslate();
 		if( gt == null ) gt = new Point();
 		if( gt == null ) gt = new Point();
-		
+
 		var idx = new hxd.IndexBuffer();
 		var idx = new hxd.IndexBuffer();
 		var midx = new Array<hxd.IndexBuffer>();
 		var midx = new Array<hxd.IndexBuffer>();
 		var pbuf = new hxd.FloatBuffer(), nbuf = (norms == null ? null : new hxd.FloatBuffer()), sbuf = (skin == null ? null : new hxd.BytesBuffer()), tbuf = (tuvs == null ? null : new hxd.FloatBuffer());
 		var pbuf = new hxd.FloatBuffer(), nbuf = (norms == null ? null : new hxd.FloatBuffer()), sbuf = (skin == null ? null : new hxd.BytesBuffer()), tbuf = (tuvs == null ? null : new hxd.FloatBuffer());
 		var cbuf = (colors == null ? null : new hxd.FloatBuffer());
 		var cbuf = (colors == null ? null : new hxd.FloatBuffer());
-		
+
 		// skin split
 		// skin split
 		var sidx = null, stri = 0;
 		var sidx = null, stri = 0;
 		if( skin != null && skin.isSplit() ) {
 		if( skin != null && skin.isSplit() ) {
 			if( multiMaterial ) throw "Multimaterial not supported with skin split";
 			if( multiMaterial ) throw "Multimaterial not supported with skin split";
 			sidx = [for( _ in skin.splitJoints ) new hxd.IndexBuffer()];
 			sidx = [for( _ in skin.splitJoints ) new hxd.IndexBuffer()];
 		}
 		}
-		
+
 		// triangulize indexes : format is  A,B,...,-X : negative values mark the end of the polygon
 		// triangulize indexes : format is  A,B,...,-X : negative values mark the end of the polygon
 		var count = 0, pos = 0, matPos = 0;
 		var count = 0, pos = 0, matPos = 0;
 		var index = geom.getPolygons();
 		var index = geom.getPolygons();
@@ -111,7 +111,7 @@ class FBXModel extends MeshPrimitive {
 				for( n in 0...count ) {
 				for( n in 0...count ) {
 					var k = n + start;
 					var k = n + start;
 					var vidx = index[k];
 					var vidx = index[k];
-					
+
 					var x = verts[vidx * 3] + gt.x;
 					var x = verts[vidx * 3] + gt.x;
 					var y = verts[vidx * 3 + 1] + gt.y;
 					var y = verts[vidx * 3 + 1] + gt.y;
 					var z = verts[vidx * 3 + 2] + gt.z;
 					var z = verts[vidx * 3 + 2] + gt.z;
@@ -130,7 +130,7 @@ class FBXModel extends MeshPrimitive {
 						tbuf.push(tuvs.values[iuv*2]);
 						tbuf.push(tuvs.values[iuv*2]);
 						tbuf.push(1 - tuvs.values[iuv * 2 + 1]);
 						tbuf.push(1 - tuvs.values[iuv * 2 + 1]);
 					}
 					}
-					
+
 					if( sbuf != null ) {
 					if( sbuf != null ) {
 						var p = vidx * skin.bonesPerVertex;
 						var p = vidx * skin.bonesPerVertex;
 						var idx = 0;
 						var idx = 0;
@@ -140,7 +140,7 @@ class FBXModel extends MeshPrimitive {
 						}
 						}
 						sbuf.writeInt32(idx);
 						sbuf.writeInt32(idx);
 					}
 					}
-					
+
 					if( cbuf != null ) {
 					if( cbuf != null ) {
 						var icol = colors.index[k];
 						var icol = colors.index[k];
 						cbuf.push(colors.values[icol * 4]);
 						cbuf.push(colors.values[icol * 4]);
@@ -182,7 +182,7 @@ class FBXModel extends MeshPrimitive {
 			}
 			}
 			pos++;
 			pos++;
 		}
 		}
-		
+
 		addBuffer("position", h3d.Buffer.ofFloats(pbuf, 3));
 		addBuffer("position", h3d.Buffer.ofFloats(pbuf, 3));
 		if( nbuf != null ) addBuffer("normal", h3d.Buffer.ofFloats(nbuf, 3));
 		if( nbuf != null ) addBuffer("normal", h3d.Buffer.ofFloats(nbuf, 3));
 		if( tbuf != null ) addBuffer("uv", h3d.Buffer.ofFloats(tbuf, 2));
 		if( tbuf != null ) addBuffer("uv", h3d.Buffer.ofFloats(tbuf, 2));
@@ -194,7 +194,7 @@ class FBXModel extends MeshPrimitive {
 			addBuffer("indexes", skinBuf, skin.bonesPerVertex);
 			addBuffer("indexes", skinBuf, skin.bonesPerVertex);
 		}
 		}
 		if( cbuf != null ) addBuffer("color", h3d.Buffer.ofFloats(cbuf, 3));
 		if( cbuf != null ) addBuffer("color", h3d.Buffer.ofFloats(cbuf, 3));
-		
+
 		indexes = h3d.Indexes.alloc(idx);
 		indexes = h3d.Indexes.alloc(idx);
 		if( mats != null ) {
 		if( mats != null ) {
 			groupIndexes = [];
 			groupIndexes = [];
@@ -207,5 +207,5 @@ class FBXModel extends MeshPrimitive {
 				groupIndexes.push(i == null ? null : h3d.Indexes.alloc(i));
 				groupIndexes.push(i == null ? null : h3d.Indexes.alloc(i));
 		}
 		}
 	}
 	}
-	
+
 }
 }

+ 4 - 4
h3d/prim/GeoSphere.hx

@@ -27,11 +27,11 @@ class GeoSphere extends Polygon {
 				pa.normalize();
 				pa.normalize();
 				pb.normalize();
 				pb.normalize();
 				pc.normalize();
 				pc.normalize();
-				
+
 				nidx.push(np);
 				nidx.push(np);
 				nidx.push(np + 1);
 				nidx.push(np + 1);
 				nidx.push(np + 2);
 				nidx.push(np + 2);
-				
+
 				nidx.push(idx[i]);
 				nidx.push(idx[i]);
 				nidx.push(np);
 				nidx.push(np);
 				nidx.push(np + 2);
 				nidx.push(np + 2);
@@ -39,11 +39,11 @@ class GeoSphere extends Polygon {
 				nidx.push(np);
 				nidx.push(np);
 				nidx.push(idx[i + 1]);
 				nidx.push(idx[i + 1]);
 				nidx.push(np + 1);
 				nidx.push(np + 1);
-				
+
 				nidx.push(np + 1);
 				nidx.push(np + 1);
 				nidx.push(idx[i + 2]);
 				nidx.push(idx[i + 2]);
 				nidx.push(np + 2);
 				nidx.push(np + 2);
-				
+
 				p[np++] = pa;
 				p[np++] = pa;
 				p[np++] = pb;
 				p[np++] = pb;
 				p[np++] = pc;
 				p[np++] = pc;

+ 6 - 6
h3d/prim/MeshPrimitive.hx

@@ -3,13 +3,13 @@ package h3d.prim;
 private typedef Cache = #if flash haxe.ds.UnsafeStringMap<h3d.Buffer.BufferOffset> #else Map<Int,h3d.Buffer.BufferOffset> #end
 private typedef Cache = #if flash haxe.ds.UnsafeStringMap<h3d.Buffer.BufferOffset> #else Map<Int,h3d.Buffer.BufferOffset> #end
 
 
 class MeshPrimitive extends Primitive {
 class MeshPrimitive extends Primitive {
-		
+
 	var bufferCache : Cache;
 	var bufferCache : Cache;
-	
+
 	function allocBuffer( engine : h3d.Engine, name : String ) {
 	function allocBuffer( engine : h3d.Engine, name : String ) {
 		return null;
 		return null;
 	}
 	}
-	
+
 	// TODO : in HxSL 3, we might instead allocate unique ID per name
 	// TODO : in HxSL 3, we might instead allocate unique ID per name
 	static inline function hash( name : String ) {
 	static inline function hash( name : String ) {
 		var id = 0;
 		var id = 0;
@@ -17,7 +17,7 @@ class MeshPrimitive extends Primitive {
 			id = id * 223 + name.charCodeAt(i);
 			id = id * 223 + name.charCodeAt(i);
 		return id & 0x0FFFFFFF;
 		return id & 0x0FFFFFFF;
 	}
 	}
-	
+
 	function addBuffer( name : String, buf, offset = 0 ) {
 	function addBuffer( name : String, buf, offset = 0 ) {
 		if( bufferCache == null )
 		if( bufferCache == null )
 			bufferCache = new Cache();
 			bufferCache = new Cache();
@@ -57,12 +57,12 @@ class MeshPrimitive extends Primitive {
 		}
 		}
 		return buffers;
 		return buffers;
 	}
 	}
-	
+
 	override function render( engine : h3d.Engine ) {
 	override function render( engine : h3d.Engine ) {
 		// the actual alloc() cache will be implemented by subclasses
 		// the actual alloc() cache will be implemented by subclasses
 		if( indexes == null || indexes.isDisposed() )
 		if( indexes == null || indexes.isDisposed() )
 			alloc(engine);
 			alloc(engine);
 		engine.renderMultiBuffers(getBuffers(engine), indexes);
 		engine.renderMultiBuffers(getBuffers(engine), indexes);
 	}
 	}
-	
+
 }
 }

+ 5 - 5
h3d/prim/Plan2D.hx

@@ -1,10 +1,10 @@
 package h3d.prim;
 package h3d.prim;
 
 
 class Plan2D extends Primitive {
 class Plan2D extends Primitive {
-	
+
 	public function new() {
 	public function new() {
 	}
 	}
-	
+
 	override function alloc( engine : h3d.Engine ) {
 	override function alloc( engine : h3d.Engine ) {
 		var v = new hxd.FloatBuffer();
 		var v = new hxd.FloatBuffer();
 		v.push( -1);
 		v.push( -1);
@@ -26,13 +26,13 @@ class Plan2D extends Primitive {
 		v.push( 1);
 		v.push( 1);
 		v.push( 1);
 		v.push( 1);
 		v.push( 0);
 		v.push( 0);
-		
+
 		buffer = h3d.Buffer.ofFloats(v, 4, [Quads]);
 		buffer = h3d.Buffer.ofFloats(v, 4, [Quads]);
 	}
 	}
-	
+
 	override function render(engine:h3d.Engine) {
 	override function render(engine:h3d.Engine) {
 		if( buffer == null ) alloc(engine);
 		if( buffer == null ) alloc(engine);
 		engine.renderQuadBuffer(buffer);
 		engine.renderQuadBuffer(buffer);
 	}
 	}
-	
+
 }
 }

+ 12 - 12
h3d/prim/Plan3D.hx

@@ -1,10 +1,10 @@
 package h3d.prim;
 package h3d.prim;
 
 
 class Plan3D extends Primitive {
 class Plan3D extends Primitive {
-	
+
 	public var width(default,set) : Float;
 	public var width(default,set) : Float;
 	public var height(default,set) : Float;
 	public var height(default,set) : Float;
-	
+
 	public function new(width = 1.0, height = 1.0) {
 	public function new(width = 1.0, height = 1.0) {
 		this.width = width;
 		this.width = width;
 		this.height = height;
 		this.height = height;
@@ -15,13 +15,13 @@ class Plan3D extends Primitive {
 		dispose();
 		dispose();
 		return w;
 		return w;
 	}
 	}
-	
+
 	function set_height(h) {
 	function set_height(h) {
 		height = h;
 		height = h;
 		dispose();
 		dispose();
 		return h;
 		return h;
 	}
 	}
-	
+
 	override function getBounds() {
 	override function getBounds() {
 		var b = new h3d.col.Bounds();
 		var b = new h3d.col.Bounds();
 		b.xMin = 0;
 		b.xMin = 0;
@@ -44,17 +44,17 @@ class Plan3D extends Primitive {
 		v.push( 0);
 		v.push( 0);
 		v.push( 0);
 		v.push( 0);
 		v.push( 1);
 		v.push( 1);
-		
+
 		v.push( -hw);
 		v.push( -hw);
 		v.push( hh);
 		v.push( hh);
 		v.push( 0);
 		v.push( 0);
 		v.push( 0);
 		v.push( 0);
 		v.push( 0);
 		v.push( 0);
-		
+
 		v.push( 0);
 		v.push( 0);
 		v.push( 0);
 		v.push( 0);
 		v.push( 1);
 		v.push( 1);
-		
+
 		v.push( hw);
 		v.push( hw);
 		v.push( -hh);
 		v.push( -hh);
 		v.push( 1);
 		v.push( 1);
@@ -63,22 +63,22 @@ class Plan3D extends Primitive {
 		v.push( 0);
 		v.push( 0);
 		v.push( 0);
 		v.push( 0);
 		v.push( 1);
 		v.push( 1);
-		
+
 		v.push( hw);
 		v.push( hw);
 		v.push( hh);
 		v.push( hh);
 		v.push( 1);
 		v.push( 1);
 		v.push( 0);
 		v.push( 0);
-		
+
 		v.push( 0);
 		v.push( 0);
 		v.push( 0);
 		v.push( 0);
 		v.push( 1);
 		v.push( 1);
-		
+
 		buffer = h3d.Buffer.ofFloats(v, 8, [Quads]);
 		buffer = h3d.Buffer.ofFloats(v, 8, [Quads]);
 	}
 	}
-	
+
 	override function render(engine:h3d.Engine) {
 	override function render(engine:h3d.Engine) {
 		if( buffer == null ) alloc(engine);
 		if( buffer == null ) alloc(engine);
 		engine.renderQuadBuffer(buffer);
 		engine.renderQuadBuffer(buffer);
 	}
 	}
-	
+
 }
 }

+ 9 - 9
h3d/prim/Polygon.hx

@@ -8,22 +8,22 @@ class Polygon extends Primitive {
 	public var uvs : Array<UV>;
 	public var uvs : Array<UV>;
 	public var idx : hxd.IndexBuffer;
 	public var idx : hxd.IndexBuffer;
 	public var colors : Array<Point>;
 	public var colors : Array<Point>;
-		
+
 	public function new( points, ?idx ) {
 	public function new( points, ?idx ) {
 		this.points = points;
 		this.points = points;
 		this.idx = idx;
 		this.idx = idx;
 	}
 	}
-	
+
 	override function getBounds() {
 	override function getBounds() {
 		var b = new h3d.col.Bounds();
 		var b = new h3d.col.Bounds();
 		for( p in points )
 		for( p in points )
 			b.addPoint(p);
 			b.addPoint(p);
 		return b;
 		return b;
 	}
 	}
-	
+
 	override function alloc( engine : h3d.Engine ) {
 	override function alloc( engine : h3d.Engine ) {
 		dispose();
 		dispose();
-		
+
 		var size = 3;
 		var size = 3;
 		if( normals != null )
 		if( normals != null )
 			size += 3;
 			size += 3;
@@ -31,7 +31,7 @@ class Polygon extends Primitive {
 			size += 2;
 			size += 2;
 		if( colors != null )
 		if( colors != null )
 			size += 3;
 			size += 3;
-			
+
 		var buf = new hxd.FloatBuffer();
 		var buf = new hxd.FloatBuffer();
 		for( k in 0...points.length ) {
 		for( k in 0...points.length ) {
 			var p = points[k];
 			var p = points[k];
@@ -57,7 +57,7 @@ class Polygon extends Primitive {
 			}
 			}
 		}
 		}
 		buffer = h3d.Buffer.ofFloats(buf, size, idx == null ? [Triangles] : null);
 		buffer = h3d.Buffer.ofFloats(buf, size, idx == null ? [Triangles] : null);
-		
+
 		if( idx != null )
 		if( idx != null )
 			indexes = h3d.Indexes.alloc(idx);
 			indexes = h3d.Indexes.alloc(idx);
 	}
 	}
@@ -107,7 +107,7 @@ class Polygon extends Primitive {
 			p.z *= s;
 			p.z *= s;
 		}
 		}
 	}
 	}
-	
+
 	public function addNormals() {
 	public function addNormals() {
 		// make per-point normal
 		// make per-point normal
 		normals = new Array();
 		normals = new Array();
@@ -143,7 +143,7 @@ class Polygon extends Primitive {
 	public function addUVs() {
 	public function addUVs() {
 		throw "Not implemented for this polygon";
 		throw "Not implemented for this polygon";
 	}
 	}
-	
+
 	public function uvScale( su : Float, sv : Float ) {
 	public function uvScale( su : Float, sv : Float ) {
 		if( uvs == null )
 		if( uvs == null )
 			throw "Missing UVs";
 			throw "Missing UVs";
@@ -155,7 +155,7 @@ class Polygon extends Primitive {
 			t.v *= sv;
 			t.v *= sv;
 		}
 		}
 	}
 	}
-	
+
 	public override function triCount() {
 	public override function triCount() {
 		var n = super.triCount();
 		var n = super.triCount();
 		if( n != 0 )
 		if( n != 0 )

+ 7 - 7
h3d/prim/Primitive.hx

@@ -1,26 +1,26 @@
 package h3d.prim;
 package h3d.prim;
 
 
 class Primitive {
 class Primitive {
-	
+
 	public var buffer : Buffer;
 	public var buffer : Buffer;
 	public var indexes : Indexes;
 	public var indexes : Indexes;
-	
+
 	public function triCount() {
 	public function triCount() {
 		return if( indexes != null ) Std.int(indexes.count / 3) else if( buffer == null ) 0 else Std.int(buffer.totalVertices() / 3);
 		return if( indexes != null ) Std.int(indexes.count / 3) else if( buffer == null ) 0 else Std.int(buffer.totalVertices() / 3);
 	}
 	}
-	
+
 	public function getBounds() : h3d.col.Bounds {
 	public function getBounds() : h3d.col.Bounds {
 		throw "not implemented";
 		throw "not implemented";
 		return null;
 		return null;
 	}
 	}
-	
+
 	public function alloc( engine : h3d.Engine ) {
 	public function alloc( engine : h3d.Engine ) {
 		throw "not implemented";
 		throw "not implemented";
 	}
 	}
 
 
 	public function selectMaterial( material : Int ) {
 	public function selectMaterial( material : Int ) {
 	}
 	}
-	
+
 	public function render( engine : h3d.Engine ) {
 	public function render( engine : h3d.Engine ) {
 		if( buffer == null || buffer.isDisposed() ) alloc(engine);
 		if( buffer == null || buffer.isDisposed() ) alloc(engine);
 		if( indexes == null )
 		if( indexes == null )
@@ -28,7 +28,7 @@ class Primitive {
 		else
 		else
 			engine.renderIndexed(buffer,indexes);
 			engine.renderIndexed(buffer,indexes);
 	}
 	}
-	
+
 	public function dispose() {
 	public function dispose() {
 		if( buffer != null ) {
 		if( buffer != null ) {
 			buffer.dispose();
 			buffer.dispose();
@@ -39,5 +39,5 @@ class Primitive {
 			indexes = null;
 			indexes = null;
 		}
 		}
 	}
 	}
-	
+
 }
 }

+ 8 - 8
h3d/prim/Quads.hx

@@ -6,13 +6,13 @@ class Quads extends Primitive {
 	var pts : Array<Point>;
 	var pts : Array<Point>;
 	var uvs : Array<UV>;
 	var uvs : Array<UV>;
 	var normals : Array<Point>;
 	var normals : Array<Point>;
-	
+
 	public function new( pts, ?uvs, ?normals ) {
 	public function new( pts, ?uvs, ?normals ) {
 		this.pts = pts;
 		this.pts = pts;
 		this.uvs = uvs;
 		this.uvs = uvs;
 		this.normals = normals;
 		this.normals = normals;
 	}
 	}
-	
+
 	public function scale( x : Float, y : Float, z : Float ) {
 	public function scale( x : Float, y : Float, z : Float ) {
 		for( p in pts ) {
 		for( p in pts ) {
 			p.x *= x;
 			p.x *= x;
@@ -20,7 +20,7 @@ class Quads extends Primitive {
 			p.z *= z;
 			p.z *= z;
 		}
 		}
 	}
 	}
-	
+
 	public function addTCoords() {
 	public function addTCoords() {
 		uvs = [];
 		uvs = [];
 		var a = new UV(0, 1);
 		var a = new UV(0, 1);
@@ -34,11 +34,11 @@ class Quads extends Primitive {
 			uvs.push(d);
 			uvs.push(d);
 		}
 		}
 	}
 	}
-	
+
 	public function addNormals() {
 	public function addNormals() {
 		throw "Not implemented";
 		throw "Not implemented";
 	}
 	}
-	
+
 	override function alloc( engine : Engine ) {
 	override function alloc( engine : Engine ) {
 		dispose();
 		dispose();
 		var v = new hxd.FloatBuffer();
 		var v = new hxd.FloatBuffer();
@@ -64,14 +64,14 @@ class Quads extends Primitive {
 		if( uvs != null ) size += 2;
 		if( uvs != null ) size += 2;
 		buffer = h3d.Buffer.ofFloats(v, size, [Quads]);
 		buffer = h3d.Buffer.ofFloats(v, size, [Quads]);
 	}
 	}
-	
+
 	public function getPoints() {
 	public function getPoints() {
 		return pts;
 		return pts;
 	}
 	}
-	
+
 	override function render(engine) {
 	override function render(engine) {
 		if( buffer == null || buffer.isDisposed() ) alloc(engine);
 		if( buffer == null || buffer.isDisposed() ) alloc(engine);
 		engine.renderQuadBuffer(buffer);
 		engine.renderQuadBuffer(buffer);
 	}
 	}
-	
+
 }
 }

+ 4 - 4
h3d/prim/Sphere.hx

@@ -2,10 +2,10 @@ package h3d.prim;
 import h3d.col.Point;
 import h3d.col.Point;
 
 
 class Sphere extends Polygon {
 class Sphere extends Polygon {
-	
+
 	var segsH : Int;
 	var segsH : Int;
 	var segsW : Int;
 	var segsW : Int;
-	
+
 	public function new( segsW = 8, segsH = 6 ) {
 	public function new( segsW = 8, segsH = 6 ) {
 		this.segsH = segsH;
 		this.segsH = segsH;
 		this.segsW = segsW;
 		this.segsW = segsW;
@@ -41,13 +41,13 @@ class Sphere extends Polygon {
 	override function addNormals() {
 	override function addNormals() {
 		normals = points;
 		normals = points;
 	}
 	}
-	
+
 	override function addUVs() {
 	override function addUVs() {
 		uvs = [];
 		uvs = [];
 		for( y in 0...segsH + 1 )
 		for( y in 0...segsH + 1 )
 			for( x in 0...segsW + 1 )
 			for( x in 0...segsW + 1 )
 				uvs.push(new UV(x / segsW, y / segsH));
 				uvs.push(new UV(x / segsW, y / segsH));
 	}
 	}
-	
+
 }
 }
 
 

+ 3 - 3
h3d/prim/UV.hx

@@ -4,16 +4,16 @@ class UV {
 
 
 	public var u : Float;
 	public var u : Float;
 	public var v : Float;
 	public var v : Float;
-	
+
 	public function new(u,v) {
 	public function new(u,v) {
 		this.u = u;
 		this.u = u;
 		this.v = v;
 		this.v = v;
 	}
 	}
-	
+
 	public function clone() {
 	public function clone() {
 		return new UV(u, v);
 		return new UV(u, v);
 	}
 	}
-	
+
 	function toString() {
 	function toString() {
 		return "{" + hxd.Math.fmt(u) + "," + hxd.Math.fmt(v) + "}";
 		return "{" + hxd.Math.fmt(u) + "," + hxd.Math.fmt(v) + "}";
 	}
 	}

+ 8 - 8
h3d/scene/Box.hx

@@ -1,28 +1,28 @@
 package h3d.scene;
 package h3d.scene;
 
 
 class Box extends Graphics {
 class Box extends Graphics {
-	
+
 	public var color : Int;
 	public var color : Int;
-	
+
 	public function new( ?color = 0xFFFF0000, ?depth = true, ?parent) {
 	public function new( ?color = 0xFFFF0000, ?depth = true, ?parent) {
 		super(parent);
 		super(parent);
 		this.color = color;
 		this.color = color;
 		if( !depth ) material.mainPass.depth(true,Always);
 		if( !depth ) material.mainPass.depth(true,Always);
 	}
 	}
-	
+
 	override function sync( ctx : RenderContext ) {
 	override function sync( ctx : RenderContext ) {
 		super.sync(ctx);
 		super.sync(ctx);
-		
+
 		var dx = new h3d.col.Point(absPos._11, absPos._12, absPos._13);
 		var dx = new h3d.col.Point(absPos._11, absPos._12, absPos._13);
 		var dy = new h3d.col.Point(absPos._21, absPos._22, absPos._23);
 		var dy = new h3d.col.Point(absPos._21, absPos._22, absPos._23);
 		var dz = new h3d.col.Point(absPos._31, absPos._32, absPos._33);
 		var dz = new h3d.col.Point(absPos._31, absPos._32, absPos._33);
-		
+
 		var p = absPos.pos().toPoint();
 		var p = absPos.pos().toPoint();
-		
+
 		p.x -= (dx.x + dy.x + dz.x) * 0.5;
 		p.x -= (dx.x + dy.x + dz.x) * 0.5;
 		p.y -= (dx.y + dy.y + dz.y) * 0.5;
 		p.y -= (dx.y + dy.y + dz.y) * 0.5;
 		p.z -= (dx.z + dy.z + dz.z) * 0.5;
 		p.z -= (dx.z + dy.z + dz.z) * 0.5;
-		
+
 		clear();
 		clear();
 		lineStyle(1, color);
 		lineStyle(1, color);
 		drawLine(p, p.add(dx));
 		drawLine(p, p.add(dx));
@@ -52,5 +52,5 @@ class Box extends Graphics {
 		b.scaleZ = bounds.zMax - bounds.zMin;
 		b.scaleZ = bounds.zMax - bounds.zMin;
 		return b;
 		return b;
 	}
 	}
-	
+
 }
 }

+ 2 - 2
h3d/scene/DirLight.hx

@@ -4,14 +4,14 @@ class DirLight extends Light {
 
 
 	var dshader : h3d.shader.DirLight;
 	var dshader : h3d.shader.DirLight;
 	public var direction : h3d.Vector;
 	public var direction : h3d.Vector;
-	
+
 	public function new(dir, ?parent) {
 	public function new(dir, ?parent) {
 		dshader = new h3d.shader.DirLight();
 		dshader = new h3d.shader.DirLight();
 		direction = dir;
 		direction = dir;
 		super(dshader, parent);
 		super(dshader, parent);
 		priority = 100;
 		priority = 100;
 	}
 	}
-	
+
 	override function get_color() {
 	override function get_color() {
 		return dshader.color;
 		return dshader.color;
 	}
 	}

+ 8 - 8
h3d/scene/Graphics.hx

@@ -5,36 +5,36 @@ class Graphics extends Mesh {
 	var curX : Float = 0.;
 	var curX : Float = 0.;
 	var curY : Float = 0.;
 	var curY : Float = 0.;
 	var curZ : Float = 0.;
 	var curZ : Float = 0.;
-	
+
 	public function new(?parent) {
 	public function new(?parent) {
 		super(null, null, parent);
 		super(null, null, parent);
 	}
 	}
-	
+
 	public function clear() {
 	public function clear() {
 	}
 	}
-	
+
 	public function selectColor(color : Int) {
 	public function selectColor(color : Int) {
 	}
 	}
-	
+
 	public function lineSize( v : Float ) {
 	public function lineSize( v : Float ) {
 	}
 	}
-	
+
 	public function lineStyle( size, color ) {
 	public function lineStyle( size, color ) {
 		lineSize(size);
 		lineSize(size);
 		selectColor(color);
 		selectColor(color);
 	}
 	}
-	
+
 	public inline function drawLine( p1 : h3d.col.Point, p2 : h3d.col.Point ) {
 	public inline function drawLine( p1 : h3d.col.Point, p2 : h3d.col.Point ) {
 		moveTo(p1.x, p1.y, p1.z);
 		moveTo(p1.x, p1.y, p1.z);
 		lineTo(p2.x, p2.y, p2.z);
 		lineTo(p2.x, p2.y, p2.z);
 	}
 	}
-	
+
 	public function moveTo( x : Float, y : Float, z : Float ) {
 	public function moveTo( x : Float, y : Float, z : Float ) {
 		curX = 0;
 		curX = 0;
 		curY = 0;
 		curY = 0;
 		curZ = 0;
 		curZ = 0;
 	}
 	}
-	
+
 	public function lineTo( x : Float, y : Float, z : Float ) {
 	public function lineTo( x : Float, y : Float, z : Float ) {
 		throw "TODO";
 		throw "TODO";
 	}
 	}

+ 3 - 3
h3d/scene/Light.hx

@@ -5,7 +5,7 @@ class Light extends Object {
 	var shader : hxsl.Shader;
 	var shader : hxsl.Shader;
 	var objectDistance : Float; // used internaly
 	var objectDistance : Float; // used internaly
 	@:noCompletion public var next : Light;
 	@:noCompletion public var next : Light;
-	
+
 	public var color(get, never) : h3d.Vector;
 	public var color(get, never) : h3d.Vector;
 	public var priority : Int = 0;
 	public var priority : Int = 0;
 
 
@@ -13,12 +13,12 @@ class Light extends Object {
 		super(parent);
 		super(parent);
 		this.shader = shader;
 		this.shader = shader;
 	}
 	}
-	
+
 	// dummy implementation
 	// dummy implementation
 	function get_color() {
 	function get_color() {
 		return new h3d.Vector();
 		return new h3d.Vector();
 	}
 	}
-	
+
 	override function emit(ctx:RenderContext) {
 	override function emit(ctx:RenderContext) {
 		ctx.emitLight(this);
 		ctx.emitLight(this);
 	}
 	}

+ 5 - 5
h3d/scene/Mesh.hx

@@ -4,14 +4,14 @@ class Mesh extends Object {
 
 
 	public var primitive : h3d.prim.Primitive;
 	public var primitive : h3d.prim.Primitive;
 	public var material : h3d.mat.MeshMaterial;
 	public var material : h3d.mat.MeshMaterial;
-	
+
 	public function new( prim, ?mat, ?parent ) {
 	public function new( prim, ?mat, ?parent ) {
 		super(parent);
 		super(parent);
 		this.primitive = prim;
 		this.primitive = prim;
 		if( mat == null ) mat = new h3d.mat.MeshMaterial(null);
 		if( mat == null ) mat = new h3d.mat.MeshMaterial(null);
 		this.material = mat;
 		this.material = mat;
 	}
 	}
-	
+
 	override function getBounds( ?b : h3d.col.Bounds, rec = false ) {
 	override function getBounds( ?b : h3d.col.Bounds, rec = false ) {
 		b = super.getBounds(b, rec);
 		b = super.getBounds(b, rec);
 		var tmp = primitive.getBounds().clone();
 		var tmp = primitive.getBounds().clone();
@@ -19,7 +19,7 @@ class Mesh extends Object {
 		b.add(tmp);
 		b.add(tmp);
 		return b;
 		return b;
 	}
 	}
-	
+
 	override function clone( ?o : Object ) : Object {
 	override function clone( ?o : Object ) : Object {
 		var m = o == null ? new Mesh(null,material) : cast o;
 		var m = o == null ? new Mesh(null,material) : cast o;
 		m.primitive = primitive;
 		m.primitive = primitive;
@@ -28,11 +28,11 @@ class Mesh extends Object {
 		super.clone(m);
 		super.clone(m);
 		return m;
 		return m;
 	}
 	}
-	
+
 	override function draw( ctx : RenderContext ) {
 	override function draw( ctx : RenderContext ) {
 		primitive.render(ctx.engine);
 		primitive.render(ctx.engine);
 	}
 	}
-	
+
 	override function emit( ctx : RenderContext ) {
 	override function emit( ctx : RenderContext ) {
 		ctx.emit(material, this);
 		ctx.emit(material, this);
 	}
 	}

+ 4 - 4
h3d/scene/MultiMaterial.hx

@@ -3,12 +3,12 @@ package h3d.scene;
 class MultiMaterial extends Mesh {
 class MultiMaterial extends Mesh {
 
 
 	public var materials : Array<h3d.mat.MeshMaterial>;
 	public var materials : Array<h3d.mat.MeshMaterial>;
-	
+
 	public function new( prim, ?mats, ?parent ) {
 	public function new( prim, ?mats, ?parent ) {
 		super(prim, mats == null ? null : mats[0], parent);
 		super(prim, mats == null ? null : mats[0], parent);
 		this.materials = mats == null ? [material] : mats;
 		this.materials = mats == null ? [material] : mats;
 	}
 	}
-	
+
 	override function clone( ?o : Object ) {
 	override function clone( ?o : Object ) {
 	/*
 	/*
 		var m = o == null ? new MultiMaterial(null,materials) : cast o;
 		var m = o == null ? new MultiMaterial(null,materials) : cast o;
@@ -20,7 +20,7 @@ class MultiMaterial extends Mesh {
 		throw "TODO";
 		throw "TODO";
 		return o;
 		return o;
 	}
 	}
-	
+
 	override function emit( ctx : RenderContext ) {
 	override function emit( ctx : RenderContext ) {
 		for( i in 0...materials.length ) {
 		for( i in 0...materials.length ) {
 			var m = materials[i];
 			var m = materials[i];
@@ -34,5 +34,5 @@ class MultiMaterial extends Mesh {
 			primitive.selectMaterial(ctx.drawPass.index);
 			primitive.selectMaterial(ctx.drawPass.index);
 		super.draw(ctx);
 		super.draw(ctx);
 	}
 	}
-	
+
 }
 }

+ 46 - 46
h3d/scene/Object.hx

@@ -3,11 +3,11 @@ package h3d.scene;
 class Object {
 class Object {
 
 
 	static inline var ROT2RAD = -0.017453292519943295769236907684886;
 	static inline var ROT2RAD = -0.017453292519943295769236907684886;
-	
+
 	var childs : Array<Object>;
 	var childs : Array<Object>;
 	public var parent(default, null) : Object;
 	public var parent(default, null) : Object;
 	public var numChildren(get, never) : Int;
 	public var numChildren(get, never) : Int;
-	
+
 	public var name : Null<String>;
 	public var name : Null<String>;
 	public var x(default,set) : Float;
 	public var x(default,set) : Float;
 	public var y(default, set) : Float;
 	public var y(default, set) : Float;
@@ -16,7 +16,7 @@ class Object {
 	public var scaleY(default, set) : Float;
 	public var scaleY(default, set) : Float;
 	public var scaleZ(default,set) : Float;
 	public var scaleZ(default,set) : Float;
 	public var visible : Bool = true;
 	public var visible : Bool = true;
-	
+
 	/**
 	/**
 		Follow a given object or joint as if it was our parent. Ignore defaultTransform when set.
 		Follow a given object or joint as if it was our parent. Ignore defaultTransform when set.
 	**/
 	**/
@@ -28,13 +28,13 @@ class Object {
 	**/
 	**/
 	public var defaultTransform(default, set) : h3d.Matrix;
 	public var defaultTransform(default, set) : h3d.Matrix;
 	public var currentAnimation(default, null) : h3d.anim.Animation;
 	public var currentAnimation(default, null) : h3d.anim.Animation;
-	
+
 	var absPos : h3d.Matrix;
 	var absPos : h3d.Matrix;
 	var invPos : h3d.Matrix;
 	var invPos : h3d.Matrix;
 	var qRot : h3d.Quat;
 	var qRot : h3d.Quat;
 	var posChanged : Bool;
 	var posChanged : Bool;
 	var lastFrame : Int;
 	var lastFrame : Int;
-	
+
 	public function new( ?parent : Object ) {
 	public function new( ?parent : Object ) {
 		absPos = new h3d.Matrix();
 		absPos = new h3d.Matrix();
 		absPos.identity();
 		absPos.identity();
@@ -45,29 +45,29 @@ class Object {
 		if( parent != null )
 		if( parent != null )
 			parent.addChild(this);
 			parent.addChild(this);
 	}
 	}
-	
+
 	public function playAnimation( a : h3d.anim.Animation ) {
 	public function playAnimation( a : h3d.anim.Animation ) {
 		return currentAnimation = a.createInstance(this);
 		return currentAnimation = a.createInstance(this);
 	}
 	}
-	
+
 	/**
 	/**
 		Changes the current animation. This animation should be an instance that was created by playAnimation!
 		Changes the current animation. This animation should be an instance that was created by playAnimation!
 	**/
 	**/
 	public function switchToAnimation( a : h3d.anim.Animation ) {
 	public function switchToAnimation( a : h3d.anim.Animation ) {
 		return currentAnimation = a;
 		return currentAnimation = a;
 	}
 	}
-	
+
 	public function stopAnimation() {
 	public function stopAnimation() {
 		currentAnimation = null;
 		currentAnimation = null;
 	}
 	}
-	
+
 	public function getObjectsCount() {
 	public function getObjectsCount() {
 		var k = 0;
 		var k = 0;
 		for( c in childs )
 		for( c in childs )
 			k += c.getObjectsCount() + 1;
 			k += c.getObjectsCount() + 1;
 		return k;
 		return k;
 	}
 	}
-	
+
 	/**
 	/**
 		Transform a point from the local object coordinates to the global ones. The point is modified and returned.
 		Transform a point from the local object coordinates to the global ones. The point is modified and returned.
 	**/
 	**/
@@ -86,7 +86,7 @@ class Object {
 		pt.transform3x4(getInvPos());
 		pt.transform3x4(getInvPos());
 		return pt;
 		return pt;
 	}
 	}
-	
+
 	function getInvPos() {
 	function getInvPos() {
 		if( invPos == null ) {
 		if( invPos == null ) {
 			invPos = new h3d.Matrix();
 			invPos = new h3d.Matrix();
@@ -115,7 +115,7 @@ class Object {
 			c.getBounds(b, true);
 			c.getBounds(b, true);
 		return b;
 		return b;
 	}
 	}
-	
+
 	public function getObjectByName( name : String ) {
 	public function getObjectByName( name : String ) {
 		if( this.name == name )
 		if( this.name == name )
 			return this;
 			return this;
@@ -125,7 +125,7 @@ class Object {
 		}
 		}
 		return null;
 		return null;
 	}
 	}
-	
+
 	public function clone( ?o : Object ) : Object {
 	public function clone( ?o : Object ) : Object {
 		if( o == null ) o = new Object();
 		if( o == null ) o = new Object();
 		o.x = x;
 		o.x = x;
@@ -145,11 +145,11 @@ class Object {
 		}
 		}
 		return o;
 		return o;
 	}
 	}
-	
+
 	public function addChild( o : Object ) {
 	public function addChild( o : Object ) {
 		addChildAt(o, childs.length);
 		addChildAt(o, childs.length);
 	}
 	}
-	
+
 	public function addChildAt( o : Object, pos : Int ) {
 	public function addChildAt( o : Object, pos : Int ) {
 		if( pos < 0 ) pos = 0;
 		if( pos < 0 ) pos = 0;
 		if( pos > childs.length ) pos = childs.length;
 		if( pos > childs.length ) pos = childs.length;
@@ -165,35 +165,35 @@ class Object {
 		o.lastFrame = -1;
 		o.lastFrame = -1;
 		o.posChanged = true;
 		o.posChanged = true;
 	}
 	}
-	
+
 	public function removeChild( o : Object ) {
 	public function removeChild( o : Object ) {
 		if( childs.remove(o) )
 		if( childs.remove(o) )
 			o.parent = null;
 			o.parent = null;
 	}
 	}
-	
+
 	public inline function isMesh() {
 	public inline function isMesh() {
 		return Std.is(this, Mesh);
 		return Std.is(this, Mesh);
 	}
 	}
-	
+
 	public function toMesh() : Mesh {
 	public function toMesh() : Mesh {
 		if( isMesh() )
 		if( isMesh() )
 			return cast this;
 			return cast this;
 		throw (name == null ? "Object" : name) + " is not a Mesh";
 		throw (name == null ? "Object" : name) + " is not a Mesh";
 	}
 	}
-	
+
 	// shortcut for parent.removeChild
 	// shortcut for parent.removeChild
 	public inline function remove() {
 	public inline function remove() {
 		if( this != null && parent != null ) parent.removeChild(this);
 		if( this != null && parent != null ) parent.removeChild(this);
 	}
 	}
-	
+
 	function draw( ctx : RenderContext ) {
 	function draw( ctx : RenderContext ) {
 	}
 	}
-		
+
 	function set_follow(v) {
 	function set_follow(v) {
 		posChanged = true;
 		posChanged = true;
 		return follow = v;
 		return follow = v;
 	}
 	}
-	
+
 	function calcAbsPos() {
 	function calcAbsPos() {
 		qRot.saveToMatrix(absPos);
 		qRot.saveToMatrix(absPos);
 		// prepend scale
 		// prepend scale
@@ -223,7 +223,7 @@ class Object {
 		if( invPos != null )
 		if( invPos != null )
 			invPos._44 = 0; // mark as invalid
 			invPos._44 = 0; // mark as invalid
 	}
 	}
-	
+
 	function sync( ctx : RenderContext ) {
 	function sync( ctx : RenderContext ) {
 		if( currentAnimation != null ) {
 		if( currentAnimation != null ) {
 			var old = parent;
 			var old = parent;
@@ -239,7 +239,7 @@ class Object {
 			posChanged = false;
 			posChanged = false;
 			calcAbsPos();
 			calcAbsPos();
 		}
 		}
-		
+
 		lastFrame = ctx.frame;
 		lastFrame = ctx.frame;
 		var p = 0, len = childs.length;
 		var p = 0, len = childs.length;
 		while( p < len ) {
 		while( p < len ) {
@@ -259,7 +259,7 @@ class Object {
 				p++;
 				p++;
 		}
 		}
 	}
 	}
-	
+
 	function syncPos() {
 	function syncPos() {
 		if( parent != null ) parent.syncPos();
 		if( parent != null ) parent.syncPos();
 		if( posChanged ) {
 		if( posChanged ) {
@@ -269,10 +269,10 @@ class Object {
 				c.posChanged = true;
 				c.posChanged = true;
 		}
 		}
 	}
 	}
-	
+
 	function emit( ctx : RenderContext ) {
 	function emit( ctx : RenderContext ) {
 	}
 	}
-	
+
 	function emitRec( ctx : RenderContext ) {
 	function emitRec( ctx : RenderContext ) {
 		if( !visible ) return;
 		if( !visible ) return;
 		// fallback in case the object was added during a sync() event and we somehow didn't update it
 		// fallback in case the object was added during a sync() event and we somehow didn't update it
@@ -288,7 +288,7 @@ class Object {
 		for( c in childs )
 		for( c in childs )
 			c.emitRec(ctx);
 			c.emitRec(ctx);
 	}
 	}
-	
+
 	inline function set_x(v) {
 	inline function set_x(v) {
 		x = v;
 		x = v;
 		posChanged = true;
 		posChanged = true;
@@ -306,13 +306,13 @@ class Object {
 		posChanged = true;
 		posChanged = true;
 		return v;
 		return v;
 	}
 	}
-	
+
 	inline function set_scaleX(v) {
 	inline function set_scaleX(v) {
 		scaleX = v;
 		scaleX = v;
 		posChanged = true;
 		posChanged = true;
 		return v;
 		return v;
 	}
 	}
-	
+
 	inline function set_scaleY(v) {
 	inline function set_scaleY(v) {
 		scaleY = v;
 		scaleY = v;
 		posChanged = true;
 		posChanged = true;
@@ -324,13 +324,13 @@ class Object {
 		posChanged = true;
 		posChanged = true;
 		return v;
 		return v;
 	}
 	}
-	
+
 	inline function set_defaultTransform(v) {
 	inline function set_defaultTransform(v) {
 		defaultTransform = v;
 		defaultTransform = v;
 		posChanged = true;
 		posChanged = true;
 		return v;
 		return v;
 	}
 	}
-	
+
 	/*
 	/*
 		Move along the current rotation axis
 		Move along the current rotation axis
 	*/
 	*/
@@ -345,7 +345,7 @@ class Object {
 		this.z = z;
 		this.z = z;
 		posChanged = true;
 		posChanged = true;
 	}
 	}
-	
+
 	/*
 	/*
 		Rotate around the current rotation axis.
 		Rotate around the current rotation axis.
 	*/
 	*/
@@ -355,63 +355,63 @@ class Object {
 		qRot.multiply(qTmp,qRot);
 		qRot.multiply(qTmp,qRot);
 		posChanged = true;
 		posChanged = true;
 	}
 	}
-	
+
 	public function setRotate( rx : Float, ry : Float, rz : Float ) {
 	public function setRotate( rx : Float, ry : Float, rz : Float ) {
 		qRot.initRotate(rx, ry, rz);
 		qRot.initRotate(rx, ry, rz);
 		posChanged = true;
 		posChanged = true;
 	}
 	}
-	
+
 	public function setRotateAxis( ax : Float, ay : Float, az : Float, angle : Float ) {
 	public function setRotateAxis( ax : Float, ay : Float, az : Float, angle : Float ) {
 		qRot.initRotateAxis(ax, ay, az, angle);
 		qRot.initRotateAxis(ax, ay, az, angle);
 		posChanged = true;
 		posChanged = true;
 	}
 	}
-	
+
 	public function getRotation() {
 	public function getRotation() {
 		return qRot.toEuler();
 		return qRot.toEuler();
 	}
 	}
-	
+
 	public function getRotationQuat() {
 	public function getRotationQuat() {
 		return qRot;
 		return qRot;
 	}
 	}
-	
+
 	public function setRotationQuat(q) {
 	public function setRotationQuat(q) {
 		qRot = q;
 		qRot = q;
 		posChanged = true;
 		posChanged = true;
 	}
 	}
-	
+
 	public inline function scale( v : Float ) {
 	public inline function scale( v : Float ) {
 		scaleX *= v;
 		scaleX *= v;
 		scaleY *= v;
 		scaleY *= v;
 		scaleZ *= v;
 		scaleZ *= v;
 		posChanged = true;
 		posChanged = true;
 	}
 	}
-	
+
 	public inline function setScale( v : Float ) {
 	public inline function setScale( v : Float ) {
 		scaleX = v;
 		scaleX = v;
 		scaleY = v;
 		scaleY = v;
 		scaleZ = v;
 		scaleZ = v;
 		posChanged = true;
 		posChanged = true;
 	}
 	}
-	
+
 	public function toString() {
 	public function toString() {
 		return Type.getClassName(Type.getClass(this)).split(".").pop() + (name == null ? "" : "(" + name + ")");
 		return Type.getClassName(Type.getClass(this)).split(".").pop() + (name == null ? "" : "(" + name + ")");
 	}
 	}
-	
+
 	public inline function getChildAt( n ) {
 	public inline function getChildAt( n ) {
 		return childs[n];
 		return childs[n];
 	}
 	}
-	
+
 	inline function get_numChildren() {
 	inline function get_numChildren() {
 		return childs.length;
 		return childs.length;
 	}
 	}
-	
+
 	public inline function iterator() : hxd.impl.ArrayIterator<Object> {
 	public inline function iterator() : hxd.impl.ArrayIterator<Object> {
 		return new hxd.impl.ArrayIterator(childs);
 		return new hxd.impl.ArrayIterator(childs);
 	}
 	}
-	
+
 	public function dispose() {
 	public function dispose() {
 		for( c in childs )
 		for( c in childs )
 			c.dispose();
 			c.dispose();
 	}
 	}
-	
+
 }
 }

+ 4 - 4
h3d/scene/PointLight.hx

@@ -4,12 +4,12 @@ class PointLight extends Light {
 
 
 	var pshader : h3d.shader.PointLight;
 	var pshader : h3d.shader.PointLight;
 	public var params(get, set) : h3d.Vector;
 	public var params(get, set) : h3d.Vector;
-	
+
 	public function new(?parent) {
 	public function new(?parent) {
 		pshader = new h3d.shader.PointLight();
 		pshader = new h3d.shader.PointLight();
 		super(pshader, parent);
 		super(pshader, parent);
 	}
 	}
-	
+
 	override function get_color() {
 	override function get_color() {
 		return pshader.color;
 		return pshader.color;
 	}
 	}
@@ -21,10 +21,10 @@ class PointLight extends Light {
 	inline function set_params(p) {
 	inline function set_params(p) {
 		return pshader.params = p;
 		return pshader.params = p;
 	}
 	}
-	
+
 	override function emit(ctx) {
 	override function emit(ctx) {
 		pshader.lightPosition.set(absPos._41, absPos._42, absPos._43);
 		pshader.lightPosition.set(absPos._41, absPos._42, absPos._43);
 		super.emit(ctx);
 		super.emit(ctx);
 	}
 	}
-	
+
 }
 }

+ 10 - 10
h3d/scene/RenderContext.hx

@@ -8,21 +8,21 @@ class RenderContext {
 	public var time : Float;
 	public var time : Float;
 	public var elapsedTime : Float;
 	public var elapsedTime : Float;
 	public var frame : Int;
 	public var frame : Int;
-	
+
 	public var drawPass : ObjectPass;
 	public var drawPass : ObjectPass;
-	
+
 	public var sharedGlobals : Map<Int,Dynamic>;
 	public var sharedGlobals : Map<Int,Dynamic>;
-	
+
 	var pool : ObjectPass;
 	var pool : ObjectPass;
 	var passes : ObjectPass;
 	var passes : ObjectPass;
 	var lights : Light;
 	var lights : Light;
-	
+
 	public function new() {
 	public function new() {
 		frame = 0;
 		frame = 0;
 		time = 0.;
 		time = 0.;
 		elapsedTime = 1. / hxd.Stage.getInstance().getFrameRate();
 		elapsedTime = 1. / hxd.Stage.getInstance().getFrameRate();
 	}
 	}
-	
+
 	@:access(h3d.mat.Pass)
 	@:access(h3d.mat.Pass)
 	public inline function emit( mat : h3d.mat.Material, obj, index = 0 ) {
 	public inline function emit( mat : h3d.mat.Material, obj, index = 0 ) {
 		var p = mat.mainPass;
 		var p = mat.mainPass;
@@ -31,7 +31,7 @@ class RenderContext {
 			p = p.nextPass;
 			p = p.nextPass;
 		}
 		}
 	}
 	}
-	
+
 	public function start() {
 	public function start() {
 		sharedGlobals = new Map();
 		sharedGlobals = new Map();
 		lights = null;
 		lights = null;
@@ -41,7 +41,7 @@ class RenderContext {
 		time += elapsedTime;
 		time += elapsedTime;
 		frame++;
 		frame++;
 	}
 	}
-	
+
 	public function emitPass( pass : h3d.mat.Pass, obj : h3d.scene.Object ) {
 	public function emitPass( pass : h3d.mat.Pass, obj : h3d.scene.Object ) {
 		var o = pool;
 		var o = pool;
 		if( o == null )
 		if( o == null )
@@ -54,12 +54,12 @@ class RenderContext {
 		passes = o;
 		passes = o;
 		return o;
 		return o;
 	}
 	}
-	
+
 	public function emitLight( l : Light ) {
 	public function emitLight( l : Light ) {
 		l.next = lights;
 		l.next = lights;
 		lights = l;
 		lights = l;
 	}
 	}
-	
+
 	public function done() {
 	public function done() {
 		drawPass = null;
 		drawPass = null;
 		// move passes to pool, and erase data
 		// move passes to pool, and erase data
@@ -81,5 +81,5 @@ class RenderContext {
 		passes = null;
 		passes = null;
 		lights = null;
 		lights = null;
 	}
 	}
-	
+
 }
 }

+ 11 - 11
h3d/scene/Scene.hx

@@ -8,7 +8,7 @@ class Scene extends Object implements h3d.IDrawable {
 	var postPasses : Array<h3d.IDrawable>;
 	var postPasses : Array<h3d.IDrawable>;
 	var passes : Map<String,h3d.pass.Base>;
 	var passes : Map<String,h3d.pass.Base>;
 	var ctx : RenderContext;
 	var ctx : RenderContext;
-	
+
 	public function new() {
 	public function new() {
 		super(null);
 		super(null);
 		camera = new h3d.Camera();
 		camera = new h3d.Camera();
@@ -17,14 +17,14 @@ class Scene extends Object implements h3d.IDrawable {
 		postPasses = [];
 		postPasses = [];
 		prePasses = [];
 		prePasses = [];
 	}
 	}
-	
+
 	override function clone( ?o : Object ) {
 	override function clone( ?o : Object ) {
 		var s = o == null ? new Scene() : cast o;
 		var s = o == null ? new Scene() : cast o;
 		s.camera = camera.clone();
 		s.camera = camera.clone();
 		super.clone(s);
 		super.clone(s);
 		return s;
 		return s;
 	}
 	}
-	
+
 	/**
 	/**
 	 allow to customize render passes (for example, branch sub scene or 2d context)
 	 allow to customize render passes (for example, branch sub scene or 2d context)
 	 */
 	 */
@@ -34,16 +34,16 @@ class Scene extends Object implements h3d.IDrawable {
 		else
 		else
 			postPasses.push(p);
 			postPasses.push(p);
 	}
 	}
-	
+
 	public function removePass(p) {
 	public function removePass(p) {
 		postPasses.remove(p);
 		postPasses.remove(p);
 		prePasses.remove(p);
 		prePasses.remove(p);
 	}
 	}
-	
+
 	public function setElapsedTime( elapsedTime ) {
 	public function setElapsedTime( elapsedTime ) {
 		ctx.elapsedTime = elapsedTime;
 		ctx.elapsedTime = elapsedTime;
 	}
 	}
-	
+
 	function createDefaultPass( name : String ) : h3d.pass.Base {
 	function createDefaultPass( name : String ) : h3d.pass.Base {
 		switch( name ) {
 		switch( name ) {
 		case "default", "alpha", "additive":
 		case "default", "alpha", "additive":
@@ -57,11 +57,11 @@ class Scene extends Object implements h3d.IDrawable {
 			return null;
 			return null;
 		}
 		}
 	}
 	}
-	
+
 	function get_mainPass() {
 	function get_mainPass() {
 		return getPass("default");
 		return getPass("default");
 	}
 	}
-	
+
 	public function getPass( name : String ) {
 	public function getPass( name : String ) {
 		var p = passes.get(name);
 		var p = passes.get(name);
 		if( p == null ) {
 		if( p == null ) {
@@ -70,7 +70,7 @@ class Scene extends Object implements h3d.IDrawable {
 		}
 		}
 		return p;
 		return p;
 	}
 	}
-	
+
 	public function setPass( name : String, p : h3d.pass.Base ) {
 	public function setPass( name : String, p : h3d.pass.Base ) {
 		passes.set(name, p);
 		passes.set(name, p);
 	}
 	}
@@ -111,7 +111,7 @@ class Scene extends Object implements h3d.IDrawable {
 		@:privateAccess passes.sort(function(p1, p2) return p2.render.priority - p1.render.priority);
 		@:privateAccess passes.sort(function(p1, p2) return p2.render.priority - p1.render.priority);
 		for( p in passes )
 		for( p in passes )
 			p.pass = p.render.draw(ctx, p.pass);
 			p.pass = p.render.draw(ctx, p.pass);
-		
+
 		// relink pass objects to reuse
 		// relink pass objects to reuse
 		var count = 0;
 		var count = 0;
 		var prev : h3d.pass.Object = null;
 		var prev : h3d.pass.Object = null;
@@ -132,5 +132,5 @@ class Scene extends Object implements h3d.IDrawable {
 		ctx.camera = null;
 		ctx.camera = null;
 		ctx.engine = null;
 		ctx.engine = null;
 	}
 	}
-	
+
 }
 }

+ 13 - 13
h3d/scene/Skin.hx

@@ -3,7 +3,7 @@ package h3d.scene;
 class Joint extends Object {
 class Joint extends Object {
 	public var skin : Skin;
 	public var skin : Skin;
 	public var index : Int;
 	public var index : Int;
-	
+
 	public function new(skin, j : h3d.anim.Skin.Joint ) {
 	public function new(skin, j : h3d.anim.Skin.Joint ) {
 		super(null);
 		super(null);
 		name = j.name;
 		name = j.name;
@@ -12,7 +12,7 @@ class Joint extends Object {
 		this.parent = skin;
 		this.parent = skin;
 		this.index = j.index;
 		this.index = j.index;
 	}
 	}
-	
+
 	@:access(h3d.scene.Skin)
 	@:access(h3d.scene.Skin)
 	override function syncPos() {
 	override function syncPos() {
 		// check if one of our parents has changed
 		// check if one of our parents has changed
@@ -46,7 +46,7 @@ class Joint extends Object {
 }
 }
 
 
 class Skin extends MultiMaterial {
 class Skin extends MultiMaterial {
-	
+
 	var skinData : h3d.anim.Skin;
 	var skinData : h3d.anim.Skin;
 	var currentRelPose : Array<h3d.Matrix>;
 	var currentRelPose : Array<h3d.Matrix>;
 	var currentAbsPose : Array<h3d.Matrix>;
 	var currentAbsPose : Array<h3d.Matrix>;
@@ -65,7 +65,7 @@ class Skin extends MultiMaterial {
 		if( s != null )
 		if( s != null )
 			setSkinData(s);
 			setSkinData(s);
 	}
 	}
-	
+
 	override function clone( ?o : Object ) {
 	override function clone( ?o : Object ) {
 		var s = o == null ? new Skin(null,materials.copy()) : cast o;
 		var s = o == null ? new Skin(null,materials.copy()) : cast o;
 		super.clone(s);
 		super.clone(s);
@@ -73,8 +73,8 @@ class Skin extends MultiMaterial {
 		s.currentRelPose = currentRelPose.copy(); // copy current pose
 		s.currentRelPose = currentRelPose.copy(); // copy current pose
 		return s;
 		return s;
 	}
 	}
-	
-	
+
+
 	override function getBounds( ?b : h3d.col.Bounds, rec = false ) {
 	override function getBounds( ?b : h3d.col.Bounds, rec = false ) {
 		b = super.getBounds(b, rec);
 		b = super.getBounds(b, rec);
 		var tmp = primitive.getBounds().clone();
 		var tmp = primitive.getBounds().clone();
@@ -107,13 +107,13 @@ class Skin extends MultiMaterial {
 		}
 		}
 		return null;
 		return null;
 	}
 	}
-	
+
 	override function calcAbsPos() {
 	override function calcAbsPos() {
 		super.calcAbsPos();
 		super.calcAbsPos();
 		// if we update our absolute position, rebuild the matrixes
 		// if we update our absolute position, rebuild the matrixes
 		jointsUpdated = true;
 		jointsUpdated = true;
 	}
 	}
-	
+
 	public function setSkinData( s ) {
 	public function setSkinData( s ) {
 		skinData = s;
 		skinData = s;
 		jointsUpdated = true;
 		jointsUpdated = true;
@@ -162,7 +162,7 @@ class Skin extends MultiMaterial {
 		} else
 		} else
 			super.sync(ctx);
 			super.sync(ctx);
 	}
 	}
-	
+
 	override function draw( ctx : RenderContext ) {
 	override function draw( ctx : RenderContext ) {
 		if( splitPalette == null ) {
 		if( splitPalette == null ) {
 			if( paletteChanged ) {
 			if( paletteChanged ) {
@@ -179,21 +179,21 @@ class Skin extends MultiMaterial {
 		if( showJoints )
 		if( showJoints )
 			throw "TODO"; //ctx.addPass(drawJoints);
 			throw "TODO"; //ctx.addPass(drawJoints);
 	}
 	}
-	
+
 	function drawJoints( ctx : RenderContext ) {
 	function drawJoints( ctx : RenderContext ) {
 		/*
 		/*
 		for( j in skinData.allJoints ) {
 		for( j in skinData.allJoints ) {
 			var m = currentAbsPose[j.index];
 			var m = currentAbsPose[j.index];
 			var mp = j.parent == null ? absPos : currentAbsPose[j.parent.index];
 			var mp = j.parent == null ? absPos : currentAbsPose[j.parent.index];
 			ctx.engine.line(mp._41, mp._42, mp._43, m._41, m._42, m._43, j.parent == null ? 0xFF0000FF : 0xFFFFFF00);
 			ctx.engine.line(mp._41, mp._42, mp._43, m._41, m._42, m._43, j.parent == null ? 0xFF0000FF : 0xFFFFFF00);
-			
+
 			var dz = new h3d.Vector(0, 0.01, 0);
 			var dz = new h3d.Vector(0, 0.01, 0);
 			dz.transform(m);
 			dz.transform(m);
 			ctx.engine.line(m._41, m._42, m._43, dz.x, dz.y, dz.z, 0xFF00FF00);
 			ctx.engine.line(m._41, m._42, m._43, dz.x, dz.y, dz.z, 0xFF00FF00);
-			
+
 			ctx.engine.point(m._41, m._42, m._43, j.bindIndex < 0 ? 0xFF0000FF : 0xFFFF0000);
 			ctx.engine.point(m._41, m._42, m._43, j.bindIndex < 0 ? 0xFF0000FF : 0xFFFF0000);
 		}
 		}
 		*/
 		*/
 	}
 	}
-	
+
 }
 }

+ 1 - 1
h3d/shader/AlphaMap.hx

@@ -12,7 +12,7 @@ class AlphaMap extends hxsl.Shader {
 			pixelColor.a *= texture.get(calculatedUV * uvScale + uvDelta).b;
 			pixelColor.a *= texture.get(calculatedUV * uvScale + uvDelta).b;
 		}
 		}
 	}
 	}
-	
+
 	public function new(texture) {
 	public function new(texture) {
 		super();
 		super();
 		uvScale.set(1, 1);
 		uvScale.set(1, 1);

+ 8 - 8
h3d/shader/AmbientLight.hx

@@ -3,32 +3,32 @@ package h3d.shader;
 class AmbientLight extends hxsl.Shader {
 class AmbientLight extends hxsl.Shader {
 
 
 	static var SRC = {
 	static var SRC = {
-		
+
 		@global var global : {
 		@global var global : {
 			var ambientLight : Vec3;
 			var ambientLight : Vec3;
 			@const var perPixelLighting : Bool;
 			@const var perPixelLighting : Bool;
 		};
 		};
-		
+
 		var pixelColor : Vec4;
 		var pixelColor : Vec4;
 		var lightPixelColor : Vec3;
 		var lightPixelColor : Vec3;
 		var lightColor : Vec3;
 		var lightColor : Vec3;
-		
+
 		function __init__() {
 		function __init__() {
 			lightColor = global.ambientLight;
 			lightColor = global.ambientLight;
 		}
 		}
-		
+
 		function __init__fragment() {
 		function __init__fragment() {
 			lightPixelColor = global.ambientLight;
 			lightPixelColor = global.ambientLight;
 		}
 		}
-		
+
 		function vertex() {
 		function vertex() {
 			if( !global.perPixelLighting ) pixelColor.rgb *= lightColor;
 			if( !global.perPixelLighting ) pixelColor.rgb *= lightColor;
 		}
 		}
-		
+
 		function fragment() {
 		function fragment() {
 			if( global.perPixelLighting ) pixelColor.rgb *= lightPixelColor;
 			if( global.perPixelLighting ) pixelColor.rgb *= lightPixelColor;
 		}
 		}
-		
+
 	}
 	}
-	
+
 }
 }

+ 3 - 3
h3d/shader/BlurShader.hx

@@ -11,13 +11,13 @@ class BlurShader extends hxsl.Shader {
 			position : Vec4,
 			position : Vec4,
 			color : Vec4,
 			color : Vec4,
 		};
 		};
-		
+
 		@param var texture : Sampler2D;
 		@param var texture : Sampler2D;
 		@param @const var Quality : Int;
 		@param @const var Quality : Int;
 		@param @const var isDepth : Bool;
 		@param @const var isDepth : Bool;
 		@param var values : Array<Float,Quality>;
 		@param var values : Array<Float,Quality>;
 		@param var pixel : Vec2;
 		@param var pixel : Vec2;
-		
+
 		function vertex() {
 		function vertex() {
 			output.position = vec4(input.position, 0, 1);
 			output.position = vec4(input.position, 0, 1);
 		}
 		}
@@ -35,5 +35,5 @@ class BlurShader extends hxsl.Shader {
 			}
 			}
 		}
 		}
 	}
 	}
-	
+
 }
 }

+ 1 - 1
h3d/shader/Buffers.hx

@@ -21,7 +21,7 @@ class ShaderBuffers {
 }
 }
 
 
 class Buffers {
 class Buffers {
-	
+
 	public var vertex : ShaderBuffers;
 	public var vertex : ShaderBuffers;
 	public var fragment : ShaderBuffers;
 	public var fragment : ShaderBuffers;
 
 

+ 3 - 3
h3d/shader/ColorAdd.hx

@@ -4,15 +4,15 @@ class ColorAdd extends hxsl.Shader {
 
 
 	static var SRC = {
 	static var SRC = {
 		var pixelColor : Vec4;
 		var pixelColor : Vec4;
-		
+
 		@param var color : Vec3;
 		@param var color : Vec3;
 
 
 		function fragment() {
 		function fragment() {
 			pixelColor.rgb += color;
 			pixelColor.rgb += color;
 		}
 		}
-		
+
 	};
 	};
-	
+
 	public function new( color : Int = 0 ) {
 	public function new( color : Int = 0 ) {
 		super();
 		super();
 		this.color.setColor(color);
 		this.color.setColor(color);

+ 3 - 3
h3d/shader/ColorKey.hx

@@ -5,16 +5,16 @@ class ColorKey extends hxsl.Shader {
 	static var SRC = {
 	static var SRC = {
 		@param var colorKey : Vec4;
 		@param var colorKey : Vec4;
 		var textureColor : Vec4;
 		var textureColor : Vec4;
-		
+
 		function fragment() {
 		function fragment() {
 			var cdiff = textureColor - colorKey;
 			var cdiff = textureColor - colorKey;
 			if( cdiff.dot(cdiff) < 0.00001 ) discard;
 			if( cdiff.dot(cdiff) < 0.00001 ) discard;
 		}
 		}
 	}
 	}
-	
+
 	public function new( v = 0 ) {
 	public function new( v = 0 ) {
 		super();
 		super();
 		colorKey.setColor(v);
 		colorKey.setColor(v);
 	}
 	}
-	
+
 }
 }

+ 3 - 3
h3d/shader/ColorMatrix.hx

@@ -4,15 +4,15 @@ class ColorMatrix extends hxsl.Shader {
 
 
 	static var SRC = {
 	static var SRC = {
 		var pixelColor : Vec4;
 		var pixelColor : Vec4;
-		
+
 		@param var matrix : Mat4;
 		@param var matrix : Mat4;
 
 
 		function fragment() {
 		function fragment() {
 			pixelColor *= matrix;
 			pixelColor *= matrix;
 		}
 		}
-		
+
 	};
 	};
-	
+
 	public function new( ?m : Array<Float> ) {
 	public function new( ?m : Array<Float> ) {
 		super();
 		super();
 		if( m != null ) this.matrix.load(m) else this.matrix.identity();
 		if( m != null ) this.matrix.load(m) else this.matrix.identity();

部分文件因为文件数量过多而无法显示