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

+ 19 - 19
h2d/Console.hx

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

+ 18 - 18
h2d/Drawable.hx

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

+ 11 - 11
h2d/Font.hx

@@ -11,22 +11,22 @@ class Kerning {
 }
 
 class FontChar {
-	
+
 	public var t : h2d.Tile;
 	public var width : Int;
 	var kerning : Null<Kerning>;
-	
+
 	public function new(t,w) {
 		this.t = t;
 		this.width = w;
 	}
-	
+
 	public function addKerning( prevChar : Int, offset : Int ) {
 		var k = new Kerning(prevChar, offset);
 		k.next = kerning;
 		kerning = k;
 	}
-	
+
 	public function getKerningOffset( prevChar : Int ) {
 		var k = kerning;
 		while( k != null ) {
@@ -40,7 +40,7 @@ class FontChar {
 }
 
 class Font {
-	
+
 	public var name(default, null) : String;
 	public var size(default, null) : Int;
 	public var lineHeight(default, null) : Int;
@@ -48,7 +48,7 @@ class Font {
 	public var charset : hxd.Charset;
 	var glyphs : Map<Int,FontChar>;
 	var defaultChar : FontChar;
-	
+
 	function new(name,size) {
 		this.name = name;
 		this.size = size;
@@ -56,7 +56,7 @@ class Font {
 		defaultChar = new FontChar(new Tile(null, 0, 0, 0, 0),0);
 		charset = hxd.Charset.getDefault();
 	}
-	
+
 	public inline function getChar( code : Int ) {
 		var c = glyphs.get(code);
 		if( c == null ) {
@@ -65,7 +65,7 @@ class Font {
 		}
 		return c;
 	}
-	
+
 	/**
 		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);
 		this.size = size;
 	}
-	
+
 	public function hasChar( code : Int ) {
 		return glyphs.get(code) != null;
 	}
-	
+
 	public function dispose() {
 		tile.dispose();
 	}
-	
+
 }

+ 1 - 1
h2d/HtmlText.hx

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

+ 9 - 9
h2d/Layers.hx

@@ -1,25 +1,25 @@
 package h2d;
 
 class Layers extends Sprite {
-	
+
 	// the per-layer insert position
 	var layers : Array<Int>;
 	var layerCount : Int;
-	
+
 	public function new(?parent) {
 		super(parent);
 		layers = [];
 		layerCount = 0;
 	}
-	
+
 	override function addChild(s) {
 		addChildAt(s, 0);
 	}
-	
+
 	public inline function add(s, layer) {
 		return addChildAt(s, layer);
 	}
-	
+
 	override function addChildAt( s : Sprite, layer : Int ) {
 		if( s.parent == this ) {
 			var old = s.allocated;
@@ -34,7 +34,7 @@ class Layers extends Sprite {
 		for( i in layer...layerCount )
 			layers[i]++;
 	}
-	
+
 	override function removeChild( s : Sprite ) {
 		for( i in 0...childs.length ) {
 			if( childs[i] == s ) {
@@ -50,7 +50,7 @@ class Layers extends Sprite {
 			}
 		}
 	}
-	
+
 	public function under( s : Sprite ) {
 		for( i in 0...childs.length )
 			if( childs[i] == s ) {
@@ -83,7 +83,7 @@ class Layers extends Sprite {
 				break;
 			}
 	}
-	
+
 	public function ysort( layer : Int ) {
 		if( layer >= layerCount ) return;
 		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;
 
 class RenderContext {
-	
+
 	public var engine : h3d.Engine;
 	public var time : Float;
 	public var elapsedTime : Float;
@@ -9,7 +9,7 @@ class RenderContext {
 
 	public var buffer : hxd.FloatBuffer;
 	public var bufPos : Int;
-	
+
 	var texture : h3d.mat.Texture;
 	var baseShader : h3d.shader.Base2d;
 	var manager : h3d.shader.Manager;
@@ -19,7 +19,7 @@ class RenderContext {
 	var currentShaders : Array<hxsl.Shader>;
 	var currentObj : Drawable;
 	var stride : Int;
-	
+
 	public function new() {
 		frame = 0;
 		time = 0.;
@@ -33,7 +33,7 @@ class RenderContext {
 		baseShader = new h3d.shader.Base2d();
 		baseShader.zValue = 0.;
 	}
-	
+
 	public function begin() {
 		texture = null;
 		currentObj = null;
@@ -45,20 +45,20 @@ class RenderContext {
 		engine.selectMaterial(pass);
 		engine.uploadShaderBuffers(buffers, Globals);
 	}
-	
+
 	function initShaders( shaders ) {
 		currentShaders = shaders;
 		compiledShader = manager.compileShaders(shaders);
 		buffers = new h3d.shader.Buffers(compiledShader);
 		manager.fillGlobals(buffers, compiledShader);
 	}
-	
+
 	public function end() {
 		flush();
 		texture = null;
 		currentObj = null;
 	}
-	
+
 	public function flush(force=false) {
 		if( bufPos == 0 ) return;
 		beforeDraw();
@@ -70,7 +70,7 @@ class RenderContext {
 		bufPos = 0;
 		texture = null;
 	}
-	
+
 	public function beforeDraw() {
 		baseShader.texture = texture;
 		texture.filter = currentObj.filter ? Linear : Nearest;
@@ -93,7 +93,7 @@ class RenderContext {
 		engine.uploadShaderBuffers(buffers, Params);
 		engine.uploadShaderBuffers(buffers, Textures);
 	}
-	
+
 	@:access(h2d.Drawable)
 	public function beginDrawObject( obj : h2d.Drawable, texture : h3d.mat.Texture ) {
 		beginDraw(obj, texture, true);
@@ -102,12 +102,12 @@ class RenderContext {
 		baseShader.absoluteMatrixB.set(obj.matB, obj.matD, obj.absY);
 		beforeDraw();
 	}
-	
+
 	@:access(h2d.Drawable)
 	public function beginDrawBatch( obj : h2d.Drawable, texture : h3d.mat.Texture ) {
 		beginDraw(obj, texture, false);
 	}
-	
+
 	@:access(h2d.Drawable)
 	function beginDraw(	obj : h2d.Drawable, texture : h3d.mat.Texture, isRelative : Bool ) {
 		var stride = 8;
@@ -144,7 +144,7 @@ class RenderContext {
 			for( i in 0...obj.shaders.length )
 				currentShaders[i+1] = obj.shaders[i];
 		}
-			
+
 		this.texture = texture;
 		this.stride = stride;
 		this.currentObj = obj;

+ 14 - 14
h2d/ScaleGrid.hx

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

+ 4 - 4
h2d/Scene3D.hx

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

+ 4 - 4
h2d/SpriteBatch.hx

@@ -37,15 +37,15 @@ class BatchElement {
 		rotation = 0; scale = 1;
 		this.t = t;
 	}
-	
+
 	inline function get_alpha() {
 		return a;
 	}
-	
+
 	inline function set_alpha(v) {
 		return a = v;
 	}
-	
+
 	function update(et:Float) {
 		return true;
 	}
@@ -242,7 +242,7 @@ class SpriteBatch extends Drawable {
 	public inline function isEmpty() {
 		return first == null;
 	}
-	
+
 	public inline function getElements() {
 		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;
 		yMax = hxd.Math.NEGATIVE_INFINITY;
 	}
-	
+
 	public function isEmpty() {
 		return triCount() == 0;
 	}
@@ -70,7 +70,7 @@ private class TileLayerContent extends h3d.prim.Primitive {
 		tmp.push(b);
 		tmp.push(a);
 	}
-	
+
 	public function addPoint( x : Float, y : Float, color : Int ) {
 		tmp.push(x);
 		tmp.push(y);
@@ -82,7 +82,7 @@ private class TileLayerContent extends h3d.prim.Primitive {
 		if( x > xMax ) xMax = x;
 		if( y > yMax ) yMax = y;
 	}
-	
+
 	inline function insertColor( c : Int ) {
 		tmp.push(((c >> 16) & 0xFF) / 255.);
 		tmp.push(((c >> 8) & 0xFF) / 255.);
@@ -204,7 +204,7 @@ class TileGroup extends Drawable {
 	override function draw(ctx:RenderContext) {
 		drawWith(ctx,this);
 	}
-	
+
 	@:allow(h2d)
 	function drawWith( ctx:RenderContext, obj : Drawable ) {
 		ctx.beginDrawObject(obj, tile.getTexture());

+ 4 - 4
h2d/col/Circle.hx

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

File diff suppressed because it is too large
+ 0 - 0
h2d/col/Delaunay.hx


+ 6 - 6
h2d/col/Line.hx

@@ -9,18 +9,18 @@ class Line {
 		this.p1 = p1;
 		this.p2 = p2;
 	}
-	
+
 	public inline function side( p : Point ) {
 		return (p2.x - p1.x) * (p.y - p1.y) - (p2.y - p1.y) * (p.x - p1.x);
 	}
-	
+
 	public inline function project( p : Point ) {
 		var dx = p2.x - p1.x;
 		var dy = p2.y - p1.y;
 		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);
 	}
-	
+
 	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);
 		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;
 		return true;
 	}
-	
+
 	public inline function distanceSq( p : Point ) {
 		var dx = p2.x - p1.x;
 		var dy = p2.y - p1.y;
@@ -49,9 +49,9 @@ class Line {
 		var my = dy * k + p1.y - p.y;
 		return mx * mx + my * my;
 	}
-	
+
 	public inline function distance( p : Point ) {
 		return hxd.Math.sqrt(distanceSq(p));
 	}
-	
+
 }

+ 7 - 7
h2d/col/Point.hx

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

+ 8 - 8
h2d/col/Poly.hx

@@ -5,11 +5,11 @@ class Poly {
 
 	public var points : Array<Point>;
 	var segments : Array<Seg>;
-	
+
 	public function new( points ) {
 		this.points = points;
 	}
-		
+
 	public function isConvex() {
 		for( i in 0...points.length ) {
 			var p1 = points[i];
@@ -20,7 +20,7 @@ class Poly {
 		}
 		return true;
 	}
-	
+
 	public function calculateArea() {
 		var s = 0.;
 		for( i in 0...points.length ) {
@@ -41,14 +41,14 @@ class Poly {
 		}
 		return segments;
 	}
-	
+
 	public function hasPoint( p : Point ) {
 		for( s in getSegments() )
 			if( s.side(p) < 0 )
 				return false;
 		return true;
 	}
-	
+
 	public function project( p : Point ) : Point {
 		var dmin = 1e20, smin = null;
 		for( s in getSegments() ) {
@@ -60,7 +60,7 @@ class Poly {
 		}
 		return smin.project(p);
 	}
-	
+
 	public function distanceSq( p : Point ) {
 		var dmin = 1e20;
 		for( s in getSegments() ) {
@@ -69,9 +69,9 @@ class Poly {
 		}
 		return dmin;
 	}
-	
+
 	public inline function distance( p : Point ) {
 		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 m : Int;
 	public var n : Int;
-	
+
 	public function new(m, n) {
 		this.m = m;
 		this.n = n;
@@ -12,7 +12,7 @@ private class Matrix {
 		for( i in 0...m )
 			data[i] = new haxe.ds.Vector(n);
 	}
-	
+
 	public function clone() {
 		var m2 = new Matrix(m, n);
 		for( i in 0...m )
@@ -20,25 +20,25 @@ private class Matrix {
 				m2.data[i][j] = data[i][j];
 		return m2;
 	}
-	
+
 	function toString() {
 		return "[" + [for( k in data ) "\n" + Std.string(k)].join("") + "\n]";
 	}
 }
 
 private class QR {
-	
+
 	var qr : haxe.ds.Vector<haxe.ds.Vector<Float>>;
 	var rDiag : haxe.ds.Vector<Float>;
 	var m : Int;
 	var n : Int;
-	
+
 	public function new( mat : Matrix ) {
 		this.m = mat.m;
 		this.n = mat.n;
 		qr = mat.clone().data;
 		rDiag = new haxe.ds.Vector(n);
-		
+
 		for( k in 0...n ) {
 			var nrm = 0.;
 			for( i in k...m )
@@ -60,14 +60,14 @@ private class QR {
 			rDiag[k] = -nrm;
 		}
 	}
-	
+
 	function isFullRank() {
 		for( j in 0...n )
 			if( rDiag[j] == 0 )
 				return false;
 		return true;
 	}
-	
+
 	public function solve( b : Matrix ) {
 		if( b.m != m ) throw "Invalid matrix size";
 		if( !isFullRank() ) return null;
@@ -96,7 +96,7 @@ private class QR {
 			beta.push(X[i][0]);
 		return beta;
 	}
-	
+
 	function hypot( x : Float, y : Float ) {
 		if( x < 0 ) x = -x;
 		if( y < 0 ) y = -y;
@@ -109,7 +109,7 @@ private class QR {
 		t = t/x;
 		return x * Math.sqrt(1+t*t);
 	}
-	
+
 }
 
 class Polynomial {
@@ -129,11 +129,11 @@ class Polynomial {
 		for( i in 0...n )
 			for( j in 0...degree+1 )
 				x.data[i][j] = Math.pow(xVals[i], j);
-				
+
 		var y = new Matrix(yVals.length, n);
 		for( i in 0...yVals.length )
 			y.data[i][0] = yVals[i];
-		
+
 		var qr = new QR(x);
 		var beta = qr.solve(y);
 		if( beta == null ) {
@@ -142,5 +142,5 @@ class Polynomial {
 		}
 		return beta;
 	}
-	
+
 }

+ 3 - 3
h2d/col/RoundRect.hx

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

+ 5 - 5
h2d/col/Seg.hx

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

+ 7 - 7
h2d/col/Triangle.hx

@@ -1,26 +1,26 @@
 package h2d.col;
 
 class Triangle {
-	
+
 	static inline var UNDEF = 1.1315e-17;
-	
+
 	public var a : Point;
 	public var b : Point;
 	public var c : Point;
 	var area : Float;
 	var invArea : Float;
-	
+
 	public inline function new( a : Point, b : Point, c : Point ) {
 		this.a = a;
 		this.b = b;
 		this.c = c;
 		area = UNDEF;
 	}
-	
+
 	public inline function getCenter() {
 		return new Point((a.x + b.x + c.x) / 3, (a.y + b.y + c.y) / 3);
 	}
-	
+
 	public function getArea() {
 		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;
@@ -33,7 +33,7 @@ class Triangle {
 		getArea();
 		return invArea;
 	}
-	
+
 	/**
 		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);
 		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>> {
-	
+
 	public var root : T;
-	
+
 	public function new() {
 		this.root = null;
     }
@@ -320,17 +320,17 @@ private class RBNode<T:RBNode<T>> {
 }
 
 class Cell {
-	
+
 	public var id : Int;
 	public var point : Point;
 	public var halfedges : Array<Halfedge>;
-	
+
 	public function new(id, point) {
 		this.id = id;
 		this.point = point;
 		this.halfedges = [];
     }
-	
+
 	public function getCircle() {
 		// 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
@@ -371,7 +371,7 @@ class Cell {
 		halfedges.sort(sortByAngle);
 		return halfedges.length;
 	}
-	
+
 	static function sortByAngle(a:Halfedge, b:Halfedge) {
 		return b.angle > a.angle ? 1 : (b.angle < a.angle ? -1 : 0);
 	}
@@ -455,7 +455,7 @@ class Cell {
 			}
 		return 1;
 	}
-	
+
 }
 
 class Edge {
@@ -467,7 +467,7 @@ class Edge {
 	public var rCell : Null<Cell>;
 	public var va : Null<Point>;
 	public var vb : Null<Point>;
-	
+
 	public function new(lPoint, rPoint) {
 		this.lPoint = lPoint;
 		this.rPoint = rPoint;
@@ -477,11 +477,11 @@ class Edge {
 
 
 class Halfedge {
-	
+
 	public var point : Point;
 	public var edge : Edge;
 	public var angle : Float;
-	
+
 	public function new(edge, lPoint:Point, rPoint:Point) {
 		this.point = lPoint;
 		this.edge = edge;
@@ -504,7 +504,7 @@ class Halfedge {
 				: Math.atan2(va.x-vb.x, vb.y-va.y);
 		}
 	}
-	
+
 	public inline function getStartpoint() {
 		return this.edge.lPoint == this.point ? this.edge.va : this.edge.vb;
     }
@@ -512,7 +512,7 @@ class Halfedge {
 	public inline function getEndpoint() {
 		return this.edge.lPoint == this.point ? this.edge.vb : this.edge.va;
     }
-	
+
 	public inline function getTarget() {
 		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 {
-	
+
 	var epsilon : Float;
 	var beachline : RBTree<Beachsection>;
 	var vertices : Array<Point>;
@@ -646,7 +646,7 @@ class Voronoi {
 	function setEdgeEndpoint(edge, lPoint, rPoint, vertex) {
 		this.setEdgeStartpoint(edge, rPoint, lPoint, vertex);
     }
-	
+
 
 	// rhill 2011-06-02: A lot of Beachsection instanciations
 	// occur during the computation of the Voronoi diagram,
@@ -1406,7 +1406,7 @@ class Voronoi {
 		var r = b.y - a.y;
 		return r < 0 ? -1 : (r > 0 ? 1 : (b.x > a.x ? 1 : b.x < a.x ? -1 : 0));
 	}
-	
+
 	// rhill 2011-05-19:
 	//   Voronoi points are kept client-side now, to allow
 	//   user to freely modify content. At compute time,
@@ -1463,7 +1463,7 @@ class Voronoi {
 			// all done, quit
 			else
 				break;
-				
+
 		}
 
 		// wrapping-up:
@@ -1475,7 +1475,7 @@ class Voronoi {
 
 		//   add missing edges in order to close opened cells
 		this.closeCells(bbox);
-		
+
 		var eid = 0;
 		for( e in edges ) {
 			e.id = eid++;

+ 5 - 5
h2d/comp/Box.hx

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

+ 6 - 6
h2d/comp/Button.hx

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

+ 7 - 7
h2d/comp/Checkbox.hx

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

+ 7 - 7
h2d/comp/Color.hx

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

+ 61 - 61
h2d/comp/ColorPicker.hx

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

+ 9 - 9
h2d/comp/Context.hx

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

+ 76 - 76
h2d/comp/GradientEditor.hx

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

+ 8 - 8
h2d/comp/Interactive.hx

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

+ 7 - 7
h2d/comp/ItemList.hx

@@ -1,28 +1,28 @@
 package h2d.comp;
 
 class ItemList extends Box {
-	
+
 	public var selected(default,set) = -1;
 	var inputs : Array<h2d.Interactive>;
-	
+
 	public function new(?parent) {
 		super(Vertical, parent);
 		this.name = "itemlist";
 		inputs = [];
 	}
-	
+
 	function set_selected(v:Int) {
 		needRebuild = true;
 		return selected = v;
 	}
-	
+
 	function onWheel( e : hxd.Event ) {
 		scrollY -= e.wheelDelta * (components.length == 0 ? 0 : (components[0].height + style.verticalSpacing));
 		if( scrollY > 0 ) scrollY = 0;
 		e.propagate = false;
 		needRebuild = true;
 	}
-	
+
 	override function resizeRec( ctx : Context ) {
 		super.resizeRec(ctx);
 		if( !ctx.measure ) {
@@ -85,8 +85,8 @@ class ItemList extends Box {
 
 	public dynamic function onItemOver( current : 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)
 @:keep
 class JQuery {
-	
+
 	var root : Component;
 	var select : Array<Component>;
-	
+
 	public function new( root : Component, query : Dynamic ) {
 		while( root.parentComponent != null )
 			root = root.parentComponent;
 		this.root = root;
 		select = getSet(query);
 	}
-	
+
 	public function getComponents() {
 		return select;
 	}
-	
+
 	public function toggleClass( cl : String, ?flag : Bool ) {
 		for( s in select ) s.toggleClass(cl,flag);
 		return this;
 	}
-	
+
 	public function find( q : Dynamic ) {
 		if( Std.is(q, Component) )
 			return new JQuery(root, Lambda.has(select, q) ? null : q);
@@ -39,7 +39,7 @@ class JQuery {
 		throw "Invalid JQuery " + q;
 		return null;
 	}
-	
+
 	public function filter( q : Dynamic ) {
 		if( Std.is(q, Component) )
 			return new JQuery(root, Lambda.has(select, q) ? null : q);
@@ -69,7 +69,7 @@ class JQuery {
 		throw "Invalid JQuery " + q;
 		return null;
 	}
-	
+
 	public function click( f : JQuery -> Void ) {
 		for( c in select ) {
 			var int = Std.instance(c, Interactive);
@@ -78,7 +78,7 @@ class JQuery {
 		}
 		return this;
 	}
-	
+
 	public function show() {
 		for( s in select )
 			s.getStyle(true).display = true;
@@ -90,7 +90,7 @@ class JQuery {
 			s.getStyle(true).display = false;
 		return this;
 	}
-	
+
 	public function toggle() {
 		for( s in select ) {
 			var s = s.getStyle(true);
@@ -98,7 +98,7 @@ class JQuery {
 		}
 		return this;
 	}
-	
+
 	public function iterator() {
 		var it = select.iterator();
 		return {
@@ -161,7 +161,7 @@ class JQuery {
 			"";
 		}
 	}
-	
+
 	function _set_text(v:String) {
 		for( c in select )
 			switch( c.name ) {
@@ -173,7 +173,7 @@ class JQuery {
 			}
 		return this;
 	}
-	
+
 	function _set_style(v:String) {
 		var s = new h2d.css.Style();
 		new h2d.css.Parser().parse(v, s);
@@ -181,7 +181,7 @@ class JQuery {
 			c.addStyle(s);
 		return this;
 	}
-	
+
 	function getSet( query : Dynamic ) {
 		var set;
 		if( query == null )
@@ -198,29 +198,29 @@ class JQuery {
 			throw "Invalid JQuery " + query;
 		return set;
 	}
-	
+
 	function lookup( root : Component, query : String ) {
 		var set = [];
 		lookupRec(root, parseQuery(query), set);
 		return set;
 	}
-	
+
 	function parseQuery(q) : Query {
 		return new h2d.css.Parser().parseClasses(q);
 	}
-	
+
 	function matchQuery(q:Query, comp:Component) {
 		for( r in q )
 			if( h2d.css.Engine.ruleMatch(r, comp) )
 				return true;
 		return false;
 	}
-	
+
 	function lookupRec(comp:Component, q, set : Array<Component> ) {
 		if( matchQuery(q, comp) )
 			set.push(comp);
 		for( s in comp.components )
 			lookupRec(s, q, set);
 	}
-	
+
 }

+ 6 - 6
h2d/comp/Label.hx

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

+ 7 - 7
h2d/comp/Parser.hx

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

+ 12 - 12
h2d/comp/Select.hx

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

+ 6 - 6
h2d/comp/Slider.hx

@@ -1,20 +1,20 @@
 package h2d.comp;
 
 class Slider extends Component {
-	
+
 	var cursor : Button;
 	var input : h2d.Interactive;
 	public var minValue : Float = 0.;
 	public var maxValue : Float = 1.;
 	public var value(default, set) : Float;
-	
+
 	@:access(h2d.comp.Button)
 	public function new(?parent) {
 		super("slider", parent);
 		cursor = new Button("", this);
 		cursor.input.cancelEvents = true;
 		cursor.onMouseDown = function() {
-			
+
 		};
 		input = new h2d.Interactive(0, 0, this);
 		input.onPush = function(e) {
@@ -29,11 +29,11 @@ class Slider extends Component {
 		}
 		value = 0.;
 	}
-	
+
 	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;
 	}
-	
+
 	function gotoValue( v : Float ) {
 		if( v < minValue ) v = minValue;
 		if( v > maxValue ) v = maxValue;
@@ -51,7 +51,7 @@ class Slider extends Component {
 			value = v;
 		onChange(value);
 	}
-	
+
 	function set_value(v:Float) {
 		if( v < minValue ) v = minValue;
 		if( v > maxValue ) v = maxValue;

+ 2 - 2
h2d/css/Fill.hx

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

+ 5 - 5
h2d/css/Parser.hx

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

+ 6 - 6
h2d/css/Style.hx

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

+ 10 - 10
h3d/Buffer.hx

@@ -32,7 +32,7 @@ class Buffer {
 	public var vertices(default,null) : Int;
 	public var next(default,null) : Buffer;
 	public var flags(default, null) : haxe.EnumFlags<BufferFlag>;
-	
+
 	public function new(vertices, stride, ?flags : Array<BufferFlag>) {
 		id = GUID++;
 		this.vertices = vertices;
@@ -49,7 +49,7 @@ class Buffer {
 	public function isDisposed() {
 		return buffer == null || buffer.isDisposed();
 	}
-	
+
 	public function dispose() {
 		if( buffer != null ) {
 			buffer.freeBuffer(this);
@@ -57,7 +57,7 @@ class Buffer {
 			if( next != null ) next.dispose();
 		}
 	}
-	
+
 	/**
 		Returns the total number of vertices including the potential next buffers if it is split.
 	**/
@@ -70,7 +70,7 @@ class Buffer {
 		}
 		return count;
 	}
-	
+
 	public function uploadVector( buf : hxd.FloatBuffer, bufPos : Int, vertices : Int ) {
 		var cur = this;
 		while( vertices > 0 ) {
@@ -82,7 +82,7 @@ class Buffer {
 			cur = cur.next;
 		}
 	}
-	
+
 	public function uploadBytes( data : haxe.io.Bytes, dataPos : Int, vertices : Int ) {
 		var cur = this;
 		while( vertices > 0 ) {
@@ -94,28 +94,28 @@ class Buffer {
 			cur = cur.next;
 		}
 	}
-	
+
 	public static function ofFloats( v : hxd.FloatBuffer, stride : Int, ?flags, ?vertices ) {
 		var nvert = vertices == null ? Std.int(v.length / stride) : vertices;
 		var b = new Buffer(nvert, stride, flags);
 		b.uploadVector(v, 0, nvert);
 		return b;
 	}
-	
+
 }
 
 class BufferOffset {
 	public var id : Int;
 	public var buffer : Buffer;
 	public var offset : Int;
-	
+
 	/*
 		This is used to return a list of BufferOffset without allocating an array
 	*/
 	public var next : BufferOffset;
-	
+
 	static var UID = 0;
-	
+
 	public function new(buffer, offset) {
 		this.id = UID++;
 		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
 
 class Camera {
-	
+
 	public var zoom : Float;
-	
+
 	/**
 		The screenRatio represents the W/H screen ratio.
 	 **/
 	public var screenRatio : Float;
-	
+
 	/**
 		The horizontal FieldOfView, in degrees.
 	**/
 	public var fovX : Float;
 	public var zNear : Float;
 	public var zFar : Float;
-	
+
 	/**
 		Set orthographic bounds.
 	**/
 	public var orthoBounds : h3d.col.Bounds;
-	
+
 	public var rightHanded : Bool;
-	
+
 	public var mproj : Matrix;
 	public var mcam : Matrix;
 	public var m : Matrix;
-	
+
 	public var pos : Vector;
 	public var up : Vector;
 	public var target : Vector;
-	
+
 	public var viewX : Float = 0.;
 	public var viewY : Float = 0.;
-	
+
 	var minv : Matrix;
 	var needInv : Bool;
 
@@ -54,14 +54,14 @@ class Camera {
 		mproj = new Matrix();
 		update();
 	}
-	
+
 	/**
 		Update the fovX value based on the requested fovY value (in degrees) and current screenRatio.
 	**/
 	public function setFovY( value : Float ) {
 		fovX = Math.atan( Math.tan(value * Math.PI / 180) / screenRatio ) * 180 / Math.PI;
 	}
-	
+
 	public function clone() {
 		var c = new Camera(fovX, zoom, screenRatio, zNear, zFar, rightHanded);
 		c.pos = pos.clone();
@@ -95,20 +95,20 @@ class Camera {
 		p.project(getInverseViewProj());
 		return p;
 	}
-	
+
 	public function update() {
 		makeCameraMatrix(mcam);
 		makeFrustumMatrix(mproj);
 		m.multiply(mcam, mproj);
 		needInv = true;
 	}
-	
+
 	public function lostUp() {
 		var p2 = pos.clone();
 		p2.normalize();
 		return Math.abs(p2.dot3(up)) > 0.999;
 	}
-	
+
 	public function movePosAxis( dx : Float, dy : Float, dz = 0. ) {
 		var p = new Vector(dx, dy, dz);
 		p.project(mcam);
@@ -124,7 +124,7 @@ class Camera {
 		target.y += p.y;
 		target.z += p.z;
 	}
-	
+
 	function makeCameraMatrix( m : Matrix ) {
 		// 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
@@ -156,26 +156,26 @@ class Camera {
 		m._43 = -az.dot3(pos);
 		m._44 = 1;
 	}
-	
+
 	function makeFrustumMatrix( m : Matrix ) {
 		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
 		// Matrixes have to solve the following formulaes :
 		//
 		// transform P by Mproj and divide everything by
 		//    [x,y,-zNear,1] => [sx/zNear, sy/zNear, 0, 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
-		
+
 		var bounds = orthoBounds;
 		if( bounds != null ) {
-			
+
 			var w = 1 / (bounds.xMax - bounds.xMin);
 			var h = 1 / (bounds.yMax - bounds.yMin);
 			var d = 1 / (bounds.zMax - bounds.zMin);
-			
+
 			m._11 = 2 * w;
 			m._22 = 2 * h;
 			m._33 = d;
@@ -183,16 +183,16 @@ class Camera {
 			m._42 = -(bounds.yMin + bounds.yMax) * h;
 			m._43 = -bounds.zMin * d;
 			m._44 = 1;
-			
+
 		} else {
-		
+
 			var scale = zoom / Math.tan(fovX * Math.PI / 360.0);
 			m._11 = scale;
 			m._22 = scale * screenRatio;
 			m._33 = zFar / (zFar - zNear);
 			m._34 = 1;
 			m._43 = -(zNear * zFar) / (zFar - zNear);
-			
+
 		}
 
 		m._11 += viewX * m._14;
@@ -204,12 +204,12 @@ class Camera {
 		m._22 += viewY * m._24;
 		m._32 += viewY * m._34;
 		m._42 += viewY * m._44;
-		
+
 		// our z is negative in that case
 		if( rightHanded ) {
 			m._33 *= -1;
 			m._34 *= -1;
 		}
 	}
-		
+
 }

+ 5 - 5
h3d/Indexes.hx

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

+ 20 - 20
h3d/Matrix.hx

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

+ 23 - 23
h3d/Quat.hx

@@ -2,43 +2,43 @@ package h3d;
 using hxd.Math;
 
 class Quat {
-	
+
 	public var x : Float;
 	public var y : Float;
 	public var z : Float;
 	public var w : Float;
-	
+
 	public inline function new( x = 0., y = 0., z = 0., w = 1. ) {
 		this.x = x;
 		this.y = y;
 		this.z = z;
 		this.w = w;
 	}
-	
+
 	public inline function set(x, y, z, w) {
 		this.x = x;
 		this.y = y;
 		this.z = z;
 		this.w = w;
 	}
-	
+
 	public inline function identity() {
 		x = y = z = 0;
 		w = 1;
 	}
-	
+
 	public inline function lengthSq() {
 		return x * x + y * y + z * z + w * w;
 	}
-	
+
 	public inline function length() {
 		return lengthSq().sqrt();
 	}
-	
+
 	public function clone() {
 		return new Quat(x, y, z, w);
 	}
-	
+
 	public function initMoveTo( from : Vector, to : Vector ) {
 		//		H = Normalize(From + To)
 		//		Q = (From ^ H, From . H)
@@ -54,7 +54,7 @@ class Quat {
 		w = from.x * hx + from.y * hy + from.z * hz;
 		normalize();
 	}
-	
+
 	public function initDirection( dir : Vector ) {
 		// inlined version of initRotationMatrix(Matrix.lookAtX(dir))
 		var ax = dir.clone().getNormalized();
@@ -96,7 +96,7 @@ class Quat {
 			w = (ax.y - ay.x) * is;
 		}
 	}
-	
+
 	public function initRotateAxis( x : Float, y : Float, z : Float, a : Float ) {
 		var sin = (a / 2).sin();
 		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
 		normalize();
 	}
-	
+
 	public function initRotateMatrix( m : Matrix ) {
 		var tr = m._11 + m._22 + m._33;
 		if( tr > 0 ) {
@@ -139,7 +139,7 @@ class Quat {
 			w = (m._12 - m._21) * is;
 		}
 	}
-	
+
 	public function normalize() {
 		var len = x * x + y * y + z * z + w * w;
 		if( len < hxd.Math.EPSILON ) {
@@ -153,7 +153,7 @@ class Quat {
 			w *= m;
 		}
 	}
-	
+
 	public function initRotate( ax : Float, ay : Float, az : Float ) {
 		var sinX = ( ax * 0.5 ).sin();
 		var cosX = ( ax * 0.5 ).cos();
@@ -168,7 +168,7 @@ class Quat {
 		z = cosX * cosY * sinZ - sinX * sinY * cosZ;
 		w = cosX * cosYZ + sinX * sinYZ;
 	}
-	
+
 	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 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;
 		w = w2;
 	}
-	
+
 	public function toMatrix() {
 		var m = new Matrix();
 		saveToMatrix(m);
 		return m;
 	}
-	
+
 	public function toEuler() {
 		return new Vector(
 			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()
 		);
 	}
-	
+
 	public inline function lerp( q1 : Quat, q2 : Quat, v : Float, nearest = false ) {
 		var v2;
 		if( nearest && q1.dot(q2) < 0 )
@@ -232,13 +232,13 @@ class Quat {
 		this.z = q1.z * a + q2.z * b;
 		this.w = q1.w * a + q2.w * b;
 	}
-	
+
 	public inline function conjugate() {
 		x *= -1;
 		y *= -1;
 		z *= -1;
 	}
-	
+
 	/**
 		Negate the quaternion: this will not change the actual angle, use `conjugate` for that.
 	**/
@@ -248,11 +248,11 @@ class Quat {
 		z *= -1;
 		w *= -1;
 	}
-	
+
 	public inline function dot( q : Quat ) {
 		return x * q.x + y * q.y + z * q.z + w * q.w;
 	}
-	
+
 	/**
 		Save to a Left-Handed matrix
 	**/
@@ -284,9 +284,9 @@ class Quat {
 		m._44 = 1;
 		return m;
 	}
-	
+
 	public function toString() {
 		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 alphas : haxe.ds.Vector<Float>;
 	public var uvs : haxe.ds.Vector<Float>;
-	
+
 	override function clone() : AnimatedObject {
 		var o = new FrameObject(objectName);
 		o.frames = frames;
@@ -14,7 +14,7 @@ class FrameObject extends AnimatedObject {
 		return o;
 	}
 }
-	
+
 class FrameAnimation extends Animation {
 
 	var syncFrame : Int;
@@ -23,13 +23,13 @@ class FrameAnimation extends Animation {
 		super(name,frame,sampling);
 		syncFrame = -1;
 	}
-	
+
 	public function addCurve( objName, frames ) {
 		var f = new FrameObject(objName);
 		f.frames = frames;
 		objects.push(f);
 	}
-	
+
 	public function addAlphaCurve( objName, alphas ) {
 		var f = new FrameObject(objName);
 		f.alphas = alphas;
@@ -41,25 +41,25 @@ class FrameAnimation extends Animation {
 		f.uvs = uvs;
 		objects.push(f);
 	}
-	
+
 	inline function getFrames() : Array<FrameObject> {
 		return cast objects;
 	}
-	
+
 	override function initInstance() {
 		super.initInstance();
 		for( a in getFrames() )
 			if( a.alphas != null && (a.targetObject == null || !a.targetObject.isMesh()) )
 				throw a.objectName + " should be a mesh";
 	}
-	
+
 	override function clone(?a:Animation) {
 		if( a == null )
 			a = new FrameAnimation(name, frameCount, sampling);
 		super.clone(a);
 		return a;
 	}
-	
+
 	@:access(h3d.scene.Skin)
 	override function sync( decompose = false ) {
 		if( decompose ) throw "Decompose not supported on Frame Animation";
@@ -80,5 +80,5 @@ class FrameAnimation extends Animation {
 				o.targetObject.defaultTransform = o.frames[frame];
 		}
 	}
-	
+
 }

+ 5 - 5
h3d/anim/SimpleBlend.hx

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

+ 16 - 16
h3d/anim/Skin.hx

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

+ 8 - 8
h3d/anim/SmoothTransition.hx

@@ -12,17 +12,17 @@ class SmoothedObject extends Animation.AnimatedObject {
 }
 
 class SmoothTransition extends Transition {
-	
+
 	static var MZERO = h3d.Matrix.L([
 		1, 0, 0, 0,
 		0, 1, 1, 0,
 		0, 0, 1, 0,
 		0, 0, 0, 1,
 	]);
-	
+
 	public var blendFactor : Float;
 	var tspeed : Float;
-	
+
 	public function new(current, target, speed) {
 		super("smooth", current, target);
 		blendFactor = 0.;
@@ -32,7 +32,7 @@ class SmoothTransition extends Transition {
 		this.isInstance = true;
 		initObjects();
 	}
-	
+
 	function initObjects() {
 		var allObjects = new Map();
 		var mzero = MZERO;
@@ -59,13 +59,13 @@ class SmoothTransition extends Transition {
 			so.isAnim2 = true;
 		}
 	}
-	
+
 	override function bind( base ) {
 		super.bind(base);
 		this.objects = [];
 		initObjects();
 	}
-	
+
 	@:access(h3d.scene.Skin)
 	override function sync( decompose = false ) {
 		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;
 		}
 	}
-	
+
 	override function update( dt : Float ) : Float {
 		var rt = super.update(dt);
 		var st = dt - rt;
@@ -123,5 +123,5 @@ class SmoothTransition extends Transition {
 		}
 		return rt;
 	}
-	
+
 }

+ 8 - 8
h3d/anim/Transition.hx

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

+ 26 - 26
h3d/col/Bounds.hx

@@ -2,18 +2,18 @@ package h3d.col;
 import hxd.Math;
 
 class Bounds {
-	
+
 	public var xMin : Float;
 	public var xMax : Float;
 	public var yMin : Float;
 	public var yMax : Float;
 	public var zMin : Float;
 	public var zMax : Float;
-	
+
 	public inline function new() {
 		empty();
 	}
-	
+
 	public function inFrustum( mvp : Matrix ) {
 		if( testPlane(Plane.frustumLeft(mvp)) < 0 )
 			return false;
@@ -29,7 +29,7 @@ class Bounds {
 			return false;
 		return true;
 	}
-	
+
 	inline function testPlane( p : Plane ) {
 		var a = p.nx;
 		var b = p.ny;
@@ -41,7 +41,7 @@ class Bounds {
 		var rr = a * (xMax - xMin) + b * (yMax - yMin) + c * (zMax - zMin);
 		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.
 	 * @param	mvp : the model-view-projection matrix to test against
@@ -49,7 +49,7 @@ class Bounds {
 	 */
 	public function inFrustumDetails( mvp : Matrix, checkZ = true ) {
 		var ret = 1;
-		
+
 		// left
 		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);
@@ -71,7 +71,7 @@ class Bounds {
 			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);
 		if( n + p.d < 0 ) ret = 0;
-		
+
 		// top
 		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);
@@ -79,7 +79,7 @@ class Bounds {
 			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);
 		if( n + p.d < 0 ) ret = 0;
-				
+
 		if( checkZ ) {
 			// nea
 			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);
 			if( n + p.d < 0 ) ret = 0;
 		}
-		
+
 		return ret;
 	}
-	
+
 	public function transform3x4( m : Matrix ) {
 		var xMin = xMin, yMin = yMin, zMin = zMin, xMax = xMax, yMax = yMax, zMax = zMax;
 		empty();
@@ -129,15 +129,15 @@ class Bounds {
 		v.transform(m);
 		addPoint(v);
 	}
-	
+
 	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);
 	}
-	
+
 	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;
 	}
-	
+
 	public inline function add( b : Bounds ) {
 		if( b.xMin < xMin ) xMin = b.xMin;
 		if( b.xMax > xMax ) xMax = b.xMax;
@@ -164,7 +164,7 @@ class Bounds {
 		if( z < zMin ) zMin = z;
 		if( z > zMax ) zMax = z;
 	}
-	
+
 	public function intersection( a : Bounds, b : Bounds ) {
 		var xMin = Math.max(a.xMin, b.xMin);
 		var yMin = Math.max(a.yMin, b.yMin);
@@ -179,7 +179,7 @@ class Bounds {
 		this.zMin = zMin;
 		this.zMax = zMax;
 	}
-	
+
 	public inline function offset( dx : Float, dy : Float, dz : Float ) {
 		xMin += dx;
 		xMax += dx;
@@ -188,7 +188,7 @@ class Bounds {
 		zMin += dz;
 		zMax += dz;
 	}
-	
+
 	public inline function setMin( p : Point ) {
 		xMin = p.x;
 		yMin = p.y;
@@ -200,7 +200,7 @@ class Bounds {
 		yMax = p.y;
 		zMax = p.z;
 	}
-	
+
 	public function load( b : Bounds ) {
 		xMin = b.xMin;
 		xMax = b.xMax;
@@ -209,7 +209,7 @@ class Bounds {
 		zMin = b.zMin;
 		zMax = b.zMax;
 	}
-	
+
 	public function scaleCenter( v : Float ) {
 		var dx = (xMax - xMin) * 0.5 * v;
 		var dy = (yMax - yMin) * 0.5 * v;
@@ -224,11 +224,11 @@ class Bounds {
 		yMax = my + dy;
 		zMax = mz + dz;
 	}
-	
+
 	public inline function getMin() {
 		return new Point(xMin, yMin, zMin);
 	}
-	
+
 	public inline function getCenter() {
 		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() {
 		return new Point(xMax - xMin, yMax - yMin, zMax - zMin);
 	}
-	
+
 	public inline function getMax() {
 		return new Point(xMax, yMax, zMax);
 	}
-	
+
 	public inline function empty() {
 		xMin = 1e20;
 		xMax = -1e20;
@@ -258,7 +258,7 @@ class Bounds {
 		zMin = -1e20;
 		zMax = 1e20;
 	}
-	
+
 	public inline function clone() {
 		var b = new Bounds();
 		b.xMin = xMin;
@@ -269,11 +269,11 @@ class Bounds {
 		b.zMax = zMax;
 		return b;
 	}
-	
+
 	public function toString() {
 		return "{" + getMin() + "," + getMax() + "}";
 	}
-	
+
 	public static inline function fromPoints( min : Point, max : Point ) {
 		var b = new Bounds();
 		b.setMin(min);
@@ -291,5 +291,5 @@ class Bounds {
 		b.zMax = z + dz;
 		return b;
 	}
-	
+
 }

+ 17 - 17
h3d/col/Plane.hx

@@ -3,31 +3,31 @@ import hxd.Math;
 
 @:allow(h3d.col)
 class Plane {
-	
+
 	// Place equation :  nx.X + ny.Y + nz.Z - d = 0
 	var nx : Float;
 	var ny : Float;
 	var nz : Float;
 	var d : Float;
-	
+
 	inline function new(nx, ny, nz, d) {
 		this.nx = nx;
 		this.ny = ny;
 		this.nz = nz;
 		this.d = d;
 	}
-	
+
 	/**
 		Returns the plan normal
 	**/
 	public inline function getNormal() {
 		return new Point(nx, ny, nz);
 	}
-	
+
 	public inline function getNormalDistance() {
 		return d;
 	}
-	
+
 	/**
 		Normalize the plan, so we can use distance().
 	**/
@@ -38,22 +38,22 @@ class Plane {
 		nz *= len;
 		d *= len;
 	}
-	
+
 	public function toString() {
 		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.
 	**/
 	public inline function distance( p : Point ) {
 		return nx * p.x + ny * p.y + nz * p.z - d;
 	}
-	
+
 	public inline function side( p : Point ) {
 		return distance(p) >= 0;
 	}
-	
+
 	public inline function project( p : Point ) : Point {
 		var d = distance(p);
 		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.z = p.z - d * nz;
 	}
-	
+
 	public static inline function fromPoints( p0 : Point, p1 : Point, p2 : Point ) {
 		var d1 = p1.sub(p0);
 		var d2 = p2.sub(p0);
 		var n = d1.cross(d2);
 		return new Plane(n.x,n.y,n.z,n.dot(p0));
 	}
-	
+
 	public static inline function fromNormalPoint( n : Point, p : Point ) {
 		return new Plane(n.x,n.y,n.z,n.dot(p));
 	}
-	
+
 	public static inline function X(v:Float) {
 		return new Plane( 1, 0, 0, v );
 	}
-	
+
 	public static inline function Y(v:Float) {
 		return new Plane( 0, 1, 0, v );
 	}
@@ -88,7 +88,7 @@ class Plane {
 	public static inline function Z(v:Float) {
 		return new Plane( 0, 0, 1, v );
 	}
-	
+
 	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));
 	}
@@ -96,7 +96,7 @@ class Plane {
 	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);
 	}
-	
+
 	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));
 	}
@@ -104,7 +104,7 @@ class Plane {
 	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);
 	}
-	
+
 	public static inline function frustumNear( mvp : Matrix ) {
 		return new Plane(mvp._13, mvp._23, mvp._33, -mvp._43);
 	}
@@ -112,5 +112,5 @@ class Plane {
 	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);
 	}
-	
+
 }

+ 12 - 12
h3d/col/Point.hx

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

+ 10 - 10
h3d/col/Ray.hx

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

+ 5 - 5
h3d/col/Seg.hx

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

+ 29 - 29
h3d/impl/Driver.hx

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

+ 8 - 8
h3d/impl/ManagedBuffer.hx

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

+ 9 - 9
h3d/mat/Material.hx

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

+ 4 - 4
h3d/mat/MeshMaterial.hx

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

+ 10 - 10
h3d/mat/Pass.hx

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

+ 20 - 20
h3d/parts/Data.hx

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

+ 70 - 70
h3d/parts/Editor.hx

@@ -25,7 +25,7 @@ private typedef Curve = {
 }
 
 class Editor extends h2d.Sprite implements Randomized {
-	
+
 	var emit : Emitter;
 	var state : State;
 	var curState : String;
@@ -53,7 +53,7 @@ class Editor extends h2d.Sprite implements Randomized {
 	public var currentFilePath : String;
 	public var autoLoop : Bool = true;
 	public var moveEmitter(default,set) : Bool = false;
-	
+
 	static var CURVES : Array<{ name : String, f : Curve -> Data.Value }> = [
 		{ name : "Const", f : function(c) return VConst(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) },
 	];
 
-	
+
 	static function solvePoly( c : Curve ) {
 
 		if( c.points == null )
 			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 yvals = [for( p in c.points ) p.y * c.max];
 		var pts = [];
@@ -83,14 +83,14 @@ class Editor extends h2d.Sprite implements Randomized {
 			beta.pop();
 		return VPoly(beta,pts);
 	}
-	
+
 	public function new(emiter, ?parent) {
 		super(parent);
 		this.emit = emiter;
 		init();
 		setState(emit.state);
 	}
-	
+
 	public dynamic function onTextureSelect() {
 		hxd.File.browse(function(sel) {
 			sel.load(function(bytes) {
@@ -102,20 +102,20 @@ class Editor extends h2d.Sprite implements Randomized {
 			fileTypes : [{ name : "Images", extensions : ["png","jpg","jpeg","gif"] }],
 		});
 	}
-	
+
 	public function changeTexture( name : String, t : h2d.Tile ) {
 		state.textureName = name;
 		curState = null; // force reload (if texture was changed)
 		setTexture(t);
 		buildUI();
 	}
-	
+
 	function set_moveEmitter(v) {
 		this.moveEmitter = v;
 		buildUI();
 		return v;
 	}
-	
+
 	public dynamic function loadTexture( textureName : String ) : h2d.Tile {
 		var bytes = null;
 		try {
@@ -128,7 +128,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		}
 		return bytes == null ? null : hxd.res.Any.fromBytes(textureName,bytes).toTile();
 	}
-	
+
 	public dynamic function onLoad() {
 		hxd.File.browse(function(sel) {
 			currentFilePath = sel.fileName;
@@ -151,7 +151,7 @@ class Editor extends h2d.Sprite implements Randomized {
 			fileTypes : [{ name : "Particle Effect", extensions : ["p"] }],
 		});
 	}
-	
+
 	public dynamic function onSave( saveData ) {
 		if( currentFilePath != null )
 			try {
@@ -166,7 +166,7 @@ class Editor extends h2d.Sprite implements Randomized {
 			saveFileName : function(path) currentFilePath = path,
 		});
 	}
-	
+
 	public function setState(s) {
 		undo = [];
 		redo = [];
@@ -184,7 +184,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		buildUI();
 		emit.reset();
 	}
-	
+
 	override function onAlloc() {
 		super.onAlloc();
 		getScene().addEventListener(onEvent);
@@ -194,7 +194,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		super.onDelete();
 		getScene().addEventListener(onEvent);
 	}
-	
+
 	var time : Float = 0.;
 	public dynamic function onMoveEmitter(dt:Float) {
 		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.z = (Math.cos(time * 1.3) * Math.sin(time * 1.5) + 1) * r;
 	}
-	
+
 	function onEvent( e : hxd.Event ) {
 		function loadHistory( h : History ) {
 			curState = h.state;
@@ -238,7 +238,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		default:
 		}
 	}
-	
+
 	function buildUI() {
 		if( ui != null ) ui.remove();
 		ui = h2d.comp.Parser.fromHtml('
@@ -247,7 +247,7 @@ class Editor extends h2d.Sprite implements Randomized {
 					* {
 						font-size : 12px;
 					}
-					
+
 					h1 {
 						font-size : 10px;
 						color : #BBB;
@@ -256,7 +256,7 @@ class Editor extends h2d.Sprite implements Randomized {
 					.body {
 						layout : dock;
 					}
-					
+
 					span {
 						padding-top : 2px;
 					}
@@ -273,7 +273,7 @@ class Editor extends h2d.Sprite implements Randomized {
 						layout : vertical;
 						margin-bottom : 10px;
 					}
-					
+
 					.sep {
 						margin-top : -10px;
 						margin-bottom : -2px;
@@ -281,11 +281,11 @@ class Editor extends h2d.Sprite implements Randomized {
 						width : 200px;
 						background-color : #555;
 					}
-					
+
 					span.label {
 						width : 97px;
 					}
-					
+
 					.buttons {
 						layout : inline;
 					}
@@ -293,7 +293,7 @@ class Editor extends h2d.Sprite implements Randomized {
 					.line {
 						layout : horizontal;
 					}
-					
+
 					.ic, .icol {
 						icon : url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAB3RJTUUH3QsHEDot9CONhQAAABd0RVh0U29mdHdhcmUAR0xEUE5HIHZlciAzLjRxhaThAAAACHRwTkdHTEQzAAAAAEqAKR8AAAAEZ0FNQQAAsY8L/GEFAAAABmJLR0QA/wD/AP+gvaeTAAAARklEQVR4nGP4z/CfJMRAmQYIIFbDfwwGJvpPHQ249PxHdtJ/LHKkaMBtBAN+80jRgCMY8GrAFjMMBGMKI+Jor4EU1eRoAADB1BsCKErgdwAAAABJRU5ErkJggg=");
 						icon-top : 1px;
@@ -301,27 +301,27 @@ class Editor extends h2d.Sprite implements Randomized {
 						icon-color : #888;
 						padding-left : 20px;
 					}
-					
+
 					.ic:hover, .icol:hover {
 						icon-top : 0px;
 					}
-					
+
 					.icol {
 						icon-color : #AAA;
 						icon : url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAB3RJTUUH3QsICwAiCSUSqgAAABd0RVh0U29mdHdhcmUAR0xEUE5HIHZlciAzLjRxhaThAAAACHRwTkdHTEQzAAAAAEqAKR8AAAAEZ0FNQQAAsY8L/GEFAAAABmJLR0QA/wD/AP+gvaeTAAAAMklEQVR4nGMwIBEwAPFJWQVMlLHvLSYayRqcdmNBD8tFMNFI1kBa4vMnETD8Z/hPEgIAvqs9dJhBcSIAAAAASUVORK5CYII==");
 					}
-					
+
 					select, button, input {
 						icon-top : 2px;
 						width : 70px;
 						height : 11px;
 						padding-top : 2px;
 					}
-					
+
 					.box {
 						width : 95px;
 					}
-					
+
 					input {
 						height : 13px;
 						padding-top : 2px;
@@ -332,39 +332,39 @@ class Editor extends h2d.Sprite implements Randomized {
 						width : 310px;
 						layout : dock;
 					}
-					
+
 					.curve {
 						dock : bottom;
 						layout : vertical;
 						padding : 5px;
 						height : 165px;
 					}
-					
+
 					.curve .title {
 						width : 180px;
 						text-align : right;
 						padding: 2px 10px;
 						background-color : #202020;
 					}
-					
+
 					.tname {
 						width : 102px;
 					}
-					
+
 					#curve {
 						width : 300px;
 						height : 110px;
 						border : 1px solid #333;
 					}
-					
+
 					button.file {
 						width : 15px;
 					}
-					
+
 					.curve .val {
 						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 {
 						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 {
 						display : block;
 					}
-					
+
 					.m_pow .v_pow {
 						display : block;
 					}
-					
+
 					.m_cos .v_freq, .m_sin .v_freq {
 						display : block;
 					}
-					
+
 					.m_curve .v_prec, .m_curve .v_clear {
 						display : block;
 					}
-					
+
 					.m_random .v_rnd {
 						display : block;
 					}
-					
+
 					.v_rnd button {
 						width : auto;
 					}
@@ -396,10 +396,10 @@ class Editor extends h2d.Sprite implements Randomized {
 					.v_rnd select {
 						width : 40px;
 					}
-					
+
 				</style>
 				<div class="main panel">
-				
+
 					<h1>Global</h1>
 					<div class="sep"></div>
 					<div class="col">
@@ -429,7 +429,7 @@ class Editor extends h2d.Sprite implements Randomized {
 							<button class="ic" value="Size" onclick="api.editCurve(\'globalSize\')"/>
 						</div>
 					</div>
-					
+
 					<h1>Emit</h1>
 					<div class="sep"></div>
 					<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>
 						</div>
 					</div>
-					
+
 					<h1>Particle</h1>
 					<div class="sep"></div>
 					<div class="col">
@@ -490,7 +490,7 @@ class Editor extends h2d.Sprite implements Randomized {
 							<button class="ic" value="Light" onclick="api.editCurve(\'light\')"/>
 						</div>
 					</div>
-					
+
 					<h1>Animation</h1>
 					<div class="sep"></div>
 					<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\')"/>
 						</div>
 					</div>
-					
+
 					<h1>Collide</h1>
 					<div class="sep"></div>
 					<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>
 						</div>
 					</div>
-					
+
 					<h1>Play</h1>
 					<div class="sep"></div>
 					<div style="layout:dock;width:200px">
@@ -620,7 +620,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		cedit.onKeyDown = onCurveEvent;
 		setCurveMode(curve.mode);
 	}
-	
+
 	function toggleSplit() {
 		if( state.frames.length == 1 ) {
 			state.frame = VLinear(0,1);
@@ -633,13 +633,13 @@ class Editor extends h2d.Sprite implements Randomized {
 		}
 		buildUI();
 	}
-	
+
 	function clearCurve() {
 		curve.points = [new h2d.col.Point(0, curve.min/curve.max), new h2d.col.Point(1, 1)];
 		curve.freq = 2;
 		buildUI();
 	}
-	
+
 	function onCurveEvent( e : hxd.Event ) {
 		if( !curve.value.match(VPoly(_)) )
 			return;
@@ -688,7 +688,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		default:
 		}
 	}
-	
+
 	function editColors() {
 		if( grad != null ) {
 			grad.remove();
@@ -710,7 +710,7 @@ class Editor extends h2d.Sprite implements Randomized {
 			if( !found ) state.colors = null;
 		};
 	}
-	
+
 	function editCurve( name : String, isShape : Bool = false ) {
 		if( curve.name == name && curve.shape == isShape ) {
 			curve.name = null;
@@ -735,11 +735,11 @@ class Editor extends h2d.Sprite implements Randomized {
 		rebuildCurve();
 		buildUI();
 	}
-	
+
 	public function rand() {
 		return randomValue;
 	}
-	
+
 	function init() {
 		var bg = new hxd.BitmapData(300, 110);
 		bg.clear(0xFF202020);
@@ -753,12 +753,12 @@ class Editor extends h2d.Sprite implements Randomized {
 		bg.dispose();
 		curveTexture = h2d.Tile.fromTexture(new h3d.mat.Texture(512, 512)).sub(0, 0, curveBG.width, curveBG.height);
 	}
-	
+
 	function rebuildCurve() {
 		var bmp = new hxd.BitmapData(512, 512);
 		var width = curveTexture.width, height = curveTexture.height;
 		var yMax;
-		
+
 		switch( curve.value ) {
 		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));
@@ -774,8 +774,8 @@ class Editor extends h2d.Sprite implements Randomized {
 		case VCustom(_):
 			throw "assert";
 		}
-		
-		
+
+
 		var sy = 1.;
 		var k = 0;
 		while( yMax > 100 * curve.incr ) {
@@ -786,7 +786,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		}
 		sy /= (100 * curve.incr);
 		curve.scaleY = sy;
-		
+
 		inline function posX(x:Float) {
 			return Std.int(x * (width - 1));
 		}
@@ -809,7 +809,7 @@ class Editor extends h2d.Sprite implements Randomized {
 			}
 			bmp.setPixel(x, iy0, 0xFFFF0000);
 		}
-		
+
 		switch( curve.value ) {
 		case VPoly(_):
 			for( p in curve.points ) {
@@ -822,11 +822,11 @@ class Editor extends h2d.Sprite implements Randomized {
 			}
 		default:
 		}
-		
+
 		curveTexture.getTexture().uploadBitmap(bmp);
 		bmp.dispose();
 	}
-	
+
 	function initCurve( v : Value ) {
 		var c : Curve = {
 			value : null,
@@ -878,7 +878,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		}
 		return c;
 	}
-	
+
 	function getShapeValue( value : String ) {
 		return switch( [state.shape, value] ) {
 		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);
 		}
 	}
-	
+
 	function rebuildShape( mode : Int, getValue ) {
 		var size = getValue("size");
 		state.shape = switch( mode ) {
@@ -897,12 +897,12 @@ class Editor extends h2d.Sprite implements Randomized {
 		default: throw "Unknown shape #" + mode;
 		}
 	}
-	
+
 	function setCurShape( mode : Int ) {
 		rebuildShape(mode, getShapeValue);
 		buildUI();
 	}
-	
+
 	function setCurveMode( mode : Int ) {
 		var cm = ui.getElementById("curve").getParent();
 		cm.removeClass("m_" + CURVES[curve.mode].name.toLowerCase());
@@ -915,7 +915,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		} else
 			updateCurve();
 	}
-	
+
 	function updateCurve() {
 		curve.value = CURVES[curve.mode].f(curve);
 		if( curve.name != null ) {
@@ -932,7 +932,7 @@ class Editor extends h2d.Sprite implements Randomized {
 		curTile = t;
 		state.initFrames();
 	}
-	
+
 	override function sync( ctx : h2d.RenderContext ) {
 		// if resized, let's reflow our ui
 		if( ctx.engine.width != width || ctx.engine.height != height ) {
@@ -983,15 +983,15 @@ class Editor extends h2d.Sprite implements Randomized {
 			}
 		} else
 			lastPartSeen = null;
-			
+
 		if( grad != null ) {
 			grad.x = width - 680;
 			grad.y = height - 190;
 			grad.colorPicker.x = grad.boxWidth - 180;
 			grad.colorPicker.y = -321;
 		}
-			
+
 		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 emitCount : Float;
 	var colorMap : ColorKey;
-		
+
 	var head : Particle;
 	var tail : Particle;
 	var pool : Particle;
-	
+
 	var tmp : h3d.Vector;
 	var tmpBuf : hxd.FloatBuffer;
 	var curPart : Particle;
-	
+
 	public function new(?state,?parent) {
 		super(parent);
 		material = new Material();
@@ -35,7 +35,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 		}
 		setState(state);
 	}
-	
+
 	/**
 		Offset all existing particles by the given values.
 	**/
@@ -48,7 +48,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 			p = p.next;
 		}
 	}
-	
+
 	public function reset() {
 		while( head != null )
 			kill(head);
@@ -56,7 +56,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 		emitCount = 0;
 		rnd = Math.random();
 	}
-	
+
 	public function setState(s) {
 		this.state = s;
 		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) {
 		return Data.State.eval(v,time, this, curPart);
 	}
-	
+
 	public function update(dt:Float) {
 		var s = state;
 		var old = time;
@@ -113,11 +113,11 @@ class Emitter extends h3d.scene.Object implements Randomized {
 		}
 		curPart = null;
 	}
-	
+
 	public inline function rand() {
 		return Math.random();
 	}
-	
+
 	function initPosDir( p : Particle ) {
 		switch( state.shape ) {
 		case SLine(size):
@@ -171,7 +171,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 			p.dz = Math.cos(phi);
 		}
 	}
-	
+
 	function initPart(p:Particle) {
 		initPosDir(p);
 		if( !state.emitLocal ) {
@@ -190,12 +190,12 @@ class Emitter extends h3d.scene.Object implements Randomized {
 		p.time = 0;
 		p.lifeTimeFactor = 1 / eval(state.life);
 	}
-	
+
 	public function emitPart() {
 		if( posChanged ) syncPos();
 		return emitParticle();
 	}
-	
+
 	function emitParticle() {
 		var p;
 		if( pool == null )
@@ -229,7 +229,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 		}
 		return p;
 	}
-	
+
 	function kill(p:Particle) {
 		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;
@@ -238,7 +238,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 		pool = p;
 		count--;
 	}
-	
+
 	function updateParticle( p : Particle, dt : Float ) {
 		p.time += dt * p.lifeTimeFactor;
 		if( p.time > 1 ) {
@@ -246,7 +246,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 			return;
 		}
 		p.randIndex = 0;
-	
+
 		// apply forces
 		if( state.force != null ) {
 			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.ratio = p.eval(state.ratio, p.time);
 		p.rotation = p.eval(state.rotation, p.time);
-		
+
 		// collide
 		if( state.collide && collider != null && collider.collidePart(p, tmp) ) {
 			if( state.collideKill ) {
@@ -276,8 +276,8 @@ class Emitter extends h3d.scene.Object implements Randomized {
 				p.dz = v.z * state.bounce;
 			}
 		}
-			
-		
+
+
 		// calc color
 		var ck = colorMap;
 		var light = p.eval(state.light, p.time);
@@ -314,27 +314,27 @@ class Emitter extends h3d.scene.Object implements Randomized {
 			p.cb = light;
 		}
 		p.ca = p.eval(state.alpha, p.time);
-		
+
 		// frame
 		if( state.frame != null ) {
 			var f = p.eval(state.frame, p.time) % 1;
 			if( f < 0 ) f += 1;
 			p.frame = Std.int(f * state.frames.length);
 		}
-		
+
 		if( state.update != null )
 			state.update(p);
 	}
-	
+
 	override function sync( ctx : h3d.scene.RenderContext ) {
 		super.sync(ctx);
 		update(ctx.elapsedTime * speed);
 	}
-	
+
 	public function isActive() {
 		return count != 0 || time < 1 || state.loop;
 	}
-	
+
 	function sort( list : Particle ) {
 		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 ) {
 		return haxe.ds.ListSort.sort(list, function(p1, p2) return p1.w < p2.w ? -1 : 1);
 	}
-	
+
 	@:access(h3d.parts.Material) @:access(h2d.Tile)
 	override function draw( ctx : h3d.scene.RenderContext ) {
 		if( head == null )
@@ -382,7 +382,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 				var f = frames[p.frame];
 				if( f == null ) f = frames[0];
 				var ratio = p.size * p.ratio * (f.height / f.width);
-				
+
 				tmp[pos++] = prevX1;
 				tmp[pos++] = prevY1;
 				tmp[pos++] = prevZ1;
@@ -402,7 +402,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 					tmp[pos++] = p.cb;
 					tmp[pos++] = p.ca;
 				}
-				
+
 				tmp[pos++] = prevX2;
 				tmp[pos++] = prevY2;
 				tmp[pos++] = prevZ2;
@@ -431,11 +431,11 @@ class Emitter extends h3d.scene.Object implements Randomized {
 				dy *= d;
 				dz *= d;
 				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;
 				prevY1 = p.y + dir.y * p.size;
 				prevZ1 = p.z + dir.z * p.size;
-				
+
 				prevX2 = p.x - dir.x * p.size;
 				prevY2 = p.y - dir.y * 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.ca;
 				}
-				
+
 				prev = p;
 				p = p.next;
 			}
@@ -501,7 +501,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 					tmp[pos++] = p.cb;
 					tmp[pos++] = p.ca;
 				}
-				
+
 				tmp[pos++] = p.x;
 				tmp[pos++] = p.y;
 				tmp[pos++] = p.z;
@@ -552,7 +552,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 					tmp[pos++] = p.cb;
 					tmp[pos++] = p.ca;
 				}
-				
+
 				p = p.next;
 			}
 		}
@@ -560,7 +560,7 @@ class Emitter extends h3d.scene.Object implements Randomized {
 		if( hasColor ) stride += 4;
 		var buffer = h3d.Buffer.ofFloats(tmp, stride, [Quads, Dynamic], Std.int(pos/stride));
 		var size = eval(state.globalSize);
-		
+
 		/*
 		material.pshader.mpos = state.emitLocal ? this.absPos : h3d.Matrix.I();
 		material.pshader.mproj = ctx.camera.m;
@@ -573,12 +573,12 @@ class Emitter extends h3d.scene.Object implements Randomized {
 		}
 		material.pshader.hasColor = hasColor;
 		material.pshader.isAlphaMap = state.isAlphaMap;
-		
+
 		ctx.engine.selectMaterial(material);
 		ctx.engine.renderQuadBuffer(buffer);
 		buffer.dispose();
 		*/
 		throw "TODO";
 	}
-	
+
 }

+ 7 - 7
h3d/parts/Material.hx

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

+ 9 - 9
h3d/parts/Particle.hx

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

+ 9 - 9
h3d/pass/Base.hx

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

+ 12 - 12
h3d/pass/Blur.hx

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

+ 3 - 3
h3d/pass/Distance.hx

@@ -1,7 +1,7 @@
 package h3d.pass;
 
 class Distance extends Base {
-	
+
 	var texture : h3d.mat.Texture;
 
 	public function new() {
@@ -13,7 +13,7 @@ class Distance extends Base {
 	override function getOutputs() {
 		return ["output.position", "output.distance"];
 	}
-	
+
 	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.dispose();
@@ -24,5 +24,5 @@ class Distance extends Base {
 		ctx.engine.setTarget(null);
 		return passes;
 	}
-	
+
 }

+ 4 - 4
h3d/pass/LightSystem.hx

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

+ 1 - 1
h3d/pass/Params.hx

@@ -3,5 +3,5 @@ package h3d.pass;
 class Params {
 
 	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();
 		blur = new Blur(2, 3);
 	}
-	
+
 	public dynamic function getSceneBounds( bounds : h3d.col.Bounds ) {
 		bounds.xMin = -10;
 		bounds.yMin = -10;
@@ -42,11 +42,11 @@ class ShadowMap extends Base {
 		bounds.yMax = 10;
 		bounds.zMax = 10;
 	}
-	
+
 	override function getOutputs() {
 		return ["output.position", "output.distance"];
 	}
-	
+
 	override function setGlobals() {
 		super.setGlobals();
 		lightCamera.orthoBounds.empty();
@@ -54,7 +54,7 @@ class ShadowMap extends Base {
 		lightCamera.update();
 		cameraViewProj = lightCamera.m;
 	}
-	
+
 	override function draw( ctx : h3d.scene.RenderContext, passes) {
 		if( texture == null || texture.width != size ) {
 			if( texture != null ) {
@@ -72,9 +72,9 @@ class ShadowMap extends Base {
 		ctx.engine.setTarget(texture, 0xFFFFFFFF);
 		passes = super.draw(ctx, passes);
 		ctx.engine.setTarget(null);
-		
+
 		blur.apply(texture, blurTexture, true);
-		
+
 		ctx.sharedGlobals.set(shadowMapId, texture);
 		ctx.sharedGlobals.set(shadowProjId, lightCamera.m);
 		ctx.sharedGlobals.set(shadowColorId, color);
@@ -83,5 +83,5 @@ class ShadowMap extends Base {
 		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);
 		super(p, idx);
 	}
-	
+
 	override function addUVs() {
 		unindex();
-		
+
 		var z = new UV(0, 0);
 		var x = new UV(1, 0);
 		var y = new UV(0, 1);
 		var o = new UV(1, 1);
-		
+
 		uvs = [
 			z, x, o,
 			z, o, y,
@@ -54,5 +54,5 @@ class Cube extends Polygon {
 			z, y, o,
 		];
 	}
-	
+
 }

+ 7 - 7
h3d/prim/Cylinder.hx

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

+ 17 - 17
h3d/prim/FBXModel.hx

@@ -16,11 +16,11 @@ class FBXModel extends MeshPrimitive {
 		this.geom = g;
 		curMaterial = -1;
 	}
-	
+
 	public function getVerticesCount() {
 		return Std.int(geom.getVertices().length / 3);
 	}
-	
+
 	override function getBounds() {
 		if( bounds != null )
 			return bounds;
@@ -47,7 +47,7 @@ class FBXModel extends MeshPrimitive {
 		}
 		return bounds;
 	}
-	
+
 	override function render( engine : h3d.Engine ) {
 		if( curMaterial < 0 ) {
 			super.render(engine);
@@ -61,11 +61,11 @@ class FBXModel extends MeshPrimitive {
 		indexes = idx;
 		curMaterial = -1;
 	}
-	
+
 	override function selectMaterial( material : Int ) {
 		curMaterial = material;
 	}
-	
+
 	override function dispose() {
 		super.dispose();
 		if( groupIndexes != null ) {
@@ -75,31 +75,31 @@ class FBXModel extends MeshPrimitive {
 			groupIndexes = null;
 		}
 	}
-	
+
 	override function alloc( engine : h3d.Engine ) {
 		dispose();
-		
+
 		var verts = geom.getVertices();
 		var norms = geom.getNormals();
 		var tuvs = geom.getUVs()[0];
 		var colors = geom.getColors();
 		var mats = multiMaterial ? geom.getMaterials() : null;
-		
+
 		var gt = geom.getGeomTranslate();
 		if( gt == null ) gt = new Point();
-		
+
 		var idx = new 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 cbuf = (colors == null ? null : new hxd.FloatBuffer());
-		
+
 		// skin split
 		var sidx = null, stri = 0;
 		if( skin != null && skin.isSplit() ) {
 			if( multiMaterial ) throw "Multimaterial not supported with skin split";
 			sidx = [for( _ in skin.splitJoints ) new hxd.IndexBuffer()];
 		}
-		
+
 		// triangulize indexes : format is  A,B,...,-X : negative values mark the end of the polygon
 		var count = 0, pos = 0, matPos = 0;
 		var index = geom.getPolygons();
@@ -111,7 +111,7 @@ class FBXModel extends MeshPrimitive {
 				for( n in 0...count ) {
 					var k = n + start;
 					var vidx = index[k];
-					
+
 					var x = verts[vidx * 3] + gt.x;
 					var y = verts[vidx * 3 + 1] + gt.y;
 					var z = verts[vidx * 3 + 2] + gt.z;
@@ -130,7 +130,7 @@ class FBXModel extends MeshPrimitive {
 						tbuf.push(tuvs.values[iuv*2]);
 						tbuf.push(1 - tuvs.values[iuv * 2 + 1]);
 					}
-					
+
 					if( sbuf != null ) {
 						var p = vidx * skin.bonesPerVertex;
 						var idx = 0;
@@ -140,7 +140,7 @@ class FBXModel extends MeshPrimitive {
 						}
 						sbuf.writeInt32(idx);
 					}
-					
+
 					if( cbuf != null ) {
 						var icol = colors.index[k];
 						cbuf.push(colors.values[icol * 4]);
@@ -182,7 +182,7 @@ class FBXModel extends MeshPrimitive {
 			}
 			pos++;
 		}
-		
+
 		addBuffer("position", h3d.Buffer.ofFloats(pbuf, 3));
 		if( nbuf != null ) addBuffer("normal", h3d.Buffer.ofFloats(nbuf, 3));
 		if( tbuf != null ) addBuffer("uv", h3d.Buffer.ofFloats(tbuf, 2));
@@ -194,7 +194,7 @@ class FBXModel extends MeshPrimitive {
 			addBuffer("indexes", skinBuf, skin.bonesPerVertex);
 		}
 		if( cbuf != null ) addBuffer("color", h3d.Buffer.ofFloats(cbuf, 3));
-		
+
 		indexes = h3d.Indexes.alloc(idx);
 		if( mats != null ) {
 			groupIndexes = [];
@@ -207,5 +207,5 @@ class FBXModel extends MeshPrimitive {
 				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();
 				pb.normalize();
 				pc.normalize();
-				
+
 				nidx.push(np);
 				nidx.push(np + 1);
 				nidx.push(np + 2);
-				
+
 				nidx.push(idx[i]);
 				nidx.push(np);
 				nidx.push(np + 2);
@@ -39,11 +39,11 @@ class GeoSphere extends Polygon {
 				nidx.push(np);
 				nidx.push(idx[i + 1]);
 				nidx.push(np + 1);
-				
+
 				nidx.push(np + 1);
 				nidx.push(idx[i + 2]);
 				nidx.push(np + 2);
-				
+
 				p[np++] = pa;
 				p[np++] = pb;
 				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
 
 class MeshPrimitive extends Primitive {
-		
+
 	var bufferCache : Cache;
-	
+
 	function allocBuffer( engine : h3d.Engine, name : String ) {
 		return null;
 	}
-	
+
 	// TODO : in HxSL 3, we might instead allocate unique ID per name
 	static inline function hash( name : String ) {
 		var id = 0;
@@ -17,7 +17,7 @@ class MeshPrimitive extends Primitive {
 			id = id * 223 + name.charCodeAt(i);
 		return id & 0x0FFFFFFF;
 	}
-	
+
 	function addBuffer( name : String, buf, offset = 0 ) {
 		if( bufferCache == null )
 			bufferCache = new Cache();
@@ -57,12 +57,12 @@ class MeshPrimitive extends Primitive {
 		}
 		return buffers;
 	}
-	
+
 	override function render( engine : h3d.Engine ) {
 		// the actual alloc() cache will be implemented by subclasses
 		if( indexes == null || indexes.isDisposed() )
 			alloc(engine);
 		engine.renderMultiBuffers(getBuffers(engine), indexes);
 	}
-	
+
 }

+ 5 - 5
h3d/prim/Plan2D.hx

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

+ 12 - 12
h3d/prim/Plan3D.hx

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

+ 9 - 9
h3d/prim/Polygon.hx

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

+ 7 - 7
h3d/prim/Primitive.hx

@@ -1,26 +1,26 @@
 package h3d.prim;
 
 class Primitive {
-	
+
 	public var buffer : Buffer;
 	public var indexes : Indexes;
-	
+
 	public function triCount() {
 		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 {
 		throw "not implemented";
 		return null;
 	}
-	
+
 	public function alloc( engine : h3d.Engine ) {
 		throw "not implemented";
 	}
 
 	public function selectMaterial( material : Int ) {
 	}
-	
+
 	public function render( engine : h3d.Engine ) {
 		if( buffer == null || buffer.isDisposed() ) alloc(engine);
 		if( indexes == null )
@@ -28,7 +28,7 @@ class Primitive {
 		else
 			engine.renderIndexed(buffer,indexes);
 	}
-	
+
 	public function dispose() {
 		if( buffer != null ) {
 			buffer.dispose();
@@ -39,5 +39,5 @@ class Primitive {
 			indexes = null;
 		}
 	}
-	
+
 }

+ 8 - 8
h3d/prim/Quads.hx

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

+ 4 - 4
h3d/prim/Sphere.hx

@@ -2,10 +2,10 @@ package h3d.prim;
 import h3d.col.Point;
 
 class Sphere extends Polygon {
-	
+
 	var segsH : Int;
 	var segsW : Int;
-	
+
 	public function new( segsW = 8, segsH = 6 ) {
 		this.segsH = segsH;
 		this.segsW = segsW;
@@ -41,13 +41,13 @@ class Sphere extends Polygon {
 	override function addNormals() {
 		normals = points;
 	}
-	
+
 	override function addUVs() {
 		uvs = [];
 		for( y in 0...segsH + 1 )
 			for( x in 0...segsW + 1 )
 				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 v : Float;
-	
+
 	public function new(u,v) {
 		this.u = u;
 		this.v = v;
 	}
-	
+
 	public function clone() {
 		return new UV(u, v);
 	}
-	
+
 	function toString() {
 		return "{" + hxd.Math.fmt(u) + "," + hxd.Math.fmt(v) + "}";
 	}

+ 8 - 8
h3d/scene/Box.hx

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

+ 2 - 2
h3d/scene/DirLight.hx

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

+ 8 - 8
h3d/scene/Graphics.hx

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

+ 3 - 3
h3d/scene/Light.hx

@@ -5,7 +5,7 @@ class Light extends Object {
 	var shader : hxsl.Shader;
 	var objectDistance : Float; // used internaly
 	@:noCompletion public var next : Light;
-	
+
 	public var color(get, never) : h3d.Vector;
 	public var priority : Int = 0;
 
@@ -13,12 +13,12 @@ class Light extends Object {
 		super(parent);
 		this.shader = shader;
 	}
-	
+
 	// dummy implementation
 	function get_color() {
 		return new h3d.Vector();
 	}
-	
+
 	override function emit(ctx:RenderContext) {
 		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 material : h3d.mat.MeshMaterial;
-	
+
 	public function new( prim, ?mat, ?parent ) {
 		super(parent);
 		this.primitive = prim;
 		if( mat == null ) mat = new h3d.mat.MeshMaterial(null);
 		this.material = mat;
 	}
-	
+
 	override function getBounds( ?b : h3d.col.Bounds, rec = false ) {
 		b = super.getBounds(b, rec);
 		var tmp = primitive.getBounds().clone();
@@ -19,7 +19,7 @@ class Mesh extends Object {
 		b.add(tmp);
 		return b;
 	}
-	
+
 	override function clone( ?o : Object ) : Object {
 		var m = o == null ? new Mesh(null,material) : cast o;
 		m.primitive = primitive;
@@ -28,11 +28,11 @@ class Mesh extends Object {
 		super.clone(m);
 		return m;
 	}
-	
+
 	override function draw( ctx : RenderContext ) {
 		primitive.render(ctx.engine);
 	}
-	
+
 	override function emit( ctx : RenderContext ) {
 		ctx.emit(material, this);
 	}

+ 4 - 4
h3d/scene/MultiMaterial.hx

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

+ 46 - 46
h3d/scene/Object.hx

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

+ 4 - 4
h3d/scene/PointLight.hx

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

+ 10 - 10
h3d/scene/RenderContext.hx

@@ -8,21 +8,21 @@ class RenderContext {
 	public var time : Float;
 	public var elapsedTime : Float;
 	public var frame : Int;
-	
+
 	public var drawPass : ObjectPass;
-	
+
 	public var sharedGlobals : Map<Int,Dynamic>;
-	
+
 	var pool : ObjectPass;
 	var passes : ObjectPass;
 	var lights : Light;
-	
+
 	public function new() {
 		frame = 0;
 		time = 0.;
 		elapsedTime = 1. / hxd.Stage.getInstance().getFrameRate();
 	}
-	
+
 	@:access(h3d.mat.Pass)
 	public inline function emit( mat : h3d.mat.Material, obj, index = 0 ) {
 		var p = mat.mainPass;
@@ -31,7 +31,7 @@ class RenderContext {
 			p = p.nextPass;
 		}
 	}
-	
+
 	public function start() {
 		sharedGlobals = new Map();
 		lights = null;
@@ -41,7 +41,7 @@ class RenderContext {
 		time += elapsedTime;
 		frame++;
 	}
-	
+
 	public function emitPass( pass : h3d.mat.Pass, obj : h3d.scene.Object ) {
 		var o = pool;
 		if( o == null )
@@ -54,12 +54,12 @@ class RenderContext {
 		passes = o;
 		return o;
 	}
-	
+
 	public function emitLight( l : Light ) {
 		l.next = lights;
 		lights = l;
 	}
-	
+
 	public function done() {
 		drawPass = null;
 		// move passes to pool, and erase data
@@ -81,5 +81,5 @@ class RenderContext {
 		passes = 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 passes : Map<String,h3d.pass.Base>;
 	var ctx : RenderContext;
-	
+
 	public function new() {
 		super(null);
 		camera = new h3d.Camera();
@@ -17,14 +17,14 @@ class Scene extends Object implements h3d.IDrawable {
 		postPasses = [];
 		prePasses = [];
 	}
-	
+
 	override function clone( ?o : Object ) {
 		var s = o == null ? new Scene() : cast o;
 		s.camera = camera.clone();
 		super.clone(s);
 		return s;
 	}
-	
+
 	/**
 	 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
 			postPasses.push(p);
 	}
-	
+
 	public function removePass(p) {
 		postPasses.remove(p);
 		prePasses.remove(p);
 	}
-	
+
 	public function setElapsedTime( elapsedTime ) {
 		ctx.elapsedTime = elapsedTime;
 	}
-	
+
 	function createDefaultPass( name : String ) : h3d.pass.Base {
 		switch( name ) {
 		case "default", "alpha", "additive":
@@ -57,11 +57,11 @@ class Scene extends Object implements h3d.IDrawable {
 			return null;
 		}
 	}
-	
+
 	function get_mainPass() {
 		return getPass("default");
 	}
-	
+
 	public function getPass( name : String ) {
 		var p = passes.get(name);
 		if( p == null ) {
@@ -70,7 +70,7 @@ class Scene extends Object implements h3d.IDrawable {
 		}
 		return p;
 	}
-	
+
 	public function setPass( name : String, p : h3d.pass.Base ) {
 		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);
 		for( p in passes )
 			p.pass = p.render.draw(ctx, p.pass);
-		
+
 		// relink pass objects to reuse
 		var count = 0;
 		var prev : h3d.pass.Object = null;
@@ -132,5 +132,5 @@ class Scene extends Object implements h3d.IDrawable {
 		ctx.camera = null;
 		ctx.engine = null;
 	}
-	
+
 }

+ 13 - 13
h3d/scene/Skin.hx

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

+ 1 - 1
h3d/shader/AlphaMap.hx

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

+ 8 - 8
h3d/shader/AmbientLight.hx

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

+ 3 - 3
h3d/shader/BlurShader.hx

@@ -11,13 +11,13 @@ class BlurShader extends hxsl.Shader {
 			position : Vec4,
 			color : Vec4,
 		};
-		
+
 		@param var texture : Sampler2D;
 		@param @const var Quality : Int;
 		@param @const var isDepth : Bool;
 		@param var values : Array<Float,Quality>;
 		@param var pixel : Vec2;
-		
+
 		function vertex() {
 			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 {
-	
+
 	public var vertex : ShaderBuffers;
 	public var fragment : ShaderBuffers;
 

+ 3 - 3
h3d/shader/ColorAdd.hx

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

+ 3 - 3
h3d/shader/ColorKey.hx

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

+ 3 - 3
h3d/shader/ColorMatrix.hx

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

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