(function ($hx_exports, $global) { "use strict";
$hx_exports["kha"] = $hx_exports["kha"] || {};
$hx_exports["kha"]["_Color"] = $hx_exports["kha"]["_Color"] || {};
;$hx_exports["kha"]["input"] = $hx_exports["kha"]["input"] || {};
var $hxClasses = {},$estr = function() { return js_Boot.__string_rec(this,''); },$hxEnums = $hxEnums || {},$_;
class HxOverrides {
	static cca(s,index) {
		let x = s.charCodeAt(index);
		if(x != x) {
			return undefined;
		}
		return x;
	}
	static substr(s,pos,len) {
		if(len == null) {
			len = s.length;
		} else if(len < 0) {
			if(pos == 0) {
				len = s.length + len;
			} else {
				return "";
			}
		}
		return s.substr(pos,len);
	}
	static remove(a,obj) {
		let i = a.indexOf(obj);
		if(i == -1) {
			return false;
		}
		a.splice(i,1);
		return true;
	}
	static now() {
		return Date.now();
	}
}
$hxClasses["HxOverrides"] = HxOverrides;
HxOverrides.__name__ = "HxOverrides";
class Main {
	static main() {
		iron_data_ShaderData.shaderPath = "";
		Main.kickstart();
	}
	static kickstart() {
		Krom.setApplicationName("ArmorPaint");
		Main.tasks = 1;
		Main.tasks++;
		arm_Config.load(function() {
			Main.tasks--;
			Main.start();
		});
		Main.tasks--;
		Main.start();
	}
	static start() {
		if(Main.tasks > 0) {
			return;
		}
		arm_Config.init();
		kha_System.start(arm_Config.getOptions(),function($window) {
			if(arm_Config.raw.layout == null) {
				arm_App.initLayout();
			}
			Krom.setApplicationName("ArmorPaint");
			iron_App.init(function() {
				iron_Scene.setActive("Scene",function(o) {
					arm_render_Uniforms.init();
					let path = new iron_RenderPath();
					arm_render_Inc.init(path);
					if(arm_Context.renderMode == 1) {
						arm_render_RenderPathDeferred.init(path);
						arm_render_RenderPathForward.init(path);
						path.commands = arm_render_RenderPathForward.commands;
					} else {
						arm_render_RenderPathDeferred.init(path);
						path.commands = arm_render_RenderPathDeferred.commands;
					}
					iron_RenderPath.setActive(path);
					new arm_App();
				});
			});
		});
	}
}
$hxClasses["Main"] = Main;
Main.__name__ = "Main";
Math.__name__ = "Math";
class Reflect {
	static field(o,field) {
		try {
			return o[field];
		} catch( _g ) {
			return null;
		}
	}
	static setField(o,field,value) {
		o[field] = value;
	}
	static setProperty(o,field,value) {
		let tmp;
		let tmp1;
		if(o.__properties__) {
			tmp = o.__properties__["set_" + field];
			tmp1 = tmp;
		} else {
			tmp1 = false;
		}
		if(tmp1) {
			o[tmp](value);
		} else {
			o[field] = value;
		}
	}
	static fields(o) {
		let a = [];
		if(o != null) {
			let hasOwnProperty = Object.prototype.hasOwnProperty;
			for( var f in o ) {
			if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
				a.push(f);
			}
			}
		}
		return a;
	}
	static compare(a,b) {
		if(a == b) {
			return 0;
		} else if(a > b) {
			return 1;
		} else {
			return -1;
		}
	}
}
$hxClasses["Reflect"] = Reflect;
Reflect.__name__ = "Reflect";
class Std {
	static isOfType(v,t) {
		return js_Boot.__instanceof(v,t);
	}
	static string(s) {
		return js_Boot.__string_rec(s,"");
	}
	static parseInt(x) {
		if(x != null) {
			let _g = 0;
			let _g1 = x.length;
			while(_g < _g1) {
				let i = _g++;
				let c = x.charCodeAt(i);
				if(c <= 8 || c >= 14 && c != 32 && c != 45) {
					let nc = x.charCodeAt(i + 1);
					let v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
					if(isNaN(v)) {
						return null;
					} else {
						return v;
					}
				}
			}
		}
		return null;
	}
}
$hxClasses["Std"] = Std;
Std.__name__ = "Std";
class StringBuf {
	constructor() {
		this.b = "";
	}
}
$hxClasses["StringBuf"] = StringBuf;
StringBuf.__name__ = "StringBuf";
Object.assign(StringBuf.prototype, {
	__class__: StringBuf
});
class StringTools {
	static htmlEscape(s,quotes) {
		let buf_b = "";
		let _g_offset = 0;
		let _g_s = s;
		while(_g_offset < _g_s.length) {
			let s = _g_s;
			let index = _g_offset++;
			let c = s.charCodeAt(index);
			if(c >= 55296 && c <= 56319) {
				c = c - 55232 << 10 | s.charCodeAt(index + 1) & 1023;
			}
			let c1 = c;
			if(c1 >= 65536) {
				++_g_offset;
			}
			let code = c1;
			switch(code) {
			case 34:
				if(quotes) {
					buf_b += "&quot;";
				} else {
					buf_b += String.fromCodePoint(code);
				}
				break;
			case 38:
				buf_b += "&amp;";
				break;
			case 39:
				if(quotes) {
					buf_b += "&#039;";
				} else {
					buf_b += String.fromCodePoint(code);
				}
				break;
			case 60:
				buf_b += "&lt;";
				break;
			case 62:
				buf_b += "&gt;";
				break;
			default:
				buf_b += String.fromCodePoint(code);
			}
		}
		return buf_b;
	}
	static isSpace(s,pos) {
		let c = HxOverrides.cca(s,pos);
		if(!(c > 8 && c < 14)) {
			return c == 32;
		} else {
			return true;
		}
	}
	static ltrim(s) {
		let l = s.length;
		let r = 0;
		while(r < l && StringTools.isSpace(s,r)) ++r;
		if(r > 0) {
			return HxOverrides.substr(s,r,l - r);
		} else {
			return s;
		}
	}
	static rtrim(s) {
		let l = s.length;
		let r = 0;
		while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
		if(r > 0) {
			return HxOverrides.substr(s,0,l - r);
		} else {
			return s;
		}
	}
	static trim(s) {
		return StringTools.ltrim(StringTools.rtrim(s));
	}
	static replace(s,sub,by) {
		return s.split(sub).join(by);
	}
}
$hxClasses["StringTools"] = StringTools;
StringTools.__name__ = "StringTools";
var ValueType = $hxEnums["ValueType"] = { __ename__:true,__constructs__:null
	,TNull: {_hx_name:"TNull",_hx_index:0,__enum__:"ValueType",toString:$estr}
	,TInt: {_hx_name:"TInt",_hx_index:1,__enum__:"ValueType",toString:$estr}
	,TFloat: {_hx_name:"TFloat",_hx_index:2,__enum__:"ValueType",toString:$estr}
	,TBool: {_hx_name:"TBool",_hx_index:3,__enum__:"ValueType",toString:$estr}
	,TObject: {_hx_name:"TObject",_hx_index:4,__enum__:"ValueType",toString:$estr}
	,TFunction: {_hx_name:"TFunction",_hx_index:5,__enum__:"ValueType",toString:$estr}
	,TClass: ($_=function(c) { return {_hx_index:6,c:c,__enum__:"ValueType",toString:$estr}; },$_._hx_name="TClass",$_.__params__ = ["c"],$_)
	,TEnum: ($_=function(e) { return {_hx_index:7,e:e,__enum__:"ValueType",toString:$estr}; },$_._hx_name="TEnum",$_.__params__ = ["e"],$_)
	,TUnknown: {_hx_name:"TUnknown",_hx_index:8,__enum__:"ValueType",toString:$estr}
};
ValueType.__constructs__ = [ValueType.TNull,ValueType.TInt,ValueType.TFloat,ValueType.TBool,ValueType.TObject,ValueType.TFunction,ValueType.TClass,ValueType.TEnum,ValueType.TUnknown];
class Type {
	static createInstance(cl,args) {
		return new (Function.prototype.bind.apply(cl,[null].concat(args)));
	}
	static typeof(v) {
		switch(typeof(v)) {
		case "boolean":
			return ValueType.TBool;
		case "function":
			if(v.__name__ || v.__ename__) {
				return ValueType.TObject;
			}
			return ValueType.TFunction;
		case "number":
			if(Math.ceil(v) == v % 2147483648.0) {
				return ValueType.TInt;
			}
			return ValueType.TFloat;
		case "object":
			if(v == null) {
				return ValueType.TNull;
			}
			let e = v.__enum__;
			if(e != null) {
				return ValueType.TEnum($hxEnums[e]);
			}
			let c = js_Boot.getClass(v);
			if(c != null) {
				return ValueType.TClass(c);
			}
			return ValueType.TObject;
		case "string":
			return ValueType.TClass(String);
		case "undefined":
			return ValueType.TNull;
		default:
			return ValueType.TUnknown;
		}
	}
	static enumEq(a,b) {
		if(a == b) {
			return true;
		}
		try {
			let e = a.__enum__;
			if(e == null || e != b.__enum__) {
				return false;
			}
			if(a._hx_index != b._hx_index) {
				return false;
			}
			let enm = $hxEnums[e];
			let params = enm.__constructs__[a._hx_index].__params__;
			let _g = 0;
			while(_g < params.length) {
				let f = params[_g];
				++_g;
				if(!Type.enumEq(a[f],b[f])) {
					return false;
				}
			}
		} catch( _g ) {
			return false;
		}
		return true;
	}
}
$hxClasses["Type"] = Type;
Type.__name__ = "Type";
class XmlType {
	static toString(this1) {
		switch(this1) {
		case 0:
			return "Element";
		case 1:
			return "PCData";
		case 2:
			return "CData";
		case 3:
			return "Comment";
		case 4:
			return "DocType";
		case 5:
			return "ProcessingInstruction";
		case 6:
			return "Document";
		}
	}
}
class Xml {
	constructor(nodeType) {
		this.nodeType = nodeType;
		this.children = [];
		this.attributeMap = new haxe_ds_StringMap();
	}
	get(att) {
		if(this.nodeType != Xml.Element) {
			throw haxe_Exception.thrown("Bad node type, expected Element but found " + (this.nodeType == null ? "null" : XmlType.toString(this.nodeType)));
		}
		return this.attributeMap.h[att];
	}
	set(att,value) {
		if(this.nodeType != Xml.Element) {
			throw haxe_Exception.thrown("Bad node type, expected Element but found " + (this.nodeType == null ? "null" : XmlType.toString(this.nodeType)));
		}
		this.attributeMap.h[att] = value;
	}
	exists(att) {
		if(this.nodeType != Xml.Element) {
			throw haxe_Exception.thrown("Bad node type, expected Element but found " + (this.nodeType == null ? "null" : XmlType.toString(this.nodeType)));
		}
		return Object.prototype.hasOwnProperty.call(this.attributeMap.h,att);
	}
	attributes() {
		if(this.nodeType != Xml.Element) {
			throw haxe_Exception.thrown("Bad node type, expected Element but found " + (this.nodeType == null ? "null" : XmlType.toString(this.nodeType)));
		}
		return new haxe_ds__$StringMap_StringMapKeyIterator(this.attributeMap.h);
	}
	elementsNamed(name) {
		if(this.nodeType != Xml.Document && this.nodeType != Xml.Element) {
			throw haxe_Exception.thrown("Bad node type, expected Element or Document but found " + (this.nodeType == null ? "null" : XmlType.toString(this.nodeType)));
		}
		let _g = [];
		let _g1 = 0;
		let _g2 = this.children;
		while(_g1 < _g2.length) {
			let child = _g2[_g1];
			++_g1;
			let tmp;
			if(child.nodeType == Xml.Element) {
				if(child.nodeType != Xml.Element) {
					throw haxe_Exception.thrown("Bad node type, expected Element but found " + (child.nodeType == null ? "null" : XmlType.toString(child.nodeType)));
				}
				tmp = child.nodeName == name;
			} else {
				tmp = false;
			}
			if(tmp) {
				_g.push(child);
			}
		}
		return new haxe_iterators_ArrayIterator(_g);
	}
	firstElement() {
		if(this.nodeType != Xml.Document && this.nodeType != Xml.Element) {
			throw haxe_Exception.thrown("Bad node type, expected Element or Document but found " + (this.nodeType == null ? "null" : XmlType.toString(this.nodeType)));
		}
		let _g = 0;
		let _g1 = this.children;
		while(_g < _g1.length) {
			let child = _g1[_g];
			++_g;
			if(child.nodeType == Xml.Element) {
				return child;
			}
		}
		return null;
	}
	addChild(x) {
		if(this.nodeType != Xml.Document && this.nodeType != Xml.Element) {
			throw haxe_Exception.thrown("Bad node type, expected Element or Document but found " + (this.nodeType == null ? "null" : XmlType.toString(this.nodeType)));
		}
		if(x.parent != null) {
			x.parent.removeChild(x);
		}
		this.children.push(x);
		x.parent = this;
	}
	removeChild(x) {
		if(this.nodeType != Xml.Document && this.nodeType != Xml.Element) {
			throw haxe_Exception.thrown("Bad node type, expected Element or Document but found " + (this.nodeType == null ? "null" : XmlType.toString(this.nodeType)));
		}
		if(HxOverrides.remove(this.children,x)) {
			x.parent = null;
			return true;
		}
		return false;
	}
	toString() {
		return haxe_xml_Printer.print(this);
	}
	static parse(str) {
		return haxe_xml_Parser.parse(str);
	}
	static createElement(name) {
		let xml = new Xml(Xml.Element);
		if(xml.nodeType != Xml.Element) {
			throw haxe_Exception.thrown("Bad node type, expected Element but found " + (xml.nodeType == null ? "null" : XmlType.toString(xml.nodeType)));
		}
		xml.nodeName = name;
		return xml;
	}
	static createPCData(data) {
		let xml = new Xml(Xml.PCData);
		if(xml.nodeType == Xml.Document || xml.nodeType == Xml.Element) {
			throw haxe_Exception.thrown("Bad node type, unexpected " + (xml.nodeType == null ? "null" : XmlType.toString(xml.nodeType)));
		}
		xml.nodeValue = data;
		return xml;
	}
	static createCData(data) {
		let xml = new Xml(Xml.CData);
		if(xml.nodeType == Xml.Document || xml.nodeType == Xml.Element) {
			throw haxe_Exception.thrown("Bad node type, unexpected " + (xml.nodeType == null ? "null" : XmlType.toString(xml.nodeType)));
		}
		xml.nodeValue = data;
		return xml;
	}
	static createComment(data) {
		let xml = new Xml(Xml.Comment);
		if(xml.nodeType == Xml.Document || xml.nodeType == Xml.Element) {
			throw haxe_Exception.thrown("Bad node type, unexpected " + (xml.nodeType == null ? "null" : XmlType.toString(xml.nodeType)));
		}
		xml.nodeValue = data;
		return xml;
	}
	static createDocType(data) {
		let xml = new Xml(Xml.DocType);
		if(xml.nodeType == Xml.Document || xml.nodeType == Xml.Element) {
			throw haxe_Exception.thrown("Bad node type, unexpected " + (xml.nodeType == null ? "null" : XmlType.toString(xml.nodeType)));
		}
		xml.nodeValue = data;
		return xml;
	}
	static createProcessingInstruction(data) {
		let xml = new Xml(Xml.ProcessingInstruction);
		if(xml.nodeType == Xml.Document || xml.nodeType == Xml.Element) {
			throw haxe_Exception.thrown("Bad node type, unexpected " + (xml.nodeType == null ? "null" : XmlType.toString(xml.nodeType)));
		}
		xml.nodeValue = data;
		return xml;
	}
	static createDocument() {
		return new Xml(Xml.Document);
	}
}
$hxClasses["Xml"] = Xml;
Xml.__name__ = "Xml";
Object.assign(Xml.prototype, {
	__class__: Xml
});
class zui_Handle {
	constructor(ops) {
		this.changed = false;
		this.dragY = 0;
		this.dragX = 0;
		this.dragEnabled = false;
		this.lastMaxY = 0.0;
		this.lastMaxX = 0.0;
		this.layout = 0;
		this.scrollEnabled = false;
		this.scrollOffset = 0.0;
		this.redraws = 2;
		this.texture = null;
		this.text = "";
		this.value = 0.0;
		this.color = -1;
		this.position = 0;
		this.selected = false;
		if(ops != null) {
			if(ops.selected != null) {
				this.selected = ops.selected;
			}
			if(ops.position != null) {
				this.position = ops.position;
			}
			if(ops.value != null) {
				this.value = ops.value;
			}
			if(ops.text != null) {
				this.text = ops.text;
			}
			if(ops.color != null) {
				this.color = ops.color;
			}
			if(ops.layout != null) {
				this.layout = ops.layout;
			}
		}
	}
	nest(i,ops) {
		if(this.children == null) {
			this.children = new haxe_ds_IntMap();
		}
		let c = this.children.h[i];
		if(c == null) {
			c = new zui_Handle(ops);
			this.children.h[i] = c;
		}
		return c;
	}
}
$hxClasses["zui.Handle"] = zui_Handle;
zui_Handle.__name__ = "zui.Handle";
Object.assign(zui_Handle.prototype, {
	__class__: zui_Handle
});
class arm_App {
	constructor() {
		arm_Console.init();
		arm_App.lastWindowWidth = kha_System.windowWidth();
		arm_App.lastWindowHeight = kha_System.windowHeight();
		iron_App.onResize = arm_App.onResize;
		kha_System.notifyOnDropFiles(function(dropPath) {
			dropPath = StringTools.rtrim(dropPath);
			arm_App.dropPaths.push(dropPath);
		});
		kha_System.notifyOnApplicationState(function() {
			arm_Context.foregroundEvent = true;
			arm_Context.lastPaintX = -1;
			arm_Context.lastPaintY = -1;
		},function() {
		},function() {
		},function() {
			iron_system_Input.getKeyboard().upListener(18);
			iron_system_Input.getKeyboard().upListener(91);
		},function() {
		});
		Krom.setSaveAndQuitCallback(arm_App.saveAndQuitCallback);
		iron_data_Data.getFont("font.ttf",function(f) {
			iron_data_Data.getImage("color_wheel.k",function(image) {
				arm_App.font = f;
				arm_Config.loadTheme(arm_Config.raw.theme,false);
				arm_App.defaultElementW = arm_App.theme.ELEMENT_W;
				arm_App.defaultFontSize = arm_App.theme.FONT_SIZE;
				arm_Translator.loadTranslations(arm_Config.raw.locale);
				arm_ui_UIFiles.filename = arm_Translator.tr("untitled");
				if(arm_Config.raw.locale == "en") {
					let kimg = Object.create(kha_KravurImage.prototype);
					kimg.mySize = 13;
					kimg.width = 128;
					kimg.height = 128;
					kimg.baseline = 10;
					let this1 = new Array(arm_data_ConstData.font_x0.length);
					let chars = this1;
					let _g = [];
					let _g1 = 32;
					while(_g1 < 127) {
						let i = _g1++;
						_g.push(i);
					}
					kha_graphics2_Graphics.fontGlyphs = _g;
					let _g2 = 0;
					while(_g2 < 95) {
						let i = _g2++;
						chars[i] = new kha_graphics2_truetype_Stbtt_$bakedchar();
					}
					let _g3 = 0;
					let _g4 = arm_data_ConstData.font_x0.length;
					while(_g3 < _g4) {
						let i = _g3++;
						chars[i].x0 = arm_data_ConstData.font_x0[i];
					}
					let _g5 = 0;
					let _g6 = arm_data_ConstData.font_y0.length;
					while(_g5 < _g6) {
						let i = _g5++;
						chars[i].y0 = arm_data_ConstData.font_y0[i];
					}
					let _g7 = 0;
					let _g8 = arm_data_ConstData.font_x1.length;
					while(_g7 < _g8) {
						let i = _g7++;
						chars[i].x1 = arm_data_ConstData.font_x1[i];
					}
					let _g9 = 0;
					let _g10 = arm_data_ConstData.font_y1.length;
					while(_g9 < _g10) {
						let i = _g9++;
						chars[i].y1 = arm_data_ConstData.font_y1[i];
					}
					let _g11 = 0;
					let _g12 = arm_data_ConstData.font_xoff.length;
					while(_g11 < _g12) {
						let i = _g11++;
						chars[i].xoff = arm_data_ConstData.font_xoff[i];
					}
					let _g13 = 0;
					let _g14 = arm_data_ConstData.font_yoff.length;
					while(_g13 < _g14) {
						let i = _g13++;
						chars[i].yoff = arm_data_ConstData.font_yoff[i];
					}
					let _g15 = 0;
					let _g16 = arm_data_ConstData.font_xadvance.length;
					while(_g15 < _g16) {
						let i = _g15++;
						chars[i].xadvance = arm_data_ConstData.font_xadvance[i];
					}
					kimg.chars = chars;
					iron_data_Data.getBlob("font13.bin",function(fontbin) {
						let tmp = fontbin.toBytes();
						kimg.texture = kha_Image.fromBytes(tmp,128,128,1);
						(js_Boot.__cast(arm_App.font , kha_Font)).images.h[130095] = kimg;
					});
				}
				arm_App.colorWheel = image;
				zui_Nodes.enumTexts = arm_App.enumTexts;
				zui_Nodes.tr = arm_Translator.tr;
				arm_App.uiBox = new zui_Zui({ theme : arm_App.theme, font : f, scaleFactor : arm_Config.raw.window_scale, color_wheel : arm_App.colorWheel});
				arm_App.uiMenu = new zui_Zui({ theme : arm_App.theme, font : f, scaleFactor : arm_Config.raw.window_scale, color_wheel : arm_App.colorWheel});
				arm_App.defaultElementH = arm_App.uiMenu.t.ELEMENT_H;
				if(arm_Config.raw.plugins != null) {
					let _g = 0;
					let _g1 = arm_Config.raw.plugins;
					while(_g < _g1.length) {
						let plugin = _g1[_g];
						++_g;
						arm_Plugin.start(plugin);
					}
				}
				arm_Args.parse();
				iron_App.notifyOnUpdate(arm_App.update);
				new arm_ui_UISidebar();
				new arm_ui_UINodes();
				new arm_ui_UIView2D();
				new arm_Camera();
				iron_App.notifyOnRender2D(($_=arm_ui_UIView2D.inst,$bind($_,$_.render)));
				iron_App.notifyOnUpdate(($_=arm_ui_UIView2D.inst,$bind($_,$_.update)));
				iron_App.notifyOnRender2D(($_=arm_ui_UISidebar.inst,$bind($_,$_.renderCursor)));
				iron_App.notifyOnUpdate(($_=arm_ui_UINodes.inst,$bind($_,$_.update)));
				iron_App.notifyOnRender2D(($_=arm_ui_UINodes.inst,$bind($_,$_.render)));
				iron_App.notifyOnUpdate(($_=arm_ui_UISidebar.inst,$bind($_,$_.update)));
				iron_App.notifyOnRender2D(($_=arm_ui_UISidebar.inst,$bind($_,$_.render)));
				iron_App.notifyOnRender2D(arm_App.render);
				arm_App.appx = arm_ui_UIToolbar.inst.toolbarw;
				arm_App.appy = arm_ui_UIHeader.inst.headerh * 2;
				let cam = iron_Scene.active.camera;
				cam.data.raw.fov = (cam.data.raw.fov * 100 | 0) / 100;
				cam.buildProjection();
				arm_Args.run();
			});
		});
	}
	static saveAndQuitCallback(save) {
		arm_App.saveWindowRect();
		if(save) {
			arm_Project.projectSave(true);
		} else {
			kha_System.stop();
		}
	}
	static w() {
		if(arm_ui_UISidebar.inst != null && arm_Context.materialPreview) {
			return 256;
		}
		if(arm_ui_UISidebar.inst != null && arm_Context.decalPreview) {
			return 512;
		}
		let res = 0;
		if(arm_ui_UINodes.inst == null || arm_ui_UISidebar.inst == null) {
			let sidebarw = arm_Config.raw.layout == null ? 280 : arm_Config.raw.layout[0];
			res = kha_System.windowWidth() - sidebarw - 36;
		} else if(arm_ui_UINodes.inst.show || arm_ui_UIView2D.inst.show) {
			res = kha_System.windowWidth() - arm_Config.raw.layout[0] - arm_Config.raw.layout[3] - arm_ui_UIToolbar.inst.toolbarw;
		} else if(arm_ui_UISidebar.inst.show) {
			res = kha_System.windowWidth() - arm_Config.raw.layout[0] - arm_ui_UIToolbar.inst.toolbarw;
		} else {
			res = kha_System.windowWidth();
		}
		if(arm_ui_UISidebar.inst != null && arm_Context.viewIndex > -1) {
			res = res / 2 | 0;
		}
		if(arm_Context.paint2dView) {
			res = arm_ui_UIView2D.inst.ww;
		}
		if(res > 0) {
			return res;
		} else {
			return 1;
		}
	}
	static h() {
		if(arm_ui_UISidebar.inst != null && arm_Context.materialPreview) {
			return 256;
		}
		if(arm_ui_UISidebar.inst != null && arm_Context.decalPreview) {
			return 512;
		}
		let res = kha_System.windowHeight();
		if(arm_ui_UISidebar.inst == null) {
			res -= 88;
		} else if(arm_ui_UISidebar.inst != null && arm_ui_UISidebar.inst.show && res > 0) {
			res -= (56 * arm_Config.raw.window_scale | 0) + arm_Config.raw.layout[5];
		}
		if(res > 0) {
			return res;
		} else {
			return 1;
		}
	}
	static x() {
		if(arm_Context.viewIndex == 1) {
			return arm_App.appx + arm_App.w();
		} else {
			return arm_App.appx;
		}
	}
	static y() {
		return arm_App.appy;
	}
	static onResize() {
		if(kha_System.windowWidth() == 0 || kha_System.windowHeight() == 0) {
			return;
		}
		let ratioW = kha_System.windowWidth() / arm_App.lastWindowWidth;
		arm_App.lastWindowWidth = kha_System.windowWidth();
		let ratioH = kha_System.windowHeight() / arm_App.lastWindowHeight;
		arm_App.lastWindowHeight = kha_System.windowHeight();
		arm_Config.raw.layout[3] = arm_Config.raw.layout[3] * ratioW | 0;
		arm_Config.raw.layout[1] = arm_Config.raw.layout[1] * ratioH | 0;
		arm_Config.raw.layout[2] = kha_System.windowHeight() - arm_Config.raw.layout[1];
		arm_App.resize();
	}
	static saveWindowRect() {
		arm_Config.raw.window_w = kha_System.windowWidth();
		arm_Config.raw.window_h = kha_System.windowHeight();
		arm_Config.raw.window_x = kha_Window.get(0).get_x();
		arm_Config.raw.window_y = kha_Window.get(0).get_y();
		arm_Config.save();
	}
	static resize() {
		if(kha_System.windowWidth() == 0 || kha_System.windowHeight() == 0) {
			return;
		}
		let cam = iron_Scene.active.camera;
		if(cam.data.raw.ortho != null) {
			cam.data.raw.ortho[2] = -2 * (arm_App.h() / arm_App.w());
			cam.data.raw.ortho[3] = 2 * (arm_App.h() / arm_App.w());
		}
		cam.buildProjection();
		if(arm_Context.cameraType == 1) {
			arm_Viewport.updateCameraType(arm_Context.cameraType);
		}
		arm_Context.ddirty = 2;
		if(arm_ui_UISidebar.inst.show) {
			arm_App.appx = arm_ui_UIToolbar.inst.toolbarw;
			arm_App.appy = arm_ui_UIHeader.inst.headerh * 2;
		} else {
			arm_App.appx = 0;
			arm_App.appy = 0;
		}
		if(arm_ui_UINodes.inst.grid != null) {
			let _grid = arm_ui_UINodes.inst.grid;
			arm_App.notifyOnNextFrame(function() {
				_grid.unload();
			});
			arm_ui_UINodes.inst.grid = null;
		}
		arm_App.redrawUI();
	}
	static redrawUI() {
		arm_ui_UISidebar.inst.hwnd0.redraws = 2;
		arm_ui_UISidebar.inst.hwnd1.redraws = 2;
		arm_ui_UIHeader.inst.headerHandle.redraws = 2;
		arm_ui_UIToolbar.inst.toolbarHandle.redraws = 2;
		arm_ui_UIStatus.inst.statusHandle.redraws = 2;
		arm_ui_UIMenubar.inst.menuHandle.redraws = 2;
		arm_ui_UIMenubar.inst.workspaceHandle.redraws = 2;
		arm_ui_UINodes.inst.hwnd.redraws = 2;
		arm_ui_UIView2D.inst.hwnd.redraws = 2;
		arm_ui_UIBox.hwnd.redraws = 2;
		if(arm_Context.ddirty < 0) {
			arm_Context.ddirty = 0;
		}
		if(arm_Context.splitView) {
			arm_Context.ddirty = 1;
		}
	}
	static update() {
		let mouse = iron_system_Input.getMouse();
		if(mouse.movementX != 0 || mouse.movementY != 0) {
			Krom.setMouseCursor(0);
		}
		let hasDrag = arm_App.dragAsset != null || arm_App.dragMaterial != null || arm_App.dragLayer != null || arm_App.dragFile != null || arm_App.dragSwatch != null;
		if(hasDrag && (mouse.movementX != 0 || mouse.movementY != 0)) {
			arm_App.isDragging = true;
		}
		if(mouse.released() && hasDrag) {
			let mx = mouse.x;
			let my = mouse.y;
			let inViewport = arm_Context.paintVec.x < 1 && arm_Context.paintVec.x > 0 && arm_Context.paintVec.y < 1 && arm_Context.paintVec.y > 0;
			let inLayers = arm_ui_UISidebar.inst.htab0.position == 0 && mx > arm_ui_UISidebar.inst.tabx && my < arm_Config.raw.layout[1];
			let inMaterials = arm_ui_UISidebar.inst.htab1.position == 0 && mx > arm_ui_UISidebar.inst.tabx && my > arm_Config.raw.layout[1] && my < arm_Config.raw.layout[2] + arm_Config.raw.layout[1];
			let in2dView = arm_ui_UIView2D.inst.show && arm_ui_UIView2D.inst.type == 0 && mx > arm_ui_UIView2D.inst.wx && mx < arm_ui_UIView2D.inst.wx + arm_ui_UIView2D.inst.ww && my > arm_ui_UIView2D.inst.wy && my < arm_ui_UIView2D.inst.wy + arm_ui_UIView2D.inst.wh;
			let inNodes = arm_ui_UINodes.inst.show && mx > arm_ui_UINodes.inst.wx && mx < arm_ui_UINodes.inst.wx + arm_ui_UINodes.inst.ww && my > arm_ui_UINodes.inst.wy && my < arm_ui_UINodes.inst.wy + arm_ui_UINodes.inst.wh;
			if(arm_App.dragAsset != null) {
				if(inNodes) {
					arm_ui_UINodes.inst.acceptAssetDrag(arm_Project.assets.indexOf(arm_App.dragAsset));
				} else if(inLayers || in2dView) {
					arm_Layers.createImageMask(arm_App.dragAsset);
				} else if(inViewport) {
					if(arm_App.dragAsset.file.toLowerCase().endsWith(".hdr")) {
						arm_io_ImportEnvmap.run(arm_App.dragAsset.file,arm_Project.getImage(arm_App.dragAsset));
					}
				}
				arm_App.dragAsset = null;
			} else if(arm_App.dragSwatch != null) {
				if(inNodes) {
					arm_ui_UINodes.inst.acceptSwatchDrag(arm_Project.raw.swatches.indexOf(arm_App.dragSwatch));
				} else if(inMaterials) {
					arm_ui_TabMaterials.acceptSwatchDrag(arm_Project.raw.swatches.indexOf(arm_App.dragSwatch));
				} else if(inLayers || inViewport) {
					arm_Layers.createColorLayer(arm_App.dragSwatch.base);
				}
				arm_App.dragSwatch = null;
			} else if(arm_App.dragMaterial != null) {
				arm_App.materialDropped(inViewport,inLayers,inNodes);
			} else if(arm_App.dragLayer != null) {
				if(inNodes) {
					arm_ui_UINodes.inst.acceptLayerDrag(arm_Project.layers.indexOf(arm_App.dragLayer));
				} else if(inLayers && arm_App.isDragging) {
					arm_App.dragLayer.move(arm_Context.dragDestination);
					arm_node_MakeMaterial.parseMeshMaterial();
				}
				arm_App.dragLayer = null;
			} else if(arm_App.dragFile != null) {
				let statush = arm_Config.raw.layout[5];
				if(!(mx > arm_App.x() && mx < arm_App.x() + (kha_System.windowWidth() - arm_ui_UIToolbar.inst.toolbarw - arm_Config.raw.layout[0]) && my > kha_System.windowHeight() - statush)) {
					arm_App.dropX = mouse.x;
					arm_App.dropY = mouse.y;
					let materialCount = arm_Project.materials.length;
					arm_io_ImportAsset.run(arm_App.dragFile,arm_App.dropX,arm_App.dropY,true,true,function() {
						if(arm_Project.materials.length > materialCount) {
							arm_App.dragMaterial = arm_Context.material;
							arm_App.materialDropped(inViewport,inLayers,inNodes);
						}
					});
				}
				arm_App.dragFile = null;
				arm_App.dragFileIcon = null;
			}
			Krom.setMouseCursor(0);
			arm_App.isDragging = false;
		}
		arm_App.handleDropPaths();
		zui_Zui.alwaysRedrawWindow = !arm_Context.cacheDraws || arm_ui_UIMenu.show || arm_ui_UIBox.show || arm_App.isDragging || arm_Context.tool == 9 || (arm_Context.tool == 3 || arm_Context.tool == 4) || arm_ui_UIView2D.inst.show || !arm_Config.raw.brush_3d || arm_Context.frame < 3;
		if(zui_Zui.alwaysRedrawWindow && arm_Context.ddirty < 0) {
			arm_Context.ddirty = 0;
		}
	}
	static materialDropped(inViewport,inLayers,inNodes) {
		if(inViewport || inLayers) {
			let uvType = iron_system_Input.getKeyboard().down("control") ? 2 : 0;
			arm_Layers.createFillLayer(uvType,uvType == 2 ? arm_util_RenderUtil.getDecalMat() : null);
		} else if(inNodes) {
			arm_ui_UINodes.inst.acceptMaterialDrag(arm_Project.materials.indexOf(arm_App.dragMaterial));
		}
		arm_App.dragMaterial = null;
	}
	static handleDropPaths() {
		if(arm_App.dropPaths.length > 0) {
			let mouse = iron_system_Input.getMouse();
			arm_App.dropX = mouse.x;
			arm_App.dropY = mouse.y;
			arm_io_ImportAsset.run(arm_App.dropPaths.shift(),arm_App.dropX,arm_App.dropY);
		}
	}
	static getDragBackground() {
		let icons = arm_Res.bundled.h["icons.k"];
		if(arm_App.dragLayer != null && !arm_App.dragLayer.isGroup() && arm_App.dragLayer.fill_layer == null) {
			return arm_Res.tile50(icons,4,1);
		}
		return null;
	}
	static getDragImage() {
		arm_App.dragTint = -1;
		arm_App.dragSize = -1;
		arm_App.dragRect = null;
		if(arm_App.dragAsset != null) {
			return arm_Project.getImage(arm_App.dragAsset);
		}
		if(arm_App.dragSwatch != null) {
			arm_App.dragTint = arm_App.dragSwatch.base;
			arm_App.dragSize = 26;
			return arm_ui_TabSwatches.empty;
		}
		if(arm_App.dragMaterial != null) {
			return arm_App.dragMaterial.imageIcon;
		}
		if(arm_App.dragLayer != null && arm_App.dragLayer.isGroup()) {
			let icons = arm_Res.bundled.h["icons.k"];
			arm_App.dragRect = arm_App.dragLayer.show_panel ? arm_Res.tile50(icons,8,1) : arm_Res.tile50(icons,2,1);
			arm_App.dragTint = arm_ui_UISidebar.inst.ui.t.LABEL_COL - 2105376;
			return icons;
		}
		if(arm_App.dragLayer != null && arm_App.dragLayer.isMask() && arm_App.dragLayer.fill_layer == null) {
			arm_ui_TabLayers.makeMaskPreviewRgba32(arm_App.dragLayer);
			return arm_Context.maskPreviewRgba32;
		}
		if(arm_App.dragLayer != null) {
			if(arm_App.dragLayer.fill_layer != null) {
				return arm_App.dragLayer.fill_layer.imageIcon;
			} else {
				return arm_App.dragLayer.texpaint_preview;
			}
		}
		if(arm_App.dragFile != null) {
			if(arm_App.dragFileIcon != null) {
				return arm_App.dragFileIcon;
			}
			let icons = arm_Res.bundled.h["icons.k"];
			arm_App.dragRect = arm_App.dragFile.indexOf(".") > 0 ? arm_Res.tile50(icons,3,1) : arm_Res.tile50(icons,2,1);
			arm_App.dragTint = arm_ui_UISidebar.inst.ui.t.HIGHLIGHT_COL;
			return icons;
		}
		return null;
	}
	static render(g) {
		if(kha_System.windowWidth() == 0 || kha_System.windowHeight() == 0) {
			return;
		}
		if(arm_Context.frame == 2) {
			arm_util_RenderUtil.makeMaterialPreview();
			arm_ui_UISidebar.inst.hwnd1.redraws = 2;
			arm_node_MakeMaterial.parseMeshMaterial();
			arm_node_MakeMaterial.parsePaintMaterial();
			arm_Context.ddirty = 0;
			if(arm_History.undoLayers == null) {
				arm_History.undoLayers = [];
				let _g = 0;
				let _g1 = arm_Config.raw.undo_steps;
				while(_g < _g1) {
					++_g;
					let l = new arm_data_LayerSlot("_undo" + arm_History.undoLayers.length);
					arm_History.undoLayers.push(l);
				}
			}
			if(arm_Config.raw.workspace != 0) {
				arm_ui_UIHeader.inst.worktab.position = arm_Config.raw.workspace;
				arm_ui_UIMenubar.inst.workspaceHandle.redraws = 2;
				if(arm_ui_UIHeader.inst.worktab.position == 2) {
					arm_Context.selectTool(11);
				} else {
					arm_Context.selectTool(10);
				}
				if(arm_ui_UIHeader.inst.worktab.position == 1) {
					arm_Layers.updateFillLayers();
					arm_ui_UINodes.inst.show = true;
				}
			}
		} else if(arm_Context.frame == 3) {
			arm_Context.ddirty = arm_Context.renderMode == 1 ? 3 : 1;
		}
		arm_Context.frame++;
		let mouse = iron_system_Input.getMouse();
		if(arm_App.isDragging) {
			Krom.setMouseCursor(1);
			let img = arm_App.getDragImage();
			let size = (arm_App.dragSize == -1 ? 50 : arm_App.dragSize) * arm_ui_UISidebar.inst.ui.ops.scaleFactor;
			let ratio = size / img.get_width();
			let h = img.get_height() * ratio;
			g.set_color(arm_App.dragTint);
			let bgRect = arm_App.getDragBackground();
			if(bgRect != null) {
				g.drawScaledSubImage(arm_Res.bundled.h["icons.k"],bgRect.x,bgRect.y,bgRect.w,bgRect.h,mouse.x + arm_App.dragOffX,mouse.y + arm_App.dragOffY,size,h);
			}
			if(arm_App.dragRect == null) {
				g.drawScaledImage(img,mouse.x + arm_App.dragOffX,mouse.y + arm_App.dragOffY,size,h);
			} else {
				g.drawScaledSubImage(img,arm_App.dragRect.x,arm_App.dragRect.y,arm_App.dragRect.w,arm_App.dragRect.h,mouse.x + arm_App.dragOffX,mouse.y + arm_App.dragOffY,size,h);
			}
			g.set_color(-1);
		}
		arm_App.uiEnabled = !arm_ui_UIBox.show && !(arm_ui_UIMenu.show && mouse.y > arm_ui_UIHeader.inst.headerh);
		if(arm_ui_UIBox.show) {
			arm_ui_UIBox.render(g);
		}
		if(arm_ui_UIMenu.show) {
			arm_ui_UIMenu.render(g);
		}
		arm_Context.lastPaintVecX = arm_Context.paintVec.x;
		arm_Context.lastPaintVecY = arm_Context.paintVec.y;
	}
	static enumTexts(nodeType) {
		if(nodeType == "TEX_IMAGE") {
			if(arm_Project.assetNames.length > 0) {
				return arm_Project.assetNames;
			} else {
				return [""];
			}
		} else if(nodeType == "LAYER" || nodeType == "LAYER_MASK") {
			let layerNames = [];
			let _g = 0;
			let _g1 = arm_Project.layers;
			while(_g < _g1.length) layerNames.push(_g1[_g++].name);
			return layerNames;
		} else if(nodeType == "MATERIAL") {
			let materialNames = [];
			let _g = 0;
			let _g1 = arm_Project.materials;
			while(_g < _g1.length) materialNames.push(_g1[_g++].canvas.name);
			return materialNames;
		}
		return null;
	}
	static getAssetIndex(fileName) {
		let i = arm_Project.assetNames.indexOf(fileName);
		if(i >= 0) {
			return i;
		} else {
			return 0;
		}
	}
	static notifyOnNextFrame(f) {
		let _render = null;
		_render = function(_) {
			iron_App.notifyOnInit(function() {
				let _update = null;
				_update = function() {
					iron_App.notifyOnInit(f);
					iron_App.removeUpdate(_update);
				};
				iron_App.notifyOnUpdate(_update);
			});
			iron_App.removeRender(_render);
		};
		iron_App.notifyOnRender(_render);
	}
	static toggleFullscreen() {
		if(kha_Window.get(0).get_mode() == 0) {
			arm_Config.raw.window_w = kha_System.windowWidth();
			arm_Config.raw.window_h = kha_System.windowHeight();
			arm_Config.raw.window_x = kha_Window.get(0).get_x();
			arm_Config.raw.window_y = kha_Window.get(0).get_y();
			kha_Window.get(0).set_mode(1);
		} else {
			kha_Window.get(0).set_mode(0);
			kha_Window.get(0).resize(arm_Config.raw.window_w,arm_Config.raw.window_h);
			kha_Window.get(0).move(arm_Config.raw.window_x,arm_Config.raw.window_y);
		}
	}
	static isScrolling() {
		let _g = 0;
		let _g1 = arm_App.getUIs();
		while(_g < _g1.length) if(_g1[_g++].isScrolling) {
			return true;
		}
		return false;
	}
	static isComboSelected() {
		let _g = 0;
		let _g1 = arm_App.getUIs();
		while(_g < _g1.length) if(_g1[_g++].comboSelectedHandle != null) {
			return true;
		}
		return false;
	}
	static getUIs() {
		return [arm_App.uiBox,arm_App.uiMenu,arm_ui_UISidebar.inst.ui,arm_ui_UINodes.inst.ui,arm_ui_UIView2D.inst.ui];
	}
	static isDecalLayer() {
		if(arm_ui_UIHeader.inst.worktab.position == 0 && arm_Context.layer.fill_layer != null) {
			return arm_Context.layer.uvType == 2;
		} else {
			return false;
		}
	}
	static redrawStatus() {
		if(arm_ui_UIStatus.inst != null) {
			arm_ui_UIStatus.inst.statusHandle.redraws = 2;
		}
	}
	static redrawConsole() {
		if(arm_ui_UIStatus.inst != null && arm_ui_UISidebar.inst != null && arm_ui_UISidebar.inst.ui != null && arm_Config.raw.layout[5] > 32 * arm_ui_UISidebar.inst.ui.ops.scaleFactor) {
			arm_ui_UIStatus.inst.statusHandle.redraws = 2;
		}
	}
	static initLayout() {
		let show2d = arm_ui_UINodes.inst != null && arm_ui_UINodes.inst.show || arm_ui_UIView2D.inst != null && arm_ui_UIView2D.inst.show;
		let raw = arm_Config.raw;
		raw.layout = [280 * raw.window_scale | 0,kha_System.windowHeight() / 2 | 0,kha_System.windowHeight() / 2 | 0,show2d ? (arm_App.w() + raw.layout[3]) / 2 | 0 : arm_App.w() / 2 | 0,arm_App.h() / 2 | 0,32 * raw.window_scale | 0];
	}
	static initConfig() {
		let raw = arm_Config.raw;
		raw.recent_projects = [];
		raw.bookmarks = [];
		raw.plugins = [];
		raw.keymap = "default.json";
		raw.theme = "default.json";
		raw.server = "https://armorpaint.fra1.digitaloceanspaces.com";
		raw.undo_steps = 4;
		raw.pressure_radius = true;
		raw.pressure_hardness = true;
		raw.pressure_angle = false;
		raw.pressure_opacity = false;
		raw.pressure_sensitivity = 1.0;
		raw.material_live = true;
		raw.brush_3d = true;
		raw.brush_depth_reject = true;
		raw.brush_angle_reject = true;
		raw.brush_live = false;
		raw.camera_speed = 1.0;
		raw.zoom_direction = 0;
		raw.displace_strength = 0.0;
		raw.show_asset_names = false;
		raw.wrap_mouse = false;
		raw.node_preview = true;
		raw.workspace = 0;
		raw.layer_res = 4;
		raw.dilate = 0;
		raw.dilate_radius = 2;
	}
}
$hxClasses["arm.App"] = arm_App;
arm_App.__name__ = "arm.App";
Object.assign(arm_App.prototype, {
	__class__: arm_App
});
class arm_Args {
	static parse() {
		if(Krom.getArgCount() > 1) {
			arm_Args.useArgs = true;
			let _g = 0;
			let _g1 = Krom.getArgCount();
			while(_g < _g1) {
				let v = _g++;
				let currentArg = Krom.getArg(v);
				if(arm_sys_Path.isProject(currentArg)) {
					arm_Project.filepath = currentArg;
				} else if(arm_sys_Path.isMesh(currentArg) || arm_sys_Path.isTexture(currentArg)) {
					arm_Args.assetPath = currentArg;
				} else if(currentArg == "--reload-mesh") {
					arm_Args.reimportMesh = true;
				} else if(currentArg == "--export-textures" && v + 3 <= Krom.getArgCount()) {
					arm_Args.exportTextures = true;
					arm_Args.exportTexturesType = Krom.getArg(v + 1);
					arm_Args.exportTexturesPreset = Krom.getArg(v + 2);
					arm_Args.exportTexturesPath = Krom.getArg(v + 3);
				} else if(currentArg == "--export-mesh" && v + 1 <= Krom.getArgCount()) {
					arm_Args.exportMesh = true;
					arm_Args.exportMeshPath = Krom.getArg(v + 1);
				} else if(currentArg == "--b" || currentArg == "--background") {
					arm_Args.background = true;
				}
			}
		}
	}
	static run() {
		if(arm_Args.useArgs) {
			iron_App.notifyOnInit(function() {
				if(arm_Project.filepath != "") {
					arm_io_ImportArm.runProject(arm_Project.filepath);
				} else if(arm_Args.assetPath != "") {
					arm_io_ImportAsset.run(arm_Args.assetPath,-1,-1,false);
					if(arm_sys_Path.isTexture(arm_Args.assetPath)) {
						arm_ui_UISidebar.inst.show2DView(1);
					}
				} else if(arm_Args.reimportMesh) {
					arm_Project.reimportMesh();
				} else if(arm_Args.exportTextures) {
					if(arm_Args.exportTexturesType == "png" || arm_Args.exportTexturesType == "jpg" || arm_Args.exportTexturesType == "exr16" || arm_Args.exportTexturesType == "exr32") {
						if(arm_sys_Path.isFolder(arm_Args.exportTexturesPath)) {
							if(arm_Args.exportTexturesType == "png") {
								arm_App.bitsHandle.position = 0;
								arm_Context.formatType = 0;
							} else if(arm_Args.exportTexturesType == "jpg") {
								arm_App.bitsHandle.position = 0;
								arm_Context.formatType = 1;
							} else if(arm_Args.exportTexturesType == "exr16") {
								arm_App.bitsHandle.position = 1;
							} else if(arm_Args.exportTexturesType == "exr32") {
								arm_App.bitsHandle.position = 2;
							}
							arm_Context.layersExport = 0;
							arm_ui_BoxExport.files = arm_sys_File.readDirectory(arm_sys_Path.data() + arm_sys_Path.sep + "export_presets");
							let _g = 0;
							let _g1 = arm_ui_BoxExport.files.length;
							while(_g < _g1) {
								let i = _g++;
								arm_ui_BoxExport.files[i] = HxOverrides.substr(arm_ui_BoxExport.files[i],0,arm_ui_BoxExport.files[i].length - 5);
							}
							let file = "export_presets/" + arm_ui_BoxExport.files[0] + ".json";
							let _g2 = 0;
							let _g3 = arm_ui_BoxExport.files;
							while(_g2 < _g3.length) {
								let f = _g3[_g2];
								++_g2;
								if(f == arm_Args.exportTexturesPreset) {
									file = "export_presets/" + arm_ui_BoxExport.files[arm_ui_BoxExport.files.indexOf(f)] + ".json";
								}
							}
							iron_data_Data.getBlob(file,function(blob) {
								arm_ui_BoxExport.preset = JSON.parse(blob.toString());
								iron_data_Data.deleteBlob("export_presets/" + file);
							});
							iron_App.notifyOnInit(function() {
								arm_io_ExportTexture.run(arm_Args.exportTexturesPath);
							});
						} else {
							haxe_Log.trace("Invalid export directory",{ fileName : "arm/Args.hx", lineNumber : 120, className : "arm.Args", methodName : "run"});
						}
					} else {
						haxe_Log.trace("Invalid texture type",{ fileName : "arm/Args.hx", lineNumber : 124, className : "arm.Args", methodName : "run"});
					}
				} else if(arm_Args.exportMesh) {
					if(arm_sys_Path.isFolder(arm_Args.exportMeshPath)) {
						let f = arm_ui_UIFiles.filename;
						if(f == "") {
							f = arm_Translator.tr("untitled");
						}
						arm_io_ExportMesh.run(arm_Args.exportMeshPath + arm_sys_Path.sep + f,null,false);
					} else {
						haxe_Log.trace("Invalid export directory",{ fileName : "arm/Args.hx", lineNumber : 134, className : "arm.Args", methodName : "run"});
					}
				}
				if(arm_Args.background) {
					kha_System.stop();
				}
			});
		}
	}
}
$hxClasses["arm.Args"] = arm_Args;
arm_Args.__name__ = "arm.Args";
class arm_Camera {
	constructor() {
		this.controlsDown = false;
		this.ease = 1.0;
		this.dir = new iron_math_Vec4();
		this.first = true;
		this.redraws = 0;
		arm_Camera.inst = this;
		let mouse = iron_system_Input.getMouse();
		let kb = iron_system_Input.getKeyboard();
		let camera = iron_Scene.active.camera;
		let _gthis = this;
		iron_App.notifyOnUpdate(function() {
			if(_gthis.first) {
				_gthis.first = false;
				_gthis.reset();
			}
			if(mouse.x - arm_App.x() < 0 || mouse.x - arm_App.x() > arm_App.w() || mouse.y - arm_App.y() < 0 || mouse.y - arm_App.y() > arm_App.h()) {
				if(arm_Config.raw.wrap_mouse && _gthis.controlsDown) {
					if(mouse.x - arm_App.x() < 0) {
						let tmp = arm_App.x();
						let tmp1 = arm_App.w();
						mouse.x = mouse.lastX = tmp + tmp1;
						Krom.setMousePosition(0,mouse.x | 0,mouse.y | 0);
					} else if(mouse.x - arm_App.x() > arm_App.w()) {
						mouse.x = mouse.lastX = arm_App.x();
						Krom.setMousePosition(0,mouse.x | 0,mouse.y | 0);
					} else if(mouse.y - arm_App.y() < 0) {
						let tmp = arm_App.y();
						let tmp1 = arm_App.h();
						mouse.y = mouse.lastY = tmp + tmp1;
						Krom.setMousePosition(0,mouse.x | 0,mouse.y | 0);
					} else if(mouse.y - arm_App.y() > arm_App.h()) {
						mouse.y = mouse.lastY = arm_App.y();
						Krom.setMousePosition(0,mouse.x | 0,mouse.y | 0);
					}
				} else {
					return;
				}
			}
			let modifKey = kb.down("alt") || kb.down("shift") || kb.down("control");
			let modif = modifKey || arm_Config.keymap.action_rotate == "middle";
			if(arm_Operator.shortcut(arm_Config.keymap.action_rotate,0) || arm_Operator.shortcut(arm_Config.keymap.action_zoom,0) || arm_Operator.shortcut(arm_Config.keymap.action_pan,0) || arm_Operator.shortcut(arm_Config.keymap.rotate_envmap,0) || arm_Operator.shortcut(arm_Config.keymap.rotate_light,0) || mouse.started("right") && !modif || mouse.started("middle") && !modif || mouse.wheelDelta != 0 && !modifKey) {
				_gthis.controlsDown = true;
			} else if(!arm_Operator.shortcut(arm_Config.keymap.action_rotate,2) && !arm_Operator.shortcut(arm_Config.keymap.action_zoom,2) && !arm_Operator.shortcut(arm_Config.keymap.action_pan,2) && !arm_Operator.shortcut(arm_Config.keymap.rotate_envmap,2) && !arm_Operator.shortcut(arm_Config.keymap.rotate_light,2) && !(mouse.down("right") && !modif) && !(mouse.down("middle") && !modif) && (mouse.wheelDelta == 0 && !modifKey)) {
				_gthis.controlsDown = false;
			}
			if(iron_system_Input.occupied || !arm_App.uiEnabled || arm_App.isDragging || arm_App.isScrolling() || arm_App.isComboSelected() || !_gthis.controlsDown) {
				return;
			}
			let controls = arm_Context.cameraControls;
			if(controls == 0) {
				if(arm_Operator.shortcut(arm_Config.keymap.action_rotate,2) || mouse.down("right") && !modif) {
					_gthis.redraws = 2;
					let dist = _gthis.distance();
					camera.transform.move(new iron_math_Vec4(-camera.transform.world.self._20,-camera.transform.world.self._21,-camera.transform.world.self._22),dist);
					camera.transform.rotate(new iron_math_Vec4(0.0,0.0,1.0),-mouse.movementX / 100 * arm_Config.raw.camera_speed);
					camera.transform.rotate(new iron_math_Vec4(camera.transform.world.self._00,camera.transform.world.self._01,camera.transform.world.self._02),-mouse.movementY / 100 * arm_Config.raw.camera_speed);
					let z = camera.transform.world.self._12;
					if(z == null) {
						z = 0.0;
					}
					if(z < 0) {
						camera.transform.rotate(new iron_math_Vec4(camera.transform.world.self._00,camera.transform.world.self._01,camera.transform.world.self._02),mouse.movementY / 100 * arm_Config.raw.camera_speed);
					}
					camera.transform.move(new iron_math_Vec4(-camera.transform.world.self._20,-camera.transform.world.self._21,-camera.transform.world.self._22),-dist);
				}
				_gthis.panAction(modif);
				if(arm_Operator.shortcut(arm_Config.keymap.action_zoom,2)) {
					_gthis.redraws = 2;
					let f = arm_Camera.getZoomDelta() / 150;
					f *= _gthis.getCameraSpeed();
					camera.transform.move(new iron_math_Vec4(-camera.transform.local.self._20,-camera.transform.local.self._21,-camera.transform.local.self._22),f);
				}
				if(mouse.wheelDelta != 0 && !modifKey) {
					_gthis.redraws = 2;
					let f = mouse.wheelDelta * -0.1;
					f *= _gthis.getCameraSpeed();
					camera.transform.move(new iron_math_Vec4(-camera.transform.local.self._20,-camera.transform.local.self._21,-camera.transform.local.self._22),f);
				}
				if(arm_Operator.shortcut(arm_Config.keymap.rotate_light,2)) {
					_gthis.redraws = 2;
					let light = iron_Scene.active.lights[0];
					let m_self = new kha_math_FastMatrix4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
					let alpha = mouse.movementX / 100;
					let ca = Math.cos(alpha);
					let sa = Math.sin(alpha);
					m_self = new kha_math_FastMatrix4(ca,-sa,0,0,sa,ca,0,0,0,0,1,0,0,0,0,1);
					let _this = light.transform.local;
					let a00 = _this.self._00;
					let a01 = _this.self._01;
					let a02 = _this.self._02;
					let a03 = _this.self._03;
					let a10 = _this.self._10;
					let a11 = _this.self._11;
					let a12 = _this.self._12;
					let a13 = _this.self._13;
					let a20 = _this.self._20;
					let a21 = _this.self._21;
					let a22 = _this.self._22;
					let a23 = _this.self._23;
					let a30 = _this.self._30;
					let a31 = _this.self._31;
					let a32 = _this.self._32;
					let a33 = _this.self._33;
					let b0 = m_self._00;
					let b1 = m_self._10;
					let b2 = m_self._20;
					let b3 = m_self._30;
					_this.self._00 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this.self._10 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this.self._20 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this.self._30 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					b0 = m_self._01;
					b1 = m_self._11;
					b2 = m_self._21;
					b3 = m_self._31;
					_this.self._01 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this.self._11 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this.self._21 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this.self._31 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					b0 = m_self._02;
					b1 = m_self._12;
					b2 = m_self._22;
					b3 = m_self._32;
					_this.self._02 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this.self._12 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this.self._22 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this.self._32 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					b0 = m_self._03;
					b1 = m_self._13;
					b2 = m_self._23;
					b3 = m_self._33;
					_this.self._03 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this.self._13 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this.self._23 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this.self._33 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					light.transform.decompose();
				}
				if(arm_Operator.shortcut(arm_Config.keymap.rotate_envmap,2)) {
					_gthis.redraws = 2;
					arm_Context.envmapAngle -= mouse.movementX / 100;
				}
			} else if(controls == 1) {
				if(arm_Operator.shortcut(arm_Config.keymap.action_rotate,2) || mouse.down("right") && !modif) {
					_gthis.redraws = 2;
					let t = arm_Context.mainObject().transform;
					let _this = t.world;
					let _this1 = new iron_math_Vec4(_this.self._20,_this.self._21,_this.self._22);
					let n = Math.sqrt(_this1.x * _this1.x + _this1.y * _this1.y + _this1.z * _this1.z);
					if(n > 0.0) {
						let invN = 1.0 / n;
						_this1.x *= invN;
						_this1.y *= invN;
						_this1.z *= invN;
					}
					t.rotate(_this1,mouse.movementX / 100);
					let _this2 = new iron_math_Vec4(camera.transform.world.self._00,camera.transform.world.self._01,camera.transform.world.self._02);
					let n1 = Math.sqrt(_this2.x * _this2.x + _this2.y * _this2.y + _this2.z * _this2.z);
					if(n1 > 0.0) {
						let invN = 1.0 / n1;
						_this2.x *= invN;
						_this2.y *= invN;
						_this2.z *= invN;
					}
					t.rotate(_this2,mouse.movementY / 100);
					t.buildMatrix();
					let z = t.world.self._22;
					if(z == null) {
						z = 0.0;
					}
					if(z < 0) {
						t.rotate(_this2,-mouse.movementY / 100);
					}
				}
				_gthis.panAction(modif);
				if(arm_Operator.shortcut(arm_Config.keymap.action_zoom,2)) {
					_gthis.redraws = 2;
					let f = arm_Camera.getZoomDelta() / 150;
					f *= _gthis.getCameraSpeed();
					camera.transform.move(new iron_math_Vec4(-camera.transform.local.self._20,-camera.transform.local.self._21,-camera.transform.local.self._22),f);
				}
				if(mouse.wheelDelta != 0) {
					_gthis.redraws = 2;
					let f = mouse.wheelDelta * -0.1;
					f *= _gthis.getCameraSpeed();
					camera.transform.move(new iron_math_Vec4(-camera.transform.local.self._20,-camera.transform.local.self._21,-camera.transform.local.self._22),f);
				}
			} else if(controls == 2 && mouse.down("right")) {
				let moveForward = kb.down("w") || kb.down("up") || mouse.wheelDelta < 0;
				let moveBackward = kb.down("s") || kb.down("down") || mouse.wheelDelta > 0;
				let strafeLeft = kb.down("a") || kb.down("left");
				let strafeRight = kb.down("d") || kb.down("right");
				let strafeUp = kb.down("e");
				let strafeDown = kb.down("q");
				let fast = kb.down("shift") ? 2.0 : kb.down("alt") ? 0.5 : 1.0;
				if(mouse.wheelDelta != 0) {
					fast *= Math.abs(mouse.wheelDelta) * 4.0;
				}
				if(moveForward || moveBackward || strafeRight || strafeLeft || strafeUp || strafeDown) {
					_gthis.ease += iron_system_Time.get_delta() * 15;
					if(_gthis.ease > 1.0) {
						_gthis.ease = 1.0;
					}
					let _this = _gthis.dir;
					_this.x = 0;
					_this.y = 0;
					_this.z = 0;
					_this.w = 1.0;
					if(moveForward) {
						let _this = _gthis.dir;
						let x = -camera.transform.local.self._20;
						if(x == null) {
							x = 0.0;
						}
						let y1 = -camera.transform.local.self._21;
						if(y1 == null) {
							y1 = 0.0;
						}
						let z2 = -camera.transform.local.self._22;
						if(z2 == null) {
							z2 = 0.0;
						}
						_this.x += x;
						_this.y += y1;
						_this.z += z2;
					}
					if(moveBackward) {
						let _this = _gthis.dir;
						let x = -camera.transform.local.self._20;
						if(x == null) {
							x = 0.0;
						}
						let y1 = -camera.transform.local.self._21;
						if(y1 == null) {
							y1 = 0.0;
						}
						let z2 = -camera.transform.local.self._22;
						if(z2 == null) {
							z2 = 0.0;
						}
						_this.x += -x;
						_this.y += -y1;
						_this.z += -z2;
					}
					if(strafeRight) {
						let _this = _gthis.dir;
						let x = camera.transform.local.self._00;
						if(x == null) {
							x = 0.0;
						}
						let y1 = camera.transform.local.self._01;
						if(y1 == null) {
							y1 = 0.0;
						}
						let z2 = camera.transform.local.self._02;
						if(z2 == null) {
							z2 = 0.0;
						}
						_this.x += x;
						_this.y += y1;
						_this.z += z2;
					}
					if(strafeLeft) {
						let _this = _gthis.dir;
						let x = camera.transform.local.self._00;
						if(x == null) {
							x = 0.0;
						}
						let y1 = camera.transform.local.self._01;
						if(y1 == null) {
							y1 = 0.0;
						}
						let z2 = camera.transform.local.self._02;
						if(z2 == null) {
							z2 = 0.0;
						}
						_this.x += -x;
						_this.y += -y1;
						_this.z += -z2;
					}
					if(strafeUp) {
						let _this = _gthis.dir;
						_this.x += 0;
						_this.y += 0;
						_this.z += 1;
					}
					if(strafeDown) {
						let _this = _gthis.dir;
						_this.x += 0;
						_this.y += 0;
						_this.z += -1;
					}
				} else {
					_gthis.ease -= iron_system_Time.get_delta() * 20.0 * _gthis.ease;
					if(_gthis.ease < 0.0) {
						_gthis.ease = 0.0;
					}
				}
				let d = iron_system_Time.get_delta() * fast * _gthis.ease * 2.0 * arm_Config.raw.camera_speed;
				if(d > 0.0) {
					camera.transform.move(_gthis.dir,d);
					if(arm_Context.cameraType == 1) {
						arm_Viewport.updateCameraType(arm_Context.cameraType);
					}
				}
				_gthis.redraws = 2;
				camera.transform.rotate(new iron_math_Vec4(0.0,0.0,1.0),-mouse.movementX / 200);
				camera.transform.rotate(new iron_math_Vec4(camera.transform.local.self._00,camera.transform.local.self._01,camera.transform.local.self._02),-mouse.movementY / 200);
			}
			if(_gthis.redraws > 0) {
				_gthis.redraws--;
				arm_Context.ddirty = 2;
				if(arm_Context.cameraType == 1) {
					arm_Viewport.updateCameraType(arm_Context.cameraType);
				}
			}
		});
	}
	distance() {
		let camera = iron_Scene.active.camera;
		let v1 = this.origins[this.index()];
		let v2 = camera.transform.loc;
		let vx = v1.x - v2.x;
		let vy = v1.y - v2.y;
		let vz = v1.z - v2.z;
		return Math.sqrt(vx * vx + vy * vy + vz * vz);
	}
	index() {
		if(arm_Context.viewIndexLast > 0) {
			return 1;
		} else {
			return 0;
		}
	}
	getCameraSpeed() {
		return arm_Config.raw.camera_speed * (arm_Config.raw.zoom_direction == 1 || arm_Config.raw.zoom_direction == 3 || arm_Config.raw.zoom_direction == 5 ? -1 : 1);
	}
	reset(viewIndex) {
		if(viewIndex == null) {
			viewIndex = -1;
		}
		let camera = iron_Scene.active.camera;
		if(viewIndex == -1) {
			this.origins = [new iron_math_Vec4(0,0,0),new iron_math_Vec4(0,0,0)];
			let _this = camera.transform.local;
			let _this1 = camera.transform.local;
			this.views = [new iron_math_Mat4(_this.self._00,_this.self._10,_this.self._20,_this.self._30,_this.self._01,_this.self._11,_this.self._21,_this.self._31,_this.self._02,_this.self._12,_this.self._22,_this.self._32,_this.self._03,_this.self._13,_this.self._23,_this.self._33),new iron_math_Mat4(_this1.self._00,_this1.self._10,_this1.self._20,_this1.self._30,_this1.self._01,_this1.self._11,_this1.self._21,_this1.self._31,_this1.self._02,_this1.self._12,_this1.self._22,_this1.self._32,_this1.self._03,_this1.self._13,_this1.self._23,_this1.self._33)];
		} else {
			this.origins[viewIndex] = new iron_math_Vec4(0,0,0);
			let _this = camera.transform.local;
			this.views[viewIndex] = new iron_math_Mat4(_this.self._00,_this.self._10,_this.self._20,_this.self._30,_this.self._01,_this.self._11,_this.self._21,_this.self._31,_this.self._02,_this.self._12,_this.self._22,_this.self._32,_this.self._03,_this.self._13,_this.self._23,_this.self._33);
		}
	}
	panAction(modif) {
		let camera = iron_Scene.active.camera;
		let mouse = iron_system_Input.getMouse();
		if(arm_Operator.shortcut(arm_Config.keymap.action_pan,2) || mouse.down("middle") && !modif) {
			this.redraws = 2;
			let _this = camera.transform.world;
			let x = _this.self._10;
			let y = _this.self._11;
			let z = _this.self._12;
			if(z == null) {
				z = 0.0;
			}
			if(y == null) {
				y = 0.0;
			}
			if(x == null) {
				x = 0.0;
			}
			let look_x = x;
			let look_y = y;
			let look_z = z;
			let n = Math.sqrt(look_x * look_x + look_y * look_y + look_z * look_z);
			if(n > 0.0) {
				let invN = 1.0 / n;
				look_x *= invN;
				look_y *= invN;
				look_z *= invN;
			}
			let f = mouse.movementY / 150 * arm_Config.raw.camera_speed;
			look_x *= f;
			look_y *= f;
			look_z *= f;
			let _this1 = camera.transform.world;
			let x1 = _this1.self._00;
			let y1 = _this1.self._01;
			let z1 = _this1.self._02;
			if(z1 == null) {
				z1 = 0.0;
			}
			if(y1 == null) {
				y1 = 0.0;
			}
			if(x1 == null) {
				x1 = 0.0;
			}
			let right_x = x1;
			let right_y = y1;
			let right_z = z1;
			let n1 = Math.sqrt(right_x * right_x + right_y * right_y + right_z * right_z);
			if(n1 > 0.0) {
				let invN = 1.0 / n1;
				right_x *= invN;
				right_y *= invN;
				right_z *= invN;
			}
			let f1 = -mouse.movementX / 150 * arm_Config.raw.camera_speed;
			right_x *= f1;
			right_y *= f1;
			right_z *= f1;
			let _this2 = camera.transform.loc;
			_this2.x += look_x;
			_this2.y += look_y;
			_this2.z += look_z;
			let _this3 = camera.transform.loc;
			_this3.x += right_x;
			_this3.y += right_y;
			_this3.z += right_z;
			let _this4 = this.origins[this.index()];
			_this4.x += look_x;
			_this4.y += look_y;
			_this4.z += look_z;
			let _this5 = this.origins[this.index()];
			_this5.x += right_x;
			_this5.y += right_y;
			_this5.z += right_z;
			camera.buildMatrix();
		}
	}
	static getZoomDelta() {
		let mouse = iron_system_Input.getMouse();
		if(arm_Config.raw.zoom_direction == 0) {
			return -mouse.movementY;
		} else if(arm_Config.raw.zoom_direction == 1) {
			return -mouse.movementY;
		} else if(arm_Config.raw.zoom_direction == 2) {
			return mouse.movementX;
		} else if(arm_Config.raw.zoom_direction == 3) {
			return mouse.movementX;
		} else {
			return -(mouse.movementY - mouse.movementX);
		}
	}
}
$hxClasses["arm.Camera"] = arm_Camera;
arm_Camera.__name__ = "arm.Camera";
Object.assign(arm_Camera.prototype, {
	__class__: arm_Camera
});
class arm_Config {
	static load(done) {
		try {
			iron_data_Data.getBlob((arm_sys_Path.isProtected() ? Krom.savePath() : "") + "config.arm",function(blob) {
				arm_Config.configLoaded = true;
				arm_Config.raw = JSON.parse(blob.toString());
				done();
			});
		} catch( _g ) {
			done();
		}
	}
	static save() {
		Krom.fileSaveBytes((arm_sys_Path.isProtected() ? Krom.savePath() : arm_sys_Path.data() + arm_sys_Path.sep) + "config.arm",haxe_io_Bytes.ofString(JSON.stringify(arm_Config.raw)).b.bufferValue);
	}
	static init() {
		while(true) {
			if(!arm_Config.configLoaded || arm_Config.raw == null) {
				arm_Config.raw = { };
				arm_Config.raw.locale = "system";
				arm_Config.raw.window_mode = 0;
				arm_Config.raw.window_resizable = true;
				arm_Config.raw.window_minimizable = true;
				arm_Config.raw.window_maximizable = true;
				arm_Config.raw.window_w = 1600;
				arm_Config.raw.window_h = 900;
				arm_Config.raw.window_x = -1;
				arm_Config.raw.window_y = -1;
				arm_Config.raw.window_scale = 1.0;
				let disp = kha_Display.get_primary();
				if(disp.get_width() >= 2560 && disp.get_height() >= 1600) {
					arm_Config.raw.window_scale = 2.0;
				}
				arm_Config.raw.window_vsync = true;
				arm_Config.raw.window_frequency = disp.get_frequency();
				arm_Config.raw.rp_bloom = false;
				arm_Config.raw.rp_gi = false;
				arm_Config.raw.rp_vignette = 0.2;
				arm_Config.raw.rp_motionblur = false;
				arm_Config.raw.rp_ssgi = true;
				arm_Config.raw.rp_ssr = false;
				arm_Config.raw.rp_supersample = 1.0;
				arm_Config.raw.version = Main.version;
				arm_Config.raw.sha = Main.sha;
				arm_App.initConfig();
			} else if(arm_Config.raw.sha != Main.sha) {
				arm_Config.configLoaded = false;
				continue;
			}
			arm_App.resHandle.position = arm_Config.raw.layer_res;
			arm_Config.loadKeymap();
			return;
		}
	}
	static getOptions() {
		let windowFeatures = 0;
		if(arm_Config.raw.window_resizable) {
			windowFeatures |= 1;
		}
		if(arm_Config.raw.window_maximizable) {
			windowFeatures |= 4;
		}
		if(arm_Config.raw.window_minimizable) {
			windowFeatures |= 2;
		}
		return new kha_SystemOptions("untitled - " + "ArmorPaint",-1,-1,new kha_WindowOptions(null,arm_Config.raw.window_x,arm_Config.raw.window_y,arm_Config.raw.window_w,arm_Config.raw.window_h,-1,true,windowFeatures,arm_Config.raw.window_mode == 0 ? 0 : 1),new kha_FramebufferOptions(arm_Config.raw.window_frequency,arm_Config.raw.window_vsync,32,16,8,1));
	}
	static restore() {
		zui_Handle.global = new zui_Handle();
		arm_Config.configLoaded = false;
		let _layout = arm_Config.raw.layout;
		arm_Config.init();
		arm_Config.raw.layout = _layout;
		arm_App.initLayout();
		arm_Translator.loadTranslations(arm_Config.raw.locale);
		arm_Config.applyConfig();
		arm_Config.loadTheme(arm_Config.raw.theme);
	}
	static importFrom(from) {
		let _sha = arm_Config.raw.sha;
		let _version = arm_Config.raw.version;
		arm_Config.raw = from;
		arm_Config.raw.sha = _sha;
		arm_Config.raw.version = _version;
		zui_Handle.global = new zui_Handle();
		arm_Config.loadKeymap();
		arm_App.initLayout();
		arm_Translator.loadTranslations(arm_Config.raw.locale);
		arm_Config.applyConfig();
		arm_Config.loadTheme(arm_Config.raw.theme);
	}
	static applyConfig() {
		arm_Config.raw.rp_ssgi = arm_Context.hssgi.selected;
		arm_Config.raw.rp_ssr = arm_Context.hssr.selected;
		arm_Config.raw.rp_bloom = arm_Context.hbloom.selected;
		arm_Config.raw.rp_gi = arm_Context.hvxao.selected;
		let i = arm_Context.hsupersample.position;
		arm_Config.raw.rp_supersample = i == 0 ? 0.25 : i == 1 ? 0.5 : i == 2 ? 1.0 : i == 3 ? 1.5 : i == 4 ? 2.0 : 4.0;
		iron_object_Uniforms.defaultFilter = arm_Config.raw.rp_supersample < 1.0 ? 0 : 1;
		arm_Config.save();
		arm_Context.ddirty = 2;
		let current = kha_graphics2_Graphics.current;
		if(current != null) {
			current.end();
		}
		arm_render_Inc.applyConfig();
		if(current != null) {
			current.begin(false);
		}
	}
	static loadKeymap() {
		iron_data_Data.getBlob("keymap_presets/" + arm_Config.raw.keymap,function(blob) {
			arm_Config.keymap = JSON.parse(blob.toString());
		});
	}
	static saveKeymap() {
		Krom.fileSaveBytes(iron_data_Data.dataPath + "keymap_presets/" + arm_Config.raw.keymap,haxe_io_Bytes.ofString(JSON.stringify(arm_Config.keymap)).b.bufferValue);
	}
	static getTextureRes() {
		let res = arm_App.resHandle.position;
		if(res == 0) {
			return 128;
		} else if(res == 1) {
			return 256;
		} else if(res == 2) {
			return 512;
		} else if(res == 3) {
			return 1024;
		} else if(res == 4) {
			return 2048;
		} else if(res == 5) {
			return 4096;
		} else if(res == 6) {
			return 8192;
		} else if(res == 7) {
			return 16384;
		} else {
			return 0;
		}
	}
	static getTextureResX() {
		if(arm_Context.projectAspectRatio == 2) {
			return arm_Config.getTextureRes() / 2 | 0;
		} else {
			return arm_Config.getTextureRes();
		}
	}
	static getTextureResY() {
		if(arm_Context.projectAspectRatio == 1) {
			return arm_Config.getTextureRes() / 2 | 0;
		} else {
			return arm_Config.getTextureRes();
		}
	}
	static getTextureResPos(i) {
		if(i == 128) {
			return 0;
		} else if(i == 256) {
			return 1;
		} else if(i == 512) {
			return 2;
		} else if(i == 1024) {
			return 3;
		} else if(i == 2048) {
			return 4;
		} else if(i == 4096) {
			return 5;
		} else if(i == 8192) {
			return 6;
		} else if(i == 16384) {
			return 7;
		} else {
			return 0;
		}
	}
	static loadTheme(theme,tagRedraw) {
		if(tagRedraw == null) {
			tagRedraw = true;
		}
		if(theme == "default.json") {
			arm_App.theme = zui_Themes.dark;
		} else {
			iron_data_Data.getBlob("themes/" + theme,function(b) {
				arm_App.theme = JSON.parse(b.toString());
			});
		}
		arm_App.theme.FILL_WINDOW_BG = true;
		if(tagRedraw) {
			let _g = 0;
			let _g1 = arm_App.getUIs();
			while(_g < _g1.length) _g1[_g++].t = arm_App.theme;
			arm_ui_UISidebar.inst.tagUIRedraw();
		}
	}
	static enablePlugin(f) {
		arm_Config.raw.plugins.push(f);
		arm_Plugin.start(f);
	}
	static disablePlugin(f) {
		HxOverrides.remove(arm_Config.raw.plugins,f);
		arm_Plugin.stop(f);
	}
}
$hxClasses["arm.Config"] = arm_Config;
arm_Config.__name__ = "arm.Config";
class arm_Console {
	static toast(s) {
		let _render = null;
		_render = function(g) {
			g.set_color(1426063360);
			g.fillRect(0,0,kha_System.windowWidth(),kha_System.windowHeight());
			let scale = arm_App.getUIs()[0].ops.scaleFactor;
			let x = kha_System.windowWidth() / 2;
			let y = kha_System.windowHeight() - 200 * scale;
			g.fillRect(x - 200 * scale,y,400 * scale,80 * scale);
			g.set_font(arm_App.font);
			g.set_fontSize(22 * scale | 0);
			g.set_color(-1);
			g.drawString(s,x - g.get_font().width(g.get_fontSize(),s) / 2,y + 40 * scale - g.get_font().height(g.get_fontSize()) / 2);
			arm_App.notifyOnNextFrame(function() {
				iron_App.removeRender2D(_render);
			});
		};
		iron_App.notifyOnRender2D(_render);
		arm_Console.consoleTrace(s,{ fileName : "Sources/arm/Console.hx", lineNumber : 32, className : "arm.Console", methodName : "toast"});
	}
	static info(s) {
		arm_Console.messageTimer = 5.0;
		arm_Console.message = s;
		arm_Console.messageColor = 0;
		arm_App.redrawStatus();
		arm_Console.consoleTrace(s,{ fileName : "Sources/arm/Console.hx", lineNumber : 40, className : "arm.Console", methodName : "info"});
	}
	static error(s) {
		arm_Console.messageTimer = 8.0;
		arm_Console.message = s;
		arm_Console.messageColor = -5636096;
		arm_App.redrawStatus();
		arm_Console.consoleTrace(s,{ fileName : "Sources/arm/Console.hx", lineNumber : 48, className : "arm.Console", methodName : "error"});
	}
	static log(s) {
		arm_Console.consoleTrace(s,{ fileName : "Sources/arm/Console.hx", lineNumber : 52, className : "arm.Console", methodName : "log"});
	}
	static init() {
		if(arm_Console.haxeTrace == null) {
			arm_Console.haxeTrace = haxe_Log.trace;
			haxe_Log.trace = arm_Console.consoleTrace;
		}
	}
	static consoleTrace(v,inf) {
		arm_App.redrawConsole();
		arm_Console.lastTraces.unshift(Std.string(v));
		if(arm_Console.lastTraces.length > 100) {
			arm_Console.lastTraces.pop();
		}
		arm_Console.haxeTrace(v,inf);
	}
}
$hxClasses["arm.Console"] = arm_Console;
arm_Console.__name__ = "arm.Console";
class iron_math_Vec4 {
	constructor(x,y,z,w) {
		if(w == null) {
			w = 1.0;
		}
		if(z == null) {
			z = 0.0;
		}
		if(y == null) {
			y = 0.0;
		}
		if(x == null) {
			x = 0.0;
		}
		this.x = x;
		this.y = y;
		this.z = z;
		this.w = w;
	}
}
$hxClasses["iron.math.Vec4"] = iron_math_Vec4;
iron_math_Vec4.__name__ = "iron.math.Vec4";
Object.assign(iron_math_Vec4.prototype, {
	__class__: iron_math_Vec4
});
class arm_Project {
	static projectOpen() {
		arm_ui_UIFiles.show("arm",false,false,function(path) {
			if(!path.endsWith(".arm")) {
				arm_Console.error(arm_Strings.error0());
				return;
			}
			let current = kha_graphics2_Graphics.current;
			if(current != null) {
				current.end();
			}
			arm_io_ImportArm.runProject(path);
			if(current != null) {
				current.begin(false);
			}
		});
	}
	static projectOpenRecentBox() {
		arm_ui_UIBox.showCustom(function(ui) {
			if(ui.tab(zui_Handle.global.nest(31,null),arm_Translator.tr("Recent Projects"))) {
				let _g = 0;
				let _g1 = arm_Config.raw.recent_projects;
				while(_g < _g1.length) {
					let path = _g1[_g];
					++_g;
					let file = path;
					file = StringTools.replace(path,"/","\\");
					file = HxOverrides.substr(file,file.lastIndexOf(arm_sys_Path.sep) + 1,null);
					if(ui.button(file,0)) {
						let current = kha_graphics2_Graphics.current;
						if(current != null) {
							current.end();
						}
						arm_io_ImportArm.runProject(path);
						if(current != null) {
							current.begin(false);
						}
						arm_ui_UIBox.show = false;
					}
					if(ui.isHovered) {
						ui.tooltip(path);
					}
				}
				if(ui.button("Clear",0)) {
					arm_Config.raw.recent_projects = [];
					arm_Config.save();
				}
			}
		},400,320);
	}
	static projectSave(saveAndQuit) {
		if(saveAndQuit == null) {
			saveAndQuit = false;
		}
		if(arm_Project.filepath == "") {
			arm_Project.projectSaveAs();
			return;
		}
		kha_Window.get(0).set_title(arm_Project.filepath.substring(arm_Project.filepath.lastIndexOf(arm_sys_Path.sep) + 1,arm_Project.filepath.length - 4) + " - " + "ArmorPaint");
		iron_App.notifyOnInit(function() {
			arm_io_ExportArm.runProject();
			if(saveAndQuit) {
				kha_System.stop();
			}
		});
	}
	static projectSaveAs() {
		arm_ui_UIFiles.show("arm",true,false,function(path) {
			let f = arm_ui_UIFiles.filename;
			if(f == "") {
				f = arm_Translator.tr("untitled");
			}
			arm_Project.filepath = path + arm_sys_Path.sep + f;
			if(!arm_Project.filepath.endsWith(".arm")) {
				arm_Project.filepath += ".arm";
			}
			arm_Project.projectSave();
		});
	}
	static projectNewBox() {
		arm_ui_UIBox.showCustom(function(ui) {
			if(ui.tab(zui_Handle.global.nest(28,null),arm_Translator.tr("New Project"))) {
				if(arm_Project.meshList == null) {
					arm_Project.meshList = arm_sys_File.readDirectory(arm_sys_Path.data() + arm_sys_Path.sep + "meshes");
					let _g = 0;
					let _g1 = arm_Project.meshList.length;
					while(_g < _g1) {
						let i = _g++;
						arm_Project.meshList[i] = HxOverrides.substr(arm_Project.meshList[i],0,arm_Project.meshList[i].length - 4);
					}
					arm_Project.meshList.unshift("plane");
					arm_Project.meshList.unshift("sphere");
					arm_Project.meshList.unshift("rounded_cube");
				}
				ui.row([0.5,0.5]);
				arm_Context.projectType = ui.combo(zui_Handle.global.nest(29,{ position : arm_Context.projectType}),arm_Project.meshList,arm_Translator.tr("Template"),true);
				arm_Context.projectAspectRatio = ui.combo(zui_Handle.global.nest(30,{ position : arm_Context.projectAspectRatio}),["1:1","2:1","1:2"],arm_Translator.tr("Aspect Ratio"),true);
				ui.endElement();
				ui.row([0.5,0.5]);
				if(ui.button(arm_Translator.tr("Cancel"))) {
					arm_ui_UIBox.show = false;
				}
				if(ui.button(arm_Translator.tr("OK")) || ui.isReturnDown) {
					arm_Project.projectNew();
					arm_Viewport.scaleToBounds();
					arm_ui_UIBox.show = false;
					arm_App.redrawUI();
				}
			}
		});
	}
	static projectNew(resetLayers) {
		if(resetLayers == null) {
			resetLayers = true;
		}
		kha_Window.get(0).set_title("ArmorPaint");
		arm_Project.filepath = "";
		if(arm_Context.mergedObject != null) {
			arm_Context.mergedObject.remove();
			iron_data_Data.deleteMesh(arm_Context.mergedObject.data.handle);
			arm_Context.mergedObject = null;
		}
		arm_Viewport.reset();
		arm_Context.layerPreviewDirty = true;
		arm_Context.layerFilter = 0;
		arm_Project.meshAssets = [];
		arm_Context.paintObject = arm_Context.mainObject();
		arm_Context.selectPaintObject(arm_Context.mainObject());
		let _g = 1;
		let _g1 = arm_Project.paintObjects.length;
		while(_g < _g1) {
			let p = arm_Project.paintObjects[_g++];
			if(p == arm_Context.paintObject) {
				continue;
			}
			iron_data_Data.deleteMesh(p.data.handle);
			p.remove();
		}
		let meshes = iron_Scene.active.meshes;
		let len = meshes.length;
		let _g2 = 0;
		while(_g2 < len) {
			let m = meshes[len - _g2++ - 1];
			if(arm_Context.projectObjects.indexOf(m) == -1 && m.name != ".ParticleEmitter" && m.name != ".Particle") {
				iron_data_Data.deleteMesh(m.data.handle);
				m.remove();
			}
		}
		let handle = arm_Context.paintObject.data.handle;
		if(handle != "SceneSphere" && handle != "ScenePlane") {
			iron_data_Data.deleteMesh(handle);
		}
		if(arm_Context.projectType != 0) {
			let raw = null;
			if(arm_Context.projectType == 1 || arm_Context.projectType == 2) {
				let mesh = arm_Context.projectType == 1 ? new arm_geom_Sphere(1,512,256) : new arm_geom_Plane(1,1,512,512);
				raw = { name : "Tessellated", vertex_arrays : [{ values : mesh.posa, attrib : "pos", data : "short4norm"},{ values : mesh.nora, attrib : "nor", data : "short2norm"},{ values : mesh.texa, attrib : "tex", data : "short2norm"}], index_arrays : [{ values : mesh.inda, material : 0}], scale_pos : mesh.scalePos, scale_tex : mesh.scaleTex};
			} else {
				iron_data_Data.getBlob("meshes/" + arm_Project.meshList[arm_Context.projectType] + ".arm",function(b) {
					let i = new haxe_io_BytesInput(b.toBytes());
					i.set_bigEndian(false);
					raw = iron_system_ArmPack.read(i).mesh_datas[0];
				});
			}
			let md = new iron_data_MeshData(raw,function(md) {
			});
			iron_data_Data.cachedMeshes.h["SceneTessellated"] = md;
			if(arm_Context.projectType == 2) {
				arm_Viewport.setView(0,0,0.75,0,0,0);
			}
		}
		let n = arm_Context.projectType == 0 ? ".Cube" : "Tessellated";
		iron_data_Data.getMesh("Scene",n,function(md) {
			let current = kha_graphics2_Graphics.current;
			if(current != null) {
				current.end();
			}
			arm_Context.pickerMaskHandle.position = 0;
			arm_Context.paintObject.setData(md);
			let _this = arm_Context.paintObject.transform.scale;
			_this.x = 1;
			_this.y = 1;
			_this.z = 1;
			_this.w = 1.0;
			arm_Context.paintObject.transform.buildMatrix();
			arm_Context.paintObject.name = n;
			arm_Project.paintObjects = [arm_Context.paintObject];
			while(arm_Project.materials.length > 0) arm_Project.materials.pop().unload();
			iron_data_Data.getMaterial("Scene","Material",function(m) {
				arm_Project.materials.push(new arm_data_MaterialSlot(m));
			});
			arm_Context.material = arm_Project.materials[0];
			arm_ui_UINodes.inst.hwnd.redraws = 2;
			arm_ui_UINodes.inst.groupStack = [];
			arm_Project.materialGroups = [];
			arm_Project.brushes = [new arm_data_BrushSlot()];
			arm_Context.brush = arm_Project.brushes[0];
			let fontNames = arm_App.font.getFontNames();
			arm_Project.fonts = [new arm_data_FontSlot(fontNames.length > 0 ? fontNames[0] : "default.ttf",arm_App.font)];
			arm_Context.font = arm_Project.fonts[0];
			arm_Project.setDefaultSwatches();
			arm_Context.swatch = arm_Project.raw.swatches[0];
			arm_Context.pickedColor = arm_Project.makeSwatch();
			arm_History.reset();
			arm_node_MakeMaterial.parsePaintMaterial();
			arm_util_RenderUtil.makeMaterialPreview();
			let _g = 0;
			let _g1 = arm_Project.assets;
			while(_g < _g1.length) iron_data_Data.deleteImage(_g1[_g++].file);
			arm_Project.assets = [];
			arm_Project.assetNames = [];
			arm_Project.assetMap = new haxe_ds_IntMap();
			arm_Project.assetId = 0;
			arm_Project.raw.packed_assets = [];
			arm_Context.ddirty = 4;
			arm_ui_UISidebar.inst.hwnd0.redraws = 2;
			arm_ui_UISidebar.inst.hwnd1.redraws = 2;
			if(resetLayers) {
				let aspectRatioChanged = arm_Project.layers[0].texpaint.get_width() != arm_Config.getTextureResX() || arm_Project.layers[0].texpaint.get_height() != arm_Config.getTextureResY();
				while(arm_Project.layers.length > 0) arm_Project.layers.pop().unload();
				let layer = new arm_data_LayerSlot();
				arm_Project.layers.push(layer);
				arm_Context.setLayer(layer);
				if(aspectRatioChanged) {
					iron_App.notifyOnInit(arm_Layers.resizeLayers);
				}
				iron_App.notifyOnInit(arm_Layers.initLayers);
			}
			if(current != null) {
				current.begin(false);
			}
			arm_Context.savedEnvmap = null;
			arm_Context.envmapLoaded = false;
			iron_Scene.active.world.envmap = arm_Context.emptyEnvmap;
			iron_Scene.active.world.raw.envmap = "World_radiance.k";
			arm_Context.showEnvmapHandle.selected = arm_Context.showEnvmap = false;
			iron_Scene.active.world.probe.radiance = arm_Context.defaultRadiance;
			iron_Scene.active.world.probe.radianceMipmaps = arm_Context.defaultRadianceMipmaps;
			iron_Scene.active.world.probe.irradiance = arm_Context.defaultIrradiance;
			iron_Scene.active.world.probe.raw.strength = 4.0;
			arm_Context.initTool();
		});
	}
	static importMaterial() {
		arm_ui_UIFiles.show("arm,blend",false,true,function(path) {
			if(path.endsWith(".blend")) {
				arm_io_ImportBlend.runMaterial(path);
			} else {
				arm_io_ImportArm.runMaterial(path);
			}
		});
	}
	static importBrush() {
		arm_ui_UIFiles.show("arm," + arm_sys_Path.textureFormats.join(","),false,true,function(path) {
			if(arm_sys_Path.isTexture(path)) {
				arm_io_ImportAsset.run(path);
				let assetIndex = 0;
				let _g = 0;
				let _g1 = arm_Project.assets.length;
				while(_g < _g1) {
					let i = _g++;
					if(arm_Project.assets[i].file == path) {
						assetIndex = i;
						break;
					}
				}
				arm_Context.brush = new arm_data_BrushSlot();
				arm_Project.brushes.push(arm_Context.brush);
				let n = arm_node_NodesBrush.createNode("TEX_IMAGE");
				n.x = 83;
				n.y = 340;
				n.buttons[0].default_value = assetIndex;
				let links = arm_Context.brush.canvas.links;
				links.push({ id : arm_Context.brush.nodes.getLinkId(links), from_id : n.id, from_socket : 0, to_id : 0, to_socket : 4});
				arm_node_MakeMaterial.parseBrush();
				arm_ui_UINodes.inst.hwnd.redraws = 2;
				iron_App.notifyOnInit(function() {
					arm_util_RenderUtil.makeBrushPreview();
				});
			} else {
				arm_io_ImportArm.runBrush(path);
			}
		});
	}
	static importMesh(replaceExisting) {
		if(replaceExisting == null) {
			replaceExisting = true;
		}
		arm_ui_UIFiles.show(arm_sys_Path.meshFormats.join(","),false,false,function(path) {
			arm_Project.importMeshBox(path,replaceExisting);
		});
	}
	static importMeshBox(path,replaceExisting,clearLayers) {
		if(clearLayers == null) {
			clearLayers = true;
		}
		if(replaceExisting == null) {
			replaceExisting = true;
		}
		arm_ui_UIBox.showCustom(function(ui) {
			if(ui.tab(zui_Handle.global.nest(32,null),arm_Translator.tr("Import Mesh"))) {
				if(path.toLowerCase().endsWith(".obj")) {
					arm_Context.splitBy = ui.combo(zui_Handle.global.nest(33,null),[arm_Translator.tr("Object"),arm_Translator.tr("Group"),arm_Translator.tr("Material"),arm_Translator.tr("UDIM Tile")],arm_Translator.tr("Split By"),true);
					if(ui.isHovered) {
						ui.tooltip(arm_Translator.tr("Split .obj mesh into objects"));
					}
				}
				if(path.toLowerCase().endsWith(".fbx")) {
					arm_Context.parseTransform = ui.check(zui_Handle.global.nest(34,{ selected : arm_Context.parseTransform}),arm_Translator.tr("Parse Transforms"));
					if(ui.isHovered) {
						ui.tooltip(arm_Translator.tr("Load per-object transforms from .fbx"));
					}
				}
				if(path.toLowerCase().endsWith(".fbx") || path.toLowerCase().endsWith(".blend")) {
					arm_Context.parseVCols = ui.check(zui_Handle.global.nest(35,{ selected : arm_Context.parseVCols}),arm_Translator.tr("Parse Vertex Colors"));
					if(ui.isHovered) {
						ui.tooltip(arm_Translator.tr("Import vertex color data"));
					}
				}
				ui.row([0.45,0.45,0.1]);
				if(ui.button(arm_Translator.tr("Cancel"))) {
					arm_ui_UIBox.show = false;
				}
				if(ui.button(arm_Translator.tr("Import")) || ui.isReturnDown) {
					arm_ui_UIBox.show = false;
					arm_App.redrawUI();
					(function() {
						arm_io_ImportMesh.run(path,clearLayers,replaceExisting);
					})();
				}
				if(ui.button(arm_Translator.tr("?"))) {
					arm_sys_File.loadUrl("https://github.com/armory3d/armorpaint_docs/blob/master/faq.md");
				}
			}
		});
		arm_ui_UIBox.clickToHide = false;
	}
	static reimportMesh() {
		if(arm_Project.meshAssets != null && arm_Project.meshAssets.length > 0 && arm_sys_File.exists(arm_Project.meshAssets[0])) {
			arm_Project.importMeshBox(arm_Project.meshAssets[0],true,false);
		} else {
			arm_Project.importAsset();
		}
	}
	static unwrapMeshBox(mesh,done) {
		arm_ui_UIBox.showCustom(function(ui) {
			if(ui.tab(zui_Handle.global.nest(36,null),arm_Translator.tr("Unwrap Mesh"))) {
				let unwrapPlugins = [];
				if(arm_ui_BoxPreferences.filesPlugin == null) {
					arm_ui_BoxPreferences.fetchPlugins();
				}
				let _g = 0;
				let _g1 = arm_ui_BoxPreferences.filesPlugin;
				while(_g < _g1.length) {
					let f = _g1[_g];
					++_g;
					if(f.indexOf("uv_unwrap") >= 0 && f.endsWith(".js")) {
						unwrapPlugins.push(f);
					}
				}
				unwrapPlugins.push("equirect");
				let unwrapBy = ui.combo(zui_Handle.global.nest(37,null),unwrapPlugins,arm_Translator.tr("Plugin"),true);
				ui.row([0.5,0.5]);
				if(ui.button(arm_Translator.tr("Cancel"))) {
					arm_ui_UIBox.show = false;
				}
				if(ui.button(arm_Translator.tr("Unwrap")) || ui.isReturnDown) {
					arm_ui_UIBox.show = false;
					arm_App.redrawUI();
					(function() {
						if(unwrapBy == unwrapPlugins.length - 1) {
							arm_util_MeshUtil.equirectUnwrap(mesh);
						} else {
							let f = unwrapPlugins[unwrapBy];
							if(arm_Config.raw.plugins.indexOf(f) == -1) {
								arm_Config.enablePlugin(f);
								arm_Console.info(f + " " + arm_Translator.tr("plugin enabled"));
							}
							arm_util_MeshUtil.unwrappers.h[f](mesh);
						}
						done();
					})();
				}
			}
		});
	}
	static importAsset(filters,hdrAsEnvmap) {
		if(hdrAsEnvmap == null) {
			hdrAsEnvmap = true;
		}
		if(filters == null) {
			filters = arm_sys_Path.textureFormats.join(",") + "," + arm_sys_Path.meshFormats.join(",");
		}
		arm_ui_UIFiles.show(filters,false,true,function(path) {
			arm_io_ImportAsset.run(path,-1.0,-1.0,true,hdrAsEnvmap);
		});
	}
	static importSwatches(replaceExisting) {
		if(replaceExisting == null) {
			replaceExisting = false;
		}
		arm_ui_UIFiles.show("arm",false,false,function(path) {
			arm_io_ImportArm.runSwatches(path,replaceExisting);
		});
	}
	static reimportTextures() {
		let _g = 0;
		let _g1 = arm_Project.assets;
		while(_g < _g1.length) arm_Project.reimportTexture(_g1[_g++]);
	}
	static reimportTexture(asset) {
		let load = function(path) {
			asset.file = path;
			let i = arm_Project.assets.indexOf(asset);
			iron_data_Data.deleteImage(asset.file);
			arm_Project.assetMap.remove(asset.id);
			let oldAsset = arm_Project.assets[i];
			arm_Project.assets.splice(i,1);
			arm_Project.assetNames.splice(i,1);
			arm_io_ImportTexture.run(asset.file);
			let _this = arm_Project.assets;
			let x = arm_Project.assets.pop();
			_this.splice(i,0,x);
			let _this1 = arm_Project.assetNames;
			let x1 = arm_Project.assetNames.pop();
			_this1.splice(i,0,x1);
			if(arm_Context.texture == oldAsset) {
				arm_Context.texture = arm_Project.assets[i];
			}
			arm_App.notifyOnNextFrame(function() {
				arm_node_MakeMaterial.parsePaintMaterial();
				arm_util_RenderUtil.makeMaterialPreview();
				arm_ui_UISidebar.inst.hwnd1.redraws = 2;
			});
		};
		if(!arm_sys_File.exists(asset.file)) {
			arm_ui_UIFiles.show(arm_sys_Path.textureFormats.join(","),false,false,function(path) {
				load(path);
			});
		} else {
			load(asset.file);
		}
	}
	static getImage(asset) {
		if(asset != null) {
			return arm_Project.assetMap.h[asset.id];
		} else {
			return null;
		}
	}
	static getUsedAtlases() {
		if(arm_Project.atlasObjects == null) {
			return null;
		}
		let used = [];
		let _g = 0;
		let _g1 = arm_Project.atlasObjects;
		while(_g < _g1.length) {
			let i = _g1[_g];
			++_g;
			if(used.indexOf(i) == -1) {
				used.push(i);
			}
		}
		if(used.length > 1) {
			let res = [];
			let _g = 0;
			while(_g < used.length) res.push(arm_Project.atlasNames[used[_g++]]);
			return res;
		} else {
			return null;
		}
	}
	static isAtlasObject(p) {
		if(arm_Context.layerFilter <= arm_Project.paintObjects.length) {
			return false;
		}
		let atlasName = arm_Project.getUsedAtlases();
		return arm_Project.atlasNames.indexOf(atlasName[arm_Context.layerFilter - arm_Project.paintObjects.length - 1]) == arm_Project.atlasObjects[arm_Project.paintObjects.indexOf(p)];
	}
	static getAtlasObjects(objectMask) {
		let atlasName = arm_Project.getUsedAtlases();
		let atlasI = arm_Project.atlasNames.indexOf(atlasName[objectMask - arm_Project.paintObjects.length - 1]);
		let visibles = [];
		let _g = 0;
		let _g1 = arm_Project.paintObjects.length;
		while(_g < _g1) {
			let i = _g++;
			if(arm_Project.atlasObjects[i] == atlasI) {
				visibles.push(arm_Project.paintObjects[i]);
			}
		}
		return visibles;
	}
	static packedAssetExists(packed_assets,name) {
		let _g = 0;
		while(_g < packed_assets.length) if(packed_assets[_g++].name == name) {
			return true;
		}
		return false;
	}
	static exportSwatches() {
		arm_ui_UIFiles.show("arm",true,false,function(path) {
			let f = arm_ui_UIFiles.filename;
			if(f == "") {
				f = arm_Translator.tr("untitled");
			}
			arm_io_ExportArm.runSwatches(path + arm_sys_Path.sep + f);
		});
	}
	static makeSwatch(base) {
		if(base == null) {
			base = -1;
		}
		return { base : base, opacity : 1.0, occlusion : 1.0, roughness : 0.0, metallic : 0.0, normal : -8355585, emission : 0.0, height : 0.0, subsurface : 0.0};
	}
	static setDefaultSwatches() {
		arm_Project.raw.swatches = [];
		let colors = [-1,-16777216,-2711408,-6214606,-381062,-286758,-1696521,-6738052,-12123873,-16445099,-11599124,-13801013,-16734482,-9442305,-16211302,-13998486,-16370151,-11908777,-7439452,-4734721,-5456228,-8225680,-10863844,-5348089,-546256,-726436,-6580992,-11116028,-15624645,-11411181,-16187956];
		let _g = 0;
		while(_g < colors.length) arm_Project.raw.swatches.push(arm_Project.makeSwatch(colors[_g++]));
	}
	static getMaterialGroupByName(groupName) {
		let _g = 0;
		let _g1 = arm_Project.materialGroups;
		while(_g < _g1.length) {
			let g = _g1[_g];
			++_g;
			if(g.canvas.name == groupName) {
				return g;
			}
		}
		return null;
	}
}
$hxClasses["arm.Project"] = arm_Project;
arm_Project.__name__ = "arm.Project";
class kha_math_FastMatrix4 {
	constructor(_00,_10,_20,_30,_01,_11,_21,_31,_02,_12,_22,_32,_03,_13,_23,_33) {
		this._00 = _00;
		this._10 = _10;
		this._20 = _20;
		this._30 = _30;
		this._01 = _01;
		this._11 = _11;
		this._21 = _21;
		this._31 = _31;
		this._02 = _02;
		this._12 = _12;
		this._22 = _22;
		this._32 = _32;
		this._03 = _03;
		this._13 = _13;
		this._23 = _23;
		this._33 = _33;
	}
}
$hxClasses["kha.math.FastMatrix4"] = kha_math_FastMatrix4;
kha_math_FastMatrix4.__name__ = "kha.math.FastMatrix4";
Object.assign(kha_math_FastMatrix4.prototype, {
	__class__: kha_math_FastMatrix4
});
class iron_math_Mat4 {
	constructor(_00,_10,_20,_30,_01,_11,_21,_31,_02,_12,_22,_32,_03,_13,_23,_33) {
		this.self = new kha_math_FastMatrix4(_00,_10,_20,_30,_01,_11,_21,_31,_02,_12,_22,_32,_03,_13,_23,_33);
	}
	toFloat32Array() {
		let array = new Float32Array(16);
		array[0] = this.self._00;
		array[1] = this.self._10;
		array[2] = this.self._20;
		array[3] = this.self._30;
		array[4] = this.self._01;
		array[5] = this.self._11;
		array[6] = this.self._21;
		array[7] = this.self._31;
		array[8] = this.self._02;
		array[9] = this.self._12;
		array[10] = this.self._22;
		array[11] = this.self._32;
		array[12] = this.self._03;
		array[13] = this.self._13;
		array[14] = this.self._23;
		array[15] = this.self._33;
		return array;
	}
}
$hxClasses["iron.math.Mat4"] = iron_math_Mat4;
iron_math_Mat4.__name__ = "iron.math.Mat4";
Object.assign(iron_math_Mat4.prototype, {
	__class__: iron_math_Mat4
});
class arm_Context {
	static selectMaterial(i) {
		if(arm_Project.materials.length <= i) {
			return;
		}
		arm_Context.setMaterial(arm_Project.materials[i]);
	}
	static setMaterial(m) {
		if(arm_Project.materials.indexOf(m) == -1) {
			return;
		}
		arm_Context.material = m;
		arm_node_MakeMaterial.parsePaintMaterial();
		arm_ui_UISidebar.inst.hwnd1.redraws = 2;
		arm_ui_UIHeader.inst.headerHandle.redraws = 2;
		arm_ui_UINodes.inst.hwnd.redraws = 2;
		arm_ui_UINodes.inst.groupStack = [];
		if(arm_Context.tool == 3 || arm_Context.tool == 4) {
			arm_App.notifyOnNextFrame(function() {
				arm_util_RenderUtil.makeDecalPreview();
			});
		}
	}
	static selectBrush(i) {
		if(arm_Project.brushes.length <= i) {
			return;
		}
		arm_Context.setBrush(arm_Project.brushes[i]);
	}
	static setBrush(b) {
		if(arm_Project.brushes.indexOf(b) == -1) {
			return;
		}
		arm_Context.brush = b;
		arm_node_MakeMaterial.parseBrush();
		arm_ui_UISidebar.inst.hwnd1.redraws = 2;
		arm_ui_UINodes.inst.hwnd.redraws = 2;
	}
	static selectFont(i) {
		if(arm_Project.fonts.length <= i) {
			return;
		}
		arm_Context.setFont(arm_Project.fonts[i]);
	}
	static setFont(f) {
		if(arm_Project.fonts.indexOf(f) == -1) {
			return;
		}
		arm_Context.font = f;
		arm_util_RenderUtil.makeTextPreview();
		arm_util_RenderUtil.makeDecalPreview();
		arm_ui_UIStatus.inst.statusHandle.redraws = 2;
		arm_ui_UIView2D.inst.hwnd.redraws = 2;
	}
	static setSwatch(s) {
		arm_Context.swatch = s;
		arm_App.notifyOnNextFrame(function() {
			arm_node_MakeMaterial.parsePaintMaterial();
			arm_util_RenderUtil.makeMaterialPreview();
			arm_ui_UISidebar.inst.hwnd1.redraws = 2;
		});
	}
	static selectLayer(i) {
		if(arm_Project.layers.length <= i) {
			return;
		}
		arm_Context.setLayer(arm_Project.layers[i]);
	}
	static setLayer(l) {
		if(l == arm_Context.layer) {
			return;
		}
		arm_Context.layer = l;
		arm_ui_UIHeader.inst.headerHandle.redraws = 2;
		let current = kha_graphics2_Graphics.current;
		if(current != null) {
			current.end();
		}
		arm_Layers.setObjectMask();
		arm_node_MakeMaterial.parseMeshMaterial();
		arm_node_MakeMaterial.parsePaintMaterial();
		if(current != null) {
			current.begin(false);
		}
		arm_ui_UISidebar.inst.hwnd0.redraws = 2;
		arm_ui_UIView2D.inst.hwnd.redraws = 2;
	}
	static selectTool(i) {
		arm_Context.tool = i;
		arm_node_MakeMaterial.parsePaintMaterial();
		arm_node_MakeMaterial.parseMeshMaterial();
		arm_ui_UIHeader.inst.headerHandle.redraws = 2;
		arm_ui_UIToolbar.inst.toolbarHandle.redraws = 2;
		arm_Context.ddirty = 3;
		arm_Context.initTool();
	}
	static initTool() {
		if(arm_Context.tool == 3 || arm_Context.tool == 4) {
			if(arm_Context.tool == 4) {
				arm_util_RenderUtil.makeTextPreview();
			}
			arm_util_RenderUtil.makeDecalPreview();
		}
		if(arm_Context.tool == 7) {
			arm_util_ParticleUtil.initParticle();
			arm_node_MakeMaterial.parseParticleMaterial();
		}
	}
	static selectPaintObject(o) {
		arm_ui_UIHeader.inst.headerHandle.redraws = 2;
		let _g = 0;
		let _g1 = arm_Project.paintObjects;
		while(_g < _g1.length) _g1[_g++].skip_context = "paint";
		arm_Context.paintObject = o;
		let mask = arm_Context.layer.getObjectMask();
		if(arm_Context.layerFilterUsed()) {
			mask = arm_Context.layerFilter;
		}
		if(arm_Context.mergedObject == null || mask > 0) {
			arm_Context.paintObject.skip_context = "";
		}
		arm_util_UVUtil.uvmapCached = false;
		arm_util_UVUtil.trianglemapCached = false;
		arm_util_UVUtil.dilatemapCached = false;
	}
	static mainObject() {
		let _g = 0;
		let _g1 = arm_Project.paintObjects;
		while(_g < _g1.length) {
			let po = _g1[_g];
			++_g;
			if(po.children.length > 0) {
				return po;
			}
		}
		return arm_Project.paintObjects[0];
	}
	static loadEnvmap() {
		if(!arm_Context.envmapLoaded) {
			arm_Context.envmapLoaded = true;
			let _this = iron_data_Data.cachedImages;
			if(Object.prototype.hasOwnProperty.call(_this.h,"World_radiance.k")) {
				delete(_this.h["World_radiance.k"]);
			}
		}
		iron_Scene.active.world.loadEnvmap(function(_) {
		});
		if(arm_Context.savedEnvmap == null) {
			arm_Context.savedEnvmap = iron_Scene.active.world.envmap;
		}
	}
	static setViewportShader(viewportShader) {
		arm_Context.viewportShader = viewportShader;
		arm_Context.setRenderPath();
	}
	static setRenderPath() {
		if(arm_Context.renderMode == 1 || arm_Context.viewportShader != null) {
			if(arm_render_RenderPathForward.path == null) {
				arm_render_RenderPathForward.init(iron_RenderPath.active);
			}
			iron_RenderPath.active.commands = arm_render_RenderPathForward.commands;
		} else {
			iron_RenderPath.active.commands = arm_render_RenderPathDeferred.commands;
		}
		iron_App.notifyOnInit(function() {
			arm_node_MakeMaterial.parseMeshMaterial();
		});
	}
	static enableImportPlugin(file) {
		if(arm_ui_BoxPreferences.filesPlugin == null) {
			arm_ui_BoxPreferences.fetchPlugins();
		}
		let ext = HxOverrides.substr(file,file.lastIndexOf(".") + 1,null);
		let _g = 0;
		let _g1 = arm_ui_BoxPreferences.filesPlugin;
		while(_g < _g1.length) {
			let f = _g1[_g];
			++_g;
			if(f.startsWith("import_") && f.indexOf(ext) >= 0) {
				arm_Config.enablePlugin(f);
				arm_Console.info(f + " " + arm_Translator.tr("plugin enabled"));
				return true;
			}
		}
		return false;
	}
	static layerFilterUsed() {
		if(arm_Context.layerFilter > 0) {
			return arm_Context.layerFilter <= arm_Project.paintObjects.length;
		} else {
			return false;
		}
	}
	static objectMaskUsed() {
		if(arm_Context.layer.getObjectMask() > 0) {
			return arm_Context.layer.getObjectMask() <= arm_Project.paintObjects.length;
		} else {
			return false;
		}
	}
}
$hxClasses["arm.Context"] = arm_Context;
arm_Context.__name__ = "arm.Context";
class arm_History {
	static undo() {
		if(arm_History.undos > 0) {
			let step = arm_History.steps[arm_History.steps.length - 1 - arm_History.redos];
			if(step.name == arm_Translator.tr("New Layer")) {
				arm_Context.layer = arm_Project.layers[step.layer];
				arm_Context.layer.delete();
			} else if(step.name == arm_Translator.tr("Delete Layer")) {
				let l = new arm_data_LayerSlot("",step.layer_type,step.layer_parent > 0 ? arm_Project.layers[step.layer_parent - 1] : null);
				arm_Project.layers.splice(step.layer,0,l);
				arm_Context.setLayer(l);
				arm_History.undoI = arm_History.undoI - 1 < 0 ? arm_Config.raw.undo_steps - 1 : arm_History.undoI - 1;
				l.swap(arm_History.undoLayers[arm_History.undoI]);
				l.maskOpacity = step.layer_opacity;
				l.blending = step.layer_blending;
				l.objectMask = step.layer_object;
				arm_node_MakeMaterial.parseMeshMaterial();
			} else if(step.name == arm_Translator.tr("Clear Layer")) {
				arm_History.undoI = arm_History.undoI - 1 < 0 ? arm_Config.raw.undo_steps - 1 : arm_History.undoI - 1;
				arm_Context.layer.swap(arm_History.undoLayers[arm_History.undoI]);
				arm_Context.layerPreviewDirty = true;
			} else if(step.name == arm_Translator.tr("Duplicate Layer")) {
				arm_Context.layer = arm_Project.layers[step.layer + 1];
				arm_Context.layer.delete();
			} else if(step.name == arm_Translator.tr("Order Layers")) {
				let target = arm_Project.layers[step.prev_order];
				arm_Project.layers[step.prev_order] = arm_Project.layers[step.layer];
				arm_Project.layers[step.layer] = target;
			} else if(step.name == arm_Translator.tr("Merge Layers")) {
				arm_Context.layer = arm_Project.layers[step.layer];
				arm_Context.layer.delete();
				let parent = step.layer_parent > 0 ? arm_Project.layers[step.layer_parent - 2] : null;
				let l = new arm_data_LayerSlot("",step.layer_type,parent);
				arm_Project.layers.splice(step.layer,0,l);
				arm_Context.setLayer(l);
				arm_History.undoI = arm_History.undoI - 1 < 0 ? arm_Config.raw.undo_steps - 1 : arm_History.undoI - 1;
				arm_Context.layer.swap(arm_History.undoLayers[arm_History.undoI]);
				let l1 = new arm_data_LayerSlot("",step.layer_type,parent);
				arm_Project.layers.splice(step.layer + 1,0,l1);
				arm_Context.setLayer(l1);
				arm_History.undoI = arm_History.undoI - 1 < 0 ? arm_Config.raw.undo_steps - 1 : arm_History.undoI - 1;
				arm_Context.layer.swap(arm_History.undoLayers[arm_History.undoI]);
				arm_Context.layer.maskOpacity = step.layer_opacity;
				arm_Context.layer.blending = step.layer_blending;
				arm_Context.layer.objectMask = step.layer_object;
				arm_Context.layersPreviewDirty = true;
				arm_node_MakeMaterial.parseMeshMaterial();
			} else if(step.name == arm_Translator.tr("Apply Mask")) {
				arm_Context.layer = arm_Project.layers[step.layer];
				arm_Context.layer.delete();
				arm_Context.layer = arm_Layers.newLayer(false);
				HxOverrides.remove(arm_Project.layers,arm_Context.layer);
				arm_Project.layers.splice(step.layer,0,arm_Context.layer);
				arm_History.undoI = arm_History.undoI - 1 < 0 ? arm_Config.raw.undo_steps - 1 : arm_History.undoI - 1;
				let lay = arm_History.undoLayers[arm_History.undoI];
				arm_Context.layer.swap(lay);
				arm_Layers.newMask(false,arm_Context.layer);
				arm_Context.layer.swap(lay);
				arm_Context.layersPreviewDirty = true;
				arm_Context.setLayer(arm_Context.layer);
			} else if(step.name == "Apply Filter") {
				arm_History.undoI = arm_History.undoI - 1 < 0 ? arm_Config.raw.undo_steps - 1 : arm_History.undoI - 1;
				let lay = arm_History.undoLayers[arm_History.undoI];
				arm_Context.setLayer(arm_Project.layers[step.layer]);
				arm_Context.layer.swap(lay);
				arm_Layers.newMask(false,arm_Context.layer);
				arm_Context.layer.swap(lay);
				arm_Context.layerPreviewDirty = true;
			} else if(step.name == arm_Translator.tr("To Fill Layer")) {
				arm_Context.layer.toPaintLayer();
				arm_History.undoI = arm_History.undoI - 1 < 0 ? arm_Config.raw.undo_steps - 1 : arm_History.undoI - 1;
				arm_Context.layer.swap(arm_History.undoLayers[arm_History.undoI]);
			} else if(step.name == arm_Translator.tr("To Paint Layer")) {
				arm_History.undoI = arm_History.undoI - 1 < 0 ? arm_Config.raw.undo_steps - 1 : arm_History.undoI - 1;
				arm_Context.layer.swap(arm_History.undoLayers[arm_History.undoI]);
				arm_Context.layer.fill_layer = arm_Project.materials[step.material];
			} else if(step.name == arm_Translator.tr("Layer Opacity")) {
				arm_Context.setLayer(arm_Project.layers[step.layer]);
				let t = arm_Context.layer.maskOpacity;
				arm_Context.layer.maskOpacity = step.layer_opacity;
				step.layer_opacity = t;
				arm_node_MakeMaterial.parseMeshMaterial();
			} else if(step.name == arm_Translator.tr("Layer Blending")) {
				arm_Context.setLayer(arm_Project.layers[step.layer]);
				let t = arm_Context.layer.blending;
				arm_Context.layer.blending = step.layer_blending;
				step.layer_blending = t;
				arm_node_MakeMaterial.parseMeshMaterial();
			} else if(step.name == arm_Translator.tr("Edit Nodes")) {
				arm_History.swapCanvas(step);
			} else if(step.name == arm_Translator.tr("New Material")) {
				arm_Context.material = arm_Project.materials[step.material];
				step.canvas = arm_Context.material.canvas;
				arm_Context.material.delete();
			} else if(step.name == arm_Translator.tr("Delete Material")) {
				arm_Context.material = new arm_data_MaterialSlot(arm_Project.materials[0].data);
				arm_Project.materials.splice(step.material,0,arm_Context.material);
				arm_Context.material.canvas = step.canvas;
				arm_ui_UINodes.inst.canvasChanged();
				arm_ui_UINodes.inst.getNodes().handle = new zui_Handle();
				arm_ui_UINodes.inst.hwnd.redraws = 2;
			} else if(step.name == arm_Translator.tr("Duplicate Material")) {
				arm_Context.material = arm_Project.materials[step.material];
				step.canvas = arm_Context.material.canvas;
				arm_Context.material.delete();
			} else {
				arm_History.undoI = arm_History.undoI - 1 < 0 ? arm_Config.raw.undo_steps - 1 : arm_History.undoI - 1;
				let lay = arm_History.undoLayers[arm_History.undoI];
				arm_Context.selectPaintObject(arm_Project.paintObjects[step.object]);
				arm_Context.setLayer(arm_Project.layers[step.layer]);
				arm_Context.layer.swap(lay);
				arm_Context.layerPreviewDirty = true;
			}
			arm_History.undos--;
			arm_History.redos++;
			arm_ui_UISidebar.inst.hwnd0.redraws = 2;
			arm_ui_UISidebar.inst.hwnd1.redraws = 2;
			arm_Context.ddirty = 2;
			if(arm_ui_UIView2D.inst.show) {
				arm_ui_UIView2D.inst.hwnd.redraws = 2;
			}
		}
	}
	static redo() {
		if(arm_History.redos > 0) {
			let step = arm_History.steps[arm_History.steps.length - arm_History.redos];
			if(step.name == arm_Translator.tr("New Layer")) {
				let l = new arm_data_LayerSlot("",step.layer_type,step.layer_parent > 0 ? arm_Project.layers[step.layer_parent - 1] : null);
				arm_Project.layers.splice(step.layer,0,l);
				arm_Context.setLayer(l);
			} else if(step.name == arm_Translator.tr("Delete Layer")) {
				arm_Context.layer = arm_Project.layers[step.layer];
				arm_History.swapActive();
				arm_Context.layer.delete();
			} else if(step.name == arm_Translator.tr("Clear Layer")) {
				arm_Context.layer = arm_Project.layers[step.layer];
				arm_History.swapActive();
				arm_Context.layer.clear();
				arm_Context.layerPreviewDirty = true;
			} else if(step.name == arm_Translator.tr("Duplicate Layer")) {
				arm_Context.layer = arm_Project.layers[step.layer];
				arm_Context.layer = arm_Context.layer.duplicate();
			} else if(step.name == arm_Translator.tr("Order Layers")) {
				let target = arm_Project.layers[step.prev_order];
				arm_Project.layers[step.prev_order] = arm_Project.layers[step.layer];
				arm_Project.layers[step.layer] = target;
			} else if(step.name == arm_Translator.tr("Merge Layers")) {
				arm_Context.layer = arm_Project.layers[step.layer + 1];
				iron_App.notifyOnInit(arm_History.redoMergeLayers);
				iron_App.notifyOnInit(arm_Layers.mergeDown);
			} else if(step.name == arm_Translator.tr("Apply Mask")) {
				arm_App.notifyOnNextFrame(function() {
					arm_Context.layer = arm_Project.layers[step.layer];
					arm_History.copyToUndo(arm_Context.layer.id,arm_History.undoI,true);
					arm_Context.layer.applyMask();
					arm_Context.setLayer(arm_Context.layer);
				});
			} else if(step.name == arm_Translator.tr("Apply Filter")) {
				let lay = arm_History.undoLayers[arm_History.undoI];
				arm_Context.setLayer(arm_Project.layers[step.layer]);
				arm_Context.layer.swap(lay);
				arm_Layers.newMask(false,lay);
				arm_Context.layer.swap(lay);
				arm_Context.layerPreviewDirty = true;
				arm_History.undoI = (arm_History.undoI + 1) % arm_Config.raw.undo_steps;
			} else if(step.name == arm_Translator.tr("To Fill Layer")) {
				arm_Context.layer.swap(arm_History.undoLayers[arm_History.undoI]);
				arm_Context.layer.fill_layer = arm_Project.materials[step.material];
				arm_History.undoI = (arm_History.undoI + 1) % arm_Config.raw.undo_steps;
			} else if(step.name == arm_Translator.tr("To Paint Layer")) {
				arm_Context.layer.toPaintLayer();
				arm_Context.layer.swap(arm_History.undoLayers[arm_History.undoI]);
				arm_History.undoI = (arm_History.undoI + 1) % arm_Config.raw.undo_steps;
			} else if(step.name == arm_Translator.tr("Layer Opacity")) {
				arm_Context.setLayer(arm_Project.layers[step.layer]);
				let t = arm_Context.layer.maskOpacity;
				arm_Context.layer.maskOpacity = step.layer_opacity;
				step.layer_opacity = t;
				arm_node_MakeMaterial.parseMeshMaterial();
			} else if(step.name == arm_Translator.tr("Layer Blending")) {
				arm_Context.setLayer(arm_Project.layers[step.layer]);
				let t = arm_Context.layer.blending;
				arm_Context.layer.blending = step.layer_blending;
				step.layer_blending = t;
				arm_node_MakeMaterial.parseMeshMaterial();
			} else if(step.name == arm_Translator.tr("Edit Nodes")) {
				arm_History.swapCanvas(step);
			} else if(step.name == arm_Translator.tr("New Material")) {
				arm_Context.material = new arm_data_MaterialSlot(arm_Project.materials[0].data);
				arm_Project.materials.splice(step.material,0,arm_Context.material);
				arm_Context.material.canvas = step.canvas;
				arm_ui_UINodes.inst.canvasChanged();
				arm_ui_UINodes.inst.getNodes().handle = new zui_Handle();
				arm_ui_UINodes.inst.hwnd.redraws = 2;
			} else if(step.name == arm_Translator.tr("Delete Material")) {
				arm_Context.material = arm_Project.materials[step.material];
				step.canvas = arm_Context.material.canvas;
				arm_Context.material.delete();
			} else if(step.name == arm_Translator.tr("Duplicate Material")) {
				arm_Context.material = new arm_data_MaterialSlot(arm_Project.materials[0].data);
				arm_Project.materials.splice(step.material,0,arm_Context.material);
				arm_Context.material.canvas = step.canvas;
				arm_ui_UINodes.inst.canvasChanged();
				arm_ui_UINodes.inst.getNodes().handle = new zui_Handle();
				arm_ui_UINodes.inst.hwnd.redraws = 2;
			} else {
				let lay = arm_History.undoLayers[arm_History.undoI];
				arm_Context.selectPaintObject(arm_Project.paintObjects[step.object]);
				arm_Context.setLayer(arm_Project.layers[step.layer]);
				arm_Context.layer.swap(lay);
				arm_Context.layerPreviewDirty = true;
				arm_History.undoI = (arm_History.undoI + 1) % arm_Config.raw.undo_steps;
			}
			arm_History.undos++;
			arm_History.redos--;
			arm_ui_UISidebar.inst.hwnd0.redraws = 2;
			arm_ui_UISidebar.inst.hwnd1.redraws = 2;
			arm_Context.ddirty = 2;
			if(arm_ui_UIView2D.inst.show) {
				arm_ui_UIView2D.inst.hwnd.redraws = 2;
			}
		}
	}
	static reset() {
		arm_History.steps = [{ name : arm_Translator.tr("New"), layer : 0, layer_type : 0, layer_parent : -1, object : 0, material : 0, brush : 0}];
		arm_History.undos = 0;
		arm_History.redos = 0;
		arm_History.undoI = 0;
	}
	static paint() {
		let isMask = arm_Context.layer.isMask();
		arm_History.copyToUndo(arm_Context.layer.id,arm_History.undoI,isMask);
		arm_History.pushUndo = false;
		arm_History.push(arm_Translator.tr(arm_ui_UIToolbar.inst.toolNames[arm_Context.tool]));
	}
	static newLayer() {
		arm_History.push(arm_Translator.tr("New Layer"));
	}
	static duplicateLayer() {
		arm_History.push(arm_Translator.tr("Duplicate Layer"));
	}
	static deleteLayer() {
		arm_History.swapActive();
		arm_History.push(arm_Translator.tr("Delete Layer"));
	}
	static clearLayer() {
		arm_History.swapActive();
		arm_History.push(arm_Translator.tr("Clear Layer"));
	}
	static orderLayers(prevOrder) {
		arm_History.push(arm_Translator.tr("Order Layers")).prev_order = prevOrder;
	}
	static mergeLayers() {
		arm_History.copyMergingLayers();
		arm_History.push(arm_Translator.tr("Merge Layers")).layer -= 1;
		arm_History.steps.shift();
		arm_History.undos--;
	}
	static applyMask() {
		arm_History.copyToUndo(arm_Context.layer.id,arm_History.undoI,true);
		arm_History.push(arm_Translator.tr("Apply Mask"));
	}
	static applyFilter() {
		arm_History.copyToUndo(arm_Context.layer.id,arm_History.undoI,true);
		arm_History.push(arm_Translator.tr("Apply Filter"));
	}
	static toFillLayer() {
		arm_History.copyToUndo(arm_Context.layer.id,arm_History.undoI,arm_Context.layer.isMask());
		arm_History.push(arm_Translator.tr("To Fill Layer"));
	}
	static toPaintLayer() {
		arm_History.copyToUndo(arm_Context.layer.id,arm_History.undoI,arm_Context.layer.isMask());
		arm_History.push(arm_Translator.tr("To Paint Layer"));
	}
	static layerOpacity() {
		arm_History.push(arm_Translator.tr("Layer Opacity"));
	}
	static layerBlending() {
		arm_History.push(arm_Translator.tr("Layer Blending"));
	}
	static newMaterial() {
		let step = arm_History.push(arm_Translator.tr("New Material"));
		step.canvas_type = 0;
		step.canvas = JSON.parse(JSON.stringify(arm_Context.material.canvas));
	}
	static deleteMaterial() {
		let step = arm_History.push(arm_Translator.tr("Delete Material"));
		step.canvas_type = 0;
		step.canvas = JSON.parse(JSON.stringify(arm_Context.material.canvas));
	}
	static duplicateMaterial() {
		let step = arm_History.push(arm_Translator.tr("Duplicate Material"));
		step.canvas_type = 0;
		step.canvas = JSON.parse(JSON.stringify(arm_Context.material.canvas));
	}
	static editNodes(canvas,canvas_type,canvas_group) {
		let step = arm_History.push(arm_Translator.tr("Edit Nodes"));
		step.canvas_type = canvas_type;
		step.canvas_group = canvas_group;
		step.canvas = JSON.parse(JSON.stringify(canvas));
	}
	static push(name) {
		kha_Window.get(0).set_title((arm_Project.filepath == "" ? arm_ui_UIFiles.filename : arm_Project.filepath.substring(arm_Project.filepath.lastIndexOf(arm_sys_Path.sep) + 1,arm_Project.filepath.length - 4)) + "* - " + "ArmorPaint");
		if(arm_History.undos < arm_Config.raw.undo_steps) {
			arm_History.undos++;
		}
		if(arm_History.redos > 0) {
			let _g = 0;
			let _g1 = arm_History.redos;
			while(_g < _g1) {
				++_g;
				arm_History.steps.pop();
			}
			arm_History.redos = 0;
		}
		let opos = arm_Project.paintObjects.indexOf(arm_Context.paintObject);
		let mpos = arm_Project.materials.indexOf(arm_Context.material);
		let bpos = arm_Project.brushes.indexOf(arm_Context.brush);
		arm_History.steps.push({ name : name, layer : arm_Project.layers.indexOf(arm_Context.layer), layer_type : arm_Context.layer.isMask() ? 1 : arm_Context.layer.isGroup() ? 2 : 0, layer_parent : arm_Context.layer.parent == null ? -1 : arm_Project.layers.indexOf(arm_Context.layer.parent), object : opos, material : mpos, brush : bpos, layer_opacity : arm_Context.layer.maskOpacity, layer_object : arm_Context.layer.objectMask, layer_blending : arm_Context.layer.blending});
		while(arm_History.steps.length > arm_Config.raw.undo_steps + 1) arm_History.steps.shift();
		return arm_History.steps[arm_History.steps.length - 1];
	}
	static redoMergeLayers() {
		arm_History.copyMergingLayers();
	}
	static copyMergingLayers() {
		let lay = arm_Context.layer;
		arm_History.copyToUndo(lay.id,arm_History.undoI,arm_Context.layer.isMask());
		lay = arm_Project.layers[arm_Project.layers.indexOf(lay) - 1];
		arm_History.copyToUndo(lay.id,arm_History.undoI,arm_Context.layer.isMask());
	}
	static swapActive() {
		arm_History.undoLayers[arm_History.undoI].swap(arm_Context.layer);
		arm_History.undoI = (arm_History.undoI + 1) % arm_Config.raw.undo_steps;
	}
	static copyToUndo(fromId,toId,isMask) {
		let path = iron_RenderPath.active;
		if(isMask) {
			path.setTarget("texpaint_undo" + toId);
			path.bindTarget("texpaint" + fromId,"tex");
			path.drawShader("shader_datas/copy_pass/copy_pass");
		} else {
			path.setTarget("texpaint_undo" + toId,["texpaint_nor_undo" + toId,"texpaint_pack_undo" + toId]);
			path.bindTarget("texpaint" + fromId,"tex0");
			path.bindTarget("texpaint_nor" + fromId,"tex1");
			path.bindTarget("texpaint_pack" + fromId,"tex2");
			path.drawShader("shader_datas/copy_mrt3_pass/copy_mrt3_pass");
		}
		arm_History.undoI = (arm_History.undoI + 1) % arm_Config.raw.undo_steps;
	}
	static getCanvasOwner(step) {
		if(step.canvas_group == null) {
			return arm_Project.materials[step.material];
		} else {
			return arm_Project.materialGroups[step.canvas_group];
		}
	}
	static swapCanvas(step) {
		if(step.canvas_type == 0) {
			let _canvas = arm_History.getCanvasOwner(step).canvas;
			arm_History.getCanvasOwner(step).canvas = step.canvas;
			step.canvas = _canvas;
			arm_Context.material = arm_Project.materials[step.material];
		} else {
			let _canvas = arm_Project.brushes[step.brush].canvas;
			arm_Project.brushes[step.brush].canvas = step.canvas;
			step.canvas = _canvas;
			arm_Context.brush = arm_Project.brushes[step.brush];
		}
		arm_ui_UINodes.inst.canvasChanged();
		arm_ui_UINodes.inst.getNodes().handle = new zui_Handle();
		arm_ui_UINodes.inst.hwnd.redraws = 2;
	}
}
$hxClasses["arm.History"] = arm_History;
arm_History.__name__ = "arm.History";
class arm_Layers {
	static initLayers() {
		arm_Project.layers[0].clear(kha_Color.fromFloats(0.5,0.5,0.5,1.0));
	}
	static resizeLayers() {
		let C = arm_Config.raw;
		if(arm_App.resHandle.position >= 7) {
			C.undo_steps = 1;
			if(arm_Context.undoHandle != null) {
				arm_Context.undoHandle.value = C.undo_steps;
			}
			while(arm_History.undoLayers.length > C.undo_steps) {
				let l = arm_History.undoLayers.pop();
				arm_App.notifyOnNextFrame(function() {
					l.unload();
				});
			}
		}
		let _g = 0;
		let _g1 = arm_Project.layers;
		while(_g < _g1.length) _g1[_g++].resizeAndSetBits();
		let _g2 = 0;
		let _g3 = arm_History.undoLayers;
		while(_g2 < _g3.length) _g3[_g2++].resizeAndSetBits();
		let rts = iron_RenderPath.active.renderTargets;
		let _texpaint_blend0 = rts.h["texpaint_blend0"].image;
		arm_App.notifyOnNextFrame(function() {
			_texpaint_blend0.unload();
		});
		rts.h["texpaint_blend0"].raw.width = arm_Config.getTextureResX();
		rts.h["texpaint_blend0"].raw.height = arm_Config.getTextureResY();
		rts.h["texpaint_blend0"].image = kha_Image.createRenderTarget(arm_Config.getTextureResX(),arm_Config.getTextureResY(),1);
		let _texpaint_blend1 = rts.h["texpaint_blend1"].image;
		arm_App.notifyOnNextFrame(function() {
			_texpaint_blend1.unload();
		});
		rts.h["texpaint_blend1"].raw.width = arm_Config.getTextureResX();
		rts.h["texpaint_blend1"].raw.height = arm_Config.getTextureResY();
		rts.h["texpaint_blend1"].image = kha_Image.createRenderTarget(arm_Config.getTextureResX(),arm_Config.getTextureResY(),1);
		arm_Context.brushBlendDirty = true;
		if(rts.h["texpaint_blur"] != null) {
			let _texpaint_blur = rts.h["texpaint_blur"].image;
			arm_App.notifyOnNextFrame(function() {
				_texpaint_blur.unload();
			});
			let sizeX = arm_Config.getTextureResX() * 0.95 | 0;
			let sizeY = arm_Config.getTextureResY() * 0.95 | 0;
			rts.h["texpaint_blur"].raw.width = sizeX;
			rts.h["texpaint_blur"].raw.height = sizeY;
			rts.h["texpaint_blur"].image = kha_Image.createRenderTarget(sizeX,sizeY);
		}
		if(arm_render_RenderPathPaint.liveLayer != null) {
			arm_render_RenderPathPaint.liveLayer.resizeAndSetBits();
		}
		arm_Context.ddirty = 2;
	}
	static setLayerBits() {
		let _g = 0;
		let _g1 = arm_Project.layers;
		while(_g < _g1.length) _g1[_g++].resizeAndSetBits();
		let _g2 = 0;
		let _g3 = arm_History.undoLayers;
		while(_g2 < _g3.length) _g3[_g2++].resizeAndSetBits();
	}
	static makeMergePipe(red,green,blue,alpha) {
		let pipe = new kha_graphics4_PipelineState();
		pipe.vertexShader = kha_Shaders.getVertex("layer_merge.vert");
		pipe.fragmentShader = kha_Shaders.getFragment("layer_merge.frag");
		let vs = new kha_graphics4_VertexStructure();
		vs.add("pos",1);
		pipe.inputLayout = [vs];
		pipe.colorWriteMasksRed = [red];
		pipe.colorWriteMasksGreen = [green];
		pipe.colorWriteMasksBlue = [blue];
		pipe.colorWriteMasksAlpha = [alpha];
		pipe.compile();
		return pipe;
	}
	static makePipe() {
		arm_Layers.pipeMerge = arm_Layers.makeMergePipe(true,true,true,true);
		arm_Layers.pipeMergeR = arm_Layers.makeMergePipe(true,false,false,false);
		arm_Layers.pipeMergeG = arm_Layers.makeMergePipe(false,true,false,false);
		arm_Layers.pipeMergeB = arm_Layers.makeMergePipe(false,false,true,false);
		arm_Layers.pipeMergeA = arm_Layers.makeMergePipe(false,false,false,true);
		arm_Layers.tex0 = arm_Layers.pipeMerge.getTextureUnit("tex0");
		arm_Layers.tex1 = arm_Layers.pipeMerge.getTextureUnit("tex1");
		arm_Layers.texmask = arm_Layers.pipeMerge.getTextureUnit("texmask");
		arm_Layers.texa = arm_Layers.pipeMerge.getTextureUnit("texa");
		arm_Layers.opac = arm_Layers.pipeMerge.getConstantLocation("opac");
		arm_Layers.blending = arm_Layers.pipeMerge.getConstantLocation("blending");
		arm_Layers.pipeCopy = new kha_graphics4_PipelineState();
		arm_Layers.pipeCopy.vertexShader = kha_Shaders.getVertex("layer_view.vert");
		arm_Layers.pipeCopy.fragmentShader = kha_Shaders.getFragment("layer_copy.frag");
		let vs = new kha_graphics4_VertexStructure();
		vs.add("pos",2);
		vs.add("tex",1);
		vs.add("col",16);
		arm_Layers.pipeCopy.inputLayout = [vs];
		arm_Layers.pipeCopy.compile();
		arm_Layers.pipeCopyBGRA = new kha_graphics4_PipelineState();
		arm_Layers.pipeCopyBGRA.vertexShader = kha_Shaders.getVertex("layer_view.vert");
		arm_Layers.pipeCopyBGRA.fragmentShader = kha_Shaders.getFragment("layer_copy_bgra.frag");
		let vs1 = new kha_graphics4_VertexStructure();
		vs1.add("pos",2);
		vs1.add("tex",1);
		vs1.add("col",16);
		arm_Layers.pipeCopyBGRA.inputLayout = [vs1];
		arm_Layers.pipeCopyBGRA.compile();
		arm_Layers.pipeCopy8 = arm_Layers.pipeCopy;
		arm_Layers.pipeCopy128 = arm_Layers.pipeCopy;
		arm_Layers.pipeInvert8 = new kha_graphics4_PipelineState();
		arm_Layers.pipeInvert8.vertexShader = kha_Shaders.getVertex("layer_view.vert");
		arm_Layers.pipeInvert8.fragmentShader = kha_Shaders.getFragment("layer_invert.frag");
		let vs2 = new kha_graphics4_VertexStructure();
		vs2.add("pos",2);
		vs2.add("tex",1);
		vs2.add("col",16);
		arm_Layers.pipeInvert8.inputLayout = [vs2];
		arm_Layers.pipeInvert8.colorAttachmentCount = 1;
		arm_Layers.pipeInvert8.colorAttachments[0] = 1;
		arm_Layers.pipeInvert8.compile();
		arm_Layers.pipeApplyMask = new kha_graphics4_PipelineState();
		arm_Layers.pipeApplyMask.vertexShader = kha_Shaders.getVertex("layer_merge.vert");
		arm_Layers.pipeApplyMask.fragmentShader = kha_Shaders.getFragment("mask_apply.frag");
		let vs3 = new kha_graphics4_VertexStructure();
		vs3.add("pos",1);
		arm_Layers.pipeApplyMask.inputLayout = [vs3];
		arm_Layers.pipeApplyMask.compile();
		arm_Layers.tex0Mask = arm_Layers.pipeApplyMask.getTextureUnit("tex0");
		arm_Layers.texaMask = arm_Layers.pipeApplyMask.getTextureUnit("texa");
		arm_Layers.pipeMergeMask = new kha_graphics4_PipelineState();
		arm_Layers.pipeMergeMask.vertexShader = kha_Shaders.getVertex("layer_merge.vert");
		arm_Layers.pipeMergeMask.fragmentShader = kha_Shaders.getFragment("mask_merge.frag");
		let vs4 = new kha_graphics4_VertexStructure();
		vs4.add("pos",1);
		arm_Layers.pipeMergeMask.inputLayout = [vs4];
		arm_Layers.pipeMergeMask.compile();
		arm_Layers.tex0MergeMask = arm_Layers.pipeMergeMask.getTextureUnit("tex0");
		arm_Layers.texaMergeMask = arm_Layers.pipeMergeMask.getTextureUnit("texa");
		arm_Layers.opacMergeMask = arm_Layers.pipeMergeMask.getConstantLocation("opac");
		arm_Layers.blendingMergeMask = arm_Layers.pipeMergeMask.getConstantLocation("blending");
	}
	static makePipeCopyRGB() {
		arm_Layers.pipeCopyRGB = new kha_graphics4_PipelineState();
		arm_Layers.pipeCopyRGB.vertexShader = kha_Shaders.getVertex("layer_view.vert");
		arm_Layers.pipeCopyRGB.fragmentShader = kha_Shaders.getFragment("layer_copy.frag");
		let vs = new kha_graphics4_VertexStructure();
		vs.add("pos",2);
		vs.add("tex",1);
		vs.add("col",16);
		arm_Layers.pipeCopyRGB.inputLayout = [vs];
		arm_Layers.pipeCopyRGB.colorWriteMasksAlpha = [false];
		arm_Layers.pipeCopyRGB.compile();
	}
	static makeCursorPipe() {
		arm_Layers.pipeCursor = new kha_graphics4_PipelineState();
		arm_Layers.pipeCursor.vertexShader = kha_Shaders.getVertex("cursor.vert");
		arm_Layers.pipeCursor.fragmentShader = kha_Shaders.getFragment("cursor.frag");
		let vs = new kha_graphics4_VertexStructure();
		vs.add("pos",27);
		vs.add("nor",23);
		vs.add("tex",23);
		arm_Layers.pipeCursor.inputLayout = [vs];
		arm_Layers.pipeCursor.blendSource = 3;
		arm_Layers.pipeCursor.blendDestination = 5;
		arm_Layers.pipeCursor.depthWrite = false;
		arm_Layers.pipeCursor.depthMode = 0;
		arm_Layers.pipeCursor.compile();
		arm_Layers.cursorVP = arm_Layers.pipeCursor.getConstantLocation("VP");
		arm_Layers.cursorInvVP = arm_Layers.pipeCursor.getConstantLocation("invVP");
		arm_Layers.cursorMouse = arm_Layers.pipeCursor.getConstantLocation("mouse");
		arm_Layers.cursorTexStep = arm_Layers.pipeCursor.getConstantLocation("texStep");
		arm_Layers.cursorRadius = arm_Layers.pipeCursor.getConstantLocation("radius");
		arm_Layers.cursorCameraRight = arm_Layers.pipeCursor.getConstantLocation("cameraRight");
		arm_Layers.cursorTint = arm_Layers.pipeCursor.getConstantLocation("tint");
		arm_Layers.cursorGbufferD = arm_Layers.pipeCursor.getTextureUnit("gbufferD");
		arm_Layers.cursorTex = arm_Layers.pipeCursor.getTextureUnit("tex");
	}
	static makeTempImg() {
		let l = arm_Project.layers[0];
		if(arm_Layers.tempImage != null && (arm_Layers.tempImage.get_width() != l.texpaint.get_width() || arm_Layers.tempImage.get_height() != l.texpaint.get_height() || arm_Layers.tempImage.format != l.texpaint.format)) {
			let _temptex0 = iron_RenderPath.active.renderTargets.h["temptex0"];
			arm_App.notifyOnNextFrame(function() {
				_temptex0.unload();
			});
			let _this = iron_RenderPath.active.renderTargets;
			if(Object.prototype.hasOwnProperty.call(_this.h,"temptex0")) {
				delete(_this.h["temptex0"]);
			}
			arm_Layers.tempImage = null;
		}
		if(arm_Layers.tempImage == null) {
			let format = arm_App.bitsHandle.position == 0 ? "RGBA32" : arm_App.bitsHandle.position == 1 ? "RGBA64" : "RGBA128";
			let t = new iron_RenderTargetRaw();
			t.name = "temptex0";
			t.width = l.texpaint.get_width();
			t.height = l.texpaint.get_height();
			t.format = format;
			arm_Layers.tempImage = iron_RenderPath.active.createRenderTarget(t).image;
		}
	}
	static makeTempMaskImg() {
		if(arm_Layers.tempMaskImage != null && (arm_Layers.tempMaskImage.get_width() != arm_Config.getTextureResX() || arm_Layers.tempMaskImage.get_height() != arm_Config.getTextureResY())) {
			let _tempMaskImage = arm_Layers.tempMaskImage;
			arm_App.notifyOnNextFrame(function() {
				_tempMaskImage.unload();
			});
			arm_Layers.tempMaskImage = null;
		}
		if(arm_Layers.tempMaskImage == null) {
			arm_Layers.tempMaskImage = kha_Image.createRenderTarget(arm_Config.getTextureResX(),arm_Config.getTextureResY(),1);
		}
	}
	static makeExportImg() {
		let l = arm_Project.layers[0];
		if(arm_Layers.expa != null && (arm_Layers.expa.get_width() != l.texpaint.get_width() || arm_Layers.expa.get_height() != l.texpaint.get_height() || arm_Layers.expa.format != l.texpaint.format)) {
			let _expa = arm_Layers.expa;
			let _expb = arm_Layers.expb;
			let _expc = arm_Layers.expc;
			arm_App.notifyOnNextFrame(function() {
				_expa.unload();
				_expb.unload();
				_expc.unload();
			});
			arm_Layers.expa = null;
			arm_Layers.expb = null;
			arm_Layers.expc = null;
			let _this = iron_RenderPath.active.renderTargets;
			if(Object.prototype.hasOwnProperty.call(_this.h,"expa")) {
				delete(_this.h["expa"]);
			}
			let _this1 = iron_RenderPath.active.renderTargets;
			if(Object.prototype.hasOwnProperty.call(_this1.h,"expb")) {
				delete(_this1.h["expb"]);
			}
			let _this2 = iron_RenderPath.active.renderTargets;
			if(Object.prototype.hasOwnProperty.call(_this2.h,"expc")) {
				delete(_this2.h["expc"]);
			}
		}
		if(arm_Layers.expa == null) {
			let format = arm_App.bitsHandle.position == 0 ? "RGBA32" : arm_App.bitsHandle.position == 1 ? "RGBA64" : "RGBA128";
			let t = new iron_RenderTargetRaw();
			t.name = "expa";
			t.width = l.texpaint.get_width();
			t.height = l.texpaint.get_height();
			t.format = format;
			arm_Layers.expa = iron_RenderPath.active.createRenderTarget(t).image;
			let t1 = new iron_RenderTargetRaw();
			t1.name = "expb";
			t1.width = l.texpaint.get_width();
			t1.height = l.texpaint.get_height();
			t1.format = format;
			arm_Layers.expb = iron_RenderPath.active.createRenderTarget(t1).image;
			let t2 = new iron_RenderTargetRaw();
			t2.name = "expc";
			t2.width = l.texpaint.get_width();
			t2.height = l.texpaint.get_height();
			t2.format = format;
			arm_Layers.expc = iron_RenderPath.active.createRenderTarget(t2).image;
		}
	}
	static applyMasks(l) {
		let masks = l.getMasks();
		if(masks != null) {
			let _g = 0;
			let _g1 = masks.length - 1;
			while(_g < _g1) {
				let i = _g++;
				arm_Layers.mergeLayer(masks[i + 1],masks[i]);
				masks[i].delete();
			}
			masks[masks.length - 1].applyMask();
			arm_Context.layerPreviewDirty = true;
		}
	}
	static mergeDown() {
		let l1 = arm_Context.layer;
		if(l1.isGroup()) {
			let children = l1.getChildren();
			if(children.length == 1 && children[0].hasMasks()) {
				arm_Layers.applyMasks(children[0]);
			}
			let _g = 0;
			let _g1 = children.length - 1;
			while(_g < _g1) {
				arm_Context.setLayer(children[children.length - 1 - _g++]);
				arm_Layers.mergeDown();
			}
			children[0].parent = null;
			children[0].name = l1.name;
			if(children[0].fill_layer != null) {
				children[0].toPaintLayer();
			}
			l1.delete();
			l1 = children[0];
			arm_Context.setLayer(l1);
		}
		if(l1.hasMasks()) {
			arm_Layers.applyMasks(l1);
			arm_Context.setLayer(l1);
		}
		let l0 = arm_Project.layers[arm_Project.layers.indexOf(l1) - 1];
		if(l0.isGroup()) {
			let children = l0.getChildren();
			if(children.length == 1 && children[0].hasMasks()) {
				arm_Layers.applyMasks(children[0]);
			}
			let _g = 0;
			let _g1 = children.length - 1;
			while(_g < _g1) {
				arm_Context.setLayer(children[children.length - 1 - _g++]);
				arm_Layers.mergeDown();
			}
			children[0].parent = null;
			children[0].name = l0.name;
			if(children[0].fill_layer != null) {
				children[0].toPaintLayer();
			}
			l0.delete();
			l0 = children[0];
			arm_Context.setLayer(l1);
		} else if(l0.hasMasks()) {
			arm_Layers.applyMasks(l0);
			arm_Context.setLayer(l1);
		}
		arm_Layers.mergeLayer(l0,l1);
		arm_Context.layer.delete();
		arm_Context.setLayer(l0);
		arm_Context.layerPreviewDirty = true;
	}
	static mergeLayer(l0,l1,use_mask) {
		if(use_mask == null) {
			use_mask = false;
		}
		if(!l1.visible || l1.isGroup()) {
			return;
		}
		if(arm_Layers.pipeMerge == null) {
			arm_Layers.makePipe();
		}
		arm_Layers.makeTempImg();
		if(iron_data_ConstData.screenAlignedVB == null) {
			iron_data_ConstData.createScreenAlignedData();
		}
		arm_Layers.tempImage.get_g2().begin(false);
		arm_Layers.tempImage.get_g2().set_pipeline(arm_Layers.pipeCopy);
		arm_Layers.tempImage.get_g2().drawImage(l0.texpaint,0,0);
		arm_Layers.tempImage.get_g2().set_pipeline(null);
		arm_Layers.tempImage.get_g2().end();
		let empty = iron_RenderPath.active.renderTargets.h["empty_white"].image;
		let mask = empty;
		let l1masks = use_mask ? l1.getMasks() : null;
		if(l1masks != null) {
			mask = l1masks[0].texpaint;
		}
		if(l1.isMask()) {
			l0.texpaint.get_g4().begin();
			l0.texpaint.get_g4().setPipeline(arm_Layers.pipeMergeMask);
			l0.texpaint.get_g4().setTexture(arm_Layers.tex0MergeMask,l1.texpaint);
			l0.texpaint.get_g4().setTexture(arm_Layers.texaMergeMask,arm_Layers.tempImage);
			l0.texpaint.get_g4().setFloat(arm_Layers.opacMergeMask,l1.getOpacity());
			l0.texpaint.get_g4().setInt(arm_Layers.blendingMergeMask,l1.blending);
			l0.texpaint.get_g4().setVertexBuffer(iron_data_ConstData.screenAlignedVB);
			l0.texpaint.get_g4().setIndexBuffer(iron_data_ConstData.screenAlignedIB);
			l0.texpaint.get_g4().drawIndexedVertices();
			l0.texpaint.get_g4().end();
		}
		if(l1.isLayer()) {
			if(l1.paintBase) {
				l0.texpaint.get_g4().begin();
				l0.texpaint.get_g4().setPipeline(arm_Layers.pipeMerge);
				l0.texpaint.get_g4().setTexture(arm_Layers.tex0,l1.texpaint);
				l0.texpaint.get_g4().setTexture(arm_Layers.tex1,empty);
				l0.texpaint.get_g4().setTexture(arm_Layers.texmask,mask);
				l0.texpaint.get_g4().setTexture(arm_Layers.texa,arm_Layers.tempImage);
				l0.texpaint.get_g4().setFloat(arm_Layers.opac,l1.getOpacity());
				l0.texpaint.get_g4().setInt(arm_Layers.blending,l1.blending);
				l0.texpaint.get_g4().setVertexBuffer(iron_data_ConstData.screenAlignedVB);
				l0.texpaint.get_g4().setIndexBuffer(iron_data_ConstData.screenAlignedIB);
				l0.texpaint.get_g4().drawIndexedVertices();
				l0.texpaint.get_g4().end();
			}
			arm_Layers.tempImage.get_g2().begin(false);
			arm_Layers.tempImage.get_g2().set_pipeline(arm_Layers.pipeCopy);
			arm_Layers.tempImage.get_g2().drawImage(l0.texpaint_nor,0,0);
			arm_Layers.tempImage.get_g2().set_pipeline(null);
			arm_Layers.tempImage.get_g2().end();
			if(l1.paintNor) {
				l0.texpaint_nor.get_g4().begin();
				l0.texpaint_nor.get_g4().setPipeline(arm_Layers.pipeMerge);
				l0.texpaint_nor.get_g4().setTexture(arm_Layers.tex0,l1.texpaint);
				l0.texpaint_nor.get_g4().setTexture(arm_Layers.tex1,l1.texpaint_nor);
				l0.texpaint_nor.get_g4().setTexture(arm_Layers.texmask,mask);
				l0.texpaint_nor.get_g4().setTexture(arm_Layers.texa,arm_Layers.tempImage);
				l0.texpaint_nor.get_g4().setFloat(arm_Layers.opac,l1.getOpacity());
				let tmp = l1.paintNorBlend ? -2 : -1;
				l0.texpaint_nor.get_g4().setInt(arm_Layers.blending,tmp);
				l0.texpaint_nor.get_g4().setVertexBuffer(iron_data_ConstData.screenAlignedVB);
				l0.texpaint_nor.get_g4().setIndexBuffer(iron_data_ConstData.screenAlignedIB);
				l0.texpaint_nor.get_g4().drawIndexedVertices();
				l0.texpaint_nor.get_g4().end();
			}
			arm_Layers.tempImage.get_g2().begin(false);
			arm_Layers.tempImage.get_g2().set_pipeline(arm_Layers.pipeCopy);
			arm_Layers.tempImage.get_g2().drawImage(l0.texpaint_pack,0,0);
			arm_Layers.tempImage.get_g2().set_pipeline(null);
			arm_Layers.tempImage.get_g2().end();
			if(l1.paintOcc || l1.paintRough || l1.paintMet || l1.paintHeight) {
				if(l1.paintOcc && l1.paintRough && l1.paintMet && l1.paintHeight) {
					arm_Layers.commandsMergePack(arm_Layers.pipeMerge,l0.texpaint_pack,l1.texpaint,l1.texpaint_pack,l1.getOpacity(),mask,l1.paintHeightBlend ? -3 : -1);
				} else {
					if(l1.paintOcc) {
						arm_Layers.commandsMergePack(arm_Layers.pipeMergeR,l0.texpaint_pack,l1.texpaint,l1.texpaint_pack,l1.getOpacity(),mask);
					}
					if(l1.paintRough) {
						arm_Layers.commandsMergePack(arm_Layers.pipeMergeG,l0.texpaint_pack,l1.texpaint,l1.texpaint_pack,l1.getOpacity(),mask);
					}
					if(l1.paintMet) {
						arm_Layers.commandsMergePack(arm_Layers.pipeMergeB,l0.texpaint_pack,l1.texpaint,l1.texpaint_pack,l1.getOpacity(),mask);
					}
				}
			}
		}
	}
	static flatten(heightToNormal,layers) {
		if(heightToNormal == null) {
			heightToNormal = false;
		}
		if(layers == null) {
			layers = arm_Project.layers;
		}
		arm_Layers.makeTempImg();
		arm_Layers.makeExportImg();
		if(arm_Layers.pipeMerge == null) {
			arm_Layers.makePipe();
		}
		if(iron_data_ConstData.screenAlignedVB == null) {
			iron_data_ConstData.createScreenAlignedData();
		}
		let empty = iron_RenderPath.active.renderTargets.h["empty_white"].image;
		arm_Layers.expa.get_g4().begin();
		arm_Layers.expa.get_g4().clear(kha_Color.fromFloats(0.0,0.0,0.0,0.0));
		arm_Layers.expa.get_g4().end();
		arm_Layers.expb.get_g4().begin();
		arm_Layers.expb.get_g4().clear(kha_Color.fromFloats(0.5,0.5,1.0,0.0));
		arm_Layers.expb.get_g4().end();
		arm_Layers.expc.get_g4().begin();
		arm_Layers.expc.get_g4().clear(kha_Color.fromFloats(1.0,0.0,0.0,0.0));
		arm_Layers.expc.get_g4().end();
		let _g = 0;
		while(_g < layers.length) {
			let l1 = layers[_g];
			++_g;
			if(!l1.isVisible()) {
				continue;
			}
			if(!l1.isLayer()) {
				continue;
			}
			let mask = empty;
			let l1masks = l1.getMasks();
			if(l1masks != null) {
				if(l1masks.length > 1) {
					arm_Layers.makeTempMaskImg();
					arm_Layers.tempMaskImage.get_g2().begin(true,0);
					arm_Layers.tempMaskImage.get_g2().end();
					let l1 = { texpaint : arm_Layers.tempMaskImage};
					let _g = 0;
					let _g1 = l1masks.length;
					while(_g < _g1) {
						let i = _g++;
						arm_Layers.mergeLayer(l1,l1masks[i]);
					}
					mask = arm_Layers.tempMaskImage;
				} else {
					mask = l1masks[0].texpaint;
				}
			}
			if(l1.paintBase) {
				arm_Layers.tempImage.get_g2().begin(false);
				arm_Layers.tempImage.get_g2().set_pipeline(arm_Layers.pipeCopy);
				arm_Layers.tempImage.get_g2().drawImage(arm_Layers.expa,0,0);
				arm_Layers.tempImage.get_g2().set_pipeline(null);
				arm_Layers.tempImage.get_g2().end();
				arm_Layers.expa.get_g4().begin();
				arm_Layers.expa.get_g4().setPipeline(arm_Layers.pipeMerge);
				arm_Layers.expa.get_g4().setTexture(arm_Layers.tex0,l1.texpaint);
				arm_Layers.expa.get_g4().setTexture(arm_Layers.tex1,empty);
				arm_Layers.expa.get_g4().setTexture(arm_Layers.texmask,mask);
				arm_Layers.expa.get_g4().setTexture(arm_Layers.texa,arm_Layers.tempImage);
				arm_Layers.expa.get_g4().setFloat(arm_Layers.opac,l1.getOpacity());
				let tmp = layers.length > 1 ? l1.blending : 0;
				arm_Layers.expa.get_g4().setInt(arm_Layers.blending,tmp);
				arm_Layers.expa.get_g4().setVertexBuffer(iron_data_ConstData.screenAlignedVB);
				arm_Layers.expa.get_g4().setIndexBuffer(iron_data_ConstData.screenAlignedIB);
				arm_Layers.expa.get_g4().drawIndexedVertices();
				arm_Layers.expa.get_g4().end();
			}
			if(l1.paintNor) {
				arm_Layers.tempImage.get_g2().begin(false);
				arm_Layers.tempImage.get_g2().set_pipeline(arm_Layers.pipeCopy);
				arm_Layers.tempImage.get_g2().drawImage(arm_Layers.expb,0,0);
				arm_Layers.tempImage.get_g2().set_pipeline(null);
				arm_Layers.tempImage.get_g2().end();
				arm_Layers.expb.get_g4().begin();
				arm_Layers.expb.get_g4().setPipeline(arm_Layers.pipeMerge);
				arm_Layers.expb.get_g4().setTexture(arm_Layers.tex0,l1.texpaint);
				arm_Layers.expb.get_g4().setTexture(arm_Layers.tex1,l1.texpaint_nor);
				arm_Layers.expb.get_g4().setTexture(arm_Layers.texmask,mask);
				arm_Layers.expb.get_g4().setTexture(arm_Layers.texa,arm_Layers.tempImage);
				arm_Layers.expb.get_g4().setFloat(arm_Layers.opac,l1.getOpacity());
				let tmp = l1.paintNorBlend ? -2 : -1;
				arm_Layers.expb.get_g4().setInt(arm_Layers.blending,tmp);
				arm_Layers.expb.get_g4().setVertexBuffer(iron_data_ConstData.screenAlignedVB);
				arm_Layers.expb.get_g4().setIndexBuffer(iron_data_ConstData.screenAlignedIB);
				arm_Layers.expb.get_g4().drawIndexedVertices();
				arm_Layers.expb.get_g4().end();
			}
			if(l1.paintOcc || l1.paintRough || l1.paintMet || l1.paintHeight) {
				arm_Layers.tempImage.get_g2().begin(false);
				arm_Layers.tempImage.get_g2().set_pipeline(arm_Layers.pipeCopy);
				arm_Layers.tempImage.get_g2().drawImage(arm_Layers.expc,0,0);
				arm_Layers.tempImage.get_g2().set_pipeline(null);
				arm_Layers.tempImage.get_g2().end();
				if(l1.paintOcc && l1.paintRough && l1.paintMet && l1.paintHeight) {
					arm_Layers.commandsMergePack(arm_Layers.pipeMerge,arm_Layers.expc,l1.texpaint,l1.texpaint_pack,l1.getOpacity(),mask,l1.paintHeightBlend ? -3 : -1);
				} else {
					if(l1.paintOcc) {
						arm_Layers.commandsMergePack(arm_Layers.pipeMergeR,arm_Layers.expc,l1.texpaint,l1.texpaint_pack,l1.getOpacity(),mask);
					}
					if(l1.paintRough) {
						arm_Layers.commandsMergePack(arm_Layers.pipeMergeG,arm_Layers.expc,l1.texpaint,l1.texpaint_pack,l1.getOpacity(),mask);
					}
					if(l1.paintMet) {
						arm_Layers.commandsMergePack(arm_Layers.pipeMergeB,arm_Layers.expc,l1.texpaint,l1.texpaint_pack,l1.getOpacity(),mask);
					}
				}
			}
		}
		let l0 = { texpaint : arm_Layers.expa, texpaint_nor : arm_Layers.expb, texpaint_pack : arm_Layers.expc};
		if(heightToNormal && arm_node_MakeMaterial.heightUsed) {
			arm_Layers.tempImage.get_g2().begin(false);
			arm_Layers.tempImage.get_g2().set_pipeline(arm_Layers.pipeCopy);
			arm_Layers.tempImage.get_g2().drawImage(l0.texpaint_nor,0,0);
			arm_Layers.tempImage.get_g2().set_pipeline(null);
			arm_Layers.tempImage.get_g2().end();
			l0.texpaint_nor.get_g4().begin();
			l0.texpaint_nor.get_g4().setPipeline(arm_Layers.pipeMerge);
			l0.texpaint_nor.get_g4().setTexture(arm_Layers.tex0,arm_Layers.tempImage);
			l0.texpaint_nor.get_g4().setTexture(arm_Layers.tex1,l0.texpaint_pack);
			l0.texpaint_nor.get_g4().setTexture(arm_Layers.texmask,empty);
			l0.texpaint_nor.get_g4().setTexture(arm_Layers.texa,empty);
			l0.texpaint_nor.get_g4().setFloat(arm_Layers.opac,1.0);
			l0.texpaint_nor.get_g4().setInt(arm_Layers.blending,-4);
			l0.texpaint_nor.get_g4().setVertexBuffer(iron_data_ConstData.screenAlignedVB);
			l0.texpaint_nor.get_g4().setIndexBuffer(iron_data_ConstData.screenAlignedIB);
			l0.texpaint_nor.get_g4().drawIndexedVertices();
			l0.texpaint_nor.get_g4().end();
		}
		return l0;
	}
	static applyMask(l,m) {
		if(!l.isLayer() || !m.isMask()) {
			return;
		}
		if(arm_Layers.pipeMerge == null) {
			arm_Layers.makePipe();
		}
		arm_Layers.makeTempImg();
		arm_Layers.tempImage.get_g2().begin(false);
		arm_Layers.tempImage.get_g2().set_pipeline(arm_Layers.pipeCopy);
		arm_Layers.tempImage.get_g2().drawImage(l.texpaint,0,0);
		arm_Layers.tempImage.get_g2().set_pipeline(null);
		arm_Layers.tempImage.get_g2().end();
		if(iron_data_ConstData.screenAlignedVB == null) {
			iron_data_ConstData.createScreenAlignedData();
		}
		l.texpaint.get_g4().begin();
		l.texpaint.get_g4().setPipeline(arm_Layers.pipeApplyMask);
		l.texpaint.get_g4().setTexture(arm_Layers.tex0Mask,arm_Layers.tempImage);
		l.texpaint.get_g4().setTexture(arm_Layers.texaMask,m.texpaint);
		l.texpaint.get_g4().setVertexBuffer(iron_data_ConstData.screenAlignedVB);
		l.texpaint.get_g4().setIndexBuffer(iron_data_ConstData.screenAlignedIB);
		l.texpaint.get_g4().drawIndexedVertices();
		l.texpaint.get_g4().end();
	}
	static commandsMergePack(pipe,i0,i1,i1pack,i1maskOpacity,i1texmask,i1blending) {
		if(i1blending == null) {
			i1blending = -1;
		}
		i0.get_g4().begin();
		i0.get_g4().setPipeline(pipe);
		i0.get_g4().setTexture(arm_Layers.tex0,i1);
		i0.get_g4().setTexture(arm_Layers.tex1,i1pack);
		i0.get_g4().setTexture(arm_Layers.texmask,i1texmask);
		i0.get_g4().setTexture(arm_Layers.texa,arm_Layers.tempImage);
		i0.get_g4().setFloat(arm_Layers.opac,i1maskOpacity);
		i0.get_g4().setInt(arm_Layers.blending,i1blending);
		i0.get_g4().setVertexBuffer(iron_data_ConstData.screenAlignedVB);
		i0.get_g4().setIndexBuffer(iron_data_ConstData.screenAlignedIB);
		i0.get_g4().drawIndexedVertices();
		i0.get_g4().end();
	}
	static isFillMaterial() {
		if(arm_ui_UIHeader.inst.worktab.position == 1) {
			return true;
		}
		let m = arm_Context.material;
		let _g = 0;
		let _g1 = arm_Project.layers;
		while(_g < _g1.length) if(_g1[_g++].fill_layer == m) {
			return true;
		}
		return false;
	}
	static updateFillLayers() {
		let _layer = arm_Context.layer;
		let _tool = arm_Context.tool;
		let _fillType = arm_Context.fillTypeHandle.position;
		let current = null;
		if(arm_ui_UIHeader.inst.worktab.position == 1) {
			if(arm_render_RenderPathPaint.liveLayer == null) {
				arm_render_RenderPathPaint.liveLayer = new arm_data_LayerSlot("_live");
			}
			current = kha_graphics2_Graphics.current;
			if(current != null) {
				current.end();
			}
			arm_ui_UIHeader.inst.worktab.position = 0;
			arm_Context.tool = 2;
			arm_Context.fillTypeHandle.position = 0;
			arm_node_MakeMaterial.parsePaintMaterial(false);
			arm_Context.pdirty = 1;
			arm_render_RenderPathPaint.useLiveLayer(true);
			arm_render_RenderPathPaint.commandsPaint(false);
			arm_render_RenderPathPaint.dilate(true,true);
			arm_render_RenderPathPaint.useLiveLayer(false);
			arm_Context.tool = _tool;
			arm_Context.fillTypeHandle.position = _fillType;
			arm_Context.pdirty = 0;
			arm_Context.rdirty = 2;
			arm_ui_UIHeader.inst.worktab.position = 1;
			if(current != null) {
				current.begin(false);
			}
			return;
		}
		let hasFillLayer = false;
		let hasFillMask = false;
		let _g = 0;
		let _g1 = arm_Project.layers;
		while(_g < _g1.length) {
			let l = _g1[_g];
			++_g;
			if(l.isLayer() && l.fill_layer == arm_Context.material) {
				hasFillLayer = true;
			}
		}
		let _g2 = 0;
		let _g3 = arm_Project.layers;
		while(_g2 < _g3.length) {
			let l = _g3[_g2];
			++_g2;
			if(l.isMask() && l.fill_layer == arm_Context.material) {
				hasFillMask = true;
			}
		}
		if(hasFillLayer || hasFillMask) {
			current = kha_graphics2_Graphics.current;
			if(current != null) {
				current.end();
			}
			arm_Context.pdirty = 1;
			arm_Context.tool = 2;
			arm_Context.fillTypeHandle.position = 0;
			if(hasFillLayer) {
				let first = true;
				let _g = 0;
				let _g1 = arm_Project.layers;
				while(_g < _g1.length) {
					let l = _g1[_g];
					++_g;
					if(l.isLayer() && l.fill_layer == arm_Context.material) {
						arm_Context.layer = l;
						if(first) {
							first = false;
							arm_node_MakeMaterial.parsePaintMaterial(false);
						}
						arm_Layers.setObjectMask();
						l.clear();
						arm_render_RenderPathPaint.commandsPaint(false);
						arm_render_RenderPathPaint.dilate(true,true);
					}
				}
			}
			if(hasFillMask) {
				let first = true;
				let _g = 0;
				let _g1 = arm_Project.layers;
				while(_g < _g1.length) {
					let l = _g1[_g];
					++_g;
					if(l.isMask() && l.fill_layer == arm_Context.material) {
						arm_Context.layer = l;
						if(first) {
							first = false;
							arm_node_MakeMaterial.parsePaintMaterial(false);
						}
						arm_Layers.setObjectMask();
						l.clear();
						arm_render_RenderPathPaint.commandsPaint(false);
						arm_render_RenderPathPaint.dilate(true,true);
					}
				}
			}
			arm_Context.pdirty = 0;
			arm_Context.ddirty = 2;
			arm_Context.rdirty = 2;
			if(current != null) {
				current.begin(false);
			}
			arm_Context.layer = _layer;
			arm_Layers.setObjectMask();
			arm_Context.tool = _tool;
			arm_Context.fillTypeHandle.position = _fillType;
		}
	}
	static updateFillLayer(parsePaint) {
		if(parsePaint == null) {
			parsePaint = true;
		}
		let current = kha_graphics2_Graphics.current;
		if(current != null) {
			current.end();
		}
		let _tool = arm_Context.tool;
		let _fillType = arm_Context.fillTypeHandle.position;
		arm_Context.tool = 2;
		arm_Context.fillTypeHandle.position = 0;
		arm_Context.pdirty = 1;
		let _workspace = arm_ui_UIHeader.inst.worktab.position;
		arm_ui_UIHeader.inst.worktab.position = 0;
		arm_Context.layer.clear();
		if(parsePaint) {
			arm_node_MakeMaterial.parsePaintMaterial(false);
		}
		arm_render_RenderPathPaint.commandsPaint(false);
		arm_render_RenderPathPaint.dilate(true,true);
		arm_Context.rdirty = 2;
		arm_Context.tool = _tool;
		arm_Context.fillTypeHandle.position = _fillType;
		arm_ui_UIHeader.inst.worktab.position = _workspace;
		if(current != null) {
			current.begin(false);
		}
	}
	static setObjectMask() {
		let ar = [arm_Translator.tr("None")];
		let _g = 0;
		let _g1 = arm_Project.paintObjects;
		while(_g < _g1.length) ar.push(_g1[_g++].name);
		let mask = arm_Context.objectMaskUsed() ? arm_Context.layer.getObjectMask() : 0;
		if(arm_Context.layerFilterUsed()) {
			mask = arm_Context.layerFilter;
		}
		if(mask > 0) {
			if(arm_Context.mergedObject != null) {
				arm_Context.mergedObject.visible = false;
			}
			let o = arm_Project.paintObjects[0];
			let _g = 0;
			let _g1 = arm_Project.paintObjects;
			while(_g < _g1.length) {
				let p = _g1[_g];
				++_g;
				if(p.name == ar[mask]) {
					o = p;
					break;
				}
			}
			arm_Context.selectPaintObject(o);
		} else {
			let isAtlas = arm_Context.layer.getObjectMask() > 0 && arm_Context.layer.getObjectMask() <= arm_Project.paintObjects.length;
			if(arm_Context.mergedObject == null || isAtlas || arm_Context.mergedObjectIsAtlas) {
				arm_util_MeshUtil.mergeMesh(isAtlas ? arm_Project.getAtlasObjects(arm_Context.layer.getObjectMask()) : null);
			}
			arm_Context.selectPaintObject(arm_Context.mainObject());
			arm_Context.paintObject.skip_context = "paint";
			arm_Context.mergedObject.visible = true;
		}
		arm_util_UVUtil.dilatemapCached = false;
	}
	static newLayer(clear) {
		if(clear == null) {
			clear = true;
		}
		if(arm_Project.layers.length > 255) {
			return null;
		}
		let l = new arm_data_LayerSlot();
		l.objectMask = arm_Context.layerFilter;
		if(arm_Context.layer.isMask()) {
			arm_Context.setLayer(arm_Context.layer.parent);
		}
		arm_Project.layers.splice(arm_Project.layers.indexOf(arm_Context.layer) + 1,0,l);
		arm_Context.setLayer(l);
		let li = arm_Project.layers.indexOf(arm_Context.layer);
		if(li > 0) {
			let below = arm_Project.layers[li - 1];
			if(below.isLayer()) {
				arm_Context.layer.parent = below.parent;
			}
		}
		if(clear) {
			iron_App.notifyOnInit(function() {
				l.clear();
			});
		}
		arm_Context.layerPreviewDirty = true;
		return l;
	}
	static newMask(clear,parent) {
		if(clear == null) {
			clear = true;
		}
		if(arm_Project.layers.length > 255) {
			return null;
		}
		let l = new arm_data_LayerSlot("",1,parent);
		arm_Project.layers.splice(arm_Project.layers.indexOf(parent),0,l);
		arm_Context.setLayer(l);
		if(clear) {
			iron_App.notifyOnInit(function() {
				l.clear();
			});
		}
		arm_Context.layerPreviewDirty = true;
		return l;
	}
	static newGroup() {
		if(arm_Project.layers.length > 255) {
			return null;
		}
		let l = new arm_data_LayerSlot("",2);
		arm_Project.layers.push(l);
		arm_Context.setLayer(l);
		return l;
	}
	static createFillLayer(uvType,decalMat) {
		if(uvType == null) {
			uvType = 0;
		}
		iron_App.notifyOnInit(function() {
			let l = arm_Layers.newLayer(false);
			arm_History.newLayer();
			l.uvType = uvType;
			if(decalMat != null) {
				l.decalMat = decalMat;
			}
			l.objectMask = arm_Context.layerFilter;
			arm_History.toFillLayer();
			l.toFillLayer();
		});
	}
	static createImageMask(asset) {
		let l = arm_Context.layer;
		if(l.isMask() || l.isGroup()) {
			return;
		}
		arm_History.newLayer();
		arm_Layers.newMask(false,l).clear(0,arm_Project.getImage(asset));
		arm_Context.layerPreviewDirty = true;
	}
	static createColorLayer(baseColor) {
		iron_App.notifyOnInit(function() {
			let l = arm_Layers.newLayer(false);
			arm_History.newLayer();
			l.uvType = 0;
			l.objectMask = arm_Context.layerFilter;
			l.clear(baseColor);
		});
	}
}
$hxClasses["arm.Layers"] = arm_Layers;
arm_Layers.__name__ = "arm.Layers";
class arm_Operator {
	static shortcut(s,type) {
		if(type == null) {
			type = 0;
		}
		if(s == "") {
			return false;
		}
		let mouse = iron_system_Input.getMouse();
		let kb = iron_system_Input.getKeyboard();
		let shift = s.indexOf("shift") >= 0;
		let ctrl = s.indexOf("ctrl") >= 0;
		let alt = s.indexOf("alt") >= 0;
		let flag = shift == kb.down("shift") && ctrl == kb.down("control") && alt == kb.down("alt");
		if(s.indexOf("+") > 0) {
			s = HxOverrides.substr(s,s.lastIndexOf("+") + 1,null);
			if(s == "number") {
				return flag;
			}
		} else if(shift || ctrl || alt) {
			return flag;
		}
		let key = s == "left" || s == "right" || s == "middle" ? type == 2 ? mouse.down(s) : mouse.started(s) : type == 1 ? kb.repeat(s) : type == 2 ? kb.down(s) : type == 3 ? kb.released(s) : kb.started(s);
		if(flag) {
			return key;
		} else {
			return false;
		}
	}
}
$hxClasses["arm.Operator"] = arm_Operator;
arm_Operator.__name__ = "arm.Operator";
class arm_Plugin {
	constructor() {
		this.apiversion = "0.1";
		this.version = "0.1";
		this.delete = null;
		this.update = null;
		this.draw = null;
		this.drawUI = null;
		this.name = arm_Plugin.pluginName;
		arm_Plugin.plugins.h[this.name] = this;
	}
	static start(plugin) {
		try {
			iron_data_Data.getBlob("plugins/" + plugin,function(blob) {
				arm_Plugin.pluginName = plugin;
				eval(blob.toString());
				iron_data_Data.deleteBlob("plugins/" + plugin);
			});
		} catch( _g ) {
			let _g1 = haxe_Exception.caught(_g).unwrap();
			haxe_Log.trace("Failed to load plugin '" + plugin + "'",{ fileName : "Sources/arm/Plugin.hx", lineNumber : 36, className : "arm.Plugin", methodName : "start"});
			haxe_Log.trace(_g1,{ fileName : "Sources/arm/Plugin.hx", lineNumber : 37, className : "arm.Plugin", methodName : "start"});
		}
	}
	static stop(plugin) {
		let p = arm_Plugin.plugins.h[plugin];
		if(p != null && p.delete != null) {
			p.delete();
		}
		let _this = arm_Plugin.plugins;
		if(Object.prototype.hasOwnProperty.call(_this.h,plugin)) {
			delete(_this.h[plugin]);
		}
	}
}
$hxClasses["arm.Plugin"] = arm_Plugin;
arm_Plugin.__name__ = "arm.Plugin";
Object.assign(arm_Plugin.prototype, {
	__class__: arm_Plugin
});
class arm_Keep {
	static keep() {
		return [iron_system_ArmPack.decode,iron_system_ArmPack.encode];
	}
}
$hxClasses["arm.Keep"] = arm_Keep;
arm_Keep.__name__ = "arm.Keep";
class kha_Blob {
	constructor(bytes) {
		this.bytes = bytes;
	}
	sub(start,length) {
		return new kha_Blob(this.bytes.sub(start,length));
	}
	get_length() {
		return this.bytes.length;
	}
	writeU8(position,value) {
		this.bytes.b[position] = value;
	}
	readU8(position) {
		return this.bytes.b[position++];
	}
	readU16BE(position) {
		let first = this.bytes.b[position];
		let second = this.bytes.b[position + 1];
		position += 2;
		return first * 256 + second;
	}
	readU32BE(position) {
		let fourth = this.bytes.b[position];
		let third = this.bytes.b[position + 1];
		let second = this.bytes.b[position + 2];
		let first = this.bytes.b[position + 3];
		position += 4;
		return first + second * 256 + third * 256 * 256 + fourth * 256 * 256 * 256;
	}
	readS16BE(position) {
		let first = this.bytes.b[position];
		let second = this.bytes.b[position + 1];
		position += 2;
		let sign = (first & 128) == 0 ? 1 : -1;
		first &= 127;
		if(sign == -1) {
			return -32767 + first * 256 + second;
		} else {
			return first * 256 + second;
		}
	}
	readS16LE(position) {
		let first = this.bytes.b[position];
		let second = this.bytes.b[position + 1];
		let sign = (second & 128) == 0 ? 1 : -1;
		second &= 127;
		position += 2;
		if(sign == -1) {
			return -32767 + second * 256 + first;
		} else {
			return second * 256 + first;
		}
	}
	readS32LE(position) {
		let fourth = this.bytes.b[position];
		let third = this.bytes.b[position + 1];
		let second = this.bytes.b[position + 2];
		let first = this.bytes.b[position + 3];
		let sign = (first & 128) == 0 ? 1 : -1;
		first &= 127;
		position += 4;
		if(sign == -1) {
			return -2147483647 + fourth + third * 256 + second * 256 * 256 + first * 256 * 256 * 256;
		} else {
			return fourth + third * 256 + second * 256 * 256 + first * 256 * 256 * 256;
		}
	}
	readS32BE(position) {
		let fourth = this.bytes.b[position];
		let third = this.bytes.b[position + 1];
		let second = this.bytes.b[position + 2];
		let first = this.bytes.b[position + 3];
		let sign = (fourth & 128) == 0 ? 1 : -1;
		fourth &= 127;
		position += 4;
		if(sign == -1) {
			return -2147483647 + first + second * 256 + third * 256 * 256 + fourth * 256 * 256 * 256;
		}
		return first + second * 256 + third * 256 * 256 + fourth * 256 * 256 * 256;
	}
	readF32LE(position) {
		return kha_Blob.readF32(this.readS32LE(position));
	}
	readF32BE(position) {
		return kha_Blob.readF32(this.readS32BE(position));
	}
	toString() {
		return this.bytes.toString();
	}
	toBytes() {
		return this.bytes;
	}
	unload() {
		this.bytes = null;
	}
	static fromBytes(bytes) {
		return new kha_Blob(bytes);
	}
	static alloc(size) {
		return new kha_Blob(new haxe_io_Bytes(new ArrayBuffer(size)));
	}
	static readF32(i) {
		let sign = (i & -2147483648) == 0 ? 1 : -1;
		let exp = i >> 23 & 255;
		let man = i & 8388607;
		switch(exp) {
		case 0:
			return 0.0;
		case 255:
			if(man != 0) {
				return NaN;
			} else if(sign > 0) {
				return Infinity;
			} else {
				return -Infinity;
			}
			break;
		default:
			return sign * ((man + 8388608) / 8388608.0) * Math.pow(2,exp - 127);
		}
	}
}
$hxClasses["kha.Blob"] = kha_Blob;
kha_Blob.__name__ = "kha.Blob";
Object.assign(kha_Blob.prototype, {
	__class__: kha_Blob
	,__properties__: {get_length: "get_length"}
});
class haxe_io_Bytes {
	constructor(data) {
		this.length = data.byteLength;
		this.b = new Uint8Array(data);
		this.b.bufferValue = data;
		data.hxBytes = this;
		data.bytes = this.b;
	}
	sub(pos,len) {
		if(pos < 0 || len < 0 || pos + len > this.length) {
			throw haxe_Exception.thrown(haxe_io_Error.OutsideBounds);
		}
		return new haxe_io_Bytes(this.b.buffer.slice(pos + this.b.byteOffset,pos + this.b.byteOffset + len));
	}
	getFloat(pos) {
		if(this.data == null) {
			this.data = new DataView(this.b.buffer,this.b.byteOffset,this.b.byteLength);
		}
		return this.data.getFloat32(pos,true);
	}
	getInt32(pos) {
		if(this.data == null) {
			this.data = new DataView(this.b.buffer,this.b.byteOffset,this.b.byteLength);
		}
		return this.data.getInt32(pos,true);
	}
	getString(pos,len,encoding) {
		if(pos < 0 || len < 0 || pos + len > this.length) {
			throw haxe_Exception.thrown(haxe_io_Error.OutsideBounds);
		}
		if(encoding == null) {
			encoding = haxe_io_Encoding.UTF8;
		}
		let s = "";
		let b = this.b;
		let i = pos;
		let max = pos + len;
		switch(encoding._hx_index) {
		case 0:
			while(i < max) {
				let c = b[i++];
				if(c < 128) {
					if(c == 0) {
						break;
					}
					s += String.fromCodePoint(c);
				} else if(c < 224) {
					let code = (c & 63) << 6 | b[i++] & 127;
					s += String.fromCodePoint(code);
				} else if(c < 240) {
					let code = (c & 31) << 12 | (b[i++] & 127) << 6 | b[i++] & 127;
					s += String.fromCodePoint(code);
				} else {
					let u = (c & 15) << 18 | (b[i++] & 127) << 12 | (b[i++] & 127) << 6 | b[i++] & 127;
					s += String.fromCodePoint(u);
				}
			}
			break;
		case 1:
			while(i < max) {
				let c = b[i++] | b[i++] << 8;
				s += String.fromCodePoint(c);
			}
			break;
		}
		return s;
	}
	toString() {
		return this.getString(0,this.length);
	}
	static ofString(s,encoding) {
		if(encoding == haxe_io_Encoding.RawNative) {
			let buf = new Uint8Array(s.length << 1);
			let _g = 0;
			let _g1 = s.length;
			while(_g < _g1) {
				let i = _g++;
				let c = s.charCodeAt(i);
				buf[i << 1] = c & 255;
				buf[i << 1 | 1] = c >> 8;
			}
			return new haxe_io_Bytes(buf.buffer);
		}
		let a = [];
		let i = 0;
		while(i < s.length) {
			let c = s.charCodeAt(i++);
			if(55296 <= c && c <= 56319) {
				c = c - 55232 << 10 | s.charCodeAt(i++) & 1023;
			}
			if(c <= 127) {
				a.push(c);
			} else if(c <= 2047) {
				a.push(192 | c >> 6);
				a.push(128 | c & 63);
			} else if(c <= 65535) {
				a.push(224 | c >> 12);
				a.push(128 | c >> 6 & 63);
				a.push(128 | c & 63);
			} else {
				a.push(240 | c >> 18);
				a.push(128 | c >> 12 & 63);
				a.push(128 | c >> 6 & 63);
				a.push(128 | c & 63);
			}
		}
		return new haxe_io_Bytes(new Uint8Array(a).buffer);
	}
	static ofData(b) {
		let hb = b.hxBytes;
		if(hb != null) {
			return hb;
		}
		return new haxe_io_Bytes(b);
	}
}
$hxClasses["haxe.io.Bytes"] = haxe_io_Bytes;
haxe_io_Bytes.__name__ = "haxe.io.Bytes";
Object.assign(haxe_io_Bytes.prototype, {
	__class__: haxe_io_Bytes
});
class haxe_io_Input {
	readByte() {
		throw new haxe_exceptions_NotImplementedException(null,null,{ fileName : "haxe/io/Input.hx", lineNumber : 53, className : "haxe.io.Input", methodName : "readByte"});
	}
	readBytes(s,pos,len) {
		let k = len;
		let b = s.b;
		if(pos < 0 || len < 0 || pos + len > s.length) {
			throw haxe_Exception.thrown(haxe_io_Error.OutsideBounds);
		}
		try {
			while(k > 0) {
				b[pos] = this.readByte();
				++pos;
				--k;
			}
		} catch( _g ) {
			if(!((haxe_Exception.caught(_g).unwrap()) instanceof haxe_io_Eof)) {
				throw _g;
			}
		}
		return len - k;
	}
	set_bigEndian(b) {
		this.bigEndian = b;
		return b;
	}
	readFullBytes(s,pos,len) {
		while(len > 0) {
			let k = this.readBytes(s,pos,len);
			if(k == 0) {
				throw haxe_Exception.thrown(haxe_io_Error.Blocked);
			}
			pos += k;
			len -= k;
		}
	}
	read(nbytes) {
		let s = new haxe_io_Bytes(new ArrayBuffer(nbytes));
		let p = 0;
		while(nbytes > 0) {
			let k = this.readBytes(s,p,nbytes);
			if(k == 0) {
				throw haxe_Exception.thrown(haxe_io_Error.Blocked);
			}
			p += k;
			nbytes -= k;
		}
		return s;
	}
	readFloat() {
		return haxe_io_FPHelper.i32ToFloat(this.readInt32());
	}
	readInt8() {
		let n = this.readByte();
		if(n >= 128) {
			return n - 256;
		}
		return n;
	}
	readInt16() {
		let ch1 = this.readByte();
		let ch2 = this.readByte();
		let n = this.bigEndian ? ch2 | ch1 << 8 : ch1 | ch2 << 8;
		if((n & 32768) != 0) {
			return n - 65536;
		}
		return n;
	}
	readUInt16() {
		let ch1 = this.readByte();
		let ch2 = this.readByte();
		if(this.bigEndian) {
			return ch2 | ch1 << 8;
		} else {
			return ch1 | ch2 << 8;
		}
	}
	readInt32() {
		let ch1 = this.readByte();
		let ch2 = this.readByte();
		let ch3 = this.readByte();
		let ch4 = this.readByte();
		if(this.bigEndian) {
			return ch4 | ch3 << 8 | ch2 << 16 | ch1 << 24;
		} else {
			return ch1 | ch2 << 8 | ch3 << 16 | ch4 << 24;
		}
	}
	readString(len,encoding) {
		let b = new haxe_io_Bytes(new ArrayBuffer(len));
		this.readFullBytes(b,0,len);
		return b.getString(0,len,encoding);
	}
}
$hxClasses["haxe.io.Input"] = haxe_io_Input;
haxe_io_Input.__name__ = "haxe.io.Input";
Object.assign(haxe_io_Input.prototype, {
	__class__: haxe_io_Input
	,__properties__: {set_bigEndian: "set_bigEndian"}
});
class haxe_io_BytesInput extends haxe_io_Input {
	constructor(b,pos,len) {
		super();
		if(pos == null) {
			pos = 0;
		}
		if(len == null) {
			len = b.length - pos;
		}
		if(pos < 0 || len < 0 || pos + len > b.length) {
			throw haxe_Exception.thrown(haxe_io_Error.OutsideBounds);
		}
		this.b = b.b;
		this.pos = pos;
		this.len = len;
		this.totlen = len;
	}
	set_position(p) {
		if(p < 0) {
			p = 0;
		} else if(p > this.totlen) {
			p = this.totlen;
		}
		this.len = this.totlen - p;
		return this.pos = p;
	}
	readByte() {
		if(this.len == 0) {
			throw haxe_Exception.thrown(new haxe_io_Eof());
		}
		this.len--;
		return this.b[this.pos++];
	}
	readBytes(buf,pos,len) {
		if(pos < 0 || len < 0 || pos + len > buf.length) {
			throw haxe_Exception.thrown(haxe_io_Error.OutsideBounds);
		}
		if(this.len == 0 && len > 0) {
			throw haxe_Exception.thrown(new haxe_io_Eof());
		}
		if(this.len < len) {
			len = this.len;
		}
		let b1 = this.b;
		let b2 = buf.b;
		let _g = 0;
		let _g1 = len;
		while(_g < _g1) {
			let i = _g++;
			b2[pos + i] = b1[this.pos + i];
		}
		this.pos += len;
		this.len -= len;
		return len;
	}
}
$hxClasses["haxe.io.BytesInput"] = haxe_io_BytesInput;
haxe_io_BytesInput.__name__ = "haxe.io.BytesInput";
haxe_io_BytesInput.__super__ = haxe_io_Input;
Object.assign(haxe_io_BytesInput.prototype, {
	__class__: haxe_io_BytesInput
	,__properties__: Object.assign({}, haxe_io_Input.prototype.__properties__, {set_position: "set_position"})
});
class haxe_io_Output {
	writeByte(c) {
		throw new haxe_exceptions_NotImplementedException(null,null,{ fileName : "haxe/io/Output.hx", lineNumber : 47, className : "haxe.io.Output", methodName : "writeByte"});
	}
	writeBytes(s,pos,len) {
		if(pos < 0 || len < 0 || pos + len > s.length) {
			throw haxe_Exception.thrown(haxe_io_Error.OutsideBounds);
		}
		let b = s.b;
		let k = len;
		while(k > 0) {
			this.writeByte(b[pos]);
			++pos;
			--k;
		}
		return len;
	}
	set_bigEndian(b) {
		this.bigEndian = b;
		return b;
	}
	writeFullBytes(s,pos,len) {
		while(len > 0) {
			let k = this.writeBytes(s,pos,len);
			pos += k;
			len -= k;
		}
	}
	writeFloat(x) {
		this.writeInt32(haxe_io_FPHelper.floatToI32(x));
	}
	writeInt16(x) {
		if(x < -32768 || x >= 32768) {
			throw haxe_Exception.thrown(haxe_io_Error.Overflow);
		}
		this.writeUInt16(x & 65535);
	}
	writeUInt16(x) {
		if(x < 0 || x >= 65536) {
			throw haxe_Exception.thrown(haxe_io_Error.Overflow);
		}
		if(this.bigEndian) {
			this.writeByte(x >> 8);
			this.writeByte(x & 255);
		} else {
			this.writeByte(x & 255);
			this.writeByte(x >> 8);
		}
	}
	writeInt32(x) {
		if(this.bigEndian) {
			this.writeByte(x >>> 24);
			this.writeByte(x >> 16 & 255);
			this.writeByte(x >> 8 & 255);
			this.writeByte(x & 255);
		} else {
			this.writeByte(x & 255);
			this.writeByte(x >> 8 & 255);
			this.writeByte(x >> 16 & 255);
			this.writeByte(x >>> 24);
		}
	}
	writeString(s,encoding) {
		let b = haxe_io_Bytes.ofString(s,encoding);
		this.writeFullBytes(b,0,b.length);
	}
}
$hxClasses["haxe.io.Output"] = haxe_io_Output;
haxe_io_Output.__name__ = "haxe.io.Output";
Object.assign(haxe_io_Output.prototype, {
	__class__: haxe_io_Output
	,__properties__: {set_bigEndian: "set_bigEndian"}
});
class haxe_io_BytesOutput extends haxe_io_Output {
	constructor() {
		super();
		this.b = new haxe_io_BytesBuffer();
	}
	writeByte(c) {
		this.b.addByte(c);
	}
	writeBytes(buf,pos,len) {
		this.b.addBytes(buf,pos,len);
		return len;
	}
	getBytes() {
		return this.b.getBytes();
	}
}
$hxClasses["haxe.io.BytesOutput"] = haxe_io_BytesOutput;
haxe_io_BytesOutput.__name__ = "haxe.io.BytesOutput";
haxe_io_BytesOutput.__super__ = haxe_io_Output;
Object.assign(haxe_io_BytesOutput.prototype, {
	__class__: haxe_io_BytesOutput
});
class kha_Canvas {
}
$hxClasses["kha.Canvas"] = kha_Canvas;
kha_Canvas.__name__ = "kha.Canvas";
kha_Canvas.__isInterface__ = true;
Object.assign(kha_Canvas.prototype, {
	__class__: kha_Canvas
	,__properties__: {get_g4: "get_g4",get_height: "get_height",get_width: "get_width"}
});
class kha_Image {
	constructor(texture) {
		this.pixels = null;
		this.texture_ = texture;
	}
	unload() {
		Krom.unloadImage(this);
		this.texture_ = null;
		this.renderTarget_ = null;
	}
	getPixels() {
		if(this.renderTarget_ != null) {
			if(this.pixels == null) {
				this.pixels = new haxe_io_Bytes(new ArrayBuffer(kha_Image.formatByteSize(this.format) * this.get_width() * this.get_height()));
			}
			Krom.getRenderTargetPixels(this.renderTarget_,this.pixels.b.bufferValue);
			return this.pixels;
		} else {
			return haxe_io_Bytes.ofData(Krom.getTexturePixels(this.texture_));
		}
	}
	generateMipmaps(levels) {
		if(this.texture_ == null) {
			Krom.generateRenderTargetMipmaps(this.renderTarget_,levels);
		} else {
			Krom.generateTextureMipmaps(this.texture_,levels);
		}
	}
	setMipmaps(mipmaps) {
		Krom.setMipmaps(this.texture_,mipmaps);
	}
	setDepthStencilFrom(image) {
		Krom.setDepthStencilFrom(this.renderTarget_,image.renderTarget_);
	}
	clear(x,y,z,width,height,depth,color) {
		Krom.clearTexture(this.texture_,x,y,z,width,height,depth,color);
	}
	get_width() {
		if(this.texture_ == null) {
			return this.renderTarget_.width;
		} else {
			return this.texture_.width;
		}
	}
	get_height() {
		if(this.texture_ == null) {
			return this.renderTarget_.height;
		} else {
			return this.texture_.height;
		}
	}
	get_depth() {
		if(this.texture_ != null) {
			return this.texture_.depth;
		} else {
			return 1;
		}
	}
	get_g2() {
		if(this.graphics2 == null) {
			this.graphics2 = new kha_graphics2_Graphics(this);
		}
		return this.graphics2;
	}
	get_g4() {
		if(this.graphics4 == null) {
			this.graphics4 = new kha_graphics4_Graphics(this);
		}
		return this.graphics4;
	}
	static getRenderTargetFormat(format) {
		switch(format) {
		case 0:
			return 0;
		case 1:
			return 5;
		case 2:
			return 3;
		case 3:
			return 4;
		case 4:
			return 1;
		case 5:
			return 2;
		case 6:
			return 6;
		default:
			return 0;
		}
	}
	static getDepthBufferBits(depthAndStencil) {
		switch(depthAndStencil) {
		case 0:
			return -1;
		case 1:
			return 24;
		case 2:
			return 24;
		case 3:
			return 24;
		case 4:
			return 32;
		case 5:
			return 16;
		}
	}
	static getStencilBufferBits(depthAndStencil) {
		switch(depthAndStencil) {
		case 0:
			return -1;
		case 1:
			return -1;
		case 2:
			return 8;
		case 3:
			return 8;
		case 4:
			return 8;
		case 5:
			return 0;
		}
	}
	static getTextureFormat(format) {
		switch(format) {
		case 0:
			return 0;
		case 2:
			return 3;
		case 4:
			return 4;
		case 5:
			return 5;
		case 6:
			return 7;
		default:
			return 1;
		}
	}
	static _fromTexture(texture) {
		return new kha_Image(texture);
	}
	static fromBytes(bytes,width,height,format,usage) {
		if(format == null) {
			format = 0;
		}
		let image = new kha_Image(null);
		image.format = format;
		image.texture_ = Krom.createTextureFromBytes(bytes.b.bufferValue,width,height,kha_Image.getTextureFormat(format),true);
		return image;
	}
	static fromBytes3D(bytes,width,height,depth,format,usage) {
		if(format == null) {
			format = 0;
		}
		let image = new kha_Image(null);
		image.format = format;
		image.texture_ = Krom.createTextureFromBytes3D(bytes.b.bufferValue,width,height,depth,kha_Image.getTextureFormat(format),true);
		return image;
	}
	static fromEncodedBytes(bytes,format,doneCallback,errorCallback,readable) {
		if(readable == null) {
			readable = false;
		}
		let image = new kha_Image(null);
		image.texture_ = Krom.createTextureFromEncodedBytes(bytes.b.bufferValue,format,readable);
		doneCallback(image);
	}
	static create(width,height,format,usage) {
		if(format == null) {
			format = 0;
		}
		let image = new kha_Image(null);
		image.format = format;
		image.texture_ = Krom.createTexture(width,height,kha_Image.getTextureFormat(format));
		return image;
	}
	static create3D(width,height,depth,format,usage) {
		if(format == null) {
			format = 0;
		}
		let image = new kha_Image(null);
		image.format = format;
		image.texture_ = Krom.createTexture3D(width,height,depth,kha_Image.getTextureFormat(format));
		return image;
	}
	static createRenderTarget(width,height,format,depthStencil,antiAliasingSamples,contextId) {
		if(contextId == null) {
			contextId = 0;
		}
		if(antiAliasingSamples == null) {
			antiAliasingSamples = 1;
		}
		if(depthStencil == null) {
			depthStencil = 0;
		}
		if(format == null) {
			format = 0;
		}
		let image = new kha_Image(null);
		image.format = format;
		image.renderTarget_ = Krom.createRenderTarget(width,height,kha_Image.getDepthBufferBits(depthStencil),kha_Image.getRenderTargetFormat(format),kha_Image.getStencilBufferBits(depthStencil),contextId);
		return image;
	}
	static get_nonPow2Supported() {
		return true;
	}
	static renderTargetsInvertedY() {
		return Krom.renderTargetsInvertedY();
	}
	static formatByteSize(format) {
		switch(format) {
		case 0:
			return 4;
		case 1:
			return 1;
		case 2:
			return 16;
		case 3:
			return 2;
		case 4:
			return 8;
		case 5:
			return 4;
		case 6:
			return 2;
		default:
			return 4;
		}
	}
}
$hxClasses["kha.Image"] = kha_Image;
kha_Image.__name__ = "kha.Image";
kha_Image.__interfaces__ = [kha_Canvas];
kha_Image.__properties__ = {get_nonPow2Supported: "get_nonPow2Supported"};
Object.assign(kha_Image.prototype, {
	__class__: kha_Image
	,__properties__: {get_g4: "get_g4",get_g2: "get_g2",get_depth: "get_depth",get_height: "get_height",get_width: "get_width"}
});
class kha_Scheduler {
	static init() {
		kha_Scheduler.deltas = [];
		let _g = 0;
		let _g1 = kha_Scheduler.DIF_COUNT;
		while(_g < _g1) kha_Scheduler.deltas[_g++] = 0;
		kha_Scheduler.stopped = true;
		kha_Scheduler.frame_tasks_sorted = true;
		kha_Scheduler.current = kha_Scheduler.lastTime = kha_Scheduler.lastFrameEnd = kha_Scheduler.realTime();
		kha_Scheduler.currentFrameTaskId = 0;
		kha_Scheduler.currentTimeTaskId = 0;
		kha_Scheduler.currentGroupId = 0;
		kha_Scheduler.timeTasks = [];
		kha_Scheduler.pausedTimeTasks = [];
		kha_Scheduler.outdatedTimeTasks = [];
		kha_Scheduler.timeTasksScratchpad = [];
		kha_Scheduler.frameTasks = [];
		kha_Scheduler.toDeleteFrame = [];
	}
	static start(restartTimers) {
		if(restartTimers == null) {
			restartTimers = false;
		}
		kha_Scheduler.vsync = kha_Window.get(0).get_vSynced();
		let hz = kha_Display.get_primary() != null ? kha_Display.get_primary().get_frequency() : 60;
		if(hz >= 57 && hz <= 63) {
			hz = 60;
		}
		kha_Scheduler.onedifhz = 1.0 / hz;
		kha_Scheduler.stopped = false;
		kha_Scheduler.resetTime();
		kha_Scheduler.lastTime = kha_Scheduler.realTime() - kha_Scheduler.startTime;
		let _g = 0;
		let _g1 = kha_Scheduler.DIF_COUNT;
		while(_g < _g1) kha_Scheduler.deltas[_g++] = 0;
		if(restartTimers) {
			let _g = 0;
			let _g1 = kha_Scheduler.timeTasks;
			while(_g < _g1.length) _g1[_g++].paused = false;
			let _g2 = 0;
			let _g3 = kha_Scheduler.frameTasks;
			while(_g2 < _g3.length) _g3[_g2++].paused = false;
		}
	}
	static executeFrame() {
		let real = kha_Scheduler.realTime();
		let now = real - kha_Scheduler.startTime;
		let delta = now - kha_Scheduler.lastTime;
		let frameEnd = kha_Scheduler.lastFrameEnd;
		if(delta >= 0) {
			if(delta > kha_Scheduler.maxframetime) {
				kha_Scheduler.startTime += delta - kha_Scheduler.maxframetime;
				now = real - kha_Scheduler.startTime;
				delta = kha_Scheduler.maxframetime;
				frameEnd += delta;
			} else if(kha_Scheduler.vsync) {
				let frames = Math.round(delta / kha_Scheduler.onedifhz);
				if(frames < 1) {
					return;
				}
				let realdif = frames * kha_Scheduler.onedifhz;
				delta = realdif;
				let _g = 0;
				let _g1 = kha_Scheduler.DIF_COUNT - 2;
				while(_g < _g1) {
					let i = _g++;
					delta += kha_Scheduler.deltas[i];
					kha_Scheduler.deltas[i] = kha_Scheduler.deltas[i + 1];
				}
				delta += kha_Scheduler.deltas[kha_Scheduler.DIF_COUNT - 2];
				delta /= kha_Scheduler.DIF_COUNT;
				kha_Scheduler.deltas[kha_Scheduler.DIF_COUNT - 2] = realdif;
				frameEnd += delta;
			} else {
				let _g = 0;
				let _g1 = kha_Scheduler.DIF_COUNT - 1;
				while(_g < _g1) {
					let i = _g++;
					kha_Scheduler.deltas[i] = kha_Scheduler.deltas[i + 1];
				}
				kha_Scheduler.deltas[kha_Scheduler.DIF_COUNT - 1] = delta;
				let next = 0;
				let _g2 = 0;
				let _g3 = kha_Scheduler.DIF_COUNT;
				while(_g2 < _g3) next += kha_Scheduler.deltas[_g2++];
				next /= kha_Scheduler.DIF_COUNT;
				frameEnd += next;
			}
			kha_Scheduler.lastTime = now;
			if(!kha_Scheduler.stopped) {
				kha_Scheduler.lastFrameEnd = frameEnd;
			}
			let _g = 0;
			let _g1 = kha_Scheduler.pausedTimeTasks;
			while(_g < _g1.length) _g1[_g++].next += delta;
			if(kha_Scheduler.stopped) {
				let _g = 0;
				let _g1 = kha_Scheduler.timeTasks;
				while(_g < _g1.length) _g1[_g++].next += delta;
			}
			kha_Scheduler.executeTimeTasks(frameEnd);
			let _g2 = 0;
			let _g3 = kha_Scheduler.outdatedTimeTasks;
			while(_g2 < _g3.length) {
				let task = _g3[_g2];
				++_g2;
				if(task.next < frameEnd - 10.0) {
					kha_Scheduler.timeTasksScratchpad.push(task);
				}
			}
			let _g4 = 0;
			let _g5 = kha_Scheduler.timeTasksScratchpad;
			while(_g4 < _g5.length) HxOverrides.remove(kha_Scheduler.outdatedTimeTasks,_g5[_g4++]);
			while(kha_Scheduler.timeTasksScratchpad.length > 0) HxOverrides.remove(kha_Scheduler.timeTasksScratchpad,kha_Scheduler.timeTasksScratchpad[0]);
		}
		kha_Scheduler.current = frameEnd;
		kha_Scheduler.sortFrameTasks();
		let _g = 0;
		let _g1 = kha_Scheduler.frameTasks;
		while(_g < _g1.length) {
			let frameTask = _g1[_g];
			++_g;
			if(!kha_Scheduler.stopped && !frameTask.paused && frameTask.active) {
				if(!frameTask.task()) {
					frameTask.active = false;
				}
			}
		}
		let _g2 = 0;
		let _g3 = kha_Scheduler.frameTasks;
		while(_g2 < _g3.length) {
			let frameTask = _g3[_g2];
			++_g2;
			if(!frameTask.active) {
				kha_Scheduler.toDeleteFrame.push(frameTask);
			}
		}
		while(kha_Scheduler.toDeleteFrame.length > 0) HxOverrides.remove(kha_Scheduler.frameTasks,kha_Scheduler.toDeleteFrame.pop());
	}
	static executeTimeTasks(until) {
		while(kha_Scheduler.timeTasks.length > 0) {
			kha_Scheduler.activeTimeTask = kha_Scheduler.timeTasks[0];
			if(kha_Scheduler.activeTimeTask.next <= until) {
				kha_Scheduler.current = kha_Scheduler.activeTimeTask.next;
				kha_Scheduler.activeTimeTask.next += kha_Scheduler.activeTimeTask.period;
				HxOverrides.remove(kha_Scheduler.timeTasks,kha_Scheduler.activeTimeTask);
				if(kha_Scheduler.activeTimeTask.active && kha_Scheduler.activeTimeTask.task()) {
					if(kha_Scheduler.activeTimeTask.period > 0 && (kha_Scheduler.activeTimeTask.duration == 0 || kha_Scheduler.activeTimeTask.duration >= kha_Scheduler.activeTimeTask.start + kha_Scheduler.activeTimeTask.next)) {
						kha_Scheduler.insertSorted(kha_Scheduler.timeTasks,kha_Scheduler.activeTimeTask);
					}
				} else {
					kha_Scheduler.activeTimeTask.active = false;
				}
			} else {
				break;
			}
		}
		kha_Scheduler.activeTimeTask = null;
	}
	static time() {
		return kha_Scheduler.current;
	}
	static realTime() {
		return kha_System.get_time();
	}
	static resetTime() {
		let now = kha_System.get_time();
		let dif = now - kha_Scheduler.startTime;
		kha_Scheduler.startTime = now;
		let _g = 0;
		let _g1 = kha_Scheduler.timeTasks;
		while(_g < _g1.length) {
			let timeTask = _g1[_g];
			++_g;
			timeTask.start -= dif;
			timeTask.next -= dif;
		}
		let _g2 = 0;
		let _g3 = kha_Scheduler.DIF_COUNT;
		while(_g2 < _g3) kha_Scheduler.deltas[_g2++] = 0;
		kha_Scheduler.current = 0;
		kha_Scheduler.lastTime = 0;
		kha_Scheduler.lastFrameEnd = 0;
	}
	static addBreakableTimeTaskToGroup(groupId,task,start,period,duration) {
		if(duration == null) {
			duration = 0;
		}
		if(period == null) {
			period = 0;
		}
		let t = new kha_TimeTask();
		t.active = true;
		t.task = task;
		t.id = ++kha_Scheduler.currentTimeTaskId;
		t.groupId = groupId;
		t.start = kha_Scheduler.current + start;
		t.period = 0;
		if(period != 0) {
			t.period = period;
		}
		t.duration = 0;
		if(duration != 0) {
			t.duration = t.start + duration;
		}
		t.next = t.start;
		kha_Scheduler.insertSorted(kha_Scheduler.timeTasks,t);
		return t.id;
	}
	static addTimeTaskToGroup(groupId,task,start,period,duration) {
		if(duration == null) {
			duration = 0;
		}
		if(period == null) {
			period = 0;
		}
		return kha_Scheduler.addBreakableTimeTaskToGroup(groupId,function() {
			task();
			return true;
		},start,period,duration);
	}
	static addTimeTask(task,start,period,duration) {
		if(duration == null) {
			duration = 0;
		}
		if(period == null) {
			period = 0;
		}
		return kha_Scheduler.addTimeTaskToGroup(0,task,start,period,duration);
	}
	static insertSorted(list,task) {
		let _g = 0;
		let _g1 = list.length;
		while(_g < _g1) {
			let i = _g++;
			if(list[i].next > task.next) {
				list.splice(i,0,task);
				return;
			}
		}
		list.push(task);
	}
	static sortFrameTasks() {
		if(kha_Scheduler.frame_tasks_sorted) {
			return;
		}
		kha_Scheduler.frameTasks.sort(function(a,b) {
			if(a.priority > b.priority) {
				return 1;
			} else if(a.priority < b.priority) {
				return -1;
			} else {
				return 0;
			}
		});
		kha_Scheduler.frame_tasks_sorted = true;
	}
}
$hxClasses["kha.Scheduler"] = kha_Scheduler;
kha_Scheduler.__name__ = "kha.Scheduler";
class js_Boot {
	static getClass(o) {
		if(o == null) {
			return null;
		} else if(((o) instanceof Array)) {
			return Array;
		} else {
			let cl = o.__class__;
			if(cl != null) {
				return cl;
			}
			let name = js_Boot.__nativeClassName(o);
			if(name != null) {
				return js_Boot.__resolveNativeClass(name);
			}
			return null;
		}
	}
	static __string_rec(o,s) {
		if(o == null) {
			return "null";
		}
		if(s.length >= 5) {
			return "<...>";
		}
		let t = typeof(o);
		if(t == "function" && (o.__name__ || o.__ename__)) {
			t = "object";
		}
		switch(t) {
		case "function":
			return "<function>";
		case "object":
			if(o.__enum__) {
				let e = $hxEnums[o.__enum__];
				let con = e.__constructs__[o._hx_index];
				let n = con._hx_name;
				if(con.__params__) {
					s = s + "\t";
					return n + "(" + ((function($this) {
						var $r;
						let _g = [];
						{
							let _g1 = 0;
							let _g2 = con.__params__;
							while(true) {
								if(!(_g1 < _g2.length)) {
									break;
								}
								let p = _g2[_g1];
								_g1 = _g1 + 1;
								_g.push(js_Boot.__string_rec(o[p],s));
							}
						}
						$r = _g;
						return $r;
					}(this))).join(",") + ")";
				} else {
					return n;
				}
			}
			if(((o) instanceof Array)) {
				let str = "[";
				s += "\t";
				let _g = 0;
				let _g1 = o.length;
				while(_g < _g1) {
					let i = _g++;
					str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
				}
				str += "]";
				return str;
			}
			let tostr;
			try {
				tostr = o.toString;
			} catch( _g ) {
				return "???";
			}
			if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
				let s2 = o.toString();
				if(s2 != "[object Object]") {
					return s2;
				}
			}
			let str = "{\n";
			s += "\t";
			let hasp = o.hasOwnProperty != null;
			let k = null;
			for( k in o ) {
			if(hasp && !o.hasOwnProperty(k)) {
				continue;
			}
			if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
				continue;
			}
			if(str.length != 2) {
				str += ", \n";
			}
			str += s + k + " : " + js_Boot.__string_rec(o[k],s);
			}
			s = s.substring(1);
			str += "\n" + s + "}";
			return str;
		case "string":
			return o;
		default:
			return String(o);
		}
	}
	static __interfLoop(cc,cl) {
		while(true) {
			if(cc == null) {
				return false;
			}
			if(cc == cl) {
				return true;
			}
			let intf = cc.__interfaces__;
			if(intf != null && (cc.__super__ == null || cc.__super__.__interfaces__ != intf)) {
				let _g = 0;
				let _g1 = intf.length;
				while(_g < _g1) {
					let i = intf[_g++];
					if(i == cl || js_Boot.__interfLoop(i,cl)) {
						return true;
					}
				}
			}
			cc = cc.__super__;
		}
	}
	static __instanceof(o,cl) {
		if(cl == null) {
			return false;
		}
		switch(cl) {
		case Array:
			return ((o) instanceof Array);
		case Bool:
			return typeof(o) == "boolean";
		case Dynamic:
			return o != null;
		case Float:
			return typeof(o) == "number";
		case Int:
			if(typeof(o) == "number") {
				return ((o | 0) === o);
			} else {
				return false;
			}
			break;
		case String:
			return typeof(o) == "string";
		default:
			if(o != null) {
				if(typeof(cl) == "function") {
					if(js_Boot.__downcastCheck(o,cl)) {
						return true;
					}
				} else if(typeof(cl) == "object" && js_Boot.__isNativeObj(cl)) {
					if(((o) instanceof cl)) {
						return true;
					}
				}
			} else {
				return false;
			}
			if(cl == Class ? o.__name__ != null : false) {
				return true;
			}
			if(cl == Enum ? o.__ename__ != null : false) {
				return true;
			}
			return o.__enum__ != null ? $hxEnums[o.__enum__] == cl : false;
		}
	}
	static __downcastCheck(o,cl) {
		if(!((o) instanceof cl)) {
			if(cl.__isInterface__) {
				return js_Boot.__interfLoop(js_Boot.getClass(o),cl);
			} else {
				return false;
			}
		} else {
			return true;
		}
	}
	static __cast(o,t) {
		if(o == null || js_Boot.__instanceof(o,t)) {
			return o;
		} else {
			throw haxe_Exception.thrown("Cannot cast " + Std.string(o) + " to " + Std.string(t));
		}
	}
	static __nativeClassName(o) {
		let name = js_Boot.__toStr.call(o).slice(8,-1);
		if(name == "Object" || name == "Function" || name == "Math" || name == "JSON") {
			return null;
		}
		return name;
	}
	static __isNativeObj(o) {
		return js_Boot.__nativeClassName(o) != null;
	}
	static __resolveNativeClass(name) {
		return $global[name];
	}
}
$hxClasses["js.Boot"] = js_Boot;
js_Boot.__name__ = "js.Boot";
class arm_CoreBridge {
	static colorFromFloats(r,g,b,a) {
		return kha_Color.fromFloats(r,g,b,a);
	}
}
$hxClasses["arm.CoreBridge"] = $hx_exports["core"] = arm_CoreBridge;
arm_CoreBridge.__name__ = "arm.CoreBridge";
class iron_App {
	constructor(done) {
		done();
		kha_System.notifyOnFrames(iron_App.render);
		kha_Scheduler.addTimeTask(iron_App.update,0,iron_system_Time.get_delta());
	}
	static init(done) {
		new iron_App(done);
	}
	static update() {
		if(iron_Scene.active == null || !iron_Scene.active.ready) {
			return;
		}
		if(iron_App.pauseUpdates) {
			return;
		}
		iron_Scene.active.updateFrame();
		let i = 0;
		let l = iron_App.traitUpdates.length;
		while(i < l) {
			if(iron_App.traitInits.length > 0) {
				let _g = 0;
				let _g1 = iron_App.traitInits;
				while(_g < _g1.length) {
					let f = _g1[_g++];
					if(iron_App.traitInits.length > 0) {
						f();
					} else {
						break;
					}
				}
				iron_App.traitInits.splice(0,iron_App.traitInits.length);
			}
			iron_App.traitUpdates[i]();
			if(l <= iron_App.traitUpdates.length) {
				++i;
			} else {
				l = iron_App.traitUpdates.length;
			}
		}
		i = 0;
		l = iron_App.traitLateUpdates.length;
		while(i < l) {
			iron_App.traitLateUpdates[i]();
			if(l <= iron_App.traitLateUpdates.length) {
				++i;
			} else {
				l = iron_App.traitLateUpdates.length;
			}
		}
		if(iron_App.onEndFrames != null) {
			let _g = 0;
			let _g1 = iron_App.onEndFrames;
			while(_g < _g1.length) _g1[_g++]();
		}
		if(iron_App.lastw == -1) {
			iron_App.lastw = arm_App.w();
			iron_App.lasth = arm_App.h();
		}
		if(iron_App.lastw != arm_App.w() || iron_App.lasth != arm_App.h()) {
			if(iron_App.onResize != null) {
				iron_App.onResize();
			} else if(iron_Scene.active != null && iron_Scene.active.camera != null) {
				iron_Scene.active.camera.buildProjection();
			}
		}
		iron_App.lastw = arm_App.w();
		iron_App.lasth = arm_App.h();
	}
	static render(frames) {
		let frame = frames[0];
		iron_App.framebuffer = frame;
		iron_system_Time.update();
		if(iron_Scene.active == null || !iron_Scene.active.ready) {
			iron_App.render2D(frame);
			return;
		}
		if(iron_App.traitInits.length > 0) {
			let _g = 0;
			let _g1 = iron_App.traitInits;
			while(_g < _g1.length) {
				let f = _g1[_g++];
				if(iron_App.traitInits.length > 0) {
					f();
				} else {
					break;
				}
			}
			iron_App.traitInits.splice(0,iron_App.traitInits.length);
		}
		iron_Scene.active.renderFrame(frame.get_g4());
		let _g = 0;
		let _g1 = iron_App.traitRenders;
		while(_g < _g1.length) {
			let f = _g1[_g++];
			if(iron_App.traitRenders.length > 0) {
				f(frame.get_g4());
			} else {
				break;
			}
		}
		iron_App.render2D(frame);
	}
	static render2D(frame) {
		if(iron_App.traitRenders2D.length > 0) {
			frame.get_g2().begin(false);
			let _g = 0;
			let _g1 = iron_App.traitRenders2D;
			while(_g < _g1.length) {
				let f = _g1[_g++];
				if(iron_App.traitRenders2D.length > 0) {
					f(frame.get_g2());
				} else {
					break;
				}
			}
			frame.get_g2().end();
		}
	}
	static notifyOnInit(f) {
		iron_App.traitInits.push(f);
	}
	static removeInit(f) {
		HxOverrides.remove(iron_App.traitInits,f);
	}
	static notifyOnUpdate(f) {
		iron_App.traitUpdates.push(f);
	}
	static removeUpdate(f) {
		HxOverrides.remove(iron_App.traitUpdates,f);
	}
	static removeLateUpdate(f) {
		HxOverrides.remove(iron_App.traitLateUpdates,f);
	}
	static notifyOnRender(f) {
		iron_App.traitRenders.push(f);
	}
	static removeRender(f) {
		HxOverrides.remove(iron_App.traitRenders,f);
	}
	static notifyOnRender2D(f) {
		iron_App.traitRenders2D.push(f);
	}
	static removeRender2D(f) {
		HxOverrides.remove(iron_App.traitRenders2D,f);
	}
	static notifyOnReset(f) {
		if(iron_App.onResets == null) {
			iron_App.onResets = [];
		}
		iron_App.onResets.push(f);
	}
	static notifyOnEndFrame(f) {
		if(iron_App.onEndFrames == null) {
			iron_App.onEndFrames = [];
		}
		iron_App.onEndFrames.push(f);
	}
}
$hxClasses["iron.App"] = iron_App;
iron_App.__name__ = "iron.App";
Object.assign(iron_App.prototype, {
	__class__: iron_App
});
class iron_system_ArmPack {
	static decode(b) {
		let i = new haxe_io_BytesInput(b);
		i.set_bigEndian(false);
		return iron_system_ArmPack.read(i);
	}
	static read(i,key,parentKey) {
		if(parentKey == null) {
			parentKey = "";
		}
		if(key == null) {
			key = "";
		}
		try {
			let b = i.readByte();
			switch(b) {
			case 192:
				return null;
			case 194:
				return false;
			case 195:
				return true;
			case 196:
				return i.read(i.readByte());
			case 197:
				return i.read(i.readUInt16());
			case 198:
				return i.read(i.readInt32());
			case 202:
				return i.readFloat();
			case 204:
				return i.readByte();
			case 205:
				return i.readUInt16();
			case 206:
				return i.readInt32();
			case 208:
				return i.readInt8();
			case 209:
				return i.readInt16();
			case 210:
				return i.readInt32();
			case 217:
				return i.readString(i.readByte());
			case 218:
				return i.readString(i.readUInt16());
			case 219:
				return i.readString(i.readInt32());
			case 220:
				return iron_system_ArmPack.readArray(i,i.readUInt16(),key,parentKey);
			case 221:
				return iron_system_ArmPack.readArray(i,i.readInt32(),key,parentKey);
			case 222:
				return iron_system_ArmPack.readMap(i,i.readUInt16(),key,parentKey);
			case 223:
				return iron_system_ArmPack.readMap(i,i.readInt32(),key,parentKey);
			default:
				if(b < 128) {
					return b;
				} else if(b < 144) {
					return iron_system_ArmPack.readMap(i,15 & b,key,parentKey);
				} else if(b < 160) {
					return iron_system_ArmPack.readArray(i,15 & b,key,parentKey);
				} else if(b < 192) {
					return i.readString(31 & b);
				} else if(b > 223) {
					return -256 | b;
				}
			}
		} catch( _g ) {
			if(!((haxe_Exception.caught(_g).unwrap()) instanceof haxe_io_Eof)) {
				throw _g;
			}
		}
		return null;
	}
	static readArray(i,length,key,parentKey) {
		if(parentKey == null) {
			parentKey = "";
		}
		if(key == null) {
			key = "";
		}
		let b = i.readByte();
		i.set_position(i.pos - 1);
		if(b == 202) {
			i.set_position(i.pos + 1);
			let a = new Float32Array(length);
			let _g = 0;
			while(_g < length) a[_g++] = i.readFloat();
			return a;
		} else if(b == 210) {
			i.set_position(i.pos + 1);
			let a = new Uint32Array(length);
			let _g = 0;
			while(_g < length) a[_g++] = i.readInt32();
			return a;
		} else if(b == 209) {
			i.set_position(i.pos + 1);
			let a = new Int16Array(length);
			let _g = 0;
			while(_g < length) a[_g++] = i.readInt16();
			return a;
		} else {
			let a = [];
			let _g = 0;
			while(_g < length) {
				++_g;
				a.push(iron_system_ArmPack.read(i,key,parentKey));
			}
			return a;
		}
	}
	static readMap(i,length,key,parentKey) {
		if(parentKey == null) {
			parentKey = "";
		}
		if(key == null) {
			key = "";
		}
		let out = { };
		let _g = 0;
		while(_g < length) {
			++_g;
			let k = Std.string(iron_system_ArmPack.read(i));
			out[k] = iron_system_ArmPack.read(i,k,key);
		}
		return out;
	}
	static encode(d) {
		let o = new haxe_io_BytesOutput();
		o.set_bigEndian(false);
		iron_system_ArmPack.write(o,d);
		return o.getBytes();
	}
	static write(o,d) {
		let _g = Type.typeof(d);
		switch(_g._hx_index) {
		case 0:
			o.writeByte(192);
			break;
		case 1:
			o.writeByte(210);
			o.writeInt32(d);
			break;
		case 2:
			o.writeByte(202);
			o.writeFloat(d);
			break;
		case 3:
			o.writeByte(d ? 195 : 194);
			break;
		case 4:
			let f = Reflect.fields(d);
			o.writeByte(223);
			o.writeInt32(f.length);
			let _g1 = 0;
			while(_g1 < f.length) {
				let k = f[_g1];
				++_g1;
				o.writeByte(219);
				let b = haxe_io_Bytes.ofString(k);
				o.writeInt32(b.length);
				o.writeFullBytes(b,0,b.length);
				iron_system_ArmPack.write(o,Reflect.field(d,k));
			}
			break;
		case 6:
			let c = _g.c;
			let _g2 = c.__name__;
			if(_g2 == null) {
				o.writeByte(221);
				o.writeInt32(d.length);
				let isInt = js_Boot.__instanceof(d[0],Int) && !((d) instanceof Float32Array);
				let isFloat = typeof(d[0]) == "number";
				if(((d) instanceof Int16Array)) {
					o.writeByte(209);
					let _g = 0;
					let _g1 = d.length;
					while(_g < _g1) o.writeInt16(d[_g++]);
				} else if(isFloat && !isInt) {
					o.writeByte(202);
					let _g = 0;
					let _g1 = d.length;
					while(_g < _g1) o.writeFloat(d[_g++]);
				} else if(isInt) {
					o.writeByte(210);
					let _g = 0;
					let _g1 = d.length;
					while(_g < _g1) o.writeInt32(d[_g++]);
				} else {
					let _g = 0;
					let _g1 = d.length;
					while(_g < _g1) iron_system_ArmPack.write(o,d[_g++]);
				}
			} else {
				switch(_g2) {
				case "Array":
					o.writeByte(221);
					o.writeInt32(d.length);
					let isInt = js_Boot.__instanceof(d[0],Int) && !((d) instanceof Float32Array);
					let isFloat = typeof(d[0]) == "number";
					if(((d) instanceof Int16Array)) {
						o.writeByte(209);
						let _g = 0;
						let _g1 = d.length;
						while(_g < _g1) o.writeInt16(d[_g++]);
					} else if(isFloat && !isInt) {
						o.writeByte(202);
						let _g = 0;
						let _g1 = d.length;
						while(_g < _g1) o.writeFloat(d[_g++]);
					} else if(isInt) {
						o.writeByte(210);
						let _g = 0;
						let _g1 = d.length;
						while(_g < _g1) o.writeInt32(d[_g++]);
					} else {
						let _g = 0;
						let _g1 = d.length;
						while(_g < _g1) iron_system_ArmPack.write(o,d[_g++]);
					}
					break;
				case "String":
					o.writeByte(219);
					let b = haxe_io_Bytes.ofString(d);
					o.writeInt32(b.length);
					o.writeFullBytes(b,0,b.length);
					break;
				case "haxe.io.Bytes":
					o.writeByte(198);
					o.writeInt32(d.length);
					o.writeFullBytes(d,0,d.length);
					break;
				default:
				}
			}
			break;
		default:
		}
	}
}
$hxClasses["iron.system.ArmPack"] = iron_system_ArmPack;
iron_system_ArmPack.__name__ = "iron.system.ArmPack";
class iron_data_Data {
	static getMesh(file,name,done) {
		let handle = file + name;
		let cached = iron_data_Data.cachedMeshes.h[handle];
		if(cached != null) {
			done(cached);
			return;
		}
		let loading = iron_data_Data.loadingMeshes.h[handle];
		if(loading != null) {
			loading.push(done);
			return;
		}
		iron_data_Data.loadingMeshes.h[handle] = [done];
		iron_data_MeshData.parse(file,name,function(b) {
			iron_data_Data.cachedMeshes.h[handle] = b;
			b.handle = handle;
			let _g = 0;
			let _g1 = iron_data_Data.loadingMeshes.h[handle];
			while(_g < _g1.length) _g1[_g++](b);
			let _this = iron_data_Data.loadingMeshes;
			if(Object.prototype.hasOwnProperty.call(_this.h,handle)) {
				delete(_this.h[handle]);
			}
		});
	}
	static deleteMesh(handle) {
		let mesh = iron_data_Data.cachedMeshes.h[handle];
		if(mesh == null) {
			return;
		}
		mesh.delete();
		let _this = iron_data_Data.cachedMeshes;
		if(Object.prototype.hasOwnProperty.call(_this.h,handle)) {
			delete(_this.h[handle]);
		}
	}
	static getLight(file,name,done) {
		let handle = file + name;
		let cached = iron_data_Data.cachedLights.h[handle];
		if(cached != null) {
			done(cached);
			return;
		}
		let loading = iron_data_Data.loadingLights.h[handle];
		if(loading != null) {
			loading.push(done);
			return;
		}
		iron_data_Data.loadingLights.h[handle] = [done];
		iron_data_LightData.parse(file,name,function(b) {
			iron_data_Data.cachedLights.h[handle] = b;
			let _g = 0;
			let _g1 = iron_data_Data.loadingLights.h[handle];
			while(_g < _g1.length) _g1[_g++](b);
			let _this = iron_data_Data.loadingLights;
			if(Object.prototype.hasOwnProperty.call(_this.h,handle)) {
				delete(_this.h[handle]);
			}
		});
	}
	static getCamera(file,name,done) {
		let handle = file + name;
		let cached = iron_data_Data.cachedCameras.h[handle];
		if(cached != null) {
			done(cached);
			return;
		}
		let loading = iron_data_Data.loadingCameras.h[handle];
		if(loading != null) {
			loading.push(done);
			return;
		}
		iron_data_Data.loadingCameras.h[handle] = [done];
		iron_data_CameraData.parse(file,name,function(b) {
			iron_data_Data.cachedCameras.h[handle] = b;
			let _g = 0;
			let _g1 = iron_data_Data.loadingCameras.h[handle];
			while(_g < _g1.length) _g1[_g++](b);
			let _this = iron_data_Data.loadingCameras;
			if(Object.prototype.hasOwnProperty.call(_this.h,handle)) {
				delete(_this.h[handle]);
			}
		});
	}
	static getMaterial(file,name,done) {
		let handle = file + name;
		let cached = iron_data_Data.cachedMaterials.h[handle];
		if(cached != null) {
			done(cached);
			return;
		}
		let loading = iron_data_Data.loadingMaterials.h[handle];
		if(loading != null) {
			loading.push(done);
			return;
		}
		iron_data_Data.loadingMaterials.h[handle] = [done];
		iron_data_MaterialData.parse(file,name,function(b) {
			iron_data_Data.cachedMaterials.h[handle] = b;
			let _g = 0;
			let _g1 = iron_data_Data.loadingMaterials.h[handle];
			while(_g < _g1.length) _g1[_g++](b);
			let _this = iron_data_Data.loadingMaterials;
			if(Object.prototype.hasOwnProperty.call(_this.h,handle)) {
				delete(_this.h[handle]);
			}
		});
	}
	static getParticle(file,name,done) {
		let handle = file + name;
		let cached = iron_data_Data.cachedParticles.h[handle];
		if(cached != null) {
			done(cached);
			return;
		}
		let loading = iron_data_Data.loadingParticles.h[handle];
		if(loading != null) {
			loading.push(done);
			return;
		}
		iron_data_Data.loadingParticles.h[handle] = [done];
		iron_data_ParticleData.parse(file,name,function(b) {
			iron_data_Data.cachedParticles.h[handle] = b;
			let _g = 0;
			let _g1 = iron_data_Data.loadingParticles.h[handle];
			while(_g < _g1.length) _g1[_g++](b);
			let _this = iron_data_Data.loadingParticles;
			if(Object.prototype.hasOwnProperty.call(_this.h,handle)) {
				delete(_this.h[handle]);
			}
		});
	}
	static getWorld(file,name,done) {
		if(name == null) {
			done(null);
			return;
		}
		let handle = file + name;
		let cached = iron_data_Data.cachedWorlds.h[handle];
		if(cached != null) {
			done(cached);
			return;
		}
		let loading = iron_data_Data.loadingWorlds.h[handle];
		if(loading != null) {
			loading.push(done);
			return;
		}
		iron_data_Data.loadingWorlds.h[handle] = [done];
		iron_data_WorldData.parse(file,name,function(b) {
			iron_data_Data.cachedWorlds.h[handle] = b;
			let _g = 0;
			let _g1 = iron_data_Data.loadingWorlds.h[handle];
			while(_g < _g1.length) _g1[_g++](b);
			let _this = iron_data_Data.loadingWorlds;
			if(Object.prototype.hasOwnProperty.call(_this.h,handle)) {
				delete(_this.h[handle]);
			}
		});
	}
	static getShader(file,name,done,overrideContext) {
		let cacheName = name;
		if(overrideContext != null) {
			cacheName += "2";
		}
		let cached = iron_data_Data.cachedShaders.h[cacheName];
		if(cached != null) {
			done(cached);
			return;
		}
		let loading = iron_data_Data.loadingShaders.h[cacheName];
		if(loading != null) {
			loading.push(done);
			return;
		}
		iron_data_Data.loadingShaders.h[cacheName] = [done];
		iron_data_ShaderData.parse(file,name,function(b) {
			iron_data_Data.cachedShaders.h[cacheName] = b;
			let _g = 0;
			let _g1 = iron_data_Data.loadingShaders.h[cacheName];
			while(_g < _g1.length) _g1[_g++](b);
			let _this = iron_data_Data.loadingShaders;
			if(Object.prototype.hasOwnProperty.call(_this.h,cacheName)) {
				delete(_this.h[cacheName]);
			}
		},overrideContext);
	}
	static getSceneRaw(file,done) {
		let cached = iron_data_Data.cachedSceneRaws.h[file];
		if(cached != null) {
			done(cached);
			return;
		}
		let loading = iron_data_Data.loadingSceneRaws.h[file];
		if(loading != null) {
			loading.push(done);
			return;
		}
		iron_data_Data.loadingSceneRaws.h[file] = [done];
		let compressed = file.endsWith(".lz4");
		let isJson = file.endsWith(".json");
		let ext = compressed || isJson || file.endsWith(".arm") ? "" : ".arm";
		iron_data_Data.getBlob(file + ext,function(b) {
			let parsed = null;
			if(isJson) {
				let s = b.toString();
				if(s.charAt(0) == "{") {
					parsed = JSON.parse(s);
				} else {
					let i = new haxe_io_BytesInput(b.toBytes());
					i.set_bigEndian(false);
					parsed = iron_system_ArmPack.read(i);
				}
			} else {
				let i = new haxe_io_BytesInput(b.toBytes());
				i.set_bigEndian(false);
				parsed = iron_system_ArmPack.read(i);
			}
			iron_data_Data.returnSceneRaw(file,parsed);
		});
	}
	static returnSceneRaw(file,parsed) {
		iron_data_Data.cachedSceneRaws.h[file] = parsed;
		let _g = 0;
		let _g1 = iron_data_Data.loadingSceneRaws.h[file];
		while(_g < _g1.length) _g1[_g++](parsed);
		let _this = iron_data_Data.loadingSceneRaws;
		if(Object.prototype.hasOwnProperty.call(_this.h,file)) {
			delete(_this.h[file]);
		}
	}
	static getMeshRawByName(datas,name) {
		if(name == "") {
			return datas[0];
		}
		let _g = 0;
		while(_g < datas.length) {
			let dat = datas[_g];
			++_g;
			if(dat.name == name) {
				return dat;
			}
		}
		return null;
	}
	static getLightRawByName(datas,name) {
		if(name == "") {
			return datas[0];
		}
		let _g = 0;
		while(_g < datas.length) {
			let dat = datas[_g];
			++_g;
			if(dat.name == name) {
				return dat;
			}
		}
		return null;
	}
	static getCameraRawByName(datas,name) {
		if(name == "") {
			return datas[0];
		}
		let _g = 0;
		while(_g < datas.length) {
			let dat = datas[_g];
			++_g;
			if(dat.name == name) {
				return dat;
			}
		}
		return null;
	}
	static getMaterialRawByName(datas,name) {
		if(name == "") {
			return datas[0];
		}
		let _g = 0;
		while(_g < datas.length) {
			let dat = datas[_g];
			++_g;
			if(dat.name == name) {
				return dat;
			}
		}
		return null;
	}
	static getParticleRawByName(datas,name) {
		if(name == "") {
			return datas[0];
		}
		let _g = 0;
		while(_g < datas.length) {
			let dat = datas[_g];
			++_g;
			if(dat.name == name) {
				return dat;
			}
		}
		return null;
	}
	static getWorldRawByName(datas,name) {
		if(name == "") {
			return datas[0];
		}
		let _g = 0;
		while(_g < datas.length) {
			let dat = datas[_g];
			++_g;
			if(dat.name == name) {
				return dat;
			}
		}
		return null;
	}
	static getShaderRawByName(datas,name) {
		if(name == "") {
			return datas[0];
		}
		let _g = 0;
		while(_g < datas.length) {
			let dat = datas[_g];
			++_g;
			if(dat.name == name) {
				return dat;
			}
		}
		return null;
	}
	static getBlob(file,done) {
		let cached = iron_data_Data.cachedBlobs.h[file];
		if(cached != null) {
			done(cached);
			return;
		}
		let loading = iron_data_Data.loadingBlobs.h[file];
		if(loading != null) {
			loading.push(done);
			return;
		}
		iron_data_Data.loadingBlobs.h[file] = [done];
		kha_Assets.loadBlobFromPath(iron_data_Data.isAbsolute(file) || file.charAt(0) == "." && file.charAt(1) == "." ? file : iron_data_Data.dataPath + file,function(b) {
			iron_data_Data.cachedBlobs.h[file] = b;
			let _g = 0;
			let _g1 = iron_data_Data.loadingBlobs.h[file];
			while(_g < _g1.length) _g1[_g++](b);
			let _this = iron_data_Data.loadingBlobs;
			if(Object.prototype.hasOwnProperty.call(_this.h,file)) {
				delete(_this.h[file]);
			}
			iron_data_Data.assetsLoaded++;
		});
	}
	static deleteBlob(handle) {
		let blob = iron_data_Data.cachedBlobs.h[handle];
		if(blob == null) {
			return;
		}
		blob.unload();
		let _this = iron_data_Data.cachedBlobs;
		if(Object.prototype.hasOwnProperty.call(_this.h,handle)) {
			delete(_this.h[handle]);
		}
	}
	static getImage(file,done,readable,format) {
		if(format == null) {
			format = "RGBA32";
		}
		if(readable == null) {
			readable = false;
		}
		let cached = iron_data_Data.cachedImages.h[file];
		if(cached != null) {
			done(cached);
			return;
		}
		let loading = iron_data_Data.loadingImages.h[file];
		if(loading != null) {
			loading.push(done);
			return;
		}
		iron_data_Data.loadingImages.h[file] = [done];
		kha_Assets.loadImageFromPath(iron_data_Data.isAbsolute(file) || file.charAt(0) == "." && file.charAt(1) == "." ? file : iron_data_Data.dataPath + file,readable,function(b) {
			iron_data_Data.cachedImages.h[file] = b;
			let _g = 0;
			let _g1 = iron_data_Data.loadingImages.h[file];
			while(_g < _g1.length) _g1[_g++](b);
			let _this = iron_data_Data.loadingImages;
			if(Object.prototype.hasOwnProperty.call(_this.h,file)) {
				delete(_this.h[file]);
			}
			iron_data_Data.assetsLoaded++;
		});
	}
	static deleteImage(handle) {
		let image = iron_data_Data.cachedImages.h[handle];
		if(image == null) {
			return;
		}
		image.unload();
		let _this = iron_data_Data.cachedImages;
		if(Object.prototype.hasOwnProperty.call(_this.h,handle)) {
			delete(_this.h[handle]);
		}
	}
	static getFont(file,done) {
		let cached = iron_data_Data.cachedFonts.h[file];
		if(cached != null) {
			done(cached);
			return;
		}
		let loading = iron_data_Data.loadingFonts.h[file];
		if(loading != null) {
			loading.push(done);
			return;
		}
		iron_data_Data.loadingFonts.h[file] = [done];
		kha_Assets.loadFontFromPath(iron_data_Data.isAbsolute(file) || file.charAt(0) == "." && file.charAt(1) == "." ? file : iron_data_Data.dataPath + file,function(b) {
			iron_data_Data.cachedFonts.h[file] = b;
			let _g = 0;
			let _g1 = iron_data_Data.loadingFonts.h[file];
			while(_g < _g1.length) _g1[_g++](b);
			let _this = iron_data_Data.loadingFonts;
			if(Object.prototype.hasOwnProperty.call(_this.h,file)) {
				delete(_this.h[file]);
			}
			iron_data_Data.assetsLoaded++;
		});
	}
	static deleteFont(handle) {
		let font = iron_data_Data.cachedFonts.h[handle];
		if(font == null) {
			return;
		}
		font.unload();
		let _this = iron_data_Data.cachedFonts;
		if(Object.prototype.hasOwnProperty.call(_this.h,handle)) {
			delete(_this.h[handle]);
		}
	}
	static isAbsolute(file) {
		if(!(file.charAt(0) == "/" || file.charAt(1) == ":")) {
			if(file.charAt(0) == "\\") {
				return file.charAt(1) == "\\";
			} else {
				return false;
			}
		} else {
			return true;
		}
	}
}
$hxClasses["iron.data.Data"] = iron_data_Data;
iron_data_Data.__name__ = "iron.data.Data";
class iron_system_Input {
	static reset() {
		iron_system_Input.occupied = false;
		if(iron_system_Input.mouse != null) {
			iron_system_Input.mouse.reset();
		}
		if(iron_system_Input.pen != null) {
			iron_system_Input.pen.reset();
		}
		if(iron_system_Input.keyboard != null) {
			iron_system_Input.keyboard.reset();
		}
		let _g = 0;
		let _g1 = iron_system_Input.gamepads;
		while(_g < _g1.length) _g1[_g++].reset();
	}
	static endFrame() {
		if(iron_system_Input.mouse != null) {
			iron_system_Input.mouse.endFrame();
		}
		if(iron_system_Input.pen != null) {
			iron_system_Input.pen.endFrame();
		}
		if(iron_system_Input.keyboard != null) {
			iron_system_Input.keyboard.endFrame();
		}
		let _g = 0;
		let _g1 = iron_system_Input.gamepads;
		while(_g < _g1.length) _g1[_g++].endFrame();
		if(iron_system_Input.virtualButtons != null) {
			let h = iron_system_Input.virtualButtons.h;
			let vb_keys = Object.keys(h);
			let vb_length = vb_keys.length;
			let vb_current = 0;
			while(vb_current < vb_length) {
				let vb = h[vb_keys[vb_current++]];
				vb.started = vb.released = false;
			}
		}
	}
	static getMouse() {
		if(!iron_system_Input.registered) {
			iron_system_Input.registered = true;
			iron_App.notifyOnEndFrame(iron_system_Input.endFrame);
			iron_App.notifyOnReset(iron_system_Input.reset);
			kha_System.notifyOnApplicationState(function() {
				iron_system_Input.getMouse().reset();
			},null,null,null,null);
		}
		if(iron_system_Input.mouse == null) {
			iron_system_Input.mouse = new iron_system_Mouse();
		}
		return iron_system_Input.mouse;
	}
	static getPen() {
		if(!iron_system_Input.registered) {
			iron_system_Input.registered = true;
			iron_App.notifyOnEndFrame(iron_system_Input.endFrame);
			iron_App.notifyOnReset(iron_system_Input.reset);
			kha_System.notifyOnApplicationState(function() {
				iron_system_Input.getMouse().reset();
			},null,null,null,null);
		}
		if(iron_system_Input.pen == null) {
			iron_system_Input.pen = new iron_system_Pen();
		}
		return iron_system_Input.pen;
	}
	static getKeyboard() {
		if(!iron_system_Input.registered) {
			iron_system_Input.registered = true;
			iron_App.notifyOnEndFrame(iron_system_Input.endFrame);
			iron_App.notifyOnReset(iron_system_Input.reset);
			kha_System.notifyOnApplicationState(function() {
				iron_system_Input.getMouse().reset();
			},null,null,null,null);
		}
		if(iron_system_Input.keyboard == null) {
			iron_system_Input.keyboard = new iron_system_Keyboard();
		}
		return iron_system_Input.keyboard;
	}
}
$hxClasses["iron.system.Input"] = iron_system_Input;
iron_system_Input.__name__ = "iron.system.Input";
class iron_object_Object {
	constructor() {
		if(iron_object_Object._hx_skip_constructor) {
			return;
		}
		this._hx_constructor();
	}
	_hx_constructor() {
		this.isEmpty = false;
		this.properties = null;
		this.culledShadow = false;
		this.culledMesh = false;
		this.culled = false;
		this.visibleShadow = true;
		this.visibleMesh = true;
		this.visible = true;
		this.animation = null;
		this.lods = null;
		this.children = [];
		this.parent = null;
		this.traits = [];
		this.constraints = null;
		this.name = "";
		this.raw = null;
		this.uid = iron_object_Object.uidCounter++;
		this.urandom = iron_object_Object.seededRandom();
		this.transform = new iron_object_Transform(this);
		this.isEmpty = js_Boot.getClass(this) == iron_object_Object;
		if(this.isEmpty && iron_Scene.active != null) {
			iron_Scene.active.empties.push(this);
		}
	}
	setParent(parentObject,parentInverse,keepTransform) {
		if(keepTransform == null) {
			keepTransform = false;
		}
		if(parentInverse == null) {
			parentInverse = false;
		}
		if(parentObject == this || parentObject == this.parent) {
			return;
		}
		if(this.parent != null) {
			HxOverrides.remove(this.parent.children,this);
			if(keepTransform) {
				this.transform.applyParent();
			}
			this.parent = null;
			this.transform.buildMatrix();
		}
		if(parentObject == null) {
			parentObject = iron_Scene.active.sceneParent;
		}
		this.parent = parentObject;
		this.parent.children.push(this);
		if(parentInverse) {
			this.transform.applyParentInverse();
		}
	}
	remove() {
		if(this.isEmpty && iron_Scene.active != null) {
			HxOverrides.remove(iron_Scene.active.empties,this);
		}
		if(this.animation != null) {
			this.animation.remove();
		}
		while(this.children.length > 0) this.children[0].remove();
		while(this.traits.length > 0) this.traits[0].remove();
		if(this.parent != null) {
			HxOverrides.remove(this.parent.children,this);
			this.parent = null;
		}
	}
	getChild(name) {
		if(this.name == name) {
			return this;
		} else {
			let _g = 0;
			let _g1 = this.children;
			while(_g < _g1.length) {
				let r = _g1[_g++].getChild(name);
				if(r != null) {
					return r;
				}
			}
		}
		return null;
	}
	getChildren(recursive) {
		if(recursive == null) {
			recursive = false;
		}
		if(!recursive) {
			return this.children;
		}
		let retChildren = this.children.slice();
		let _g = 0;
		let _g1 = this.children;
		while(_g < _g1.length) retChildren = retChildren.concat(_g1[_g++].getChildren(recursive));
		return retChildren;
	}
	addTrait(t) {
		this.traits.push(t);
		t.object = this;
		if(t._add != null) {
			let _g = 0;
			let _g1 = t._add;
			while(_g < _g1.length) _g1[_g++]();
			t._add = null;
		}
	}
	removeTrait(t) {
		if(t._init != null) {
			let _g = 0;
			let _g1 = t._init;
			while(_g < _g1.length) iron_App.removeInit(_g1[_g++]);
			t._init = null;
		}
		if(t._update != null) {
			let _g = 0;
			let _g1 = t._update;
			while(_g < _g1.length) iron_App.removeUpdate(_g1[_g++]);
			t._update = null;
		}
		if(t._lateUpdate != null) {
			let _g = 0;
			let _g1 = t._lateUpdate;
			while(_g < _g1.length) iron_App.removeLateUpdate(_g1[_g++]);
			t._lateUpdate = null;
		}
		if(t._render != null) {
			let _g = 0;
			let _g1 = t._render;
			while(_g < _g1.length) iron_App.removeRender(_g1[_g++]);
			t._render = null;
		}
		if(t._render2D != null) {
			let _g = 0;
			let _g1 = t._render2D;
			while(_g < _g1.length) iron_App.removeRender2D(_g1[_g++]);
			t._render2D = null;
		}
		if(t._remove != null) {
			let _g = 0;
			let _g1 = t._remove;
			while(_g < _g1.length) _g1[_g++]();
			t._remove = null;
		}
		HxOverrides.remove(this.traits,t);
	}
	getTrait(c) {
		let _g = 0;
		let _g1 = this.traits;
		while(_g < _g1.length) {
			let t = _g1[_g];
			++_g;
			if(js_Boot.getClass(t) == c) {
				return t;
			}
		}
		return null;
	}
	setupAnimation(oactions) {
		if(oactions == null) {
			return;
		}
		this.animation = new iron_object_ObjectAnimation(this,oactions);
	}
	static seededRandom() {
		iron_object_Object.seed = (iron_object_Object.seed * 9301 + 49297) % 233280;
		return iron_object_Object.seed / 233280.0;
	}
}
$hxClasses["iron.object.Object"] = iron_object_Object;
iron_object_Object.__name__ = "iron.object.Object";
Object.assign(iron_object_Object.prototype, {
	__class__: iron_object_Object
});
class iron_RenderPath {
	constructor() {
		this.onVoxelize = null;
		this.voxelized = 0;
		this.depthBuffers = [];
		this.cachedShaderContexts = new haxe_ds_StringMap();
		this.loading = 0;
		this.lastFrameTime = 0.0;
		this.viewportScaled = false;
		this.scissorSet = false;
		this.lastH = 0;
		this.lastW = 0;
		this.depthToRenderTarget = new haxe_ds_StringMap();
		this.renderTargets = new haxe_ds_StringMap();
		this.commands = null;
		this.paused = false;
		this.drawOrder = 0;
		this.currentG = null;
		this.isProbe = false;
		this.isProbeCube = false;
		this.isProbePlanar = false;
		this.point = null;
		this.sun = null;
		this.light = null;
		this.currentTarget = null;
		this.frame = 0;
		this.frameTime = 0.0;
		this.frameScissorH = 0;
		this.frameScissorW = 0;
		this.frameScissorY = 0;
		this.frameScissorX = 0;
		this.frameScissor = false;
	}
	get_ready() {
		return this.loading == 0;
	}
	voxelize() {
		if(this.onVoxelize != null) {
			return this.onVoxelize();
		}
		return true;
	}
	renderFrame(g) {
		if(!this.get_ready() || this.paused || arm_App.w() == 0 || arm_App.h() == 0) {
			return;
		}
		if(this.lastW > 0 && (this.lastW != arm_App.w() || this.lastH != arm_App.h())) {
			this.resize();
		}
		this.lastW = arm_App.w();
		this.lastH = arm_App.h();
		this.frameTime = kha_Scheduler.time() - this.lastFrameTime;
		this.lastFrameTime = kha_Scheduler.time();
		let cam = iron_Scene.active.camera;
		this.isProbePlanar = cam != null && cam.renderTarget != null;
		this.isProbeCube = cam != null && cam.renderTargetCube != null;
		this.isProbe = this.isProbePlanar || this.isProbeCube;
		if(this.isProbePlanar) {
			this.frameG = cam.renderTarget.get_g4();
		} else if(this.isProbeCube) {
			this.frameG = cam.renderTargetCube.get_g4();
		} else {
			this.frameG = g;
		}
		this.currentW = arm_App.w();
		this.currentH = arm_App.h();
		this.currentD = 1;
		this.currentFace = -1;
		this.meshesSorted = false;
		let _g = 0;
		let _g1 = iron_Scene.active.lights;
		while(_g < _g1.length) {
			let l = _g1[_g];
			++_g;
			if(l.visible) {
				l.buildMatrix(iron_Scene.active.camera);
			}
			if(l.data.raw.type == "sun") {
				this.sun = l;
			} else {
				this.point = l;
			}
		}
		this.light = iron_Scene.active.lights[0];
		this.commands();
		if(!this.isProbe) {
			this.frame++;
		}
	}
	setTarget(target,additional,viewportScale) {
		if(viewportScale == null) {
			viewportScale = 1.0;
		}
		if(target == "") {
			this.currentD = 1;
			this.currentTarget = null;
			this.currentFace = -1;
			if(this.isProbeCube) {
				this.currentW = iron_Scene.active.camera.renderTargetCube.get_width();
				this.currentH = iron_Scene.active.camera.renderTargetCube.get_height();
				let g = this.frameG;
				let additionalRenderTargets = null;
				let face = iron_Scene.active.camera.currentFace;
				if(face == null) {
					face = -1;
				}
				if(this.currentG != null) {
					if(this.scissorSet) {
						this.currentG.disableScissor();
						this.scissorSet = false;
					}
					this.currentG.end();
					this.currentG = null;
					this.bindParams = null;
				}
				this.currentG = g;
				this.additionalTargets = additionalRenderTargets;
				if(face >= 0) {
					g.beginFace(face);
				} else {
					g.begin(additionalRenderTargets);
				}
			} else {
				this.currentW = arm_App.w();
				this.currentH = arm_App.h();
				if(this.frameScissor) {
					this.setFrameScissor();
				}
				let g = this.frameG;
				let additionalRenderTargets = null;
				if(this.currentG != null) {
					if(this.scissorSet) {
						this.currentG.disableScissor();
						this.scissorSet = false;
					}
					this.currentG.end();
					this.currentG = null;
					this.bindParams = null;
				}
				this.currentG = g;
				this.additionalTargets = additionalRenderTargets;
				g.begin(additionalRenderTargets);
				if(!this.isProbe) {
					this.setCurrentViewport(arm_App.w(),arm_App.h());
					this.setCurrentScissor(arm_App.w(),arm_App.h());
				}
			}
		} else {
			let rt = this.renderTargets.h[target];
			this.currentTarget = rt;
			let additionalImages = null;
			if(additional != null) {
				additionalImages = [];
				let _g = 0;
				while(_g < additional.length) additionalImages.push(this.renderTargets.h[additional[_g++]].image);
			}
			let targetG = rt.isCubeMap ? rt.cubeMap.get_g4() : rt.image.get_g4();
			this.currentW = rt.isCubeMap ? rt.cubeMap.get_width() : rt.image.get_width();
			this.currentH = rt.isCubeMap ? rt.cubeMap.get_height() : rt.image.get_height();
			if(rt.is3D) {
				this.currentD = rt.image.get_depth();
			}
			let face = this.currentFace;
			if(face == null) {
				face = -1;
			}
			if(this.currentG != null) {
				if(this.scissorSet) {
					this.currentG.disableScissor();
					this.scissorSet = false;
				}
				this.currentG.end();
				this.currentG = null;
				this.bindParams = null;
			}
			this.currentG = targetG;
			this.additionalTargets = additionalImages;
			if(face >= 0) {
				targetG.beginFace(face);
			} else {
				targetG.begin(additionalImages);
			}
		}
		if(viewportScale != 1.0) {
			this.viewportScaled = true;
			let viewW = this.currentW * viewportScale | 0;
			let viewH = this.currentH * viewportScale | 0;
			this.currentG.viewport(0,viewH,viewW,viewH);
			this.currentG.scissor(0,viewH,viewW,viewH);
		} else if(this.viewportScaled) {
			this.viewportScaled = false;
			this.setCurrentViewport(this.currentW,this.currentH);
			this.setCurrentScissor(this.currentW,this.currentH);
		}
		this.bindParams = null;
	}
	setDepthFrom(target,from) {
		this.renderTargets.h[target].image.setDepthStencilFrom(this.renderTargets.h[from].image);
	}
	setCurrentViewport(viewW,viewH) {
		this.currentG.viewport(arm_App.x(),this.currentH - (viewH - arm_App.y()),viewW,viewH);
	}
	setCurrentScissor(viewW,viewH) {
		this.currentG.scissor(arm_App.x(),this.currentH - (viewH - arm_App.y()),viewW,viewH);
		this.scissorSet = true;
	}
	setFrameScissor() {
		this.frameG.scissor(this.frameScissorX,this.currentH - (this.frameScissorH - this.frameScissorY),this.frameScissorW,this.frameScissorH);
	}
	setViewport(viewW,viewH) {
		this.setCurrentViewport(viewW,viewH);
		this.setCurrentScissor(viewW,viewH);
	}
	clearTarget(colorFlag,depthFlag) {
		if(colorFlag == -1) {
			if(iron_Scene.active.world != null) {
				colorFlag = iron_Scene.active.world.raw.background_color;
			} else if(iron_Scene.active.camera != null) {
				let cc = iron_Scene.active.camera.data.raw.clear_color;
				if(cc != null) {
					colorFlag = kha_Color.fromFloats(cc[0],cc[1],cc[2]);
				}
			}
		}
		this.currentG.clear(colorFlag,depthFlag,null);
	}
	clearImage(target,color) {
		let rt = this.renderTargets.h[target];
		rt.image.clear(0,0,0,rt.image.get_width(),rt.image.get_height(),rt.image.get_depth(),color);
	}
	generateMipmaps(target) {
		this.renderTargets.h[target].image.generateMipmaps(1000);
	}
	drawMeshes(context) {
		if(context == "shadowmap") {
			if(this.light == null || !this.light.data.raw.cast_shadow || !this.light.visible || this.light.data.raw.strength == 0) {
				return;
			}
		}
		if(this.currentFace >= 0 && this.light != null) {
			this.light.setCubeFace(this.currentFace,iron_Scene.active.camera);
		}
		this.submitDraw(context);
		if(this.scissorSet) {
			this.currentG.disableScissor();
			this.scissorSet = false;
		}
		this.currentG.end();
		this.currentG = null;
		this.bindParams = null;
	}
	submitDraw(context) {
		let camera = iron_Scene.active.camera;
		let meshes = iron_Scene.active.meshes;
		iron_object_MeshObject.lastPipeline = null;
		if(!this.meshesSorted && camera != null) {
			let camX = camera.transform.world.self._30;
			let camY = camera.transform.world.self._31;
			let camZ = camera.transform.world.self._32;
			let _g = 0;
			while(_g < meshes.length) {
				let mesh = meshes[_g];
				++_g;
				let vx = camX - mesh.transform.world.self._30;
				let vy = camY - mesh.transform.world.self._31;
				let vz = camZ - mesh.transform.world.self._32;
				mesh.cameraDistance = Math.sqrt(vx * vx + vy * vy + vz * vz);
			}
			if(this.drawOrder == 1) {
				iron_RenderPath.sortMeshesShader(meshes);
			} else {
				iron_RenderPath.sortMeshesDistance(meshes);
			}
			this.meshesSorted = true;
		}
		let _g = 0;
		while(_g < meshes.length) meshes[_g++].render(this.currentG,context,this.bindParams);
	}
	drawSkydome(handle) {
		if(iron_data_ConstData.skydomeVB == null) {
			iron_data_ConstData.createSkydomeData();
		}
		let cc = this.cachedShaderContexts.h[handle];
		if(cc.context == null) {
			return;
		}
		this.currentG.setPipeline(cc.context.pipeState);
		iron_object_Uniforms.setContextConstants(this.currentG,cc.context,this.bindParams);
		iron_object_Uniforms.setObjectConstants(this.currentG,cc.context,null);
		this.currentG.setVertexBuffer(iron_data_ConstData.skydomeVB);
		this.currentG.setIndexBuffer(iron_data_ConstData.skydomeIB);
		this.currentG.drawIndexedVertices();
		if(this.scissorSet) {
			this.currentG.disableScissor();
			this.scissorSet = false;
		}
		this.currentG.end();
		this.currentG = null;
		this.bindParams = null;
	}
	bindTarget(target,uniform) {
		if(this.bindParams != null) {
			this.bindParams.push(target);
			this.bindParams.push(uniform);
		} else {
			this.bindParams = [target,uniform];
		}
	}
	drawShader(handle) {
		let cc = this.cachedShaderContexts.h[handle];
		if(iron_data_ConstData.screenAlignedVB == null) {
			iron_data_ConstData.createScreenAlignedData();
		}
		this.currentG.setPipeline(cc.context.pipeState);
		iron_object_Uniforms.setContextConstants(this.currentG,cc.context,this.bindParams);
		iron_object_Uniforms.setObjectConstants(this.currentG,cc.context,null);
		this.currentG.setVertexBuffer(iron_data_ConstData.screenAlignedVB);
		this.currentG.setIndexBuffer(iron_data_ConstData.screenAlignedIB);
		this.currentG.drawIndexedVertices();
		if(this.scissorSet) {
			this.currentG.disableScissor();
			this.scissorSet = false;
		}
		this.currentG.end();
		this.currentG = null;
		this.bindParams = null;
	}
	loadShader(handle) {
		this.loading++;
		let cc = this.cachedShaderContexts.h[handle];
		if(cc != null) {
			this.loading--;
			return;
		}
		cc = new iron_CachedShaderContext();
		this.cachedShaderContexts.h[handle] = cc;
		let shaderPath = handle.split("/");
		let _gthis = this;
		iron_data_Data.getShader(shaderPath[0],shaderPath[1],function(res) {
			cc.context = res.getContext(shaderPath[2]);
			_gthis.loading--;
		});
	}
	resize() {
		if(kha_System.windowWidth() == 0 || kha_System.windowHeight() == 0) {
			return;
		}
		let h = this.renderTargets.h;
		let rt_keys = Object.keys(h);
		let rt_length = rt_keys.length;
		let rt_current = 0;
		while(rt_current < rt_length) {
			let rt = h[rt_keys[rt_current++]];
			if(rt == null || rt.raw.width > 0 || rt.depthStencilFrom == "" || rt == this.depthToRenderTarget.h[rt.depthStencilFrom]) {
				continue;
			}
			let nodepth = null;
			let h1 = this.renderTargets.h;
			let rt2_keys = Object.keys(h1);
			let rt2_length = rt2_keys.length;
			let rt2_current = 0;
			while(rt2_current < rt2_length) {
				let rt2 = h1[rt2_keys[rt2_current++]];
				if(rt2 == null || rt2.raw.width > 0 || rt2.depthStencilFrom != "" || this.depthToRenderTarget.h[rt2.raw.depth_buffer] != null) {
					continue;
				}
				nodepth = rt2;
				break;
			}
			if(nodepth != null) {
				rt.image.setDepthStencilFrom(nodepth.image);
			}
		}
		let h1 = this.renderTargets.h;
		let rt_keys1 = Object.keys(h1);
		let rt_length1 = rt_keys1.length;
		let rt_current1 = 0;
		while(rt_current1 < rt_length1) {
			let rt = h1[rt_keys1[rt_current1++]];
			if(rt != null && rt.raw.width == 0) {
				iron_App.notifyOnInit(($_=rt.image,$bind($_,$_.unload)));
				rt.image = this.createImage(rt.raw,rt.depthStencil);
			}
		}
		let h2 = this.renderTargets.h;
		let rt_keys2 = Object.keys(h2);
		let rt_length2 = rt_keys2.length;
		let rt_current2 = 0;
		while(rt_current2 < rt_length2) {
			let rt = h2[rt_keys2[rt_current2++]];
			if(rt != null && rt.depthStencilFrom != "") {
				rt.image.setDepthStencilFrom(this.depthToRenderTarget.h[rt.depthStencilFrom].image);
			}
		}
	}
	createRenderTarget(t) {
		let rt = this.createTarget(t);
		this.renderTargets.h[t.name] = rt;
		return rt;
	}
	createDepthBuffer(name,format) {
		this.depthBuffers.push({ name : name, format : format});
	}
	createTarget(t) {
		let rt = new iron_RenderTarget(t);
		if(t.depth_buffer != null) {
			rt.hasDepth = true;
			let depthTarget = this.depthToRenderTarget.h[t.depth_buffer];
			if(depthTarget == null) {
				let _g = 0;
				let _g1 = this.depthBuffers;
				while(_g < _g1.length) {
					let db = _g1[_g];
					++_g;
					if(db.name == t.depth_buffer) {
						this.depthToRenderTarget.h[db.name] = rt;
						let s = db.format;
						let tmp;
						if(s == null || s == "") {
							tmp = 1;
						} else {
							switch(s) {
							case "DEPTH16":
								tmp = 5;
								break;
							case "DEPTH24":
								tmp = 1;
								break;
							default:
								tmp = 1;
							}
						}
						rt.depthStencil = tmp;
						rt.image = this.createImage(t,rt.depthStencil);
						break;
					}
				}
			} else {
				rt.depthStencil = 0;
				rt.depthStencilFrom = t.depth_buffer;
				rt.image = this.createImage(t,rt.depthStencil);
				rt.image.setDepthStencilFrom(depthTarget.image);
			}
		} else {
			rt.hasDepth = false;
			if(t.depth != null && t.depth > 1) {
				rt.is3D = true;
			}
			if(t.is_cubemap) {
				rt.isCubeMap = true;
				rt.depthStencil = 0;
				rt.cubeMap = this.createCubeMap(t,rt.depthStencil);
			} else {
				rt.depthStencil = 0;
				rt.image = this.createImage(t,rt.depthStencil);
			}
		}
		return rt;
	}
	createImage(t,depthStencil) {
		let width = t.width == 0 ? arm_App.w() : t.width;
		let height = t.height == 0 ? arm_App.h() : t.height;
		let depth = t.depth != null ? t.depth : 0;
		if(t.displayp != null) {
			if(width > height) {
				width = width * (t.displayp / height) | 0;
				height = t.displayp;
			} else {
				height = height * (t.displayp / width) | 0;
				width = t.displayp;
			}
		}
		if(t.scale != null) {
			width = width * t.scale | 0;
			height = height * t.scale | 0;
			depth = depth * t.scale | 0;
		}
		if(width < 1) {
			width = 1;
		}
		if(height < 1) {
			height = 1;
		}
		if(t.depth != null && t.depth > 1) {
			let img;
			if(t.format != null) {
				switch(t.format) {
				case "DEPTH16":
					img = 3;
					break;
				case "R16":
					img = 6;
					break;
				case "R32":
					img = 5;
					break;
				case "R8":
					img = 1;
					break;
				case "RGBA128":
					img = 2;
					break;
				case "RGBA32":
					img = 0;
					break;
				case "RGBA64":
					img = 4;
					break;
				default:
					img = 0;
				}
			} else {
				img = 0;
			}
			let img1 = kha_Image.create3D(width,height,depth,img);
			if(t.mipmaps) {
				img1.generateMipmaps(1000);
			}
			return img1;
		} else if(t.is_image != null && t.is_image) {
			let tmp;
			if(t.format != null) {
				switch(t.format) {
				case "DEPTH16":
					tmp = 3;
					break;
				case "R16":
					tmp = 6;
					break;
				case "R32":
					tmp = 5;
					break;
				case "R8":
					tmp = 1;
					break;
				case "RGBA128":
					tmp = 2;
					break;
				case "RGBA32":
					tmp = 0;
					break;
				case "RGBA64":
					tmp = 4;
					break;
				default:
					tmp = 0;
				}
			} else {
				tmp = 0;
			}
			return kha_Image.create(width,height,tmp);
		} else {
			let tmp;
			if(t.format != null) {
				switch(t.format) {
				case "DEPTH16":
					tmp = 3;
					break;
				case "R16":
					tmp = 6;
					break;
				case "R32":
					tmp = 5;
					break;
				case "R8":
					tmp = 1;
					break;
				case "RGBA128":
					tmp = 2;
					break;
				case "RGBA32":
					tmp = 0;
					break;
				case "RGBA64":
					tmp = 4;
					break;
				default:
					tmp = 0;
				}
			} else {
				tmp = 0;
			}
			return kha_Image.createRenderTarget(width,height,tmp,depthStencil);
		}
	}
	createCubeMap(t,depthStencil) {
		let tmp;
		if(t.format != null) {
			switch(t.format) {
			case "DEPTH16":
				tmp = 3;
				break;
			case "R16":
				tmp = 6;
				break;
			case "R32":
				tmp = 5;
				break;
			case "R8":
				tmp = 1;
				break;
			case "RGBA128":
				tmp = 2;
				break;
			case "RGBA32":
				tmp = 0;
				break;
			case "RGBA64":
				tmp = 4;
				break;
			default:
				tmp = 0;
			}
		} else {
			tmp = 0;
		}
		return kha_graphics4_CubeMap.createRenderTarget(t.width,tmp,depthStencil);
	}
	static setActive(renderPath) {
		iron_RenderPath.active = renderPath;
	}
	static sortMeshesDistance(meshes) {
		meshes.sort(function(a,b) {
			if(a.cameraDistance >= b.cameraDistance) {
				return 1;
			} else {
				return -1;
			}
		});
	}
	static sortMeshesShader(meshes) {
		meshes.sort(function(a,b) {
			if(a.materials[0].name >= b.materials[0].name) {
				return 1;
			} else {
				return -1;
			}
		});
	}
}
$hxClasses["iron.RenderPath"] = iron_RenderPath;
iron_RenderPath.__name__ = "iron.RenderPath";
Object.assign(iron_RenderPath.prototype, {
	__class__: iron_RenderPath
	,__properties__: {get_ready: "get_ready"}
});
class iron_Scene {
	constructor() {
		this.traitRemoves = [];
		this.traitInits = [];
		this.groups = null;
		this.uid = iron_Scene.uidCounter++;
		this.meshes = [];
		this.lights = [];
		this.cameras = [];
		this.empties = [];
		this.animations = [];
		this.embedded = new haxe_ds_StringMap();
		this.root = new iron_object_Object();
		this.root.name = "Root";
		this.traitInits = [];
		this.traitRemoves = [];
		this.initializing = true;
		if(iron_Scene.global == null) {
			iron_Scene.global = new iron_object_Object();
		}
	}
	remove() {
		let _g = 0;
		let _g1 = this.traitRemoves;
		while(_g < _g1.length) _g1[_g++]();
		let _g2 = 0;
		let _g3 = this.meshes;
		while(_g2 < _g3.length) _g3[_g2++].remove();
		let _g4 = 0;
		let _g5 = this.lights;
		while(_g4 < _g5.length) _g5[_g4++].remove();
		let _g6 = 0;
		let _g7 = this.cameras;
		while(_g6 < _g7.length) _g7[_g6++].remove();
		let _g8 = 0;
		let _g9 = this.empties;
		while(_g8 < _g9.length) _g9[_g8++].remove();
		this.groups = null;
		this.root.remove();
	}
	updateFrame() {
		if(!this.ready) {
			return;
		}
		let _g = 0;
		let _g1 = this.animations;
		while(_g < _g1.length) _g1[_g++].update(iron_system_Time.get_delta());
		let _g2 = 0;
		let _g3 = this.empties;
		while(_g2 < _g3.length) {
			let e = _g3[_g2];
			++_g2;
			if(e != null && e.parent != null) {
				e.transform.update();
			}
		}
	}
	renderFrame(g) {
		if(!this.ready || iron_RenderPath.active == null) {
			return;
		}
		iron_Scene.framePassed = true;
		if(this.camera != null) {
			this.camera.renderFrame(g);
		} else {
			iron_RenderPath.active.renderFrame(g);
		}
	}
	addObject(parent) {
		let object = new iron_object_Object();
		if(parent != null) {
			object.setParent(parent);
		} else {
			object.setParent(this.root);
		}
		return object;
	}
	getChild(name) {
		return this.root.getChild(name);
	}
	getCamera(name) {
		let _g = 0;
		let _g1 = this.cameras;
		while(_g < _g1.length) {
			let c = _g1[_g];
			++_g;
			if(c.name == name) {
				return c;
			}
		}
		return null;
	}
	addMeshObject(data,materials,parent) {
		let object = new iron_object_MeshObject(data,materials);
		if(parent != null) {
			object.setParent(parent);
		} else {
			object.setParent(this.root);
		}
		return object;
	}
	addLightObject(data,parent) {
		let object = new iron_object_LightObject(data);
		if(parent != null) {
			object.setParent(parent);
		} else {
			object.setParent(this.root);
		}
		return object;
	}
	addCameraObject(data,parent) {
		let object = new iron_object_CameraObject(data);
		if(parent != null) {
			object.setParent(parent);
		} else {
			object.setParent(this.root);
		}
		return object;
	}
	addScene(sceneName,parent,done) {
		if(parent == null) {
			parent = this.addObject();
			parent.name = sceneName;
		}
		let _gthis = this;
		iron_data_Data.getSceneRaw(sceneName,function(format) {
			iron_Scene.createTraits(format.traits,parent);
			_gthis.loadEmbeddedData(format.embedded_datas,function() {
				let objectsTraversed = 0;
				let objectsCount = _gthis.getObjectsCount(format.objects);
				let traverseObjects = null;
				traverseObjects = function(parent,objects,parentObject,done) {
					if(objects == null) {
						return;
					}
					let _g = 0;
					let _g1 = objects.length;
					while(_g < _g1) {
						let o = objects[_g++];
						if(o.spawn != null && o.spawn == false) {
							if((objectsTraversed += 1) == objectsCount) {
								done();
							}
							continue;
						}
						_gthis.createObject(o,format,parent,parentObject,function(object) {
							traverseObjects(object,o.children,o,done);
							if((objectsTraversed += 1) == objectsCount) {
								done();
							}
						});
					}
				};
				if(format.objects == null || format.objects.length == 0) {
					done(parent);
				} else {
					traverseObjects(parent,format.objects,null,function() {
						done(parent);
					});
				}
			});
		});
	}
	getObjectsCount(objects,discardNoSpawn) {
		if(discardNoSpawn == null) {
			discardNoSpawn = true;
		}
		if(objects == null) {
			return 0;
		}
		let result = objects.length;
		let _g = 0;
		while(_g < objects.length) {
			let o = objects[_g];
			++_g;
			if(discardNoSpawn && o.spawn != null && o.spawn == false) {
				continue;
			}
			if(o.children != null) {
				result += this.getObjectsCount(o.children);
			}
		}
		return result;
	}
	spawnObject(name,parent,done,spawnChildren,srcRaw) {
		if(spawnChildren == null) {
			spawnChildren = true;
		}
		if(srcRaw == null) {
			srcRaw = this.raw;
		}
		let objectsTraversed = 0;
		let obj = iron_Scene.getRawObjectByName(srcRaw,name);
		let objectsCount = spawnChildren ? this.getObjectsCount([obj],false) : 1;
		let rootId = -1;
		let spawnObjectTree = null;
		let _gthis = this;
		spawnObjectTree = function(obj,parent,parentObject,done) {
			_gthis.createObject(obj,srcRaw,parent,parentObject,function(object) {
				if(rootId == -1) {
					rootId = object.uid;
				}
				if(spawnChildren && obj.children != null) {
					let _g = 0;
					let _g1 = obj.children;
					while(_g < _g1.length) spawnObjectTree(_g1[_g++],object,obj,done);
				}
				if((objectsTraversed += 1) == objectsCount && done != null) {
					while(object.uid != rootId) object = object.parent;
					done(object);
				}
			});
		};
		spawnObjectTree(obj,parent,null,done);
	}
	createObject(o,format,parent,parentObject,done) {
		let sceneName = format.name;
		let _gthis = this;
		if(o.type == "camera_object") {
			iron_data_Data.getCamera(sceneName,o.data_ref,function(b) {
				let object = _gthis.addCameraObject(b,parent);
				_gthis.returnObject(object,o,done);
			});
		} else if(o.type == "light_object") {
			iron_data_Data.getLight(sceneName,o.data_ref,function(b) {
				let object = _gthis.addLightObject(b,parent);
				_gthis.returnObject(object,o,done);
			});
		} else if(o.type == "mesh_object") {
			if(o.material_refs == null || o.material_refs.length == 0) {
				this.createMeshObject(o,format,parent,parentObject,null,done);
			} else {
				let materials = new Array(o.material_refs.length);
				let materialsLoaded = 0;
				let _g = 0;
				let _g1 = o.material_refs.length;
				while(_g < _g1) {
					let i = _g++;
					iron_data_Data.getMaterial(sceneName,o.material_refs[i],function(mat) {
						materials[i] = mat;
						materialsLoaded += 1;
						if(materialsLoaded == o.material_refs.length) {
							_gthis.createMeshObject(o,format,parent,parentObject,materials,done);
						}
					});
				}
			}
		} else if(o.type == "object") {
			this.returnObject(this.addObject(parent),o,function(ro) {
				if(o.group_ref != null) {
					_gthis.spawnGroup(format,o.group_ref,ro,function() {
						done(ro);
					});
				} else {
					done(ro);
				}
			});
		} else {
			done(null);
		}
	}
	spawnGroup(format,groupRef,groupOwner,done,failed) {
		let spawned = 0;
		let object_refs = this.getGroupObjectRefs(groupRef);
		let _gthis = this;
		if(object_refs == null) {
			if(failed != null) {
				failed();
			}
		} else if(object_refs.length == 0) {
			done();
		} else {
			let _g = 0;
			while(_g < object_refs.length) this.spawnObject(object_refs[_g++],groupOwner,function(spawnedObject) {
				if(!_gthis.isObjectInGroup(groupRef,spawnedObject.parent)) {
					let _g = 0;
					let _g1 = format.groups;
					while(_g < _g1.length) {
						let group = _g1[_g];
						++_g;
						if(group.name == groupRef) {
							spawnedObject.transform.applyParent();
							spawnedObject.transform.translate(-group.instance_offset[0],-group.instance_offset[1],-group.instance_offset[2]);
							break;
						}
					}
				}
				if((spawned += 1) == object_refs.length) {
					groupOwner.transform.reset();
					done();
				}
			});
		}
	}
	getGroupObjectRefs(group_ref) {
		let _g = 0;
		let _g1 = iron_Scene.active.raw.groups;
		while(_g < _g1.length) {
			let g = _g1[_g];
			++_g;
			if(g.name == group_ref) {
				return g.object_refs;
			}
		}
		return null;
	}
	getGroupObjectsRaw(groupRef) {
		let objectRefs = this.getGroupObjectRefs(groupRef);
		let objects = [];
		if(objectRefs == null) {
			return objects;
		}
		let _g = 0;
		while(_g < objectRefs.length) {
			let rawObj = iron_Scene.getRawObjectByName(this.raw,objectRefs[_g++]);
			objects.push(rawObj);
			objects = objects.concat(this.getChildObjectsRaw(rawObj));
		}
		return objects;
	}
	getChildObjectsRaw(rawObj,recursive) {
		if(recursive == null) {
			recursive = true;
		}
		let children = rawObj.children;
		if(children == null) {
			return [];
		}
		children = children.slice();
		if(recursive) {
			let _g = 0;
			let _g1 = rawObj.children;
			while(_g < _g1.length) children = children.concat(this.getChildObjectsRaw(_g1[_g++]));
		}
		return children;
	}
	isObjectInGroup(groupRef,object) {
		let _g = 0;
		let _g1 = this.getGroupObjectsRaw(groupRef);
		while(_g < _g1.length) if(_g1[_g++].name == object.name) {
			return true;
		}
		return false;
	}
	createMeshObject(o,format,parent,parentObject,materials,done) {
		let ref = o.data_ref.split("/");
		let object_file = "";
		let data_ref = "";
		let sceneName = format.name;
		if(ref.length == 2) {
			object_file = ref[0];
			data_ref = ref[1];
		} else {
			object_file = sceneName;
			data_ref = o.data_ref;
		}
		this.returnMeshObject(object_file,data_ref,sceneName,null,materials,parent,parentObject,o,done);
	}
	returnMeshObject(object_file,data_ref,sceneName,armature,materials,parent,parentObject,o,done) {
		let _gthis = this;
		iron_data_Data.getMesh(object_file,data_ref,function(mesh) {
			let object = _gthis.addMeshObject(mesh,materials,parent);
			if(o.particle_refs != null) {
				let _g = 0;
				let _g1 = o.particle_refs;
				while(_g < _g1.length) (js_Boot.__cast(object , iron_object_MeshObject)).setupParticleSystem(sceneName,_g1[_g++]);
			}
			if(o.tilesheet_ref != null) {
				(js_Boot.__cast(object , iron_object_MeshObject)).setupTilesheet(sceneName,o.tilesheet_ref,o.tilesheet_action_ref);
			}
			_gthis.returnObject(object,o,done);
		});
	}
	returnObject(object,o,done) {
		let _gthis = this;
		if(object != null && o.object_actions != null) {
			let oactions = [];
			while(oactions.length < o.object_actions.length) oactions.push(null);
			let actionsLoaded = 0;
			let _g = 0;
			let _g1 = o.object_actions.length;
			while(_g < _g1) {
				let i = _g++;
				let ref = o.object_actions[i];
				if(ref == "null") {
					actionsLoaded += 1;
					continue;
				}
				iron_data_Data.getSceneRaw(ref,function(action) {
					oactions[i] = action;
					actionsLoaded += 1;
					if(actionsLoaded == o.object_actions.length) {
						_gthis.returnObjectLoaded(object,o,oactions,done);
					}
				});
			}
		} else {
			this.returnObjectLoaded(object,o,null,done);
		}
	}
	returnObjectLoaded(object,o,oactions,done) {
		if(object != null) {
			object.raw = o;
			object.name = o.name;
			if(o.visible != null) {
				object.visible = o.visible;
			}
			if(o.visible_mesh != null) {
				object.visibleMesh = o.visible_mesh;
			}
			if(o.visible_shadow != null) {
				object.visibleShadow = o.visible_shadow;
			}
			iron_Scene.createConstraints(o.constraints,object);
			iron_Scene.generateTransform(o,object.transform);
			object.setupAnimation(oactions);
			if(o.properties != null) {
				object.properties = new haxe_ds_StringMap();
				let _g = 0;
				let _g1 = o.properties;
				while(_g < _g1.length) {
					let p = _g1[_g];
					++_g;
					object.properties.h[p.name] = p.value;
				}
			}
			if(!iron_Scene.active.initializing) {
				iron_Scene.createTraits(o.traits,object);
			}
		}
		done(object);
	}
	loadEmbeddedData(datas,done) {
		if(datas == null) {
			done();
			return;
		}
		let loaded = 0;
		let _g = 0;
		while(_g < datas.length) this.embedData(datas[_g++],function() {
			loaded += 1;
			if(loaded == datas.length) {
				done();
			}
		});
	}
	embedData(file,done) {
		let _gthis = this;
		if(file.endsWith(".raw")) {
			iron_data_Data.getBlob(file,function(blob) {
				let b = blob.toBytes();
				let w = (Math.pow(b.length,0.33333333333333331) | 0) + 1;
				let image = kha_Image.fromBytes3D(b,w,w,w,1);
				_gthis.embedded.h[file] = image;
				done();
			});
		} else {
			iron_data_Data.getImage(file,function(image) {
				_gthis.embedded.h[file] = image;
				done();
			});
		}
	}
	static create(format,done) {
		iron_Scene.active = new iron_Scene();
		iron_Scene.active.ready = false;
		iron_Scene.active.raw = format;
		iron_data_Data.getWorld(format.name,format.world_ref,function(world) {
			iron_Scene.active.world = world;
			iron_Scene.active.addScene(format.name,null,function(sceneObject) {
				let _g = 0;
				let _g1 = sceneObject.getChildren(true);
				while(_g < _g1.length) {
					let object = _g1[_g];
					++_g;
					iron_Scene.createTraits(object.raw.traits,object);
				}
				if(iron_Scene.active.cameras.length == 0) {
					haxe_Log.trace("No camera found for scene \"" + format.name + "\"",{ fileName : "Sources/iron/Scene.hx", lineNumber : 135, className : "iron.Scene", methodName : "create"});
				}
				iron_Scene.active.camera = iron_Scene.active.getCamera(format.camera_ref);
				iron_Scene.active.ready = true;
				let _g2 = 0;
				let _g3 = iron_Scene.active.traitInits;
				while(_g2 < _g3.length) _g3[_g2++]();
				iron_Scene.active.traitInits = [];
				iron_Scene.active.sceneParent = sceneObject;
				iron_Scene.active.initializing = false;
				done(sceneObject);
			});
		});
	}
	static setActive(sceneName,done) {
		if(!iron_Scene.framePassed) {
			return;
		}
		iron_Scene.framePassed = false;
		if(iron_Scene.active != null) {
			iron_Scene.active.remove();
		}
		iron_data_Data.getSceneRaw(sceneName,function(format) {
			iron_Scene.create(format,function(o) {
				if(done != null) {
					done(o);
				}
				iron_RenderPath.active.voxelized = 0;
			});
		});
	}
	static getRawObjectByName(format,name) {
		return iron_Scene.traverseObjs(format.objects,name);
	}
	static traverseObjs(children,name) {
		let _g = 0;
		while(_g < children.length) {
			let o = children[_g];
			++_g;
			if(o.name == name) {
				return o;
			}
			if(o.children != null) {
				let res = iron_Scene.traverseObjs(o.children,name);
				if(res != null) {
					return res;
				}
			}
		}
		return null;
	}
	static generateTransform(object,transform) {
		let tmp;
		if(object.transform != null) {
			let a = object.transform.values;
			tmp = new iron_math_Mat4(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15]);
		} else {
			tmp = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
		}
		transform.world = tmp;
		let _this = transform.world;
		let loc = transform.loc;
		let quat = transform.rot;
		let scale = transform.scale;
		loc.x = _this.self._30;
		loc.y = _this.self._31;
		loc.z = _this.self._32;
		let _this1 = iron_math_Mat4.helpVec;
		_this1.x = _this.self._00;
		_this1.y = _this.self._01;
		_this1.z = _this.self._02;
		_this1.w = 1.0;
		scale.x = Math.sqrt(_this1.x * _this1.x + _this1.y * _this1.y + _this1.z * _this1.z);
		let _this2 = iron_math_Mat4.helpVec;
		_this2.x = _this.self._10;
		_this2.y = _this.self._11;
		_this2.z = _this.self._12;
		_this2.w = 1.0;
		scale.y = Math.sqrt(_this2.x * _this2.x + _this2.y * _this2.y + _this2.z * _this2.z);
		let _this3 = iron_math_Mat4.helpVec;
		_this3.x = _this.self._20;
		_this3.y = _this.self._21;
		_this3.z = _this.self._22;
		_this3.w = 1.0;
		scale.z = Math.sqrt(_this3.x * _this3.x + _this3.y * _this3.y + _this3.z * _this3.z);
		let _this4 = _this.self;
		let m3 = _this4._12;
		let m4 = _this4._22;
		let m5 = _this4._32;
		let m6 = _this4._13;
		let m7 = _this4._23;
		let m8 = _this4._33;
		let m31 = _this4._12;
		let m41 = _this4._22;
		let m51 = _this4._32;
		let m61 = _this4._13;
		let m71 = _this4._23;
		let m81 = _this4._33;
		let m32 = _this4._11;
		let m42 = _this4._21;
		let m52 = _this4._31;
		let m62 = _this4._13;
		let m72 = _this4._23;
		let m82 = _this4._33;
		let m33 = _this4._11;
		let m43 = _this4._21;
		let m53 = _this4._31;
		let m63 = _this4._12;
		let m73 = _this4._22;
		let m83 = _this4._32;
		if(_this4._00 * (_this4._11 * (m4 * m8 - m5 * m7) - _this4._21 * (m3 * m8 - m5 * m6) + _this4._31 * (m3 * m7 - m4 * m6)) - _this4._01 * (_this4._10 * (m41 * m81 - m51 * m71) - _this4._20 * (m31 * m81 - m51 * m61) + _this4._30 * (m31 * m71 - m41 * m61)) + _this4._02 * (_this4._10 * (m42 * m82 - m52 * m72) - _this4._20 * (m32 * m82 - m52 * m62) + _this4._30 * (m32 * m72 - m42 * m62)) - _this4._03 * (_this4._10 * (m43 * m83 - m53 * m73) - _this4._20 * (m33 * m83 - m53 * m63) + _this4._30 * (m33 * m73 - m43 * m63)) < 0.0) {
			scale.x = -scale.x;
		}
		let invs = 1.0 / scale.x;
		iron_math_Mat4.helpMat.self._00 = _this.self._00 * invs;
		iron_math_Mat4.helpMat.self._01 = _this.self._01 * invs;
		iron_math_Mat4.helpMat.self._02 = _this.self._02 * invs;
		invs = 1.0 / scale.y;
		iron_math_Mat4.helpMat.self._10 = _this.self._10 * invs;
		iron_math_Mat4.helpMat.self._11 = _this.self._11 * invs;
		iron_math_Mat4.helpMat.self._12 = _this.self._12 * invs;
		invs = 1.0 / scale.z;
		iron_math_Mat4.helpMat.self._20 = _this.self._20 * invs;
		iron_math_Mat4.helpMat.self._21 = _this.self._21 * invs;
		iron_math_Mat4.helpMat.self._22 = _this.self._22 * invs;
		let m = iron_math_Mat4.helpMat;
		let m11 = m.self._00;
		let m12 = m.self._10;
		let m13 = m.self._20;
		let m21 = m.self._01;
		let m22 = m.self._11;
		let m23 = m.self._21;
		let m311 = m.self._02;
		let m321 = m.self._12;
		let m331 = m.self._22;
		let tr = m11 + m22 + m331;
		let s = 0.0;
		if(tr > 0) {
			s = 0.5 / Math.sqrt(tr + 1.0);
			quat.w = 0.25 / s;
			quat.x = (m321 - m23) * s;
			quat.y = (m13 - m311) * s;
			quat.z = (m21 - m12) * s;
		} else if(m11 > m22 && m11 > m331) {
			s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m331);
			quat.w = (m321 - m23) / s;
			quat.x = 0.25 * s;
			quat.y = (m12 + m21) / s;
			quat.z = (m13 + m311) / s;
		} else if(m22 > m331) {
			s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m331);
			quat.w = (m13 - m311) / s;
			quat.x = (m12 + m21) / s;
			quat.y = 0.25 * s;
			quat.z = (m23 + m321) / s;
		} else {
			s = 2.0 * Math.sqrt(1.0 + m331 - m11 - m22);
			quat.w = (m21 - m12) / s;
			quat.x = (m13 + m311) / s;
			quat.y = (m23 + m321) / s;
			quat.z = 0.25 * s;
		}
		if(object.local_only != null) {
			transform.localOnly = object.local_only;
		}
		if(transform.object.parent != null) {
			transform.update();
		}
	}
	static createTraits(traits,object) {
		if(traits == null) {
			return;
		}
		let _g = 0;
		while(_g < traits.length) {
			let t = traits[_g];
			++_g;
			if(t.type == "Script") {
				let args = [];
				if(t.parameters != null) {
					let _g = 0;
					let _g1 = t.parameters;
					while(_g < _g1.length) args.push(iron_Scene.parseArg(_g1[_g++]));
				}
				let traitInst = iron_Scene.createTraitClassInstance(t.class_name,args);
				if(traitInst == null) {
					haxe_Log.trace("Error: Trait '" + t.class_name + "' referenced in object '" + object.name + "' not found",{ fileName : "Sources/iron/Scene.hx", lineNumber : 862, className : "iron.Scene", methodName : "createTraits"});
					continue;
				}
				if(t.props != null) {
					let _g = 0;
					let _g1 = t.props.length / 3 | 0;
					while(_g < _g1) {
						let i = _g++;
						let pname = t.props[i * 3];
						let ptype = t.props[i * 3 + 1];
						let pval = t.props[i * 3 + 2];
						if(ptype.endsWith("Object") && pval != "") {
							Reflect.setProperty(traitInst,pname,iron_Scene.active.getChild(pval));
						} else {
							switch(ptype) {
							case "Vec2":
								let pVec = pval;
								Reflect.setProperty(traitInst,pname,new iron_math_Vec2(pVec[0],pVec[1]));
								break;
							case "Vec3":
								let pVec1 = pval;
								Reflect.setProperty(traitInst,pname,new iron_math_Vec3(pVec1[0],pVec1[1],pVec1[2]));
								break;
							case "Vec4":
								let pVec2 = pval;
								Reflect.setProperty(traitInst,pname,new iron_math_Vec4(pVec2[0],pVec2[1],pVec2[2],pVec2[3]));
								break;
							default:
								Reflect.setProperty(traitInst,pname,pval);
							}
						}
					}
				}
				object.addTrait(traitInst);
			}
		}
	}
	static parseArg(str) {
		if(str == "true") {
			return true;
		} else if(str == "false") {
			return false;
		} else if(str == "null") {
			return null;
		} else if(str.charAt(0) == "'") {
			return StringTools.replace(str,"'","");
		} else if(str.charAt(0) == "\"") {
			return StringTools.replace(str,"\"","");
		} else if(str.charAt(0) == "[") {
			str = StringTools.replace(str,"[","");
			str = StringTools.replace(str,"]","");
			str = StringTools.replace(str," ","");
			let ar = [];
			let vals = str.split(",");
			let _g = 0;
			while(_g < vals.length) ar.push(iron_Scene.parseArg(vals[_g++]));
			return ar;
		} else {
			let f = parseFloat(str);
			let i = Std.parseInt(str);
			if(f == i) {
				return i;
			} else {
				return f;
			}
		}
	}
	static createConstraints(constraints,object) {
		if(constraints == null) {
			return;
		}
		object.constraints = [];
		let _g = 0;
		while(_g < constraints.length) object.constraints.push(new iron_object_Constraint(constraints[_g++]));
	}
	static createTraitClassInstance(traitName,args) {
		let cname = $hxClasses[traitName];
		if(cname == null) {
			return null;
		}
		return Type.createInstance(cname,args);
	}
}
$hxClasses["iron.Scene"] = iron_Scene;
iron_Scene.__name__ = "iron.Scene";
Object.assign(iron_Scene.prototype, {
	__class__: iron_Scene
});
class iron_system_Time {
	static get_delta() {
		if(iron_system_Time.frequency == null) {
			iron_system_Time.initFrequency();
		}
		return 1 / iron_system_Time.frequency * iron_system_Time.scale;
	}
	static initFrequency() {
		iron_system_Time.frequency = kha_Display.get_primary() != null ? kha_Display.get_primary().get_frequency() : 60;
	}
	static update() {
		iron_system_Time.realDelta = kha_Scheduler.realTime() - iron_system_Time.last;
		iron_system_Time.last = kha_Scheduler.realTime();
	}
}
$hxClasses["iron.system.Time"] = iron_system_Time;
iron_system_Time.__name__ = "iron.system.Time";
iron_system_Time.__properties__ = {get_delta: "get_delta"};
class arm_IronBridge {
}
$hxClasses["arm.IronBridge"] = $hx_exports["iron"] = arm_IronBridge;
arm_IronBridge.__name__ = "arm.IronBridge";
class zui_Ext {
	static floatInput(ui,handle,label,align,precision) {
		if(precision == null) {
			precision = 1000.0;
		}
		if(align == null) {
			align = 0;
		}
		if(label == null) {
			label = "";
		}
		handle.text = Std.string(Math.round(handle.value * precision) / precision);
		handle.value = parseFloat(ui.textInput(handle,label,align));
		return handle.value;
	}
	static inlineRadio(ui,handle,texts,align) {
		if(align == null) {
			align = 0;
		}
		if(!ui.isVisible(ui.t.ELEMENT_H * ui.ops.scaleFactor)) {
			ui.endElement();
			return handle.position;
		}
		let step = ui._w / texts.length;
		let hovered = -1;
		if(ui.getHover()) {
			let ix = ui.inputX - ui._x - ui._windowX | 0;
			let _g = 0;
			let _g1 = texts.length;
			while(_g < _g1) {
				let i = _g++;
				if(ix < i * step + step) {
					hovered = i;
					break;
				}
			}
		}
		if(ui.getReleased()) {
			handle.position = hovered;
			handle.changed = ui.changed = true;
		} else {
			handle.changed = false;
		}
		let _g = 0;
		let _g1 = texts.length;
		while(_g < _g1) {
			let i = _g++;
			if(handle.position == i) {
				ui.g.set_color(ui.t.ACCENT_HOVER_COL);
				if(!ui.enabled) {
					ui.fadeColor();
				}
				ui.g.fillRect(ui._x + step * i,ui._y + ui.buttonOffsetY,step,ui.t.BUTTON_H * ui.ops.scaleFactor);
			} else if(hovered == i) {
				ui.g.set_color(ui.t.ACCENT_COL);
				if(!ui.enabled) {
					ui.fadeColor();
				}
				ui.g.drawRect(ui._x + step * i,ui._y + ui.buttonOffsetY,step,ui.t.BUTTON_H * ui.ops.scaleFactor);
			}
			ui.g.set_color(ui.t.TEXT_COL);
			ui._x += step * i;
			let _w = ui._w;
			ui._w = step | 0;
			ui.drawString(ui.g,texts[i],null,0,align);
			ui._x -= step * i;
			ui._w = _w;
		}
		ui.endElement();
		return handle.position;
	}
	static colorWheel(ui,handle,alpha,w,h,colorPreview) {
		if(colorPreview == null) {
			colorPreview = true;
		}
		if(alpha == null) {
			alpha = false;
		}
		if(w == null) {
			w = ui._w;
		}
		zui_Ext.rgbToHsv(((handle.color & 16711680) >>> 16) * 0.00392156862745098,((handle.color & 65280) >>> 8) * 0.00392156862745098,(handle.color & 255) * 0.00392156862745098,zui_Ext.ar);
		let chue = zui_Ext.ar[0];
		let csat = zui_Ext.ar[1];
		let cval = zui_Ext.ar[2];
		let calpha = (handle.color >>> 24) * 0.00392156862745098;
		let px = ui._x;
		let py = ui._y;
		let scroll = ui.currentWindow != null && ui.currentWindow.scrollEnabled;
		if(!scroll) {
			w -= ui.t.SCROLL_W * ui.ops.scaleFactor | 0;
			px += (ui.t.SCROLL_W * ui.ops.scaleFactor | 0) / 2;
		}
		ui.image(ui.ops.color_wheel,kha_Color.fromFloats(cval,cval,cval));
		let ph = ui._y - py;
		let ox = px + w / 2;
		let oy = py + ph / 2;
		let cw = w * 0.7;
		let cwh = cw / 2;
		let cx = ox;
		let cy = oy + csat * cwh;
		let theta = chue * (Math.PI * 2.0);
		let cx2 = Math.cos(theta) * (cx - ox) - Math.sin(theta) * (cy - oy) + ox;
		let cy2 = Math.sin(theta) * (cx - ox) + Math.cos(theta) * (cy - oy) + oy;
		cx = cx2;
		cy = cy2;
		ui.g.set_color(-16777216);
		ui.g.fillRect(cx - 3 * ui.ops.scaleFactor,cy - 3 * ui.ops.scaleFactor,6 * ui.ops.scaleFactor,6 * ui.ops.scaleFactor);
		ui.g.set_color(-1);
		ui.g.fillRect(cx - 2 * ui.ops.scaleFactor,cy - 2 * ui.ops.scaleFactor,4 * ui.ops.scaleFactor,4 * ui.ops.scaleFactor);
		if(alpha) {
			let alphaHandle = handle.nest(1,{ value : Math.round(calpha * 100) / 100});
			calpha = ui.slider(alphaHandle,"Alpha",0.0,1.0,true);
			if(alphaHandle.changed) {
				handle.changed = ui.changed = true;
			}
		}
		let gx = ox + ui._windowX;
		let gy = oy + ui._windowY;
		if(ui.inputStarted && ui.getInputInRect(gx - cwh,gy - cwh,cw,cw)) {
			zui_Ext.wheelSelectedHande = handle;
		}
		if(ui.inputReleased) {
			zui_Ext.wheelSelectedHande = null;
		}
		if(ui.inputDown && zui_Ext.wheelSelectedHande == handle) {
			let vx = gx - ui.inputX;
			let vy = gy - ui.inputY;
			csat = Math.min(Math.sqrt(vx * vx + vy * vy),cwh) / cwh;
			let angle = Math.atan2(ui.inputX - gx,ui.inputY - gy);
			if(angle < 0) {
				angle = Math.PI + (Math.PI - Math.abs(angle));
			}
			angle = Math.PI * 2 - angle;
			chue = angle / (Math.PI * 2);
			handle.changed = ui.changed = true;
		}
		zui_Ext.hsvToRgb(chue,csat,cval,zui_Ext.ar);
		handle.color = kha_Color.fromFloats(zui_Ext.ar[0],zui_Ext.ar[1],zui_Ext.ar[2],calpha);
		if(colorPreview) {
			ui.text("",2,handle.color);
		}
		let pos = zui_Ext.inlineRadio(ui,zui_Handle.global.nest(54,null),["RGB","HSV","Hex"]);
		let h0 = handle.nest(0).nest(0);
		let h1 = handle.nest(0).nest(1);
		let h2 = handle.nest(0).nest(2);
		if(pos == 0) {
			h0.value = ((handle.color & 16711680) >>> 16) * 0.00392156862745098;
			let f = ui.slider(h0,"R",0,1,true);
			handle.color = Math.round((handle.color >>> 24) * 0.00392156862745098 * 255) << 24 | Math.round(f * 255) << 16 | Math.round(((handle.color & 65280) >>> 8) * 0.00392156862745098 * 255) << 8 | Math.round((handle.color & 255) * 0.00392156862745098 * 255);
			h1.value = ((handle.color & 65280) >>> 8) * 0.00392156862745098;
			let f1 = ui.slider(h1,"G",0,1,true);
			handle.color = Math.round((handle.color >>> 24) * 0.00392156862745098 * 255) << 24 | Math.round(((handle.color & 16711680) >>> 16) * 0.00392156862745098 * 255) << 16 | Math.round(f1 * 255) << 8 | Math.round((handle.color & 255) * 0.00392156862745098 * 255);
			h2.value = (handle.color & 255) * 0.00392156862745098;
			let f2 = ui.slider(h2,"B",0,1,true);
			handle.color = Math.round((handle.color >>> 24) * 0.00392156862745098 * 255) << 24 | Math.round(((handle.color & 16711680) >>> 16) * 0.00392156862745098 * 255) << 16 | Math.round(((handle.color & 65280) >>> 8) * 0.00392156862745098 * 255) << 8 | Math.round(f2 * 255);
		} else if(pos == 1) {
			zui_Ext.rgbToHsv(((handle.color & 16711680) >>> 16) * 0.00392156862745098,((handle.color & 65280) >>> 8) * 0.00392156862745098,(handle.color & 255) * 0.00392156862745098,zui_Ext.ar);
			h0.value = zui_Ext.ar[0];
			h1.value = zui_Ext.ar[1];
			h2.value = zui_Ext.ar[2];
			let chue = ui.slider(h0,"H",0,1,true);
			let csat = ui.slider(h1,"S",0,1,true);
			let cval = ui.slider(h2,"V",0,1,true);
			zui_Ext.hsvToRgb(chue,csat,cval,zui_Ext.ar);
			handle.color = kha_Color.fromFloats(zui_Ext.ar[0],zui_Ext.ar[1],zui_Ext.ar[2]);
		} else if(pos == 2) {
			handle.text = (handle.color >>> 0).toString(16);
			let hexCode = ui.textInput(handle,"#");
			if(hexCode.length >= 1 && hexCode.charAt(0) == "#") {
				hexCode = HxOverrides.substr(hexCode,1,null);
			}
			if(hexCode.length == 3) {
				hexCode = hexCode.charAt(0) + hexCode.charAt(0) + hexCode.charAt(1) + hexCode.charAt(1) + hexCode.charAt(2) + hexCode.charAt(2);
			}
			if(hexCode.length == 4) {
				hexCode = hexCode.charAt(0) + hexCode.charAt(0) + hexCode.charAt(1) + hexCode.charAt(1) + hexCode.charAt(2) + hexCode.charAt(2) + hexCode.charAt(3) + hexCode.charAt(3);
			}
			if(hexCode.length == 6) {
				hexCode = "ff" + hexCode;
			}
			handle.color = parseInt(hexCode,16);
		}
		if(h0.changed || h1.changed || h2.changed) {
			handle.changed = ui.changed = true;
		}
		if(ui.getInputInRect(ui._windowX + px,ui._windowY + py,w,h == null ? ui._y - py : h) && ui.inputReleased) {
			ui.changed = true;
		}
		return handle.color;
	}
	static textArea(ui,handle,align,editable) {
		if(editable == null) {
			editable = true;
		}
		if(align == null) {
			align = 0;
		}
		handle.text = StringTools.replace(handle.text,"\t","    ");
		let lines = handle.text.split("\n");
		let selected = ui.textSelectedHandle == handle;
		let cursorStartX = ui.cursorX;
		let keyPressed = selected && ui.isKeyPressed;
		ui.highlightOnSelect = false;
		ui.tabSwitchEnabled = false;
		ui.g.set_color(ui.t.SEPARATOR_COL);
		let g = ui.g;
		let x = ui._x + ui.buttonOffsetY;
		let y = ui._y + ui.buttonOffsetY;
		let w = ui._w - ui.buttonOffsetY * 2;
		let h = lines.length * (ui.t.ELEMENT_H * ui.ops.scaleFactor) - ui.buttonOffsetY * 2;
		if(!ui.enabled) {
			ui.fadeColor();
		}
		g.fillRect(x,y - 1,w,h + 1);
		let _g = 0;
		let _g1 = lines.length;
		while(_g < _g1) {
			let i = _g++;
			if(!selected && ui.getHover() || selected && i == handle.position) {
				handle.position = i;
				handle.text = lines[i];
				ui.submitTextHandle = null;
				ui.textInput(handle,"",align,editable);
				if(keyPressed && ui.key != 13 && ui.key != 27) {
					lines[i] = ui.textSelected;
				}
			} else {
				ui.text(lines[i],align);
			}
			ui._y -= ui.t.ELEMENT_OFFSET * ui.ops.scaleFactor;
		}
		ui._y += ui.t.ELEMENT_OFFSET * ui.ops.scaleFactor;
		if(keyPressed) {
			if(ui.key == 40 && handle.position < lines.length - 1) {
				handle.position++;
			}
			if(ui.key == 38 && handle.position > 0) {
				handle.position--;
			}
			if(editable && ui.key == 13) {
				handle.position++;
				lines.splice(handle.position,0,HxOverrides.substr(lines[handle.position - 1],ui.cursorX,null));
				lines[handle.position - 1] = HxOverrides.substr(lines[handle.position - 1],0,ui.cursorX);
				ui.startTextEdit(handle);
				ui.cursorX = ui.highlightAnchor = 0;
			}
			if(editable && ui.key == 8 && cursorStartX == 0 && handle.position > 0) {
				handle.position--;
				ui.cursorX = ui.highlightAnchor = lines[handle.position].length;
				lines[handle.position] += lines[handle.position + 1];
				lines.splice(handle.position + 1,1);
			}
			ui.textSelected = lines[handle.position];
		}
		ui.highlightOnSelect = true;
		ui.tabSwitchEnabled = true;
		handle.text = lines.join("\n");
		return handle.text;
	}
	static beginMenu(ui) {
		zui_Ext._ELEMENT_OFFSET = ui.t.ELEMENT_OFFSET;
		zui_Ext._BUTTON_COL = ui.t.BUTTON_COL;
		ui.t.ELEMENT_OFFSET = 0;
		ui.t.BUTTON_COL = ui.t.SEPARATOR_COL;
		ui.g.set_color(ui.t.SEPARATOR_COL);
		ui.g.fillRect(0,0,ui._windowW,ui.t.BUTTON_H * ui.ops.scaleFactor * 1.1 + 2 + ui.buttonOffsetY);
	}
	static endMenu(ui) {
		ui.t.ELEMENT_OFFSET = zui_Ext._ELEMENT_OFFSET;
		ui.t.BUTTON_COL = zui_Ext._BUTTON_COL;
	}
	static menuButton(ui,text) {
		ui._w = ui.ops.font.width(ui.fontSize,text) + 25 * ui.ops.scaleFactor | 0;
		return ui.button(text);
	}
	static hsvToRgb(cR,cG,cB,out) {
		let f = cR + 1.0;
		let f1 = cR + 0.66666666666666663;
		let py = Math.abs((f1 - (f1 | 0)) * 6.0 - 3.0);
		let f2 = cR + 0.33333333333333331;
		let pz = Math.abs((f2 - (f2 | 0)) * 6.0 - 3.0);
		out[0] = cB * (1.0 - cG + Math.min(Math.max(Math.abs((f - (f | 0)) * 6.0 - 3.0) - 1.0,0.0),1.0) * cG);
		out[1] = cB * (1.0 - cG + Math.min(Math.max(py - 1.0,0.0),1.0) * cG);
		out[2] = cB * (1.0 - cG + Math.min(Math.max(pz - 1.0,0.0),1.0) * cG);
	}
	static rgbToHsv(cR,cG,cB,out) {
		let a = cG < cB ? 0.0 : 1.0;
		let px = cB * (1.0 - a) + cG * a;
		let a1 = cG < cB ? 0.0 : 1.0;
		let py = cG * (1.0 - a1) + cB * a1;
		let a2 = cG < cB ? 0.0 : 1.0;
		let a3 = cG < cB ? 0.0 : 1.0;
		let a4 = cR < px ? 0.0 : 1.0;
		let qx = px * (1.0 - a4) + cR * a4;
		let a5 = cR < px ? 0.0 : 1.0;
		let qy = py * (1.0 - a5) + py * a5;
		let a6 = cR < px ? 0.0 : 1.0;
		let a7 = cR < px ? 0.0 : 1.0;
		let qw = cR * (1.0 - a7) + px * a7;
		let d = qx - Math.min(qw,qy);
		out[0] = Math.abs((0.66666666666666663 * (1.0 - a3) + -0.33333333333333331 * a3) * (1.0 - a6) + (-1.0 * (1.0 - a2) + 0.0 * a2) * a6 + (qw - qy) / (6.0 * d + 1.0e-10));
		out[1] = d / (qx + 1.0e-10);
		out[2] = qx;
	}
}
$hxClasses["zui.Ext"] = zui_Ext;
zui_Ext.__name__ = "zui.Ext";
class zui_Zui {
	constructor(ops) {
		this.checkSelectImage = null;
		this.elementsBaked = false;
		this.scissor = false;
		this.sticky = false;
		this.tabVertical = false;
		this.tabScroll = 0.0;
		this.tabHandle = null;
		this.tabColors = null;
		this.tabNames = null;
		this.tooltipTime = 0.0;
		this.tooltipWait = false;
		this.tooltipShown = false;
		this.tooltipY = 0.0;
		this.tooltipX = 0.0;
		this.tooltipInvertY = false;
		this.tooltipImgMaxWidth = null;
		this.tooltipImg = null;
		this.tooltipText = "";
		this.comboToSubmit = 0;
		this.submitComboHandle = null;
		this.comboSelectedWindow = null;
		this.comboSelectedHandle = null;
		this.tabPressedHandle = null;
		this.tabPressed = false;
		this.textToSubmit = "";
		this.submitTextHandle = null;
		this.textSelectedHandle = null;
		this.restoreY = -1.0;
		this.restoreX = -1.0;
		this.windowHeaderH = 0.0;
		this.windowHeaderW = 0.0;
		this.dragHandle = null;
		this.scrollHandle = null;
		this.windowEnded = true;
		this._windowY = 0.0;
		this._windowX = 0.0;
		this.imageScrollAlign = true;
		this.scrollAlign = 0.0;
		this.curRatio = -1;
		this.highlightAnchor = 0;
		this.cursorX = 0;
		this.inputStartedTime = 0.0;
		this.key = null;
		this.isTabDown = false;
		this.isReturnDown = false;
		this.isEscapeDown = false;
		this.isDeleteDown = false;
		this.isBackspaceDown = false;
		this.isADown = false;
		this.isAltDown = false;
		this.isCtrlDown = false;
		this.isShiftDown = false;
		this.isKeyDown = false;
		this.isKeyPressed = false;
		this.inputWheelDelta = 0;
		this.inputEnabled = true;
		this.inputRegistered = false;
		this.sliderTooltipW = 0.0;
		this.sliderTooltipY = 0.0;
		this.sliderTooltipX = 0.0;
		this.sliderTooltip = false;
		this.touchHold = false;
		this.highlightFullRow = false;
		this.windowBorderRight = 0;
		this.windowBorderBottom = 0;
		this.windowBorderTop = 0;
		this.tabSwitchEnabled = true;
		this.highlightOnSelect = true;
		this.alwaysRedraw = false;
		this.scrollEnabled = true;
		this.imageInvertY = false;
		this.changed = false;
		this.isReleased = false;
		this.isHovered = false;
		this.isPushed = false;
		this.isStarted = false;
		this.enabled = true;
		this.isTyping = false;
		this.isScrolling = false;
		if(ops.theme == null) {
			ops.theme = zui_Themes.dark;
		}
		this.t = ops.theme;
		if(ops.khaWindowId == null) {
			ops.khaWindowId = 0;
		}
		if(ops.scaleFactor == null) {
			ops.scaleFactor = 1.0;
		}
		if(ops.autoNotifyInput == null) {
			ops.autoNotifyInput = true;
		}
		this.ops = ops;
		this.setScale(ops.scaleFactor);
		if(ops.autoNotifyInput) {
			this.registerInput();
		}
		if(zui_Zui.copyReceiver == null) {
			zui_Zui.copyReceiver = this;
			kha_System.notifyOnCutCopyPaste($bind(this,this.onCut),$bind(this,this.onCopy),$bind(this,this.onPaste));
			kha_System.notifyOnFrames(function(frames) {
				if((zui_Zui.isCopy || zui_Zui.isPaste) && ++zui_Zui.copyFrame > 1) {
					zui_Zui.isCopy = zui_Zui.isCut = zui_Zui.isPaste = false;
				} else if(zui_Zui.copyFrame > 1 && ++zui_Zui.copyFrame > 2) {
					zui_Zui.copyFrame = 0;
					zui_Zui.textToPaste = "";
				}
			});
		}
		this.rtTextPipeline = kha_graphics2_Graphics.createTextPipeline(kha_graphics2_Graphics.createTextVertexStructure());
		this.rtTextPipeline.alphaBlendSource = 1;
		this.rtTextPipeline.compile();
	}
	setScale(factor) {
		this.ops.scaleFactor = factor;
		this.fontSize = this.t.FONT_SIZE * this.ops.scaleFactor | 0;
		let fontHeight = this.ops.font.height(this.fontSize);
		this.fontOffsetY = (this.t.ELEMENT_H * this.ops.scaleFactor - fontHeight) / 2;
		this.arrowOffsetY = (this.t.ELEMENT_H * this.ops.scaleFactor - this.t.ARROW_SIZE * this.ops.scaleFactor) / 2;
		this.arrowOffsetX = this.arrowOffsetY;
		this.titleOffsetX = (this.arrowOffsetX * 2 + this.t.ARROW_SIZE * this.ops.scaleFactor) / this.ops.scaleFactor;
		this.buttonOffsetY = (this.t.ELEMENT_H * this.ops.scaleFactor - this.t.BUTTON_H * this.ops.scaleFactor) / 2;
		this.checkOffsetY = (this.t.ELEMENT_H * this.ops.scaleFactor - this.t.CHECK_SIZE * this.ops.scaleFactor) / 2;
		this.checkOffsetX = this.checkOffsetY;
		this.checkSelectOffsetY = (this.t.CHECK_SIZE * this.ops.scaleFactor - this.t.CHECK_SELECT_SIZE * this.ops.scaleFactor) / 2;
		this.checkSelectOffsetX = this.checkSelectOffsetY;
		this.radioOffsetY = (this.t.ELEMENT_H * this.ops.scaleFactor - this.t.CHECK_SIZE * this.ops.scaleFactor) / 2;
		this.radioOffsetX = this.radioOffsetY;
		this.radioSelectOffsetY = (this.t.CHECK_SIZE * this.ops.scaleFactor - this.t.CHECK_SELECT_SIZE * this.ops.scaleFactor) / 2;
		this.radioSelectOffsetX = this.radioSelectOffsetY;
		this.elementsBaked = false;
	}
	bakeElements() {
		if(this.checkSelectImage != null) {
			this.checkSelectImage.unload();
		}
		this.checkSelectImage = kha_Image.createRenderTarget(this.t.CHECK_SELECT_SIZE * this.ops.scaleFactor | 0,this.t.CHECK_SELECT_SIZE * this.ops.scaleFactor | 0,null,0,1,this.ops.khaWindowId);
		let g = this.checkSelectImage.get_g2();
		g.begin(true,0);
		g.set_color(this.t.ACCENT_SELECT_COL);
		g.drawLine(0,0,this.checkSelectImage.get_width(),this.checkSelectImage.get_height(),2 * this.ops.scaleFactor);
		g.drawLine(this.checkSelectImage.get_width(),0,0,this.checkSelectImage.get_height(),2 * this.ops.scaleFactor);
		g.end();
		this.elementsBaked = true;
	}
	registerInput() {
		kha_input_Mouse.get().notifyWindowed(this.ops.khaWindowId,$bind(this,this.onMouseDown),$bind(this,this.onMouseUp),$bind(this,this.onMouseMove),$bind(this,this.onMouseWheel));
		kha_input_Keyboard.get().notify($bind(this,this.onKeyDown),$bind(this,this.onKeyUp),$bind(this,this.onKeyPress));
		let _gthis = this;
		kha_System.notifyOnApplicationState(function() {
			_gthis.inputDX = _gthis.inputDY = 0;
		},null,null,null,null);
		this.inputRegistered = true;
	}
	begin(g) {
		if(!this.elementsBaked) {
			this.bakeElements();
		}
		this.changed = false;
		this.globalG = g;
		zui_Zui.current = this;
		this._x = 0;
		this._y = 0;
		this._w = 0;
		this._h = 0;
	}
	end(last) {
		if(last == null) {
			last = true;
		}
		if(!this.windowEnded) {
			this.endWindow();
		}
		this.drawCombo();
		this.drawTooltip(true);
		this.tabPressedHandle = null;
		if(last) {
			this.endInput();
		}
	}
	beginRegion(g,x,y,w) {
		if(!this.elementsBaked) {
			g.end();
			this.bakeElements();
			g.begin(false);
		}
		this.changed = false;
		this.globalG = g;
		this.g = g;
		this.currentWindow = null;
		this.tooltipText = "";
		this.tooltipImg = null;
		this._windowX = 0;
		this._windowY = 0;
		this._windowW = w;
		this._x = x;
		this._y = y;
		this._w = w;
	}
	endRegion(last) {
		if(last == null) {
			last = true;
		}
		this.drawTooltip(false);
		this.tabPressedHandle = null;
		if(last) {
			this.endInput();
		}
	}
	beginSticky() {
		this.sticky = true;
		this._y -= this.currentWindow.scrollOffset;
	}
	endSticky() {
		this.sticky = false;
		this.scissor = true;
		this.g.scissor(0,this._y | 0,this._windowW | 0,this._windowH - this._y | 0);
		this.windowHeaderH += this._y - this.windowHeaderH;
		this._y += this.currentWindow.scrollOffset;
		this.isHovered = false;
	}
	endInput() {
		this.isKeyPressed = false;
		this.inputStarted = false;
		this.inputStartedR = false;
		this.inputReleased = false;
		this.inputReleasedR = false;
		this.inputDX = 0;
		this.inputDY = 0;
		this.inputWheelDelta = 0;
		if(zui_Zui.keyRepeat && this.isKeyDown && kha_Scheduler.time() - zui_Zui.keyRepeatTime > 0.05) {
			if(this.key == 8 || this.key == 46 || this.key == 37 || this.key == 39 || this.key == 38 || this.key == 40) {
				zui_Zui.keyRepeatTime = kha_Scheduler.time();
				this.isKeyPressed = true;
			}
		}
		if(zui_Zui.touchControls && this.inputDown && this.inputX == this.inputStartedX && this.inputY == this.inputStartedY && this.inputStartedTime > 0 && kha_Scheduler.time() - this.inputStartedTime > 0.5) {
			this.touchHold = true;
			this.inputStartedTime = 0;
		}
	}
	inputChanged() {
		if(!(this.inputDX != 0 || this.inputDY != 0 || this.inputWheelDelta != 0 || this.inputStarted || this.inputStartedR || this.inputReleased || this.inputReleasedR || this.inputDown || this.inputDownR)) {
			return this.isKeyPressed;
		} else {
			return true;
		}
	}
	windowDirty(handle,x,y,w,h) {
		let inputChanged = this.getInputInRect(x + handle.dragX,y + handle.dragY,w,h) && this.inputChanged();
		if(!(this.alwaysRedraw || this.isScrolling || this.isTyping)) {
			return inputChanged;
		} else {
			return true;
		}
	}
	window(handle,x,y,w,h,drag) {
		if(drag == null) {
			drag = false;
		}
		if(handle.texture == null || w != handle.texture.get_width() || h != handle.texture.get_height()) {
			this.resize(handle,w,h,this.ops.khaWindowId);
		}
		if(!this.windowEnded) {
			this.endWindow();
		}
		this.windowEnded = false;
		this.g = handle.texture.get_g2();
		this.currentWindow = handle;
		this._windowX = x + handle.dragX;
		this._windowY = y + handle.dragY;
		this._windowW = w;
		this._windowH = h;
		this.windowHeaderW = 0;
		this.windowHeaderH = 0;
		if(this.windowDirty(handle,x,y,w,h)) {
			handle.redraws = 2;
		}
		if(zui_Zui.onBorderHover != null) {
			if(this.getInputInRect(this._windowX - 4,this._windowY,8,this._windowH)) {
				zui_Zui.onBorderHover(handle,0);
			} else if(this.getInputInRect(this._windowX + this._windowW - 4,this._windowY,8,this._windowH)) {
				zui_Zui.onBorderHover(handle,1);
			} else if(this.getInputInRect(this._windowX,this._windowY - 4,this._windowW,8)) {
				zui_Zui.onBorderHover(handle,2);
			} else if(this.getInputInRect(this._windowX,this._windowY + this._windowH - 4,this._windowW,8)) {
				zui_Zui.onBorderHover(handle,3);
			}
		}
		if(handle.redraws <= 0) {
			return false;
		}
		this._x = 0;
		this._y = handle.scrollOffset;
		if(handle.layout == 1) {
			w = this.t.ELEMENT_W * this.ops.scaleFactor | 0;
		}
		this._w = !handle.scrollEnabled ? w : w - (this.t.SCROLL_W * this.ops.scaleFactor | 0);
		this._h = h;
		this.tooltipText = "";
		this.tooltipImg = null;
		this.tabNames = null;
		if(this.t.FILL_WINDOW_BG) {
			this.g.begin(true,this.t.WINDOW_BG_COL);
		} else {
			this.g.begin(true,0);
			this.g.set_color(this.t.WINDOW_BG_COL);
			this.g.fillRect(this._x,this._y - handle.scrollOffset,handle.lastMaxX,handle.lastMaxY);
		}
		handle.dragEnabled = drag;
		if(drag) {
			if(this.inputStarted && this.getInputInRect(this._windowX,this._windowY,this._windowW,15 * this.ops.scaleFactor | 0)) {
				this.dragHandle = handle;
			} else if(this.inputReleased) {
				this.dragHandle = null;
			}
			if(handle == this.dragHandle) {
				handle.redraws = 2;
				handle.dragX += this.inputDX | 0;
				handle.dragY += this.inputDY | 0;
			}
			this._y += 15 * this.ops.scaleFactor | 0;
			this.windowHeaderH += 15 * this.ops.scaleFactor | 0;
		}
		return true;
	}
	endWindow(bindGlobalG) {
		if(bindGlobalG == null) {
			bindGlobalG = true;
		}
		let handle = this.currentWindow;
		if(handle == null) {
			return;
		}
		if(handle.redraws > 0 || this.isScrolling || this.isTyping) {
			if(this.scissor) {
				this.scissor = false;
				this.g.disableScissor();
			}
			if(this.tabNames != null) {
				this.drawTabs();
			}
			if(handle.dragEnabled) {
				this.g.set_color(this.t.SEPARATOR_COL);
				this.g.fillRect(0,0,this._windowW,15 * this.ops.scaleFactor | 0);
			}
			let wh = this._windowH - this.windowHeaderH;
			let fullHeight = this._y - handle.scrollOffset - this.windowHeaderH;
			if(fullHeight < wh || handle.layout == 1 || !this.scrollEnabled) {
				handle.scrollEnabled = false;
				handle.scrollOffset = 0;
			} else {
				handle.scrollEnabled = true;
				if(this.tabScroll < 0) {
					handle.scrollOffset = this.tabScroll;
					this.tabScroll = 0;
				}
				let wy = this._windowY + this.windowHeaderH;
				let amountToScroll = fullHeight - wh;
				let barH = wh * Math.abs(wh / fullHeight);
				barH = Math.max(barH,this.t.ELEMENT_H * this.ops.scaleFactor);
				let totalScrollableArea = wh - barH;
				let barY = totalScrollableArea * (-handle.scrollOffset / amountToScroll) + this.windowHeaderH;
				let barFocus = this.getInputInRect(this._windowX + this._windowW - (this.t.SCROLL_W * this.ops.scaleFactor | 0),barY + this._windowY,this.t.SCROLL_W * this.ops.scaleFactor | 0,barH);
				if(this.inputStarted && barFocus) {
					this.scrollHandle = handle;
					this.isScrolling = true;
				}
				let scrollDelta = this.inputWheelDelta;
				if(zui_Zui.touchControls && this.inputDown && this.inputDY != 0) {
					this.isScrolling = true;
					scrollDelta = -this.inputDY / 20;
				}
				if(handle == this.scrollHandle) {
					this.scroll(this.inputDY * (amountToScroll / totalScrollableArea),fullHeight);
				} else if(scrollDelta != 0 && this.comboSelectedHandle == null && this.getInputInRect(this._windowX,wy,this._windowW,wh)) {
					this.scroll(scrollDelta * (this.t.ELEMENT_H * this.ops.scaleFactor),fullHeight);
				}
				if(handle.scrollOffset > 0) {
					handle.scrollOffset = 0;
				} else if(fullHeight + handle.scrollOffset < wh) {
					handle.scrollOffset = wh - fullHeight;
				}
				this.g.set_color(this.t.ACCENT_COL);
				let barW = this.getInputInRect(this._windowX + this._windowW - (this.t.SCROLL_W * this.ops.scaleFactor | 0),wy,this.t.SCROLL_W * this.ops.scaleFactor | 0,wh) || handle == this.scrollHandle ? this.t.SCROLL_W * this.ops.scaleFactor | 0 : (this.t.SCROLL_W * this.ops.scaleFactor | 0) / 3;
				this.g.fillRect(this._windowW - barW - this.scrollAlign,barY,barW,barH);
			}
			handle.lastMaxX = this._x;
			handle.lastMaxY = this._y;
			if(handle.layout == 0) {
				handle.lastMaxX += this._windowW;
			} else {
				handle.lastMaxY += this._windowH;
			}
			handle.redraws--;
			this.g.end();
		}
		this.windowEnded = true;
		if(zui_Zui.alwaysRedrawWindow || handle.redraws > -4) {
			if(bindGlobalG) {
				this.globalG.begin(false);
			}
			this.globalG.set_color(this.t.WINDOW_TINT_COL);
			this.globalG.drawImage(handle.texture,this._windowX,this._windowY);
			if(bindGlobalG) {
				this.globalG.end();
			}
			if(handle.redraws <= 0) {
				handle.redraws--;
			}
		}
	}
	scroll(delta,fullHeight) {
		this.currentWindow.scrollOffset -= delta;
	}
	tab(handle,text,vertical,color) {
		if(color == null) {
			color = -1;
		}
		if(vertical == null) {
			vertical = false;
		}
		if(this.tabNames == null) {
			this.tabNames = [];
			this.tabColors = [];
			this.tabHandle = handle;
			this.tabVertical = vertical;
			this._w -= this.tabVertical ? this.t.ELEMENT_OFFSET * this.ops.scaleFactor + this.t.ELEMENT_W * this.ops.scaleFactor - this.ops.scaleFactor | 0 : 0;
			if(vertical) {
				this.windowHeaderW += this.t.ELEMENT_W * this.ops.scaleFactor;
			} else {
				this.windowHeaderH += this.t.BUTTON_H * this.ops.scaleFactor + this.buttonOffsetY + this.t.ELEMENT_OFFSET * this.ops.scaleFactor;
			}
			this.restoreX = this.inputX;
			this.restoreY = this.inputY;
			if(!vertical && this.getInputInRect(this._windowX,this._windowY,this._windowW,this.windowHeaderH)) {
				this.inputX = this.inputY = -1;
			}
			if(vertical) {
				this._x += this.windowHeaderW + 6;
				this._w -= 6;
			} else {
				this._y += this.windowHeaderH + 3;
			}
		}
		this.tabNames.push(text);
		this.tabColors.push(color);
		return handle.position == this.tabNames.length - 1;
	}
	drawTabs() {
		this.inputX = this.restoreX;
		this.inputY = this.restoreY;
		if(this.currentWindow == null) {
			return;
		}
		let tabX = 0.0;
		let tabY = 0.0;
		let tabHMin = this.t.BUTTON_H * this.ops.scaleFactor * 1.1 | 0;
		let headerH = this.currentWindow.dragEnabled ? 15 * this.ops.scaleFactor | 0 : 0;
		let tabH = this.t.FULL_TABS && this.tabVertical ? (this._windowH - headerH) / this.tabNames.length | 0 : tabHMin;
		let origy = this._y;
		this._y = headerH;
		this.tabHandle.changed = false;
		if(this.isCtrlDown && this.isTabDown) {
			this.tabHandle.position++;
			if(this.tabHandle.position >= this.tabNames.length) {
				this.tabHandle.position = 0;
			}
			this.tabHandle.changed = true;
			this.isTabDown = false;
		}
		if(this.tabHandle.position >= this.tabNames.length) {
			this.tabHandle.position = this.tabNames.length - 1;
		}
		this.g.set_color(this.t.SEPARATOR_COL);
		if(this.tabVertical) {
			this.g.fillRect(0,this._y,this.t.ELEMENT_W * this.ops.scaleFactor,this._windowH);
		} else {
			this.g.fillRect(0,this._y,this._windowW,this.buttonOffsetY + tabH + 2);
		}
		this.g.set_color(this.t.ACCENT_COL);
		if(this.tabVertical) {
			this.g.fillRect(this.t.ELEMENT_W * this.ops.scaleFactor,this._y,1,this._windowH);
		} else {
			this.g.fillRect(this.buttonOffsetY,this._y + this.buttonOffsetY + tabH + 2,this._windowW - this.buttonOffsetY * 2,1);
		}
		let basey = this.tabVertical ? this._y : this._y + 2;
		let _g = 0;
		let _g1 = this.tabNames.length;
		while(_g < _g1) {
			let i = _g++;
			this._x = tabX;
			this._y = basey + tabY;
			this._w = this.tabVertical ? this.t.ELEMENT_W * this.ops.scaleFactor - this.ops.scaleFactor | 0 : this.t.FULL_TABS ? this._windowW / this.tabNames.length | 0 : this.ops.font.width(this.fontSize,this.tabNames[i]) + this.buttonOffsetY * 2 + 18 * this.ops.scaleFactor | 0;
			let released = this.getReleased(tabH);
			let pushed = this.getPushed(tabH);
			let hover = this.getHover(tabH);
			if(released) {
				let h = this.tabHandle.nest(this.tabHandle.position);
				h.scrollOffset = this.currentWindow.scrollOffset;
				h = this.tabHandle.nest(i);
				this.tabScroll = h.scrollOffset;
				this.tabHandle.position = i;
				this.currentWindow.redraws = 3;
				this.tabHandle.changed = true;
			}
			let selected = this.tabHandle.position == i;
			this.g.set_color(pushed || hover ? this.t.BUTTON_HOVER_COL : this.tabColors[i] != -1 ? this.tabColors[i] : selected ? this.t.WINDOW_BG_COL : this.t.SEPARATOR_COL);
			if(this.tabVertical) {
				tabY += tabH + 1;
			} else {
				tabX += this._w + 1;
			}
			let g = this.g;
			let x = this._x + this.buttonOffsetY;
			let y = this._y + this.buttonOffsetY;
			let w = this._w;
			if(!this.enabled) {
				this.fadeColor();
			}
			g.fillRect(x,y - 1,w,tabH + 1);
			this.g.set_color(selected ? this.t.BUTTON_TEXT_COL : this.t.LABEL_COL);
			this.drawString(this.g,this.tabNames[i],null,(tabH - tabHMin) / 2,this.t.FULL_TABS ? 1 : 0);
			if(selected) {
				if(this.tabVertical) {
					this.g.set_color(this.t.HIGHLIGHT_COL);
					this.g.fillRect(this._x + this.buttonOffsetY,this._y + this.buttonOffsetY - 1,2,tabH + this.buttonOffsetY);
				} else {
					this.g.set_color(this.t.WINDOW_BG_COL);
					this.g.fillRect(this._x + this.buttonOffsetY + 1,this._y + this.buttonOffsetY + tabH,this._w - 1,1);
					this.g.set_color(this.t.HIGHLIGHT_COL);
					this.g.fillRect(this._x + this.buttonOffsetY,this._y + this.buttonOffsetY,this._w,2);
				}
			}
		}
		this._x = 0;
		this._y = origy;
		this._w = (!this.currentWindow.scrollEnabled ? this._windowW : this._windowW - (this.t.SCROLL_W * this.ops.scaleFactor | 0)) | 0;
	}
	panel(handle,text,isTree,filled,pack) {
		if(pack == null) {
			pack = true;
		}
		if(filled == null) {
			filled = true;
		}
		if(isTree == null) {
			isTree = false;
		}
		if(!this.isVisible(this.t.ELEMENT_H * this.ops.scaleFactor)) {
			this.endElement();
			return handle.selected;
		}
		if(this.getReleased()) {
			handle.selected = !handle.selected;
			handle.changed = this.changed = true;
		}
		if(filled) {
			this.g.set_color(this.t.PANEL_BG_COL);
			let g = this.g;
			let x = this._x;
			let y = this._y;
			let w = this._w;
			let h = this.t.ELEMENT_H * this.ops.scaleFactor;
			if(!this.enabled) {
				this.fadeColor();
			}
			g.fillRect(x,y - 1,w,h + 1);
		}
		if(isTree) {
			this.drawTree(handle.selected);
		} else {
			this.drawArrow(handle.selected);
		}
		this.g.set_color(this.t.LABEL_COL);
		this.g.set_opacity(1.0);
		this.drawString(this.g,text,this.titleOffsetX,0);
		this.endElement();
		if(pack && !handle.selected) {
			this._y -= this.t.ELEMENT_OFFSET * this.ops.scaleFactor;
		}
		return handle.selected;
	}
	image(image,tint,h,sx,sy,sw,sh) {
		if(sh == null) {
			sh = 0;
		}
		if(sw == null) {
			sw = 0;
		}
		if(sy == null) {
			sy = 0;
		}
		if(sx == null) {
			sx = 0;
		}
		if(tint == null) {
			tint = -1;
		}
		let iw = (sw > 0 ? sw : image.get_width()) * this.ops.scaleFactor;
		let ih = (sh > 0 ? sh : image.get_height()) * this.ops.scaleFactor;
		let w = Math.min(iw,this._w);
		let x = this._x;
		let scroll = this.currentWindow != null && this.currentWindow.scrollEnabled;
		let r;
		if(this.curRatio == -1) {
			r = 1.0;
		} else {
			let ratio = this.ratios[this.curRatio];
			r = ratio < 0 ? -ratio : ratio;
		}
		if(this.imageScrollAlign) {
			w = Math.min(iw,this._w - this.buttonOffsetY * 2);
			x += this.buttonOffsetY;
			if(!scroll) {
				w -= (this.t.SCROLL_W * this.ops.scaleFactor | 0) * r;
				x += (this.t.SCROLL_W * this.ops.scaleFactor | 0) * r / 2;
			}
		} else if(scroll) {
			w += (this.t.SCROLL_W * this.ops.scaleFactor | 0) * r;
		}
		let ratio = h == null ? w / iw : h / ih;
		if(h == null) {
			h = ih * ratio;
		} else {
			w = iw * ratio;
		}
		if(!this.isVisible(h)) {
			this.endElement(h);
			return 0;
		}
		let started = this.getStarted(h);
		let down = this.getPushed(h);
		let released = this.getReleased(h);
		let hover = this.getHover(h);
		if(this.curRatio == -1 && (started || down || released || hover)) {
			if(this.inputX < this._windowX + this._x || this.inputX > this._windowX + this._x + w) {
				hover = false;
				released = false;
				down = false;
				started = false;
			}
		}
		this.g.set_color(tint);
		if(!this.enabled) {
			this.fadeColor();
		}
		let h_float = h;
		if(sw > 0) {
			if(this.imageInvertY) {
				this.g.drawScaledSubImage(image,sx,sy,sw,sh,x,this._y + h_float,w,-h_float);
			} else {
				this.g.drawScaledSubImage(image,sx,sy,sw,sh,x,this._y,w,h_float);
			}
		} else if(this.imageInvertY) {
			this.g.drawScaledImage(image,x,this._y + h_float,w,-h_float);
		} else {
			this.g.drawScaledImage(image,x,this._y,w,h_float);
		}
		this.endElement(h);
		if(started) {
			return 1;
		} else if(released) {
			return 3;
		} else if(down) {
			return 2;
		} else if(hover) {
			return 4;
		} else {
			return 0;
		}
	}
	text(text,align,bg) {
		if(bg == null) {
			bg = 0;
		}
		if(align == null) {
			align = 0;
		}
		if(text.indexOf("\n") >= 0) {
			let align1 = align;
			let bg1 = bg;
			if(bg == null) {
				bg1 = 0;
			}
			if(align == null) {
				align1 = 0;
			}
			let _g = 0;
			let _g1 = text.split("\n");
			while(_g < _g1.length) this.text(_g1[_g++],align1,bg1);
			return 0;
		}
		let h = Math.max(this.t.ELEMENT_H * this.ops.scaleFactor,this.ops.font.height(this.fontSize));
		if(!this.isVisible(h)) {
			this.endElement(h + this.t.ELEMENT_OFFSET * this.ops.scaleFactor);
			return 0;
		}
		let started = this.getStarted(h);
		let down = this.getPushed(h);
		let released = this.getReleased(h);
		this.getHover(h);
		if(bg != 0) {
			this.g.set_color(bg);
			this.g.fillRect(this._x + this.buttonOffsetY,this._y + this.buttonOffsetY,this._w - this.buttonOffsetY * 2,this.t.BUTTON_H * this.ops.scaleFactor);
		}
		this.g.set_color(this.t.TEXT_COL);
		this.drawString(this.g,text,null,0,align);
		this.endElement(h + this.t.ELEMENT_OFFSET * this.ops.scaleFactor);
		if(started) {
			return 1;
		} else if(released) {
			return 3;
		} else if(down) {
			return 2;
		} else {
			return 0;
		}
	}
	startTextEdit(handle,align) {
		if(align == null) {
			align = 0;
		}
		this.isTyping = true;
		this.submitTextHandle = this.textSelectedHandle;
		this.textToSubmit = this.textSelected;
		this.textSelectedHandle = handle;
		this.textSelected = handle.text;
		this.cursorX = handle.text.length;
		if(this.tabPressed) {
			this.tabPressed = false;
			this.isKeyPressed = false;
		} else if(!this.highlightOnSelect) {
			this.setCursorToInput(align);
		}
		this.tabPressedHandle = handle;
		this.highlightAnchor = this.highlightOnSelect ? 0 : this.cursorX;
		if(kha_input_Keyboard.get() != null) {
			kha_input_Keyboard.get().show();
		}
	}
	submitTextEdit() {
		this.submitTextHandle.text = this.textToSubmit;
		this.submitTextHandle.changed = this.changed = true;
		this.submitTextHandle = null;
		this.textToSubmit = "";
		this.textSelected = "";
	}
	updateTextEdit(align,editable) {
		if(editable == null) {
			editable = true;
		}
		if(align == null) {
			align = 0;
		}
		let text = this.textSelected;
		if(this.isKeyPressed) {
			if(this.key == 37) {
				if(this.cursorX > 0) {
					this.cursorX--;
				}
			} else if(this.key == 39) {
				if(this.cursorX < text.length) {
					this.cursorX++;
				}
			} else if(editable && this.key == 8) {
				if(this.cursorX > 0 && this.highlightAnchor == this.cursorX) {
					text = HxOverrides.substr(text,0,this.cursorX - 1) + HxOverrides.substr(text,this.cursorX,text.length);
					this.cursorX--;
				} else if(this.highlightAnchor < this.cursorX) {
					text = HxOverrides.substr(text,0,this.highlightAnchor) + HxOverrides.substr(text,this.cursorX,text.length);
					this.cursorX = this.highlightAnchor;
				} else {
					text = HxOverrides.substr(text,0,this.cursorX) + HxOverrides.substr(text,this.highlightAnchor,text.length);
				}
			} else if(editable && this.key == 46) {
				if(this.highlightAnchor == this.cursorX) {
					text = HxOverrides.substr(text,0,this.cursorX) + HxOverrides.substr(text,this.cursorX + 1,null);
				} else if(this.highlightAnchor < this.cursorX) {
					text = HxOverrides.substr(text,0,this.highlightAnchor) + HxOverrides.substr(text,this.cursorX,text.length);
					this.cursorX = this.highlightAnchor;
				} else {
					text = HxOverrides.substr(text,0,this.cursorX) + HxOverrides.substr(text,this.highlightAnchor,text.length);
				}
			} else if(this.key == 13) {
				this.deselectText();
			} else if(this.key == 27) {
				this.textSelected = this.textSelectedHandle.text;
				this.deselectText();
			} else if(this.key == 9 && this.tabSwitchEnabled && !this.isCtrlDown) {
				this.tabPressed = true;
				this.deselectText();
				this.key = null;
			} else if(this.key == 36) {
				this.cursorX = 0;
			} else if(this.key == 35) {
				this.cursorX = text.length;
			} else if(this.isCtrlDown && this.isADown) {
				this.cursorX = text.length;
				this.highlightAnchor = 0;
			} else if(editable && this.key != 16 && this.key != 20 && this.key != 17 && this.key != 224 && this.key != 18 && this.key != 38 && this.key != 40 && this.char != null && this.char != "" && HxOverrides.cca(this.char,0) >= 32) {
				text = HxOverrides.substr(text,0,this.highlightAnchor) + this.char + HxOverrides.substr(text,this.cursorX,null);
				this.cursorX = this.cursorX + 1 > text.length ? text.length : this.cursorX + 1;
			}
			if(!(this.isShiftDown && (this.key == 37 || this.key == 39 || this.key == 16)) && (!this.isCtrlDown || this.isCtrlDown && this.isAltDown)) {
				this.highlightAnchor = this.cursorX;
			}
		}
		if(editable && zui_Zui.textToPaste != "") {
			text = HxOverrides.substr(text,0,this.highlightAnchor) + zui_Zui.textToPaste + HxOverrides.substr(text,this.cursorX,null);
			this.cursorX += zui_Zui.textToPaste.length;
			this.highlightAnchor = this.cursorX;
			zui_Zui.textToPaste = "";
			zui_Zui.isPaste = false;
		}
		if(this.highlightAnchor == this.cursorX) {
			zui_Zui.textToCopy = text;
		} else if(this.highlightAnchor < this.cursorX) {
			zui_Zui.textToCopy = text.substring(this.highlightAnchor,this.cursorX);
		} else {
			zui_Zui.textToCopy = text.substring(this.cursorX,this.highlightAnchor);
		}
		if(editable && zui_Zui.isCut) {
			if(this.highlightAnchor == this.cursorX) {
				text = "";
			} else if(this.highlightAnchor < this.cursorX) {
				text = HxOverrides.substr(text,0,this.highlightAnchor) + HxOverrides.substr(text,this.cursorX,text.length);
				this.cursorX = this.highlightAnchor;
			} else {
				text = HxOverrides.substr(text,0,this.cursorX) + HxOverrides.substr(text,this.highlightAnchor,text.length);
			}
		}
		let off = this.t.TEXT_OFFSET * this.ops.scaleFactor;
		let cursorHeight = this.t.ELEMENT_H * this.ops.scaleFactor - this.buttonOffsetY * 3.0;
		if(this.highlightAnchor != this.cursorX) {
			let istart = this.cursorX;
			let iend = this.highlightAnchor;
			if(this.highlightAnchor < this.cursorX) {
				istart = this.highlightAnchor;
				iend = this.cursorX;
			}
			let hlstrw = this.ops.font.width(this.fontSize,HxOverrides.substr(text,istart,iend - istart));
			let startoff = this.ops.font.width(this.fontSize,HxOverrides.substr(text,0,istart));
			let hlStart = align == 0 ? this._x + startoff + off : this._x + this._w - hlstrw - off;
			if(align == 2) {
				hlStart -= this.ops.font.width(this.fontSize,HxOverrides.substr(text,iend,text.length));
			}
			this.g.set_color(this.t.ACCENT_SELECT_COL);
			this.g.fillRect(hlStart,this._y + this.buttonOffsetY * 1.5,hlstrw,cursorHeight);
		}
		if(this.isKeyDown || kha_Scheduler.time() % 1. < 0.5) {
			let strw = this.ops.font.width(this.fontSize,align == 0 ? HxOverrides.substr(text,0,this.cursorX) : text.substring(this.cursorX,text.length));
			let cursorX = align == 0 ? this._x + strw + off : this._x + this._w - strw - off;
			this.g.set_color(this.t.TEXT_COL);
			this.g.fillRect(cursorX,this._y + this.buttonOffsetY * 1.5,this.ops.scaleFactor,cursorHeight);
		}
		this.textSelected = text;
	}
	textInput(handle,label,align,editable) {
		if(editable == null) {
			editable = true;
		}
		if(align == null) {
			align = 0;
		}
		if(label == null) {
			label = "";
		}
		if(!this.isVisible(this.t.ELEMENT_H * this.ops.scaleFactor)) {
			this.endElement();
			return handle.text;
		}
		let hover = this.getHover();
		if(hover && zui_Zui.onTextHover != null) {
			zui_Zui.onTextHover();
		}
		this.g.set_color(hover ? this.t.ACCENT_HOVER_COL : this.t.ACCENT_COL);
		let g = this.g;
		let fill = this.t.FILL_ACCENT_BG;
		let x = this._x + this.buttonOffsetY;
		let y = this._y + this.buttonOffsetY;
		let w = this._w - this.buttonOffsetY * 2;
		let h = this.t.BUTTON_H * this.ops.scaleFactor;
		let strength = 0.0;
		strength = 1;
		if(!this.enabled) {
			this.fadeColor();
		}
		if(fill) {
			g.fillRect(x,y - 1,w,h + 1);
		} else {
			g.drawRect(x,y,w,h,strength);
		}
		let released = this.getReleased();
		if(this.submitTextHandle == handle && released) {
			this.textSelectedHandle = this.submitTextHandle;
			this.submitTextHandle = null;
			this.setCursorToInput(align);
		}
		if(this.textSelectedHandle != handle && (released || this.tabPressed)) {
			this.startTextEdit(handle,align);
		}
		if(this.textSelectedHandle == handle) {
			this.updateTextEdit(align,editable);
		}
		if(this.submitTextHandle == handle) {
			this.submitTextEdit();
		} else {
			handle.changed = false;
		}
		if(label != "") {
			this.g.set_color(this.t.LABEL_COL);
			let labelAlign = align == 2 ? 0 : 2;
			this.drawString(this.g,label,labelAlign == 0 ? null : 0,0,labelAlign);
		}
		this.g.set_color(this.t.TEXT_COL);
		if(this.textSelectedHandle != handle) {
			this.drawString(this.g,handle.text,null,0,align);
		} else {
			this.drawString(this.g,this.textSelected,null,0,align,false);
		}
		this.endElement();
		return handle.text;
	}
	setCursorToInput(align) {
		let off = align == 0 ? this.t.TEXT_OFFSET * this.ops.scaleFactor : this._w - this.ops.font.width(this.fontSize,this.textSelected);
		let x = this.inputX - (this._windowX + this._x + off);
		this.cursorX = 0;
		while(this.cursorX < this.textSelected.length && this.ops.font.width(this.fontSize,HxOverrides.substr(this.textSelected,0,this.cursorX)) < x) this.cursorX++;
		this.highlightAnchor = this.cursorX;
	}
	deselectText() {
		if(this.textSelectedHandle == null) {
			return;
		}
		this.submitTextHandle = this.textSelectedHandle;
		this.textToSubmit = this.textSelected;
		this.textSelectedHandle = null;
		this.isTyping = false;
		if(this.currentWindow != null) {
			this.currentWindow.redraws = 2;
		}
		if(kha_input_Keyboard.get() != null) {
			kha_input_Keyboard.get().hide();
		}
		this.highlightAnchor = this.cursorX;
	}
	button(text,align,label) {
		if(label == null) {
			label = "";
		}
		if(align == null) {
			align = 1;
		}
		if(!this.isVisible(this.t.ELEMENT_H * this.ops.scaleFactor)) {
			this.endElement();
			return false;
		}
		let released = this.getReleased();
		let pushed = this.getPushed();
		let hover = this.getHover();
		if(released) {
			this.changed = true;
		}
		this.g.set_color(pushed ? this.t.BUTTON_PRESSED_COL : hover ? this.t.BUTTON_HOVER_COL : this.t.BUTTON_COL);
		let g = this.g;
		let fill = this.t.FILL_BUTTON_BG;
		let x = this._x + this.buttonOffsetY;
		let y = this._y + this.buttonOffsetY;
		let w = this._w - this.buttonOffsetY * 2;
		let h = this.t.BUTTON_H * this.ops.scaleFactor;
		let strength = 0.0;
		strength = 1;
		if(!this.enabled) {
			this.fadeColor();
		}
		if(fill) {
			g.fillRect(x,y - 1,w,h + 1);
		} else {
			g.drawRect(x,y,w,h,strength);
		}
		this.g.set_color(this.t.BUTTON_TEXT_COL);
		this.drawString(this.g,text,null,0,align);
		if(label != "") {
			this.g.set_color(this.t.LABEL_COL);
			this.drawString(this.g,label,null,0,align == 2 ? 0 : 2);
		}
		this.endElement();
		return released;
	}
	check(handle,text) {
		if(!this.isVisible(this.t.ELEMENT_H * this.ops.scaleFactor)) {
			this.endElement();
			return handle.selected;
		}
		if(this.getReleased()) {
			handle.selected = !handle.selected;
			handle.changed = this.changed = true;
		} else {
			handle.changed = false;
		}
		let hover = this.getHover();
		this.drawCheck(handle.selected,hover);
		this.g.set_color(this.t.TEXT_COL);
		this.drawString(this.g,text,this.titleOffsetX,0,0);
		this.endElement();
		return handle.selected;
	}
	radio(handle,position,text) {
		if(!this.isVisible(this.t.ELEMENT_H * this.ops.scaleFactor)) {
			this.endElement();
			return handle.position == position;
		}
		if(position == 0) {
			handle.changed = false;
		}
		if(this.getReleased()) {
			handle.position = position;
			handle.changed = this.changed = true;
		}
		let hover = this.getHover();
		this.drawRadio(handle.position == position,hover);
		this.g.set_color(this.t.TEXT_COL);
		this.drawString(this.g,text,this.titleOffsetX,0);
		this.endElement();
		return handle.position == position;
	}
	combo(handle,texts,label,showLabel,align) {
		if(align == null) {
			align = 0;
		}
		if(showLabel == null) {
			showLabel = false;
		}
		if(label == null) {
			label = "";
		}
		if(!this.isVisible(this.t.ELEMENT_H * this.ops.scaleFactor)) {
			this.endElement();
			return handle.position;
		}
		if(this.getReleased()) {
			if(this.comboSelectedHandle == null) {
				this.inputEnabled = false;
				this.comboSelectedHandle = handle;
				this.comboSelectedWindow = this.currentWindow;
				this.comboSelectedAlign = align;
				this.comboSelectedTexts = texts;
				this.comboSelectedLabel = label;
				this.comboSelectedX = this._x + this._windowX | 0;
				this.comboSelectedY = this._y + this._windowY + this.t.ELEMENT_H * this.ops.scaleFactor | 0;
				this.comboSelectedW = this._w | 0;
				let _g = 0;
				while(_g < texts.length) {
					let w = (this.ops.font.width(this.fontSize,texts[_g++]) | 0) + 10;
					if(this.comboSelectedW < w) {
						this.comboSelectedW = w;
					}
				}
				if(this.comboSelectedW > this._w * 2) {
					this.comboSelectedW = this._w * 2 | 0;
				}
				if(this.comboSelectedW > this._w) {
					this.comboSelectedW += this.t.TEXT_OFFSET * this.ops.scaleFactor | 0;
				}
				this.comboToSubmit = handle.position;
			}
		}
		if(handle == this.submitComboHandle) {
			handle.position = this.comboToSubmit;
			this.submitComboHandle = null;
			handle.changed = this.changed = true;
		} else {
			handle.changed = false;
		}
		if(this.getHover()) {
			this.g.set_color(this.t.ACCENT_HOVER_COL);
			let g = this.g;
			let fill = this.t.FILL_ACCENT_BG;
			let x = this._x + this.buttonOffsetY;
			let y = this._y + this.buttonOffsetY;
			let w = this._w - this.buttonOffsetY * 2;
			let h = this.t.BUTTON_H * this.ops.scaleFactor;
			let strength = 0.0;
			strength = 1;
			if(!this.enabled) {
				this.fadeColor();
			}
			if(fill) {
				g.fillRect(x,y - 1,w,h + 1);
			} else {
				g.drawRect(x,y,w,h,strength);
			}
		} else {
			this.g.set_color(this.t.ACCENT_COL);
			let g = this.g;
			let fill = this.t.FILL_ACCENT_BG;
			let x = this._x + this.buttonOffsetY;
			let y = this._y + this.buttonOffsetY;
			let w = this._w - this.buttonOffsetY * 2;
			let h = this.t.BUTTON_H * this.ops.scaleFactor;
			let strength = 0.0;
			strength = 1;
			if(!this.enabled) {
				this.fadeColor();
			}
			if(fill) {
				g.fillRect(x,y - 1,w,h + 1);
			} else {
				g.drawRect(x,y,w,h,strength);
			}
		}
		let x = this._x + this._w - this.arrowOffsetX - 8;
		let y = this._y + this.arrowOffsetY + 3;
		this.g.fillTriangle(x,y,x + this.t.ARROW_SIZE * this.ops.scaleFactor,y,x + this.t.ARROW_SIZE * this.ops.scaleFactor / 2,y + this.t.ARROW_SIZE * this.ops.scaleFactor / 2);
		if(showLabel && label != "") {
			if(align == 0) {
				this._x -= 15;
			}
			this.g.set_color(this.t.LABEL_COL);
			this.drawString(this.g,label,null,0,align == 0 ? 2 : 0);
			if(align == 0) {
				this._x += 15;
			}
		}
		if(align == 2) {
			this._x -= 15;
		}
		this.g.set_color(this.t.TEXT_COL);
		if(handle.position < texts.length) {
			this.drawString(this.g,texts[handle.position],null,0,align);
		}
		if(align == 2) {
			this._x += 15;
		}
		this.endElement();
		return handle.position;
	}
	slider(handle,text,from,to,filled,precision,displayValue,align,textEdit) {
		if(textEdit == null) {
			textEdit = true;
		}
		if(align == null) {
			align = 2;
		}
		if(displayValue == null) {
			displayValue = true;
		}
		if(precision == null) {
			precision = 100.0;
		}
		if(filled == null) {
			filled = false;
		}
		if(to == null) {
			to = 1.0;
		}
		if(from == null) {
			from = 0.0;
		}
		if(!this.isVisible(this.t.ELEMENT_H * this.ops.scaleFactor)) {
			this.endElement();
			return handle.value;
		}
		if(this.getStarted()) {
			this.scrollHandle = handle;
			this.isScrolling = true;
			this.changed = handle.changed = true;
			if(zui_Zui.touchControls) {
				this.sliderTooltip = true;
				this.sliderTooltipX = this._x + this._windowX;
				this.sliderTooltipY = this._y + this._windowY;
				this.sliderTooltipW = this._w;
			}
		} else {
			handle.changed = false;
		}
		if(handle == this.scrollHandle && this.inputDX != 0) {
			handle.value = Math.round((from + (this.inputX - (this._x + this._windowX + this.buttonOffsetY)) * ((to - from) / (this._w - this.buttonOffsetY * 2))) * precision) / precision;
			if(handle.value < from) {
				handle.value = from;
			} else if(handle.value > to) {
				handle.value = to;
			}
			handle.changed = this.changed = true;
		}
		let hover = this.getHover();
		this.drawSlider(handle.value,from,to,filled,hover);
		if((this.getReleased() || this.tabPressed) && textEdit) {
			handle.text = handle.value + "";
			this.startTextEdit(handle);
			handle.changed = this.changed = true;
		}
		let lalign = align == 0 ? 2 : 0;
		if(this.textSelectedHandle == handle) {
			this.updateTextEdit(lalign);
		}
		if(this.submitTextHandle == handle) {
			this.submitTextEdit();
			try {
				let code = handle.text;
				handle.value = eval(code);
			} catch( _g ) {
			}
			handle.changed = this.changed = true;
		}
		this.g.set_color(this.t.LABEL_COL);
		this.drawString(this.g,text,null,0,align);
		if(displayValue) {
			this.g.set_color(this.t.TEXT_COL);
			if(this.textSelectedHandle != handle) {
				this.drawString(this.g,Math.round(handle.value * precision) / precision + "",null,0,lalign);
			} else {
				this.drawString(this.g,this.textSelected,null,0,lalign);
			}
		}
		this.endElement();
		return handle.value;
	}
	separator(h,fill) {
		if(fill == null) {
			fill = true;
		}
		if(h == null) {
			h = 4;
		}
		if(!this.isVisible(this.t.ELEMENT_H * this.ops.scaleFactor)) {
			this._y += h * this.ops.scaleFactor;
			return;
		}
		if(fill) {
			this.g.set_color(this.t.SEPARATOR_COL);
			this.g.fillRect(this._x,this._y,this._w,h * this.ops.scaleFactor);
		}
		this._y += h * this.ops.scaleFactor;
	}
	tooltip(text) {
		this.tooltipText = text;
		this.tooltipY = this._y + this._windowY;
	}
	tooltipImage(image,maxWidth) {
		this.tooltipImg = image;
		this.tooltipImgMaxWidth = maxWidth;
		this.tooltipInvertY = this.imageInvertY;
		this.tooltipY = this._y + this._windowY;
	}
	drawArrow(selected) {
		let x = this._x + this.arrowOffsetX;
		let y = this._y + this.arrowOffsetY;
		this.g.set_color(this.t.TEXT_COL);
		if(selected) {
			this.g.fillTriangle(x,y,x + this.t.ARROW_SIZE * this.ops.scaleFactor,y,x + this.t.ARROW_SIZE * this.ops.scaleFactor / 2,y + this.t.ARROW_SIZE * this.ops.scaleFactor);
		} else {
			this.g.fillTriangle(x,y,x,y + this.t.ARROW_SIZE * this.ops.scaleFactor,x + this.t.ARROW_SIZE * this.ops.scaleFactor,y + this.t.ARROW_SIZE * this.ops.scaleFactor / 2);
		}
	}
	drawTree(selected) {
		let SIGN_W = 7 * this.ops.scaleFactor;
		let x = this._x + this.arrowOffsetX + 1;
		let y = this._y + this.arrowOffsetY + 1;
		this.g.set_color(this.t.TEXT_COL);
		if(selected) {
			this.g.fillRect(x,y + SIGN_W / 2 - 1,SIGN_W,SIGN_W / 8);
		} else {
			this.g.fillRect(x,y + SIGN_W / 2 - 1,SIGN_W,SIGN_W / 8);
			this.g.fillRect(x + SIGN_W / 2 - 1,y,SIGN_W / 8,SIGN_W);
		}
	}
	drawCheck(selected,hover) {
		let x = this._x + this.checkOffsetX;
		let y = this._y + this.checkOffsetY;
		this.g.set_color(hover ? this.t.ACCENT_HOVER_COL : this.t.ACCENT_COL);
		let g = this.g;
		let fill = this.t.FILL_ACCENT_BG;
		let w = this.t.CHECK_SIZE * this.ops.scaleFactor;
		let h = this.t.CHECK_SIZE * this.ops.scaleFactor;
		let strength = 0.0;
		strength = 1;
		if(!this.enabled) {
			this.fadeColor();
		}
		if(fill) {
			g.fillRect(x,y - 1,w,h + 1);
		} else {
			g.drawRect(x,y,w,h,strength);
		}
		if(selected) {
			this.g.set_color(-1);
			if(!this.enabled) {
				this.fadeColor();
			}
			let size = this.t.CHECK_SELECT_SIZE * this.ops.scaleFactor | 0;
			this.g.drawScaledImage(this.checkSelectImage,x + this.checkSelectOffsetX,y + this.checkSelectOffsetY,size,size);
		}
	}
	drawRadio(selected,hover) {
		let x = this._x + this.radioOffsetX;
		let y = this._y + this.radioOffsetY;
		this.g.set_color(hover ? this.t.ACCENT_HOVER_COL : this.t.ACCENT_COL);
		let g = this.g;
		let fill = this.t.FILL_ACCENT_BG;
		let w = this.t.CHECK_SIZE * this.ops.scaleFactor;
		let h = this.t.CHECK_SIZE * this.ops.scaleFactor;
		let strength = 0.0;
		strength = 1;
		if(!this.enabled) {
			this.fadeColor();
		}
		if(fill) {
			g.fillRect(x,y - 1,w,h + 1);
		} else {
			g.drawRect(x,y,w,h,strength);
		}
		if(selected) {
			this.g.set_color(this.t.ACCENT_SELECT_COL);
			if(!this.enabled) {
				this.fadeColor();
			}
			this.g.fillRect(x + this.radioSelectOffsetX,y + this.radioSelectOffsetY,this.t.CHECK_SELECT_SIZE * this.ops.scaleFactor,this.t.CHECK_SELECT_SIZE * this.ops.scaleFactor);
		}
	}
	drawSlider(value,from,to,filled,hover) {
		let x = this._x + this.buttonOffsetY;
		let y = this._y + this.buttonOffsetY;
		let w = this._w - this.buttonOffsetY * 2;
		this.g.set_color(hover ? this.t.ACCENT_HOVER_COL : this.t.ACCENT_COL);
		let g = this.g;
		let fill = this.t.FILL_ACCENT_BG;
		let h = this.t.BUTTON_H * this.ops.scaleFactor;
		let strength = 0.0;
		strength = 1;
		if(!this.enabled) {
			this.fadeColor();
		}
		if(fill) {
			g.fillRect(x,y - 1,w,h + 1);
		} else {
			g.drawRect(x,y,w,h,strength);
		}
		this.g.set_color(hover ? this.t.ACCENT_HOVER_COL : this.t.ACCENT_COL);
		let offset = (value - from) / (to - from);
		let barW = 8 * this.ops.scaleFactor;
		let sliderX = filled ? x : x + (w - barW) * offset;
		sliderX = Math.max(Math.min(sliderX,x + (w - barW)),x);
		let sliderW = filled ? w * offset : barW;
		sliderW = Math.max(Math.min(sliderW,w),0);
		let g1 = this.g;
		let h1 = this.t.BUTTON_H * this.ops.scaleFactor;
		if(!this.enabled) {
			this.fadeColor();
		}
		g1.fillRect(sliderX,y - 1,sliderW,h1 + 1);
	}
	drawCombo() {
		if(this.comboSelectedHandle == null) {
			return;
		}
		let _g = this.g;
		this.globalG.set_color(this.t.SEPARATOR_COL);
		this.globalG.begin(false);
		let comboH = (this.comboSelectedTexts.length + (this.comboSelectedLabel != "" ? 1 : 0)) * (this.t.ELEMENT_H * this.ops.scaleFactor | 0);
		let distTop = this.comboSelectedY - comboH - (this.t.ELEMENT_H * this.ops.scaleFactor | 0) - this.windowBorderTop;
		let distBottom = kha_System.windowHeight() - this.windowBorderBottom - (this.comboSelectedY + comboH);
		let unrollUp = distBottom < 0 && distBottom < distTop;
		this.beginRegion(this.globalG,this.comboSelectedX,this.comboSelectedY,this.comboSelectedW);
		if(this.isKeyPressed || this.inputWheelDelta != 0) {
			if((this.isKeyPressed && this.key == (unrollUp ? 40 : 38) || (unrollUp && this.inputWheelDelta > 0 || !unrollUp && this.inputWheelDelta < 0)) && this.comboToSubmit > 0) {
				this.comboToSubmit--;
				this.submitComboHandle = this.comboSelectedHandle;
			} else if((this.isKeyPressed && this.key == (unrollUp ? 38 : 40) || (unrollUp && this.inputWheelDelta < 0 || !unrollUp && this.inputWheelDelta > 0)) && this.comboToSubmit < this.comboSelectedTexts.length - 1) {
				this.comboToSubmit++;
				this.submitComboHandle = this.comboSelectedHandle;
			}
			if(this.comboSelectedWindow != null) {
				this.comboSelectedWindow.redraws = 2;
			}
		}
		this.inputEnabled = true;
		let _BUTTON_COL = this.t.BUTTON_COL;
		let _ELEMENT_OFFSET = this.t.ELEMENT_OFFSET;
		this.t.ELEMENT_OFFSET = 0;
		let unrollRight = this._x + this.comboSelectedW * 2 < kha_System.windowWidth() - this.windowBorderRight ? 1 : -1;
		let _g1 = 0;
		let _g2 = this.comboSelectedTexts.length;
		while(_g1 < _g2) {
			let i = _g1++;
			if(unrollUp) {
				this._y -= this.t.ELEMENT_H * this.ops.scaleFactor * 2;
			}
			this.t.BUTTON_COL = i == this.comboSelectedHandle.position ? this.t.ACCENT_SELECT_COL : this.t.SEPARATOR_COL;
			this.fill(0,0,this._w / this.ops.scaleFactor,this.t.ELEMENT_H * this.ops.scaleFactor / this.ops.scaleFactor,this.t.SEPARATOR_COL);
			if(this.button(this.comboSelectedTexts[i],this.comboSelectedAlign)) {
				this.comboToSubmit = i;
				this.submitComboHandle = this.comboSelectedHandle;
				if(this.comboSelectedWindow != null) {
					this.comboSelectedWindow.redraws = 2;
				}
				break;
			}
			if(this._y + this.t.ELEMENT_H * this.ops.scaleFactor > kha_System.windowHeight() - this.windowBorderBottom || this._y - this.t.ELEMENT_H * this.ops.scaleFactor * 2 < this.windowBorderTop) {
				this._x += this.comboSelectedW * unrollRight;
				this._y = this.comboSelectedY;
			}
		}
		this.t.BUTTON_COL = _BUTTON_COL;
		this.t.ELEMENT_OFFSET = _ELEMENT_OFFSET;
		if(this.comboSelectedLabel != "") {
			if(unrollUp) {
				this._y -= this.t.ELEMENT_H * this.ops.scaleFactor * 2;
				this.fill(0,0,this._w / this.ops.scaleFactor,this.t.ELEMENT_H * this.ops.scaleFactor / this.ops.scaleFactor,this.t.SEPARATOR_COL);
				this.g.set_color(this.t.LABEL_COL);
				this.drawString(this.g,this.comboSelectedLabel,null,0,2);
				this._y += this.t.ELEMENT_H * this.ops.scaleFactor;
				this.fill(0,0,this._w / this.ops.scaleFactor,this.ops.scaleFactor,this.t.ACCENT_SELECT_COL);
			} else {
				this.fill(0,0,this._w / this.ops.scaleFactor,this.t.ELEMENT_H * this.ops.scaleFactor / this.ops.scaleFactor,this.t.SEPARATOR_COL);
				this.fill(0,0,this._w / this.ops.scaleFactor,this.ops.scaleFactor,this.t.ACCENT_SELECT_COL);
				this.g.set_color(this.t.LABEL_COL);
				this.drawString(this.g,this.comboSelectedLabel,null,0,2);
			}
		}
		if((this.inputReleased || this.isEscapeDown || this.isReturnDown) && !zui_Zui.comboFirst) {
			this.comboSelectedHandle = null;
			zui_Zui.comboFirst = true;
		} else {
			zui_Zui.comboFirst = false;
		}
		this.inputEnabled = this.comboSelectedHandle == null;
		this.endRegion(false);
		this.globalG.end();
		this.g = _g;
	}
	drawTooltip(bindGlobalG) {
		if(this.sliderTooltip) {
			if(bindGlobalG) {
				this.globalG.begin(false);
			}
			this.globalG.set_font(this.ops.font);
			this.globalG.set_fontSize(this.fontSize * 2);
			let text = Math.round(this.scrollHandle.value * 100) / 100 + "";
			let xoff = this.ops.font.width(this.globalG.get_fontSize(),text) / 2;
			let yoff = this.ops.font.height(this.globalG.get_fontSize());
			let x = Math.min(Math.max(this.sliderTooltipX,this.inputX),this.sliderTooltipX + this.sliderTooltipW);
			this.globalG.set_color(this.t.ACCENT_COL);
			this.globalG.fillRect(x - xoff,this.sliderTooltipY - yoff,xoff * 2,yoff);
			this.globalG.set_color(this.t.TEXT_COL);
			this.globalG.drawString(text,x - xoff,this.sliderTooltipY - yoff);
			if(bindGlobalG) {
				this.globalG.end();
			}
		}
		if(this.tooltipText != "" || this.tooltipImg != null) {
			if(this.inputChanged()) {
				this.tooltipShown = false;
				this.tooltipWait = this.inputDX == 0 && this.inputDY == 0;
			}
			if(!this.tooltipShown) {
				this.tooltipShown = true;
				this.tooltipX = this.inputX;
				this.tooltipTime = kha_Scheduler.time();
			}
			if(!this.tooltipWait && kha_Scheduler.time() - this.tooltipTime > 1.0) {
				if(this.tooltipImg != null) {
					this.drawTooltipImage(bindGlobalG);
				}
				if(this.tooltipText != "") {
					this.drawTooltipText(bindGlobalG);
				}
			}
		} else {
			this.tooltipShown = false;
		}
	}
	drawTooltipText(bindGlobalG) {
		this.globalG.set_color(this.t.TEXT_COL);
		let lines = this.tooltipText.split("\n");
		let tooltipW = 0.0;
		let _g = 0;
		while(_g < lines.length) {
			let lineTooltipW = this.ops.font.width(this.fontSize,lines[_g++]);
			if(lineTooltipW > tooltipW) {
				tooltipW = lineTooltipW;
			}
		}
		this.tooltipX = Math.min(this.tooltipX,kha_System.windowWidth() - tooltipW - 20);
		if(bindGlobalG) {
			this.globalG.begin(false);
		}
		let fontHeight = this.ops.font.height(this.fontSize);
		let off = 0;
		if(this.tooltipImg != null) {
			let w = this.tooltipImg.get_width();
			if(this.tooltipImgMaxWidth != null && w > this.tooltipImgMaxWidth) {
				w = this.tooltipImgMaxWidth;
			}
			off = this.tooltipImg.get_height() * (w / this.tooltipImg.get_width()) | 0;
		}
		this.globalG.fillRect(this.tooltipX,this.tooltipY + off,tooltipW + 20,fontHeight * lines.length);
		this.globalG.set_font(this.ops.font);
		this.globalG.set_fontSize(this.fontSize);
		this.globalG.set_color(this.t.ACCENT_COL);
		let _g1 = 0;
		let _g2 = lines.length;
		while(_g1 < _g2) {
			let i = _g1++;
			this.globalG.drawString(lines[i],this.tooltipX + 5,this.tooltipY + off + i * this.fontSize);
		}
		if(bindGlobalG) {
			this.globalG.end();
		}
	}
	drawTooltipImage(bindGlobalG) {
		let w = this.tooltipImg.get_width();
		if(this.tooltipImgMaxWidth != null && w > this.tooltipImgMaxWidth) {
			w = this.tooltipImgMaxWidth;
		}
		let h = this.tooltipImg.get_height() * (w / this.tooltipImg.get_width());
		this.tooltipX = Math.min(this.tooltipX,kha_System.windowWidth() - w - 20);
		this.tooltipY = Math.min(this.tooltipY,kha_System.windowHeight() - h - 20);
		if(bindGlobalG) {
			this.globalG.begin(false);
		}
		this.globalG.set_color(-16777216);
		this.globalG.fillRect(this.tooltipX,this.tooltipY,w,h);
		this.globalG.set_color(-1);
		if(this.tooltipInvertY) {
			this.globalG.drawScaledImage(this.tooltipImg,this.tooltipX,this.tooltipY + h,w,-h);
		} else {
			this.globalG.drawScaledImage(this.tooltipImg,this.tooltipX,this.tooltipY,w,h);
		}
		if(bindGlobalG) {
			this.globalG.end();
		}
	}
	drawString(g,text,xOffset,yOffset,align,truncation) {
		if(truncation == null) {
			truncation = true;
		}
		if(align == null) {
			align = 0;
		}
		if(yOffset == null) {
			yOffset = 0;
		}
		let fullText = text;
		if(truncation) {
			while(text.length > 0 && this.ops.font.width(this.fontSize,text) > this._w - 6 * this.ops.scaleFactor) text = HxOverrides.substr(text,0,text.length - 1);
			if(text.length < fullText.length) {
				text += "..";
				while(text.length > 2 && this.ops.font.width(this.fontSize,text) > this._w - 10 * this.ops.scaleFactor) text = HxOverrides.substr(text,0,text.length - 3) + "..";
				if(this.isHovered) {
					this.tooltip(fullText);
				}
			}
		}
		if(zui_Zui.dynamicGlyphLoad) {
			let _g = 0;
			let _g1 = text.length;
			while(_g < _g1) {
				let i = _g++;
				if(HxOverrides.cca(text,i) > 126 && kha_graphics2_Graphics.fontGlyphs.indexOf(HxOverrides.cca(text,i)) == -1) {
					kha_graphics2_Graphics.fontGlyphs.push(HxOverrides.cca(text,i));
					kha_graphics2_Graphics.fontGlyphs = kha_graphics2_Graphics.fontGlyphs.slice();
				}
			}
		}
		if(xOffset == null) {
			xOffset = this.t.TEXT_OFFSET;
		}
		xOffset *= this.ops.scaleFactor;
		g.set_font(this.ops.font);
		g.set_fontSize(this.fontSize);
		if(align == 1) {
			xOffset = this._w / 2 - this.ops.font.width(this.fontSize,text) / 2;
		} else if(align == 2) {
			xOffset = this._w - this.ops.font.width(this.fontSize,text) - this.t.TEXT_OFFSET * this.ops.scaleFactor;
		}
		if(!this.enabled) {
			this.fadeColor();
		}
		g.set_pipeline(this.rtTextPipeline);
		g.drawString(text,this._x + xOffset,this._y + this.fontOffsetY + yOffset);
		g.set_pipeline(null);
	}
	endElement(elementSize) {
		if(elementSize == null) {
			elementSize = this.t.ELEMENT_H * this.ops.scaleFactor + this.t.ELEMENT_OFFSET * this.ops.scaleFactor;
		}
		if(this.currentWindow == null || this.currentWindow.layout == 0) {
			if(this.curRatio == -1 || this.ratios != null && this.curRatio == this.ratios.length - 1) {
				this._y += elementSize;
				if(this.ratios != null && this.curRatio == this.ratios.length - 1) {
					this.curRatio = -1;
					this.ratios = null;
					this._x = this.xBeforeSplit;
					this._w = this.wBeforeSplit;
					this.highlightFullRow = false;
				}
			} else {
				this.curRatio++;
				this._x += this._w;
				let ratio = this.ratios[this.curRatio];
				this._w = (ratio < 0 ? -ratio : ratio * this.wBeforeSplit) | 0;
			}
		} else {
			this._x += this._w + this.t.ELEMENT_OFFSET * this.ops.scaleFactor;
		}
	}
	row(ratios) {
		this.ratios = ratios;
		this.curRatio = 0;
		this.xBeforeSplit = this._x;
		this.wBeforeSplit = this._w;
		let ratio = ratios[this.curRatio];
		this._w = (ratio < 0 ? -ratio : ratio * this._w) | 0;
	}
	fadeColor() {
		this.g.set_color(kha_Color.fromFloats(((this.g.get_color() & 16711680) >>> 16) * 0.00392156862745098,((this.g.get_color() & 65280) >>> 8) * 0.00392156862745098,(this.g.get_color() & 255) * 0.00392156862745098,0.25));
	}
	fill(x,y,w,h,color) {
		this.g.set_color(color);
		if(!this.enabled) {
			this.fadeColor();
		}
		this.g.fillRect(this._x + x * this.ops.scaleFactor,this._y + y * this.ops.scaleFactor - 1,w * this.ops.scaleFactor,h * this.ops.scaleFactor);
		this.g.set_color(-1);
	}
	rect(x,y,w,h,color,strength) {
		if(strength == null) {
			strength = 1.0;
		}
		this.g.set_color(color);
		if(!this.enabled) {
			this.fadeColor();
		}
		this.g.drawRect(this._x + x * this.ops.scaleFactor,this._y + y * this.ops.scaleFactor,w * this.ops.scaleFactor,h * this.ops.scaleFactor,strength);
		this.g.set_color(-1);
	}
	isVisible(elemH) {
		if(this.currentWindow == null) {
			return true;
		}
		if(this._y + elemH > this.windowHeaderH) {
			return this._y < this.currentWindow.texture.get_height();
		} else {
			return false;
		}
	}
	getReleased(elemH) {
		if(elemH == null) {
			elemH = -1.0;
		}
		this.isReleased = this.enabled && this.inputEnabled && this.inputReleased && this.getHover(elemH) && this.getInitialHover(elemH);
		return this.isReleased;
	}
	getPushed(elemH) {
		if(elemH == null) {
			elemH = -1.0;
		}
		this.isPushed = this.enabled && this.inputEnabled && this.inputDown && this.getHover(elemH) && this.getInitialHover(elemH);
		return this.isPushed;
	}
	getStarted(elemH) {
		if(elemH == null) {
			elemH = -1.0;
		}
		this.isStarted = this.enabled && this.inputEnabled && this.inputStarted && this.getHover(elemH);
		return this.isStarted;
	}
	getInitialHover(elemH) {
		if(elemH == null) {
			elemH = -1.0;
		}
		if(this.scissor && this.inputY < this._windowY + this.windowHeaderH) {
			return false;
		}
		if(elemH == -1.0) {
			elemH = this.t.ELEMENT_H * this.ops.scaleFactor;
		}
		if(this.enabled && this.inputEnabled && this.inputStartedX >= this._windowX + this._x && this.inputStartedX < this._windowX + this._x + this._w && this.inputStartedY >= this._windowY + this._y) {
			return this.inputStartedY < this._windowY + this._y + elemH;
		} else {
			return false;
		}
	}
	getHover(elemH) {
		if(elemH == null) {
			elemH = -1.0;
		}
		if(this.scissor && this.inputY < this._windowY + this.windowHeaderH) {
			return false;
		}
		if(elemH == -1.0) {
			elemH = this.t.ELEMENT_H * this.ops.scaleFactor;
		}
		this.isHovered = this.enabled && this.inputEnabled && this.inputX >= this._windowX + (this.highlightFullRow ? 0 : this._x) && this.inputX < this._windowX + this._x + (this.highlightFullRow ? this._windowW : this._w) && this.inputY >= this._windowY + this._y && this.inputY < this._windowY + this._y + elemH;
		return this.isHovered;
	}
	getInputInRect(x,y,w,h,scale) {
		if(scale == null) {
			scale = 1.0;
		}
		if(this.enabled && this.inputEnabled && this.inputX >= x * scale && this.inputX < (x + w) * scale && this.inputY >= y * scale) {
			return this.inputY < (y + h) * scale;
		} else {
			return false;
		}
	}
	onMouseDown(button,x,y) {
		if(button == 0) {
			this.inputStarted = true;
		} else {
			this.inputStartedR = true;
		}
		if(button == 0) {
			this.inputDown = true;
		} else {
			this.inputDownR = true;
		}
		this.inputStartedTime = kha_Scheduler.time();
		this.inputStartedX = x;
		this.inputStartedY = y;
	}
	onMouseUp(button,x,y) {
		if(this.isScrolling) {
			this.isScrolling = false;
			this.scrollHandle = null;
			this.sliderTooltip = false;
			if(x == this.inputStartedX && y == this.inputStartedY) {
				if(button == 0) {
					this.inputReleased = true;
				} else {
					this.inputReleasedR = true;
				}
			}
		} else if(button == 0) {
			this.inputReleased = true;
		} else {
			this.inputReleasedR = true;
		}
		if(button == 0) {
			this.inputDown = false;
		} else {
			this.inputDownR = false;
		}
		this.deselectText();
		if(this.touchHold) {
			this.touchHold = false;
			this.inputReleased = false;
			this.inputReleasedR = true;
		}
	}
	onMouseMove(x,y,movementX,movementY) {
		this.setInputPosition(x,y);
	}
	onMouseWheel(delta) {
		this.inputWheelDelta = delta;
	}
	setInputPosition(x,y) {
		this.inputDX += x - this.inputX;
		this.inputDY += y - this.inputY;
		this.inputX = x;
		this.inputY = y;
	}
	onKeyDown(code) {
		this.key = code;
		this.isKeyPressed = true;
		this.isKeyDown = true;
		zui_Zui.keyRepeatTime = kha_Scheduler.time() + 0.4;
		switch(code) {
		case 8:
			this.isBackspaceDown = true;
			break;
		case 9:
			this.isTabDown = true;
			break;
		case 13:
			this.isReturnDown = true;
			break;
		case 16:
			this.isShiftDown = true;
			break;
		case 17:
			this.isCtrlDown = true;
			break;
		case 18:
			this.isAltDown = true;
			break;
		case 27:
			this.isEscapeDown = true;
			break;
		case 32:
			this.char = " ";
			break;
		case 46:
			this.isDeleteDown = true;
			break;
		case 65:
			this.isADown = true;
			break;
		default:
		}
	}
	onKeyUp(code) {
		this.isKeyDown = false;
		switch(code) {
		case 8:
			this.isBackspaceDown = false;
			break;
		case 9:
			this.isTabDown = false;
			break;
		case 13:
			this.isReturnDown = false;
			break;
		case 16:
			this.isShiftDown = false;
			break;
		case 17:
			this.isCtrlDown = false;
			break;
		case 18:
			this.isAltDown = false;
			break;
		case 27:
			this.isEscapeDown = false;
			break;
		case 46:
			this.isDeleteDown = false;
			break;
		case 65:
			this.isADown = false;
			break;
		default:
		}
	}
	onKeyPress(char) {
		this.char = char;
		this.isKeyPressed = true;
	}
	onCut() {
		zui_Zui.isCut = true;
		return this.onCopy();
	}
	onCopy() {
		zui_Zui.isCopy = true;
		return zui_Zui.textToCopy;
	}
	onPaste(s) {
		zui_Zui.isPaste = true;
		zui_Zui.textToPaste = s;
	}
	resize(handle,w,h,khaWindowId) {
		if(khaWindowId == null) {
			khaWindowId = 0;
		}
		handle.redraws = 2;
		if(handle.texture != null) {
			handle.texture.unload();
		}
		if(w < 1) {
			w = 1;
		}
		if(h < 1) {
			h = 1;
		}
		handle.texture = kha_Image.createRenderTarget(w,h,0,0,1,khaWindowId);
		handle.texture.get_g2().set_imageScaleQuality(kha_graphics2_ImageScaleQuality.High);
	}
}
$hxClasses["zui.Zui"] = zui_Zui;
zui_Zui.__name__ = "zui.Zui";
Object.assign(zui_Zui.prototype, {
	__class__: zui_Zui
});
class arm_ZuiBridge {
}
$hxClasses["arm.ZuiBridge"] = $hx_exports["zui"] = arm_ZuiBridge;
arm_ZuiBridge.__name__ = "arm.ZuiBridge";
class arm_ui_UIStatus {
	constructor() {
		this.statustab = zui_Handle.global.nest(102,null);
		this.statusHandle = new zui_Handle();
		arm_ui_UIStatus.inst = this;
	}
	renderUI(g) {
		let ui = arm_ui_UISidebar.inst.ui;
		let statush = arm_Config.raw.layout[5];
		if(ui.window(this.statusHandle,arm_App.x(),kha_System.windowHeight() - statush,kha_System.windowWidth() - arm_ui_UIToolbar.inst.toolbarw - arm_Config.raw.layout[0],statush)) {
			ui._y += 2;
			ui.g.set_color(ui.t.SEPARATOR_COL);
			ui.g.fillRect(0,0,1,ui._windowH);
			ui.g.fillRect(ui._windowW - 1,0,1,ui._windowH);
			arm_ui_TabBrowser.draw();
			arm_ui_TabTextures.draw();
			arm_ui_TabMeshes.draw();
			arm_ui_TabFonts.draw();
			arm_ui_TabSwatches.draw();
			arm_ui_TabScript.draw();
			arm_ui_TabConsole.draw();
			if(this.statustab.changed && (this.statustab.position == arm_Context.lastStatusPosition || statush <= 32 * arm_Config.raw.window_scale)) {
				arm_ui_UISidebar.inst.toggleBrowser();
			}
			arm_Context.lastStatusPosition = this.statustab.position;
		}
	}
}
$hxClasses["arm.ui.UIStatus"] = arm_ui_UIStatus;
arm_ui_UIStatus.__name__ = "arm.ui.UIStatus";
Object.assign(arm_ui_UIStatus.prototype, {
	__class__: arm_ui_UIStatus
});
class arm_ui_UISidebar {
	constructor() {
		this.borderHandle = null;
		this.borderStarted = 0;
		this.hminimize = zui_Handle.global.nest(170,null);
		this.htab1 = zui_Handle.global.nest(0,null);
		this.htab0 = zui_Handle.global.nest(104,null);
		this.hwnd1 = zui_Handle.global.nest(3,null);
		this.hwnd0 = zui_Handle.global.nest(4,null);
		this.show = true;
		this.tabx = 0;
		arm_ui_UISidebar.inst = this;
		new arm_ui_UIToolbar();
		new arm_ui_UIHeader();
		new arm_ui_UIStatus();
		new arm_ui_UIMenubar();
		arm_Context.textToolText = arm_Translator.tr("Text");
		arm_ui_UIToolbar.inst.toolbarw = 36 * arm_Config.raw.window_scale | 0;
		arm_ui_UIHeader.inst.headerh = 28 * arm_Config.raw.window_scale | 0;
		arm_ui_UIMenubar.inst.menubarw = 330 * arm_Config.raw.window_scale | 0;
		if(arm_Project.materials == null) {
			arm_Project.materials = [];
			iron_data_Data.getMaterial("Scene","Material",function(m) {
				arm_Project.materials.push(new arm_data_MaterialSlot(m));
				arm_Context.material = arm_Project.materials[0];
			});
		}
		if(arm_Project.brushes == null) {
			arm_Project.brushes = [];
			arm_Project.brushes.push(new arm_data_BrushSlot());
			arm_Context.brush = arm_Project.brushes[0];
			arm_node_MakeMaterial.parseBrush();
		}
		if(arm_Project.fonts == null) {
			arm_Project.fonts = [];
			let fontNames = arm_App.font.getFontNames();
			arm_Project.fonts.push(new arm_data_FontSlot(fontNames.length > 0 ? fontNames[0] : "default.ttf",arm_App.font));
			arm_Context.font = arm_Project.fonts[0];
		}
		if(arm_Project.layers == null) {
			arm_Project.layers = [];
			arm_Project.layers.push(new arm_data_LayerSlot());
			arm_Context.layer = arm_Project.layers[0];
		}
		if(arm_Project.raw.swatches == null) {
			arm_Project.setDefaultSwatches();
			arm_Context.swatch = arm_Project.raw.swatches[0];
		}
		if(arm_Context.emptyEnvmap == null) {
			let b = new haxe_io_Bytes(new ArrayBuffer(4));
			b.b[0] = 2;
			b.b[1] = 2;
			b.b[2] = 2;
			b.b[3] = 255;
			arm_Context.emptyEnvmap = kha_Image.fromBytes(b,1,1);
		}
		if(arm_Context.previewEnvmap == null) {
			let b = new haxe_io_Bytes(new ArrayBuffer(4));
			b.b[0] = 0;
			b.b[1] = 0;
			b.b[2] = 0;
			b.b[3] = 255;
			arm_Context.previewEnvmap = kha_Image.fromBytes(b,1,1);
		}
		let world = iron_Scene.active.world;
		if(arm_Context.savedEnvmap == null) {
			arm_Context.defaultIrradiance = world.probe.irradiance;
			arm_Context.defaultRadiance = world.probe.radiance;
			arm_Context.defaultRadianceMipmaps = world.probe.radianceMipmaps;
		}
		world.envmap = arm_Context.showEnvmap ? arm_Context.savedEnvmap : arm_Context.emptyEnvmap;
		arm_Context.ddirty = 1;
		arm_History.reset();
		this.ui = new zui_Zui({ theme : arm_App.theme, font : arm_App.font, scaleFactor : arm_Config.raw.window_scale, color_wheel : arm_App.colorWheel});
		zui_Zui.onBorderHover = $bind(this,this.onBorderHover);
		zui_Zui.onTextHover = $bind(this,this.onTextHover);
		arm_Res.load(["cursor.k","icons.k"],$bind(this,this.done));
		arm_Context.projectObjects = [];
		let _g = 0;
		let _g1 = iron_Scene.active.meshes;
		while(_g < _g1.length) arm_Context.projectObjects.push(_g1[_g++]);
	}
	done() {
		if(this.ui.ops.scaleFactor > 1) {
			this.setIconScale();
		}
		arm_Context.gizmo = iron_Scene.active.getChild(".Gizmo");
		arm_Context.gizmoTranslateX = arm_Context.gizmo.getChild(".TranslateX");
		arm_Context.gizmoTranslateY = arm_Context.gizmo.getChild(".TranslateY");
		arm_Context.gizmoTranslateZ = arm_Context.gizmo.getChild(".TranslateZ");
		arm_Context.gizmoScaleX = arm_Context.gizmo.getChild(".ScaleX");
		arm_Context.gizmoScaleY = arm_Context.gizmo.getChild(".ScaleY");
		arm_Context.gizmoScaleZ = arm_Context.gizmo.getChild(".ScaleZ");
		arm_Context.gizmoRotateX = arm_Context.gizmo.getChild(".RotateX");
		arm_Context.gizmoRotateY = arm_Context.gizmo.getChild(".RotateY");
		arm_Context.gizmoRotateZ = arm_Context.gizmo.getChild(".RotateZ");
		arm_Context.paintObject = js_Boot.__cast(iron_Scene.active.getChild(".Cube") , iron_object_MeshObject);
		arm_Project.paintObjects = [arm_Context.paintObject];
		if(arm_Project.filepath == "") {
			iron_App.notifyOnInit(arm_Layers.initLayers);
		}
	}
	update() {
		this.updateUI();
		let h = arm_Plugin.plugins.h;
		let p_keys = Object.keys(h);
		let p_length = p_keys.length;
		let p_current = 0;
		while(p_current < p_length) {
			let p = h[p_keys[p_current++]];
			if(p.update != null) {
				p.update();
			}
		}
		if(!arm_App.uiEnabled) {
			return;
		}
		if(!arm_ui_UINodes.inst.ui.isTyping && !this.ui.isTyping) {
			if(arm_Operator.shortcut(arm_Config.keymap.toggle_2d_view)) {
				this.show2DView(0);
			} else if(arm_Operator.shortcut(arm_Config.keymap.toggle_node_editor)) {
				if(arm_ui_UINodes.inst.canvasType == 0) {
					this.showMaterialNodes();
				} else {
					this.showBrushNodes();
				}
			} else if(arm_Operator.shortcut(arm_Config.keymap.toggle_browser)) {
				this.toggleBrowser();
			}
		}
		if(arm_Operator.shortcut(arm_Config.keymap.file_save_as)) {
			arm_Project.projectSaveAs();
		} else if(arm_Operator.shortcut(arm_Config.keymap.file_save)) {
			arm_Project.projectSave();
		} else if(arm_Operator.shortcut(arm_Config.keymap.file_open)) {
			arm_Project.projectOpen();
		} else if(arm_Operator.shortcut(arm_Config.keymap.file_open_recent)) {
			arm_Project.projectOpenRecentBox();
		} else if(arm_Operator.shortcut(arm_Config.keymap.file_reimport_mesh)) {
			arm_Project.reimportMesh();
		} else if(arm_Operator.shortcut(arm_Config.keymap.file_reimport_textures)) {
			arm_Project.reimportTextures();
		} else if(arm_Operator.shortcut(arm_Config.keymap.file_new)) {
			arm_Project.projectNewBox();
		} else if(arm_Operator.shortcut(arm_Config.keymap.file_export_textures)) {
			if(arm_Context.textureExportPath == "") {
				arm_Context.layersExport = 0;
				arm_ui_BoxExport.showTextures();
			} else {
				iron_App.notifyOnInit(function() {
					arm_io_ExportTexture.run(arm_Context.textureExportPath);
				});
			}
		} else if(arm_Operator.shortcut(arm_Config.keymap.file_export_textures_as)) {
			arm_Context.layersExport = 0;
			arm_ui_BoxExport.showTextures();
		} else if(arm_Operator.shortcut(arm_Config.keymap.file_import_assets)) {
			arm_Project.importAsset();
		} else if(arm_Operator.shortcut(arm_Config.keymap.edit_prefs)) {
			arm_ui_BoxPreferences.show();
		}
		let kb = iron_system_Input.getKeyboard();
		if(kb.started(arm_Config.keymap.view_distract_free) || kb.started("escape") && !this.show && !arm_ui_UIBox.show) {
			this.toggleDistractFree();
		}
		let mouse = iron_system_Input.getMouse();
		let decalMask = (arm_Context.tool == 3 || arm_Context.tool == 4) && arm_Operator.shortcut(arm_Config.keymap.decal_mask,2);
		if((arm_Context.brushCanLock || arm_Context.brushLocked) && mouse.moved) {
			if(arm_Operator.shortcut(arm_Config.keymap.brush_radius,2) || arm_Operator.shortcut(arm_Config.keymap.brush_opacity,2) || arm_Operator.shortcut(arm_Config.keymap.brush_angle,2) || decalMask && arm_Operator.shortcut(arm_Config.keymap.decal_mask + "+" + arm_Config.keymap.brush_radius,2)) {
				if(arm_Context.brushLocked) {
					if(arm_Operator.shortcut(arm_Config.keymap.brush_opacity,2)) {
						arm_Context.brushOpacity += mouse.movementX / 500;
						arm_Context.brushOpacity = Math.max(0.0,Math.min(1.0,arm_Context.brushOpacity));
						arm_Context.brushOpacity = Math.round(arm_Context.brushOpacity * 100) / 100;
						arm_Context.brushOpacityHandle.value = arm_Context.brushOpacity;
					} else if(arm_Operator.shortcut(arm_Config.keymap.brush_angle,2)) {
						arm_Context.brushAngle += mouse.movementX / 5;
						arm_Context.brushAngle = (arm_Context.brushAngle | 0) % 360;
						if(arm_Context.brushAngle < 0) {
							arm_Context.brushAngle += 360;
						}
						arm_Context.brushAngleHandle.value = arm_Context.brushAngle;
						arm_node_MakeMaterial.parsePaintMaterial();
					} else if(decalMask && arm_Operator.shortcut(arm_Config.keymap.decal_mask + "+" + arm_Config.keymap.brush_radius,2)) {
						arm_Context.brushDecalMaskRadius += mouse.movementX / 150;
						arm_Context.brushDecalMaskRadius = Math.max(0.01,Math.min(4.0,arm_Context.brushDecalMaskRadius));
						arm_Context.brushDecalMaskRadius = Math.round(arm_Context.brushDecalMaskRadius * 100) / 100;
						arm_Context.brushDecalMaskRadiusHandle.value = arm_Context.brushDecalMaskRadius;
					} else {
						arm_Context.brushRadius += mouse.movementX / 150;
						arm_Context.brushRadius = Math.max(0.01,Math.min(4.0,arm_Context.brushRadius));
						arm_Context.brushRadius = Math.round(arm_Context.brushRadius * 100) / 100;
						arm_Context.brushRadiusHandle.value = arm_Context.brushRadius;
					}
					arm_ui_UIHeader.inst.headerHandle.redraws = 2;
				} else if(arm_Context.brushCanLock) {
					arm_Context.brushCanLock = false;
					arm_Context.brushLocked = true;
				}
			}
		}
		let right = arm_App.w();
		if(arm_ui_UIView2D.inst.show) {
			right += arm_ui_UIView2D.inst.ww;
		}
		let decalMask1 = (arm_Context.tool == 3 || arm_Context.tool == 4) && arm_Operator.shortcut(arm_Config.keymap.decal_mask,2);
		let isTyping = this.ui.isTyping || arm_ui_UIView2D.inst.ui.isTyping || arm_ui_UINodes.inst.ui.isTyping;
		if(!isTyping) {
			if(arm_Operator.shortcut(arm_Config.keymap.select_material,2)) {
				if(kb.started(1 + "")) {
					arm_Context.selectMaterial(0);
				}
				if(kb.started(2 + "")) {
					arm_Context.selectMaterial(1);
				}
				if(kb.started(3 + "")) {
					arm_Context.selectMaterial(2);
				}
				if(kb.started(4 + "")) {
					arm_Context.selectMaterial(3);
				}
				if(kb.started(5 + "")) {
					arm_Context.selectMaterial(4);
				}
				if(kb.started(6 + "")) {
					arm_Context.selectMaterial(5);
				}
				if(kb.started(7 + "")) {
					arm_Context.selectMaterial(6);
				}
				if(kb.started(8 + "")) {
					arm_Context.selectMaterial(7);
				}
				if(kb.started(9 + "")) {
					arm_Context.selectMaterial(8);
				}
			} else if(arm_Operator.shortcut(arm_Config.keymap.select_layer,2)) {
				if(kb.started(1 + "")) {
					arm_Context.selectLayer(0);
				}
				if(kb.started(2 + "")) {
					arm_Context.selectLayer(1);
				}
				if(kb.started(3 + "")) {
					arm_Context.selectLayer(2);
				}
				if(kb.started(4 + "")) {
					arm_Context.selectLayer(3);
				}
				if(kb.started(5 + "")) {
					arm_Context.selectLayer(4);
				}
				if(kb.started(6 + "")) {
					arm_Context.selectLayer(5);
				}
				if(kb.started(7 + "")) {
					arm_Context.selectLayer(6);
				}
				if(kb.started(8 + "")) {
					arm_Context.selectLayer(7);
				}
				if(kb.started(9 + "")) {
					arm_Context.selectLayer(8);
				}
			}
		}
		if(mouse.x - arm_App.x() > 0 && mouse.x - arm_App.x() < right && mouse.y - arm_App.y() > 0 && mouse.y - arm_App.y() < arm_App.h() && !isTyping) {
			if(arm_ui_UIHeader.inst.worktab.position == 0) {
				if(!mouse.down("right")) {
					if(arm_Operator.shortcut(arm_Config.keymap.tool_brush)) {
						arm_Context.selectTool(0);
					} else if(arm_Operator.shortcut(arm_Config.keymap.tool_eraser)) {
						arm_Context.selectTool(1);
					} else if(arm_Operator.shortcut(arm_Config.keymap.tool_fill)) {
						arm_Context.selectTool(2);
					} else if(arm_Operator.shortcut(arm_Config.keymap.tool_colorid)) {
						arm_Context.selectTool(8);
					} else if(arm_Operator.shortcut(arm_Config.keymap.tool_decal)) {
						arm_Context.selectTool(3);
					} else if(arm_Operator.shortcut(arm_Config.keymap.tool_text)) {
						arm_Context.selectTool(4);
					} else if(arm_Operator.shortcut(arm_Config.keymap.tool_clone)) {
						arm_Context.selectTool(5);
					} else if(arm_Operator.shortcut(arm_Config.keymap.tool_blur)) {
						arm_Context.selectTool(6);
					} else if(arm_Operator.shortcut(arm_Config.keymap.tool_particle)) {
						arm_Context.selectTool(7);
					} else if(arm_Operator.shortcut(arm_Config.keymap.tool_picker)) {
						arm_Context.selectTool(9);
					} else if(arm_Operator.shortcut(arm_Config.keymap.swap_brush_eraser)) {
						arm_Context.selectTool(arm_Context.tool == 0 ? 1 : 0);
					}
				}
				if(arm_Context.tool == 0 || arm_Context.tool == 1 || arm_Context.tool == 3 || arm_Context.tool == 4 || arm_Context.tool == 5 || arm_Context.tool == 6 || arm_Context.tool == 7) {
					if(arm_Operator.shortcut(arm_Config.keymap.brush_radius) || arm_Operator.shortcut(arm_Config.keymap.brush_opacity) || arm_Operator.shortcut(arm_Config.keymap.brush_angle) || decalMask1 && arm_Operator.shortcut(arm_Config.keymap.decal_mask + "+" + arm_Config.keymap.brush_radius)) {
						arm_Context.brushCanLock = true;
						if(!iron_system_Input.getPen().connected) {
							mouse.lock();
						}
						arm_Context.lockStartedX = mouse.x;
						arm_Context.lockStartedY = mouse.y;
					} else if(arm_Operator.shortcut(arm_Config.keymap.brush_radius_decrease,1)) {
						arm_Context.brushRadius -= 0.1;
						arm_Context.brushRadius = Math.max(Math.round(arm_Context.brushRadius * 100) / 100,0.01);
						arm_Context.brushRadiusHandle.value = arm_Context.brushRadius;
						arm_ui_UIHeader.inst.headerHandle.redraws = 2;
					} else if(arm_Operator.shortcut(arm_Config.keymap.brush_radius_increase,1)) {
						arm_Context.brushRadius += 0.1;
						arm_Context.brushRadius = Math.round(arm_Context.brushRadius * 100) / 100;
						arm_Context.brushRadiusHandle.value = arm_Context.brushRadius;
						arm_ui_UIHeader.inst.headerHandle.redraws = 2;
					} else if(decalMask1) {
						if(arm_Operator.shortcut(arm_Config.keymap.decal_mask + "+" + arm_Config.keymap.brush_radius_decrease,1)) {
							arm_Context.brushDecalMaskRadius -= 0.1;
							arm_Context.brushDecalMaskRadius = Math.max(Math.round(arm_Context.brushDecalMaskRadius * 100) / 100,0.01);
							arm_Context.brushDecalMaskRadiusHandle.value = arm_Context.brushDecalMaskRadius;
							arm_ui_UIHeader.inst.headerHandle.redraws = 2;
						} else if(arm_Operator.shortcut(arm_Config.keymap.decal_mask + "+" + arm_Config.keymap.brush_radius_increase,1)) {
							arm_Context.brushDecalMaskRadius += 0.1;
							arm_Context.brushDecalMaskRadius = Math.round(arm_Context.brushDecalMaskRadius * 100) / 100;
							arm_Context.brushDecalMaskRadiusHandle.value = arm_Context.brushDecalMaskRadius;
							arm_ui_UIHeader.inst.headerHandle.redraws = 2;
						}
					}
				}
				if(decalMask1 && (arm_Operator.shortcut(arm_Config.keymap.decal_mask,0) || arm_Operator.shortcut(arm_Config.keymap.decal_mask,3))) {
					arm_ui_UIHeader.inst.headerHandle.redraws = 2;
				}
			}
			if(mouse.x - arm_App.x() < arm_App.w()) {
				if(arm_Operator.shortcut(arm_Config.keymap.view_reset)) {
					arm_Viewport.reset();
					arm_Viewport.scaleToBounds();
				} else if(arm_Operator.shortcut(arm_Config.keymap.view_back)) {
					arm_Viewport.setView(0,1,0,Math.PI / 2,0,Math.PI);
				} else if(arm_Operator.shortcut(arm_Config.keymap.view_front)) {
					arm_Viewport.setView(0,-1,0,Math.PI / 2,0,0);
				} else if(arm_Operator.shortcut(arm_Config.keymap.view_left)) {
					arm_Viewport.setView(-1,0,0,Math.PI / 2,0,-Math.PI / 2);
				} else if(arm_Operator.shortcut(arm_Config.keymap.view_right)) {
					arm_Viewport.setView(1,0,0,Math.PI / 2,0,Math.PI / 2);
				} else if(arm_Operator.shortcut(arm_Config.keymap.view_bottom)) {
					arm_Viewport.setView(0,0,-1,Math.PI,0,Math.PI);
				} else if(arm_Operator.shortcut(arm_Config.keymap.view_top)) {
					arm_Viewport.setView(0,0,1,0,0,0);
				} else if(arm_Operator.shortcut(arm_Config.keymap.view_camera_type)) {
					arm_Context.cameraType = arm_Context.cameraType == 0 ? 1 : 0;
					arm_Context.camHandle.position = arm_Context.cameraType;
					arm_Viewport.updateCameraType(arm_Context.cameraType);
				} else if(arm_Operator.shortcut(arm_Config.keymap.view_orbit_left,1)) {
					arm_Viewport.orbit(-Math.PI / 12,0);
				} else if(arm_Operator.shortcut(arm_Config.keymap.view_orbit_right,1)) {
					arm_Viewport.orbit(Math.PI / 12,0);
				} else if(arm_Operator.shortcut(arm_Config.keymap.view_orbit_up,1)) {
					arm_Viewport.orbit(0,-Math.PI / 12);
				} else if(arm_Operator.shortcut(arm_Config.keymap.view_orbit_down,1)) {
					arm_Viewport.orbit(0,Math.PI / 12);
				} else if(arm_Operator.shortcut(arm_Config.keymap.view_orbit_opposite)) {
					arm_Viewport.orbitOpposite();
				} else if(arm_Operator.shortcut(arm_Config.keymap.view_zoom_in,1)) {
					arm_Viewport.zoom(0.2);
				} else if(arm_Operator.shortcut(arm_Config.keymap.view_zoom_out,1)) {
					arm_Viewport.zoom(-0.2);
				}
			}
		}
		if(arm_Context.brushCanLock || arm_Context.brushLocked) {
			if(mouse.moved && arm_Context.brushCanUnlock) {
				arm_Context.brushLocked = false;
				arm_Context.brushCanUnlock = false;
			}
			if((arm_Context.brushCanLock || arm_Context.brushLocked) && !arm_Operator.shortcut(arm_Config.keymap.brush_radius,2) && !arm_Operator.shortcut(arm_Config.keymap.brush_opacity,2) && !arm_Operator.shortcut(arm_Config.keymap.brush_angle,2) && !(decalMask1 && arm_Operator.shortcut(arm_Config.keymap.decal_mask + "+" + arm_Config.keymap.brush_radius,2))) {
				mouse.unlock();
				arm_Context.lastPaintX = -1;
				arm_Context.lastPaintY = -1;
				if(arm_Context.brushCanLock) {
					arm_Context.brushCanLock = false;
					arm_Context.brushCanUnlock = false;
					arm_Context.brushLocked = false;
				} else {
					arm_Context.brushCanUnlock = true;
				}
			}
		}
		if(this.borderHandle != null) {
			if(this.borderHandle == arm_ui_UINodes.inst.hwnd || this.borderHandle == arm_ui_UIView2D.inst.hwnd) {
				if(this.borderStarted == 0) {
					arm_Config.raw.layout[3] -= mouse.movementX | 0;
					if(arm_Config.raw.layout[3] < 32) {
						arm_Config.raw.layout[3] = 32;
					} else if(arm_Config.raw.layout[3] > kha_System.windowWidth() * 0.7) {
						arm_Config.raw.layout[3] = kha_System.windowWidth() * 0.7 | 0;
					}
				} else {
					arm_Config.raw.layout[4] -= mouse.movementY | 0;
					if(arm_Config.raw.layout[4] < 32) {
						arm_Config.raw.layout[4] = 32;
					} else if(arm_Config.raw.layout[4] > arm_App.h() * 0.95) {
						arm_Config.raw.layout[4] = arm_App.h() * 0.95 | 0;
					}
				}
			} else if(this.borderHandle == arm_ui_UIStatus.inst.statusHandle) {
				let my = mouse.movementY | 0;
				if(arm_Config.raw.layout[5] - my >= 32 * arm_Config.raw.window_scale && arm_Config.raw.layout[5] - my < kha_System.windowHeight() * 0.7) {
					arm_Config.raw.layout[5] -= my;
				}
			} else if(this.borderStarted == 0) {
				arm_Config.raw.layout[0] -= mouse.movementX | 0;
				if(arm_Config.raw.layout[0] < 32) {
					arm_Config.raw.layout[0] = 32;
				} else if(arm_Config.raw.layout[0] > kha_System.windowWidth() - 32) {
					arm_Config.raw.layout[0] = kha_System.windowWidth() - 32;
				}
			} else {
				let my = mouse.movementY | 0;
				if(this.borderHandle == this.hwnd1 && this.borderStarted == 2) {
					if(arm_Config.raw.layout[1] + my > 32 && arm_Config.raw.layout[2] - my > 32) {
						arm_Config.raw.layout[1] += my;
						arm_Config.raw.layout[2] -= my;
					}
				}
			}
		}
		if(!mouse.down()) {
			this.borderHandle = null;
			arm_App.isResizing = false;
		}
	}
	toggleDistractFree() {
		this.show = !this.show;
		arm_App.resize();
	}
	getBrushStencilRect() {
		return { w : arm_Context.brushStencilImage.get_width() * (arm_App.h() / arm_Context.brushStencilImage.get_height()) * arm_Context.brushStencilScale | 0, h : arm_App.h() * arm_Context.brushStencilScale | 0, x : arm_App.x() + arm_Context.brushStencilX * arm_App.w() | 0, y : arm_App.y() + arm_Context.brushStencilY * arm_App.h() | 0};
	}
	updateUI() {
		if(arm_Console.messageTimer > 0) {
			arm_Console.messageTimer -= iron_system_Time.get_delta();
			if(arm_Console.messageTimer <= 0) {
				arm_ui_UIStatus.inst.statusHandle.redraws = 2;
			}
		}
		if(!arm_App.uiEnabled) {
			return;
		}
		let mouse = iron_system_Input.getMouse();
		let kb = iron_system_Input.getKeyboard();
		if(arm_Context.brushStencilImage != null && arm_Operator.shortcut(arm_Config.keymap.stencil_transform,2)) {
			let r = this.getBrushStencilRect();
			if(mouse.started("left")) {
				arm_Context.brushStencilScaling = arm_ui_UISidebar.hitRect(mouse.x,mouse.y,r.x - 8,r.y - 8,16,16) || arm_ui_UISidebar.hitRect(mouse.x,mouse.y,r.x - 8,r.h + r.y - 8,16,16) || arm_ui_UISidebar.hitRect(mouse.x,mouse.y,r.w + r.x - 8,r.y - 8,16,16) || arm_ui_UISidebar.hitRect(mouse.x,mouse.y,r.w + r.x - 8,r.h + r.y - 8,16,16);
				let cosa = Math.cos(-arm_Context.brushStencilAngle);
				let sina = Math.sin(-arm_Context.brushStencilAngle);
				let oy = -r.h / 2;
				let x = 0 * cosa - oy * sina;
				let y = 0 * sina + oy * cosa;
				x += r.x + r.w / 2;
				y += r.y + r.h / 2;
				arm_Context.brushStencilRotating = arm_ui_UISidebar.hitRect(mouse.x,mouse.y,x - 16 | 0,y - 16 | 0,32,32);
			}
			let _scale = arm_Context.brushStencilScale;
			if(mouse.down("left")) {
				if(arm_Context.brushStencilScaling) {
					arm_Context.brushStencilScale += mouse.movementX / 400 * (mouse.x > r.x + r.w / 2 ? 1 : -1);
				} else if(arm_Context.brushStencilRotating) {
					arm_Context.brushStencilAngle = -Math.atan2(mouse.y - (r.y + r.h / 2),mouse.x - (r.x + r.w / 2)) - Math.PI / 2;
				} else {
					arm_Context.brushStencilX += mouse.movementX / arm_App.w();
					arm_Context.brushStencilY += mouse.movementY / arm_App.h();
				}
			} else {
				arm_Context.brushStencilScaling = false;
			}
			if(mouse.wheelDelta != 0) {
				arm_Context.brushStencilScale -= mouse.wheelDelta / 10;
			}
			let ratio = arm_App.h() / arm_Context.brushStencilImage.get_height();
			let oldW = _scale * arm_Context.brushStencilImage.get_width() * ratio;
			let newW = arm_Context.brushStencilScale * arm_Context.brushStencilImage.get_width() * ratio;
			let oldH = _scale * arm_App.h();
			let newH = arm_Context.brushStencilScale * arm_App.h();
			arm_Context.brushStencilX += (oldW - newW) / arm_App.w() / 2;
			arm_Context.brushStencilY += (oldH - newH) / arm_App.h() / 2;
		}
		let decalMask = (arm_Context.tool == 3 || arm_Context.tool == 4) && arm_Operator.shortcut(arm_Config.keymap.decal_mask + "+" + arm_Config.keymap.action_paint,2);
		let setCloneSource = arm_Context.tool == 5 && arm_Operator.shortcut(arm_Config.keymap.set_clone_source + "+" + arm_Config.keymap.action_paint,2);
		if(arm_Operator.shortcut(arm_Config.keymap.action_paint,2) || decalMask || setCloneSource || arm_Operator.shortcut(arm_Config.keymap.brush_ruler + "+" + arm_Config.keymap.action_paint,2) || iron_system_Input.getPen().down() && !kb.down("alt")) {
			let mx = mouse.x - arm_App.x();
			let my = mouse.y - arm_App.y();
			let ww = arm_App.w();
			if(arm_Context.paint2d) {
				mx -= arm_App.w();
				ww = arm_ui_UIView2D.inst.ww;
			}
			if(mx < ww && mx > arm_App.x() && my < arm_App.h() && my > arm_App.y()) {
				if(setCloneSource) {
					arm_Context.cloneStartX = mx;
					arm_Context.cloneStartY = my;
				} else {
					if(arm_Context.brushTime == 0 && !arm_App.isDragging && !arm_App.isResizing && !arm_App.isComboSelected()) {
						if(arm_Operator.shortcut(arm_Config.keymap.brush_ruler + "+" + arm_Config.keymap.action_paint,2)) {
							arm_Context.lastPaintVecX = arm_Context.lastPaintX;
							arm_Context.lastPaintVecY = arm_Context.lastPaintY;
						}
						arm_History.pushUndo = true;
						if(arm_Context.tool == 5 && arm_Context.cloneStartX >= 0.0) {
							arm_Context.cloneDeltaX = (arm_Context.cloneStartX - mx) / ww;
							arm_Context.cloneDeltaY = (arm_Context.cloneStartY - my) / arm_App.h();
							arm_Context.cloneStartX = -1;
						} else if(arm_Context.tool == 7) {
							iron_Scene.active.getChild(".ParticleEmitter").particleSystems[0].time = 0;
						} else if(arm_Context.tool == 2 && arm_Context.fillTypeHandle.position == 3) {
							arm_util_UVUtil.uvislandmapCached = false;
						}
					}
					arm_Context.brushTime += iron_system_Time.get_delta();
					if(arm_Context.runBrush != null) {
						arm_Context.runBrush(0);
					}
				}
			}
		} else if(arm_Context.brushTime > 0) {
			arm_Context.brushTime = 0;
			arm_Context.prevPaintVecX = -1;
			arm_Context.prevPaintVecY = -1;
			arm_Context.ddirty = 3;
			arm_Context.brushBlendDirty = true;
			arm_Context.layerPreviewDirty = true;
			if(arm_Context.tool == 8 && arm_Context.layer.fill_layer != null) {
				arm_App.notifyOnNextFrame(function() {
					arm_Layers.updateFillLayer();
					arm_node_MakeMaterial.parsePaintMaterial(false);
				});
			}
		}
		if(arm_Context.layersPreviewDirty) {
			arm_Context.layersPreviewDirty = false;
			arm_Context.layerPreviewDirty = false;
			arm_Context.maskPreviewLast = null;
			if(arm_Layers.pipeMerge == null) {
				arm_Layers.makePipe();
			}
			let _g = 0;
			let _g1 = arm_Project.layers;
			while(_g < _g1.length) {
				let l = _g1[_g];
				++_g;
				if(l.isGroup()) {
					continue;
				}
				let target = l.texpaint_preview;
				let source = l.texpaint;
				let g2 = target.get_g2();
				g2.begin(true,0);
				g2.set_pipeline(l.isMask() ? arm_Layers.pipeCopy8 : arm_Layers.pipeCopy);
				g2.drawScaledImage(source,0,0,target.get_width(),target.get_height());
				g2.set_pipeline(null);
				g2.end();
			}
			this.hwnd0.redraws = 2;
		}
		if(arm_Context.layerPreviewDirty && !arm_Context.layer.isGroup()) {
			arm_Context.layerPreviewDirty = false;
			arm_Context.maskPreviewLast = null;
			if(arm_Layers.pipeMerge == null) {
				arm_Layers.makePipe();
			}
			let l = arm_Context.layer;
			let target = l.texpaint_preview;
			let source = l.texpaint;
			let g2 = target.get_g2();
			g2.begin(true,0);
			g2.set_pipeline(arm_Context.layer.isMask() ? arm_Layers.pipeCopy8 : arm_Layers.pipeCopy);
			g2.drawScaledImage(source,0,0,target.get_width(),target.get_height());
			g2.set_pipeline(null);
			g2.end();
			this.hwnd0.redraws = 2;
		}
		let undoPressed = arm_Operator.shortcut(arm_Config.keymap.edit_undo);
		let redoPressed = arm_Operator.shortcut(arm_Config.keymap.edit_redo) || kb.down("control") && kb.started("y");
		if(undoPressed) {
			arm_History.undo();
		} else if(redoPressed) {
			arm_History.redo();
		}
		arm_render_Gizmo.update();
	}
	render(g) {
		if(!this.show || kha_System.windowWidth() == 0 || kha_System.windowHeight() == 0) {
			return;
		}
		this.ui.inputEnabled = arm_App.uiEnabled;
		g.end();
		this.ui.begin(g);
		arm_ui_UIToolbar.inst.renderUI(g);
		arm_ui_UIMenubar.inst.renderUI(g);
		arm_ui_UIHeader.inst.renderUI(g);
		arm_ui_UIStatus.inst.renderUI(g);
		this.tabx = kha_System.windowWidth() - arm_Config.raw.layout[0];
		if(this.ui.window(this.hwnd0,this.tabx,0,arm_Config.raw.layout[0],arm_Config.raw.layout[1])) {
			arm_ui_TabLayers.draw();
			arm_ui_TabHistory.draw();
			arm_ui_TabPlugins.draw();
		}
		if(this.ui.window(this.hwnd1,this.tabx,arm_Config.raw.layout[1],arm_Config.raw.layout[0],arm_Config.raw.layout[2])) {
			arm_ui_TabMaterials.draw();
			arm_ui_TabBrushes.draw();
			arm_ui_TabParticles.draw();
		}
		if(arm_Config.raw.layout[0] == 0) {
			let width = this.ui.ops.font.width(this.ui.fontSize,"<<") + 25 * this.ui.ops.scaleFactor | 0;
			let tmp = this.ui;
			let tmp1 = this.hminimize;
			let tmp2 = kha_System.windowWidth() - width;
			let _this = this.ui;
			if(tmp.window(tmp1,tmp2,0,width,_this.t.BUTTON_H * _this.ops.scaleFactor | 0)) {
				this.ui._w = width;
				if(this.ui.button("<<")) {
					arm_Config.raw.layout[0] = arm_Context.maximizedSidebarWidth != 0 ? arm_Context.maximizedSidebarWidth : 280 * arm_Config.raw.window_scale | 0;
				}
			}
		}
		if(this.htab0.changed && this.htab0.position == arm_Context.lastHtab0Position && arm_Config.raw.layout[0] != 0) {
			arm_Context.maximizedSidebarWidth = arm_Config.raw.layout[0];
			arm_Config.raw.layout[0] = 0;
		}
		arm_Context.lastHtab0Position = this.htab0.position;
		this.ui.end();
		g.begin(false);
	}
	renderCursor(g) {
		g.set_color(-1);
		if(arm_App.uiEnabled && arm_ui_UIHeader.inst.worktab.position == 0) {
			arm_Context.viewIndex = arm_Context.viewIndexLast;
			let mx = arm_App.x() + arm_Context.paintVec.x * arm_App.w();
			let my = arm_App.y() + arm_Context.paintVec.y * arm_App.h();
			arm_Context.viewIndex = -1;
			if(arm_Context.brushLocked) {
				mx += arm_Context.lockStartedX - kha_System.windowWidth() / 2;
				my += arm_Context.lockStartedY - kha_System.windowHeight() / 2;
			}
			if(arm_Context.brushStencilImage != null && arm_Context.tool != 11 && arm_Context.tool != 9 && arm_Context.tool != 8) {
				let r = this.getBrushStencilRect();
				if(!arm_Operator.shortcut(arm_Config.keymap.stencil_hide,2)) {
					g.set_color(-1996488705);
					g.pushRotation(-arm_Context.brushStencilAngle,r.x + r.w / 2,r.y + r.h / 2);
					g.drawScaledImage(arm_Context.brushStencilImage,r.x,r.y,r.w,r.h);
					g.popTransformation();
					g.set_color(-1);
				}
				if(arm_Operator.shortcut(arm_Config.keymap.stencil_transform,2)) {
					g.drawRect(r.x,r.y,r.w,r.h);
					g.drawRect(r.x - 8,r.y - 8,16,16);
					g.drawRect(r.x - 8 + r.w,r.y - 8,16,16);
					g.drawRect(r.x - 8,r.y - 8 + r.h,16,16);
					g.drawRect(r.x - 8 + r.w,r.y - 8 + r.h,16,16);
					g.pushRotation(-arm_Context.brushStencilAngle,r.x + r.w / 2,r.y + r.h / 2);
					kha_graphics2_GraphicsExtension.fillCircle(g,r.x + r.w / 2,r.y - 4,8);
					g.popTransformation();
				}
			}
			if(arm_Context.tool == 9 && arm_Context.pickerSelectMaterial) {
				g.drawImage(arm_Context.material.imageIcon,mx + 10,my + 10);
			}
			let cursorImg = arm_Res.bundled.h["cursor.k"];
			let psize = cursorImg.get_width() * (arm_Context.brushRadius * arm_Context.brushNodesRadius) * this.ui.ops.scaleFactor | 0;
			let mouse = iron_system_Input.getMouse();
			let pen = iron_system_Input.getPen();
			let kb = iron_system_Input.getKeyboard();
			if(arm_Context.tool == 5 && !kb.down("alt") && (mouse.down() || pen.down())) {
				g.set_color(1728053247);
				g.drawScaledImage(cursorImg,mx + arm_Context.cloneDeltaX * arm_App.w() - psize / 2,my + arm_Context.cloneDeltaY * arm_App.h() - psize / 2,psize,psize);
				g.set_color(-1);
			}
			let in2dView = arm_ui_UIView2D.inst.show && arm_ui_UIView2D.inst.type == 0 && mx > arm_ui_UIView2D.inst.wx && mx < arm_ui_UIView2D.inst.wx + arm_ui_UIView2D.inst.ww && my > arm_ui_UIView2D.inst.wy && my < arm_ui_UIView2D.inst.wy + arm_ui_UIView2D.inst.wh;
			let inNodes = arm_ui_UINodes.inst.show && mx > arm_ui_UINodes.inst.wx && mx < arm_ui_UINodes.inst.wx + arm_ui_UINodes.inst.ww && my > arm_ui_UINodes.inst.wy && my < arm_ui_UINodes.inst.wy + arm_ui_UINodes.inst.wh;
			let decal = arm_Context.tool == 3 || arm_Context.tool == 4;
			if(!arm_Config.raw.brush_3d || in2dView || decal) {
				let decalMask = decal && arm_Operator.shortcut(arm_Config.keymap.decal_mask,2);
				if(decal && !inNodes) {
					let decalAlpha = 0.5;
					if(!decalMask) {
						arm_Context.decalX = arm_Context.paintVec.x;
						arm_Context.decalY = arm_Context.paintVec.y;
						decalAlpha = arm_Context.brushOpacity;
						if(arm_Context.brushLocked) {
							arm_Context.decalX += (arm_Context.lockStartedX - kha_System.windowWidth() / 2) / arm_App.w();
							arm_Context.decalY += (arm_Context.lockStartedY - kha_System.windowHeight() / 2) / arm_App.h();
						}
					}
					if(!arm_Config.raw.brush_live) {
						let psizex = 256 * this.ui.ops.scaleFactor * (arm_Context.brushRadius * arm_Context.brushNodesRadius * arm_Context.brushScaleX) | 0;
						let psizey = 256 * this.ui.ops.scaleFactor * (arm_Context.brushRadius * arm_Context.brushNodesRadius) | 0;
						arm_Context.viewIndex = arm_Context.viewIndexLast;
						let decalX = arm_App.x() + arm_Context.decalX * arm_App.w() - psizex / 2;
						let decalY = arm_App.y() + arm_Context.decalY * arm_App.h() - psizey / 2;
						arm_Context.viewIndex = -1;
						g.set_color(kha_Color.fromFloats(1,1,1,decalAlpha));
						g.pushRotation(-((arm_Context.brushAngle + arm_Context.brushNodesAngle) * (Math.PI / 180)),decalX + psizex / 2,decalY + psizey / 2);
						g.drawScaledImage(arm_Context.decalImage,decalX,decalY,psizex,psizey);
						g.popTransformation();
						g.set_color(-1);
					}
				}
				if(arm_Context.tool == 0 || arm_Context.tool == 1 || arm_Context.tool == 5 || arm_Context.tool == 6 || arm_Context.tool == 7 || decalMask && !arm_Config.raw.brush_3d || decalMask && in2dView) {
					if(decalMask) {
						psize = cursorImg.get_width() * (arm_Context.brushDecalMaskRadius * arm_Context.brushNodesRadius) * this.ui.ops.scaleFactor | 0;
					}
					if(arm_Config.raw.brush_3d && in2dView) {
						psize = psize * arm_ui_UIView2D.inst.panScale | 0;
					}
					g.drawScaledImage(cursorImg,mx - psize / 2,my - psize / 2,psize,psize);
				}
			}
			if(arm_Context.brushLazyRadius > 0 && !arm_Context.brushLocked && (arm_Context.tool == 0 || arm_Context.tool == 1 || arm_Context.tool == 3 || arm_Context.tool == 4 || arm_Context.tool == 5 || arm_Context.tool == 6 || arm_Context.tool == 7)) {
				g.fillRect(mx - 1,my - 1,2,2);
				let mx1 = arm_Context.brushLazyX * arm_App.w() + arm_App.x();
				let my1 = arm_Context.brushLazyY * arm_App.h() + arm_App.y();
				let radius = arm_Context.brushLazyRadius * 180;
				g.set_color(-10066330);
				g.drawScaledImage(cursorImg,mx1 - radius / 2,my1 - radius / 2,radius,radius);
				g.set_color(-1);
			}
		}
	}
	showMaterialNodes() {
		arm_ui_UINodes.inst.ui.endInput();
		arm_ui_UINodes.inst.show = !arm_ui_UINodes.inst.show || arm_ui_UINodes.inst.canvasType != 0;
		arm_ui_UINodes.inst.canvasType = 0;
		arm_App.resize();
	}
	showBrushNodes() {
		arm_ui_UINodes.inst.ui.endInput();
		arm_ui_UINodes.inst.show = !arm_ui_UINodes.inst.show || arm_ui_UINodes.inst.canvasType != 1;
		arm_ui_UINodes.inst.canvasType = 1;
		arm_App.resize();
	}
	show2DView(type) {
		arm_ui_UIView2D.inst.ui.endInput();
		if(arm_ui_UIView2D.inst.type != type) {
			arm_ui_UIView2D.inst.show = true;
		} else {
			arm_ui_UIView2D.inst.show = !arm_ui_UIView2D.inst.show;
		}
		arm_ui_UIView2D.inst.type = type;
		arm_ui_UIView2D.inst.hwnd.redraws = 2;
		arm_App.resize();
	}
	toggleBrowser() {
		arm_Config.raw.layout[5] = arm_Config.raw.layout[5] <= 32 * arm_Config.raw.window_scale ? 240 : 32;
		arm_Config.raw.layout[5] = arm_Config.raw.layout[5] * arm_Config.raw.window_scale | 0;
	}
	setIconScale() {
		if(this.ui.ops.scaleFactor > 1) {
			arm_Res.load(["icons2x.k"],function() {
				arm_Res.bundled.h["icons.k"] = arm_Res.bundled.h["icons2x.k"];
			});
		} else {
			arm_Res.load(["icons.k"],function() {
			});
		}
	}
	onBorderHover(handle,side) {
		if(!arm_App.uiEnabled) {
			return;
		}
		if(handle != this.hwnd0 && handle != this.hwnd1 && handle != arm_ui_UIStatus.inst.statusHandle && handle != arm_ui_UINodes.inst.hwnd && handle != arm_ui_UIView2D.inst.hwnd) {
			return;
		}
		if(handle == arm_ui_UINodes.inst.hwnd && side != 0 && side != 2) {
			return;
		}
		if(handle == arm_ui_UINodes.inst.hwnd && side == 2 && !arm_ui_UIView2D.inst.show) {
			return;
		}
		if(handle == arm_ui_UIView2D.inst.hwnd && side != 0) {
			return;
		}
		if(handle == this.hwnd0 && side == 2) {
			return;
		}
		if(handle == arm_ui_UIStatus.inst.statusHandle && side != 2) {
			return;
		}
		if(side == 1) {
			return;
		}
		if(side == 0 || side == 1) {
			Krom.setMouseCursor(3);
		} else {
			Krom.setMouseCursor(4);
		}
		if(zui_Zui.current.inputStarted) {
			this.borderStarted = side;
			this.borderHandle = handle;
			arm_App.isResizing = true;
		}
	}
	onTextHover() {
		Krom.setMouseCursor(2);
	}
	tagUIRedraw() {
		arm_ui_UIHeader.inst.headerHandle.redraws = 2;
		arm_ui_UIToolbar.inst.toolbarHandle.redraws = 2;
		arm_ui_UIStatus.inst.statusHandle.redraws = 2;
		arm_ui_UIMenubar.inst.workspaceHandle.redraws = 2;
		arm_ui_UIMenubar.inst.menuHandle.redraws = 2;
		this.hwnd0.redraws = 2;
		this.hwnd1.redraws = 2;
	}
	static hitRect(mx,my,x,y,w,h) {
		if(mx > x && mx < x + w && my > y) {
			return my < y + h;
		} else {
			return false;
		}
	}
}
$hxClasses["arm.ui.UISidebar"] = arm_ui_UISidebar;
arm_ui_UISidebar.__name__ = "arm.ui.UISidebar";
Object.assign(arm_ui_UISidebar.prototype, {
	__class__: arm_ui_UISidebar
});
class arm_ConsoleBridge {
}
$hxClasses["arm.ConsoleBridge"] = $hx_exports["console"] = arm_ConsoleBridge;
arm_ConsoleBridge.__name__ = "arm.ConsoleBridge";
class arm_node_Brush {
	static getNode(id) {
		let _g = 0;
		let _g1 = arm_node_Brush.nodes;
		while(_g < _g1.length) {
			let n = _g1[_g];
			++_g;
			if(n.id == id) {
				return n;
			}
		}
		return null;
	}
	static getInputLink(inp) {
		let _g = 0;
		let _g1 = arm_node_Brush.links;
		while(_g < _g1.length) {
			let l = _g1[_g];
			++_g;
			if(l.to_id == inp.node_id) {
				let node = arm_node_Brush.getNode(inp.node_id);
				if(node.inputs.length <= l.to_socket) {
					return null;
				}
				if(node.inputs[l.to_socket] == inp) {
					return l;
				}
			}
		}
		return null;
	}
	static getOutputLinks(out) {
		let res = [];
		let _g = 0;
		let _g1 = arm_node_Brush.links;
		while(_g < _g1.length) {
			let l = _g1[_g];
			++_g;
			if(l.from_id == out.node_id) {
				let node = arm_node_Brush.getNode(out.node_id);
				if(node.outputs.length <= l.from_socket) {
					continue;
				}
				if(node.outputs[l.from_socket] == out) {
					res.push(l);
				}
			}
		}
		return res;
	}
	static safesrc(s) {
		return StringTools.replace(s," ","");
	}
	static node_name(node) {
		return arm_node_Brush.safesrc(node.name) + node.id;
	}
	static parse(canvas,onAdd) {
		if(onAdd == null) {
			onAdd = true;
		}
		arm_node_Brush.nodes = canvas.nodes;
		arm_node_Brush.links = canvas.links;
		arm_node_Brush.parsed_nodes = [];
		arm_node_Brush.parsed_labels = new haxe_ds_StringMap();
		arm_node_Brush.nodeMap = new haxe_ds_StringMap();
		let root_nodes = arm_node_Brush.get_root_nodes(canvas);
		arm_node_Brush.tree = new arm_node_LogicTree();
		if(onAdd) {
			arm_node_Brush.tree.notifyOnAdd(function() {
				let _g = 0;
				while(_g < root_nodes.length) arm_node_Brush.build_node(root_nodes[_g++]);
			});
		} else {
			let _g = 0;
			while(_g < root_nodes.length) arm_node_Brush.build_node(root_nodes[_g++]);
		}
	}
	static build_node(node) {
		let name = arm_node_Brush.node_name(node);
		if(arm_node_Brush.parsed_nodes.indexOf(name) != -1) {
			return name;
		}
		arm_node_Brush.parsed_nodes.push(name);
		let v = arm_node_Brush.createClassInstance(node.type,[arm_node_Brush.tree]);
		arm_node_Brush.nodeMap.h[name] = v;
		let _g = 0;
		let _g1 = node.buttons;
		while(_g < _g1.length) {
			let b = _g1[_g];
			++_g;
			if(b.type == "ENUM") {
				let texts = ((b.data) instanceof Array) ? b.data : zui_Nodes.enumTexts(node.type);
				Reflect.setProperty(v,b.name,texts[b.default_value]);
			} else {
				Reflect.setProperty(v,b.name,b.default_value);
			}
		}
		let inp_node = null;
		let inp_from = 0;
		let _g2 = 0;
		let _g3 = node.inputs.length;
		while(_g2 < _g3) {
			let i = _g2++;
			let inp = node.inputs[i];
			let l = arm_node_Brush.getInputLink(inp);
			if(l != null) {
				let n = arm_node_Brush.getNode(l.from_id);
				let socket = n.outputs[l.from_socket];
				if(socket.type == node.inputs[i].type) {
					let this1 = arm_node_Brush.nodeMap;
					let key = arm_node_Brush.build_node(n);
					inp_node = this1.h[key];
					let _g = 0;
					let _g1 = n.outputs.length;
					while(_g < _g1) {
						let i = _g++;
						if(n.outputs[i] == socket) {
							inp_from = i;
							break;
						}
					}
				} else {
					inp_node = arm_node_Brush.build_default_node(inp);
					inp_from = 0;
				}
			} else {
				inp_node = arm_node_Brush.build_default_node(inp);
				inp_from = 0;
			}
			v.addInput(inp_node,inp_from);
		}
		let _g4 = 0;
		let _g5 = node.outputs;
		while(_g4 < _g5.length) {
			let out = _g5[_g4];
			++_g4;
			let outNodes = [];
			let ls = arm_node_Brush.getOutputLinks(out);
			if(ls != null && ls.length > 0) {
				let _g = 0;
				while(_g < ls.length) {
					let out_name = arm_node_Brush.build_node(arm_node_Brush.getNode(ls[_g++].to_id));
					outNodes.push(arm_node_Brush.nodeMap.h[out_name]);
				}
			} else {
				outNodes.push(arm_node_Brush.build_default_node(out));
			}
			v.addOutputs(outNodes);
		}
		return name;
	}
	static get_root_nodes(node_group) {
		let roots = [];
		let _g = 0;
		let _g1 = node_group.nodes;
		while(_g < _g1.length) {
			let node = _g1[_g];
			++_g;
			let linked = false;
			let _g2 = 0;
			let _g3 = node.outputs;
			while(_g2 < _g3.length) {
				let ls = arm_node_Brush.getOutputLinks(_g3[_g2++]);
				if(ls != null && ls.length > 0) {
					linked = true;
					break;
				}
			}
			if(!linked) {
				roots.push(node);
			}
		}
		return roots;
	}
	static build_default_node(inp) {
		let v = null;
		if(inp.type == "VECTOR") {
			if(inp.default_value == null) {
				inp.default_value = [0,0,0];
			}
			v = arm_node_Brush.createClassInstance("VectorNode",[arm_node_Brush.tree,inp.default_value[0],inp.default_value[1],inp.default_value[2]]);
		} else if(inp.type == "RGBA") {
			if(inp.default_value == null) {
				inp.default_value = [0,0,0];
			}
			v = arm_node_Brush.createClassInstance("ColorNode",[arm_node_Brush.tree,inp.default_value[0],inp.default_value[1],inp.default_value[2],inp.default_value[3]]);
		} else if(inp.type == "RGB") {
			if(inp.default_value == null) {
				inp.default_value = [0,0,0];
			}
			v = arm_node_Brush.createClassInstance("ColorNode",[arm_node_Brush.tree,inp.default_value[0],inp.default_value[1],inp.default_value[2]]);
		} else if(inp.type == "VALUE") {
			v = arm_node_Brush.createClassInstance("FloatNode",[arm_node_Brush.tree,inp.default_value]);
		} else if(inp.type == "INT") {
			v = arm_node_Brush.createClassInstance("IntegerNode",[arm_node_Brush.tree,inp.default_value]);
		} else if(inp.type == "BOOLEAN") {
			v = arm_node_Brush.createClassInstance("BooleanNode",[arm_node_Brush.tree,inp.default_value]);
		} else if(inp.type == "STRING") {
			v = arm_node_Brush.createClassInstance("StringNode",[arm_node_Brush.tree,inp.default_value]);
		} else {
			v = arm_node_Brush.createClassInstance("NullNode",[arm_node_Brush.tree]);
		}
		return v;
	}
	static createClassInstance(className,args) {
		if(arm_node_Brush.customNodes.get(className) != null) {
			let node = new arm_node_LogicNode(args[0]);
			node.get = function(from) {
				return (arm_node_Brush.customNodes.get(className))(node,from);
			};
			return node;
		}
		let name = arm_node_Brush.packageName + "." + className;
		let cname = $hxClasses[name];
		if(cname == null) {
			return null;
		}
		return Type.createInstance(cname,args);
	}
}
$hxClasses["arm.node.Brush"] = arm_node_Brush;
arm_node_Brush.__name__ = "arm.node.Brush";
class arm_sys_File {
	static readDirectory(path,foldersOnly) {
		if(foldersOnly == null) {
			foldersOnly = false;
		}
		if(path.startsWith("cloud")) {
			let files;
			if(arm_sys_File.cloud != null) {
				let this1 = arm_sys_File.cloud;
				let key = StringTools.replace(path,"\\","/");
				files = this1.h[key];
			} else {
				files = null;
			}
			if(files != null) {
				return files;
			} else {
				return [];
			}
		}
		return Krom.readDirectory(path,foldersOnly).split("\n");
	}
	static createDirectory(path) {
		Krom.sysCommand("mkdir" + " \"" + path + "\"");
	}
	static copy(srcPath,dstPath) {
		Krom.sysCommand("copy" + " \"" + srcPath + "\" \"" + dstPath + "\"");
	}
	static start(path) {
		Krom.sysCommand("start \"\" \"" + path + "\"");
	}
	static loadUrl(url) {
		Krom.sysCommand("start \"\" \"" + url + "\"");
	}
	static delete(path) {
		Krom.deleteFile(path);
	}
	static exists(path) {
		return Krom.fileExists(path);
	}
	static download(url,dstPath,done,size) {
		if(size == null) {
			size = 0;
		}
		Krom.httpRequest(url,size,function(ab) {
			if(ab != null) {
				Krom.fileSaveBytes(dstPath,ab);
			}
			done();
		});
	}
	static downloadBytes(url,done) {
		let save = (arm_sys_Path.isProtected() ? Krom.savePath() : arm_sys_Path.data() + arm_sys_Path.sep) + "download.bin";
		arm_sys_File.download(url,save,function() {
			try {
				done(haxe_io_Bytes.ofData(Krom.loadBlob(save)));
			} catch( _g ) {
				done(null);
			}
		});
	}
	static cacheCloud(path,done) {
		let path2 = path;
		let dest = (arm_sys_Path.isProtected() ? Krom.savePath() : Krom.getFilesLocation() + arm_sys_Path.sep) + path2;
		if(arm_sys_File.exists(dest)) {
			done((arm_sys_Path.isProtected() ? Krom.savePath() : arm_sys_Path.workingDir() + arm_sys_Path.sep) + path);
			return;
		}
		let fileDir = HxOverrides.substr(dest,0,dest.lastIndexOf(arm_sys_Path.sep));
		if(arm_sys_File.readDirectory(fileDir)[0] == "") {
			arm_sys_File.createDirectory(fileDir);
		}
		path = StringTools.replace(path,"\\","/");
		arm_sys_File.download(arm_Config.raw.server + "/" + path,dest,function() {
			if(!arm_sys_File.exists(dest)) {
				arm_Console.error(arm_Strings.error5());
				done(null);
				return;
			}
			done((arm_sys_Path.isProtected() ? Krom.savePath() : arm_sys_Path.workingDir() + arm_sys_Path.sep) + path);
		},arm_sys_File.cloudSizes.h[path]);
	}
	static initCloud(done) {
		arm_sys_File.cloud = new haxe_ds_StringMap();
		arm_sys_File.cloudSizes = new haxe_ds_StringMap();
		arm_sys_File.downloadBytes(arm_Config.raw.server,function(bytes) {
			if(bytes == null) {
				arm_sys_File.cloud.h["cloud"] = [];
				arm_Console.error(arm_Strings.error5());
				return;
			}
			let files = [];
			let sizes = [];
			let e = Xml.parse(bytes.toString()).firstElement().elementsNamed("Contents");
			while(e.hasNext()) {
				let e1 = e.next();
				let k = e1.elementsNamed("Key");
				while(k.hasNext()) {
					let k1 = k.next();
					if(k1.nodeType != Xml.Document && k1.nodeType != Xml.Element) {
						throw haxe_Exception.thrown("Bad node type, expected Element or Document but found " + (k1.nodeType == null ? "null" : XmlType.toString(k1.nodeType)));
					}
					let _this = k1.children[0];
					if(_this.nodeType == Xml.Document || _this.nodeType == Xml.Element) {
						throw haxe_Exception.thrown("Bad node type, unexpected " + (_this.nodeType == null ? "null" : XmlType.toString(_this.nodeType)));
					}
					files.push(_this.nodeValue);
				}
				let k1 = e1.elementsNamed("Size");
				while(k1.hasNext()) {
					let k = k1.next();
					if(k.nodeType != Xml.Document && k.nodeType != Xml.Element) {
						throw haxe_Exception.thrown("Bad node type, expected Element or Document but found " + (k.nodeType == null ? "null" : XmlType.toString(k.nodeType)));
					}
					let _this = k.children[0];
					if(_this.nodeType == Xml.Document || _this.nodeType == Xml.Element) {
						throw haxe_Exception.thrown("Bad node type, unexpected " + (_this.nodeType == null ? "null" : XmlType.toString(_this.nodeType)));
					}
					sizes.push(Std.parseInt(_this.nodeValue));
				}
			}
			let _g = 0;
			while(_g < files.length) {
				let file = files[_g];
				++_g;
				if(arm_sys_Path.isFolder(file)) {
					arm_sys_File.cloud.h[HxOverrides.substr(file,0,file.length - 1)] = [];
				}
			}
			let _g1 = 0;
			let _g2 = files.length;
			while(_g1 < _g2) {
				let i = _g1++;
				let file = files[i];
				if(file.indexOf("/") != file.lastIndexOf("/")) {
					let delim = arm_sys_Path.isFolder(file) ? HxOverrides.substr(file,0,file.length - 1).lastIndexOf("/") : file.lastIndexOf("/");
					let parent = HxOverrides.substr(file,0,delim);
					let child = arm_sys_Path.isFolder(file) ? file.substring(delim + 1,file.length - 1) : HxOverrides.substr(file,delim + 1,null);
					arm_sys_File.cloud.h[parent].push(child);
					if(!arm_sys_Path.isFolder(file)) {
						arm_sys_File.cloudSizes.h[file] = sizes[i];
					}
				}
			}
			done();
		});
	}
}
$hxClasses["arm.sys.File"] = arm_sys_File;
arm_sys_File.__name__ = "arm.sys.File";
class arm_node_MakeMaterial {
	static getMOut() {
		let _g = 0;
		let _g1 = arm_ui_UINodes.inst.getCanvasMaterial().nodes;
		while(_g < _g1.length) if(_g1[_g++].type == "OUTPUT_MATERIAL_PBR") {
			return true;
		}
		return false;
	}
	static parseMeshMaterial() {
		let m = arm_Project.materials[0].data;
		let _g = 0;
		let _g1 = m.shader.contexts;
		while(_g < _g1.length) {
			let c = _g1[_g];
			++_g;
			if(c.raw.name == "mesh") {
				HxOverrides.remove(m.shader.raw.contexts,c.raw);
				HxOverrides.remove(m.shader.contexts,c);
				c.delete();
				break;
			}
		}
		if(arm_node_MakeMesh.layerPassCount > 1) {
			let i = 0;
			while(i < m.shader.contexts.length) {
				let c = m.shader.contexts[i];
				let _g = 1;
				let _g1 = arm_node_MakeMesh.layerPassCount;
				while(_g < _g1) if(c.raw.name == "mesh" + _g++) {
					HxOverrides.remove(m.shader.raw.contexts,c.raw);
					HxOverrides.remove(m.shader.contexts,c);
					c.delete();
					--i;
					break;
				}
				++i;
			}
			i = 0;
			while(i < m.contexts.length) {
				let c = m.contexts[i];
				let _g = 1;
				let _g1 = arm_node_MakeMesh.layerPassCount;
				while(_g < _g1) if(c.raw.name == "mesh" + _g++) {
					HxOverrides.remove(m.raw.contexts,c.raw);
					HxOverrides.remove(m.contexts,c);
					--i;
					break;
				}
				++i;
			}
		}
		let con = arm_node_MakeMesh.run(new arm_shader_NodeShaderData({ name : "Material", canvas : null}));
		let scon = new iron_data_ShaderContext(con.data,function(scon) {
		});
		scon.overrideContext = { };
		if(con.frag.sharedSamplers.length > 0) {
			let sampler = con.frag.sharedSamplers[0];
			scon.overrideContext.shared_sampler = HxOverrides.substr(sampler,sampler.lastIndexOf(" ") + 1,null);
		}
		if(!arm_Context.textureFilter) {
			scon.overrideContext.filter = "point";
		}
		m.shader.raw.contexts.push(scon.raw);
		m.shader.contexts.push(scon);
		let _g2 = 1;
		let _g3 = arm_node_MakeMesh.layerPassCount;
		while(_g2 < _g3) {
			let i = _g2++;
			let con = arm_node_MakeMesh.run(new arm_shader_NodeShaderData({ name : "Material", canvas : null}),i);
			let scon = new iron_data_ShaderContext(con.data,function(scon) {
			});
			scon.overrideContext = { };
			if(con.frag.sharedSamplers.length > 0) {
				let sampler = con.frag.sharedSamplers[0];
				scon.overrideContext.shared_sampler = HxOverrides.substr(sampler,sampler.lastIndexOf(" ") + 1,null);
			}
			if(!arm_Context.textureFilter) {
				scon.overrideContext.filter = "point";
			}
			m.shader.raw.contexts.push(scon.raw);
			m.shader.contexts.push(scon);
			let mcon = new iron_data_MaterialContext({ name : "mesh" + i, bind_textures : []},function(self) {
			});
			m.raw.contexts.push(mcon.raw);
			m.contexts.push(mcon);
		}
		arm_Context.ddirty = 2;
		arm_node_MakeMaterial.makeVoxel(m);
	}
	static parseParticleMaterial() {
		let m = arm_Context.particleMaterial;
		let sc = null;
		let _g = 0;
		let _g1 = m.shader.contexts;
		while(_g < _g1.length) {
			let c = _g1[_g];
			++_g;
			if(c.raw.name == "mesh") {
				sc = c;
				break;
			}
		}
		if(sc != null) {
			HxOverrides.remove(m.shader.raw.contexts,sc.raw);
			HxOverrides.remove(m.shader.contexts,sc);
		}
		let con = arm_node_MakeParticle.run(new arm_shader_NodeShaderData({ name : "MaterialParticle", canvas : null}));
		if(sc != null) {
			sc.delete();
		}
		sc = new iron_data_ShaderContext(con.data,function(sc) {
		});
		m.shader.raw.contexts.push(sc.raw);
		m.shader.contexts.push(sc);
	}
	static parseMeshPreviewMaterial() {
		if(!arm_node_MakeMaterial.getMOut()) {
			return;
		}
		let m = arm_Project.materials[0].data;
		let scon = null;
		let _g = 0;
		let _g1 = m.shader.contexts;
		while(_g < _g1.length) {
			let c = _g1[_g];
			++_g;
			if(c.raw.name == "mesh") {
				scon = c;
				break;
			}
		}
		HxOverrides.remove(m.shader.raw.contexts,scon.raw);
		HxOverrides.remove(m.shader.contexts,scon);
		let mcon = { name : "mesh", bind_textures : []};
		let con = arm_node_MakeMeshPreview.run(new arm_shader_NodeShaderData({ name : "Material", canvas : null}),mcon);
		let _g2 = 0;
		let _g3 = m.contexts.length;
		while(_g2 < _g3) {
			let i = _g2++;
			if(m.contexts[i].raw.name == "mesh") {
				m.contexts[i] = new iron_data_MaterialContext(mcon,function(self) {
				});
				break;
			}
		}
		if(scon != null) {
			scon.delete();
		}
		let compileError = false;
		scon = new iron_data_ShaderContext(con.data,function(scon) {
			if(scon == null) {
				compileError = true;
			}
		});
		if(compileError) {
			return;
		}
		m.shader.raw.contexts.push(scon.raw);
		m.shader.contexts.push(scon);
	}
	static makeVoxel(m) {
		if(arm_Config.raw.rp_gi != false && arm_node_MakeMaterial.heightUsed) {
			let scon = null;
			let _g = 0;
			let _g1 = m.shader.contexts;
			while(_g < _g1.length) {
				let c = _g1[_g];
				++_g;
				if(c.raw.name == "voxel") {
					scon = c;
					break;
				}
			}
			if(scon != null) {
				arm_node_MakeVoxel.run(scon);
			}
		}
	}
	static parsePaintMaterial(bakePreviews) {
		if(bakePreviews == null) {
			bakePreviews = true;
		}
		if(!arm_node_MakeMaterial.getMOut()) {
			return;
		}
		if(bakePreviews) {
			let current = kha_graphics2_Graphics.current;
			if(current != null) {
				current.end();
			}
			arm_node_MakeMaterial.bakeNodePreviews();
			if(current != null) {
				current.begin(false);
			}
		}
		let m = arm_Project.materials[0].data;
		let _g = 0;
		let _g1 = m.shader.contexts;
		while(_g < _g1.length) {
			let c = _g1[_g];
			++_g;
			if(c.raw.name == "paint") {
				HxOverrides.remove(m.shader.raw.contexts,c.raw);
				HxOverrides.remove(m.shader.contexts,c);
				if(c != arm_node_MakeMaterial.defaultScon) {
					c.delete();
				}
				break;
			}
		}
		let _g2 = 0;
		let _g3 = m.contexts;
		while(_g2 < _g3.length) {
			let c = _g3[_g2];
			++_g2;
			if(c.raw.name == "paint") {
				HxOverrides.remove(m.raw.contexts,c.raw);
				HxOverrides.remove(m.contexts,c);
				break;
			}
		}
		let sdata = new arm_shader_NodeShaderData({ name : "Material", canvas : arm_ui_UINodes.inst.getCanvasMaterial()});
		let mcon = { name : "paint", bind_textures : []};
		let compileError = false;
		let scon = new iron_data_ShaderContext(arm_node_MakePaint.run(sdata,mcon).data,function(scon) {
			if(scon == null) {
				compileError = true;
			}
		});
		if(compileError) {
			return;
		}
		scon.overrideContext = { };
		scon.overrideContext.addressing = "repeat";
		let mcon1 = new iron_data_MaterialContext(mcon,function(mcon) {
		});
		m.shader.raw.contexts.push(scon.raw);
		m.shader.contexts.push(scon);
		m.raw.contexts.push(mcon1.raw);
		m.contexts.push(mcon1);
		if(arm_node_MakeMaterial.defaultScon == null) {
			arm_node_MakeMaterial.defaultScon = scon;
		}
		if(arm_node_MakeMaterial.defaultMcon == null) {
			arm_node_MakeMaterial.defaultMcon = mcon1;
		}
	}
	static bakeNodePreviews() {
		arm_Context.nodePreviewsUsed = [];
		if(arm_Context.nodePreviews == null) {
			arm_Context.nodePreviews = new haxe_ds_StringMap();
		}
		arm_node_MakeMaterial.traverseNodes(arm_ui_UINodes.inst.getCanvasMaterial().nodes,null,[]);
		let key_keys = Object.keys(arm_Context.nodePreviews.h);
		let key_length = key_keys.length;
		let key_current = 0;
		while(key_current < key_length) {
			let key = key_keys[key_current++];
			if(arm_Context.nodePreviewsUsed.indexOf(key) == -1) {
				arm_App.notifyOnNextFrame(($_=arm_Context.nodePreviews.h[key],$bind($_,$_.unload)));
				let _this = arm_Context.nodePreviews;
				if(Object.prototype.hasOwnProperty.call(_this.h,key)) {
					delete(_this.h[key]);
				}
			}
		}
	}
	static traverseNodes(nodes,group,parents) {
		let _g = 0;
		while(_g < nodes.length) {
			let node = nodes[_g];
			++_g;
			arm_node_MakeMaterial.bakeNodePreview(node,group,parents);
			if(node.type == "GROUP") {
				let _g = 0;
				let _g1 = arm_Project.materialGroups;
				while(_g < _g1.length) {
					let g = _g1[_g];
					++_g;
					if(g.canvas.name == node.name) {
						parents.push(node);
						arm_node_MakeMaterial.traverseNodes(g.canvas.nodes,g.canvas,parents);
						parents.pop();
						break;
					}
				}
			}
		}
	}
	static bakeNodePreview(node,group,parents) {
		if(node.type == "BLUR") {
			let id = arm_shader_MaterialParser.node_name(node,parents);
			let image = arm_Context.nodePreviews.h[id];
			arm_Context.nodePreviewsUsed.push(id);
			let resX = arm_Config.getTextureResX() / 4 | 0;
			let resY = arm_Config.getTextureResY() / 4 | 0;
			if(image == null || image.get_width() != resX || image.get_height() != resY) {
				if(image != null) {
					image.unload();
				}
				image = kha_Image.createRenderTarget(resX,resY);
				arm_Context.nodePreviews.h[id] = image;
			}
			arm_shader_MaterialParser.blur_passthrough = true;
			arm_util_RenderUtil.makeNodePreview(arm_ui_UINodes.inst.getCanvasMaterial(),node,image,group,parents);
			arm_shader_MaterialParser.blur_passthrough = false;
		} else if(node.type == "DIRECT_WARP") {
			let id = arm_shader_MaterialParser.node_name(node,parents);
			let image = arm_Context.nodePreviews.h[id];
			arm_Context.nodePreviewsUsed.push(id);
			let resX = arm_Config.getTextureResX() | 0;
			let resY = arm_Config.getTextureResY() | 0;
			if(image == null || image.get_width() != resX || image.get_height() != resY) {
				if(image != null) {
					image.unload();
				}
				image = kha_Image.createRenderTarget(resX,resY);
				arm_Context.nodePreviews.h[id] = image;
			}
			arm_shader_MaterialParser.warp_passthrough = true;
			arm_util_RenderUtil.makeNodePreview(arm_ui_UINodes.inst.getCanvasMaterial(),node,image,group,parents);
			arm_shader_MaterialParser.warp_passthrough = false;
		} else if(node.type == "BAKE_CURVATURE") {
			let id = arm_shader_MaterialParser.node_name(node,parents);
			let image = arm_Context.nodePreviews.h[id];
			arm_Context.nodePreviewsUsed.push(id);
			let resX = arm_Config.getTextureResX() | 0;
			let resY = arm_Config.getTextureResY() | 0;
			if(image == null || image.get_width() != resX || image.get_height() != resY) {
				if(image != null) {
					image.unload();
				}
				image = kha_Image.createRenderTarget(resX,resY,1);
				arm_Context.nodePreviews.h[id] = image;
			}
			if(arm_render_RenderPathPaint.liveLayer == null) {
				arm_render_RenderPathPaint.liveLayer = new arm_data_LayerSlot("_live");
			}
			let _space = arm_ui_UIHeader.inst.worktab.position;
			let _tool = arm_Context.tool;
			let _bakeType = arm_Context.bakeType;
			arm_ui_UIHeader.inst.worktab.position = 0;
			arm_Context.tool = 11;
			arm_Context.bakeType = 1;
			arm_shader_MaterialParser.bake_passthrough = true;
			arm_shader_MaterialParser.start_node = node;
			arm_shader_MaterialParser.start_group = group;
			arm_shader_MaterialParser.start_parents = parents;
			arm_node_MakeMaterial.parsePaintMaterial(false);
			arm_shader_MaterialParser.bake_passthrough = false;
			arm_shader_MaterialParser.start_node = null;
			arm_shader_MaterialParser.start_group = null;
			arm_shader_MaterialParser.start_parents = null;
			arm_Context.pdirty = 1;
			arm_render_RenderPathPaint.useLiveLayer(true);
			arm_render_RenderPathPaint.commandsPaint(false);
			arm_render_RenderPathPaint.dilate(true,false);
			arm_render_RenderPathPaint.useLiveLayer(false);
			arm_Context.pdirty = 0;
			arm_ui_UIHeader.inst.worktab.position = _space;
			arm_Context.tool = _tool;
			arm_Context.bakeType = _bakeType;
			arm_node_MakeMaterial.parsePaintMaterial(false);
			let texpaint_live = iron_RenderPath.active.renderTargets.h["texpaint_live"];
			image.get_g2().begin(false);
			image.get_g2().drawImage(texpaint_live.image,0,0);
			image.get_g2().end();
		}
	}
	static parseNodePreviewMaterial(node,group,parents) {
		if(node.outputs.length == 0) {
			return null;
		}
		let sdata = new arm_shader_NodeShaderData({ name : "Material", canvas : arm_ui_UINodes.inst.getCanvasMaterial()});
		let mcon_raw = { name : "mesh", bind_textures : []};
		let compileError = false;
		let scon = new iron_data_ShaderContext(arm_node_MakeNodePreview.run(sdata,mcon_raw,node,group,parents).data,function(scon) {
			if(scon == null) {
				compileError = true;
			}
		});
		if(compileError) {
			return null;
		}
		return { scon : scon, mcon : new iron_data_MaterialContext(mcon_raw,function(mcon) {
		})};
	}
	static parseBrush() {
		arm_node_Brush.parse(arm_Context.brush.canvas,false);
	}
	static blendMode(frag,blending,cola,colb,opac) {
		if(blending == 0) {
			return "mix(" + cola + ", " + colb + ", " + opac + ")";
		} else if(blending == 1) {
			return "mix(" + cola + ", min(" + cola + ", " + colb + "), " + opac + ")";
		} else if(blending == 2) {
			return "mix(" + cola + ", " + cola + " * " + colb + ", " + opac + ")";
		} else if(blending == 3) {
			return "mix(" + cola + ", vec3(1.0, 1.0, 1.0) - (vec3(1.0, 1.0, 1.0) - " + cola + ") / " + colb + ", " + opac + ")";
		} else if(blending == 4) {
			return "max(" + cola + ", " + colb + " * " + opac + ")";
		} else if(blending == 5) {
			return "(vec3(1.0, 1.0, 1.0) - (vec3(1.0 - " + opac + ", 1.0 - " + opac + ", 1.0 - " + opac + ") + " + opac + " * (vec3(1.0, 1.0, 1.0) - " + colb + ")) * (vec3(1.0, 1.0, 1.0) - " + cola + "))";
		} else if(blending == 6) {
			return "mix(" + cola + ", " + cola + " / (vec3(1.0, 1.0, 1.0) - " + colb + "), " + opac + ")";
		} else if(blending == 7) {
			return "mix(" + cola + ", " + cola + " + " + colb + ", " + opac + ")";
		} else if(blending == 8) {
			return "mix(" + cola + ", vec3(\r\n\t\t\t\t" + cola + ".r < 0.5 ? 2.0 * " + cola + ".r * " + colb + ".r : 1.0 - 2.0 * (1.0 - " + cola + ".r) * (1.0 - " + colb + ".r),\r\n\t\t\t\t" + cola + ".g < 0.5 ? 2.0 * " + cola + ".g * " + colb + ".g : 1.0 - 2.0 * (1.0 - " + cola + ".g) * (1.0 - " + colb + ".g),\r\n\t\t\t\t" + cola + ".b < 0.5 ? 2.0 * " + cola + ".b * " + colb + ".b : 1.0 - 2.0 * (1.0 - " + cola + ".b) * (1.0 - " + colb + ".b)\r\n\t\t\t), " + opac + ")";
		} else if(blending == 9) {
			return "((1.0 - " + opac + ") * " + cola + " + " + opac + " * ((vec3(1.0, 1.0, 1.0) - " + cola + ") * " + colb + " * " + cola + " + " + cola + " * (vec3(1.0, 1.0, 1.0) - (vec3(1.0, 1.0, 1.0) - " + colb + ") * (vec3(1.0, 1.0, 1.0) - " + cola + "))))";
		} else if(blending == 10) {
			return "(" + cola + " + " + opac + " * (vec3(2.0, 2.0, 2.0) * (" + colb + " - vec3(0.5, 0.5, 0.5))))";
		} else if(blending == 11) {
			return "mix(" + cola + ", abs(" + cola + " - " + colb + "), " + opac + ")";
		} else if(blending == 12) {
			return "mix(" + cola + ", " + cola + " - " + colb + ", " + opac + ")";
		} else if(blending == 13) {
			return "vec3(1.0 - " + opac + ", 1.0 - " + opac + ", 1.0 - " + opac + ") * " + cola + " + vec3(" + opac + ", " + opac + ", " + opac + ") * " + cola + " / " + colb;
		} else if(blending == 14) {
			frag.add_function(arm_shader_ShaderFunctions.str_hue_sat);
			return "mix(" + cola + ", hsv_to_rgb(vec3(rgb_to_hsv(" + colb + ").r, rgb_to_hsv(" + cola + ").g, rgb_to_hsv(" + cola + ").b)), " + opac + ")";
		} else if(blending == 15) {
			frag.add_function(arm_shader_ShaderFunctions.str_hue_sat);
			return "mix(" + cola + ", hsv_to_rgb(vec3(rgb_to_hsv(" + cola + ").r, rgb_to_hsv(" + colb + ").g, rgb_to_hsv(" + cola + ").b)), " + opac + ")";
		} else if(blending == 16) {
			frag.add_function(arm_shader_ShaderFunctions.str_hue_sat);
			return "mix(" + cola + ", hsv_to_rgb(vec3(rgb_to_hsv(" + colb + ").r, rgb_to_hsv(" + colb + ").g, rgb_to_hsv(" + cola + ").b)), " + opac + ")";
		} else {
			frag.add_function(arm_shader_ShaderFunctions.str_hue_sat);
			return "mix(" + cola + ", hsv_to_rgb(vec3(rgb_to_hsv(" + cola + ").r, rgb_to_hsv(" + cola + ").g, rgb_to_hsv(" + colb + ").b)), " + opac + ")";
		}
	}
	static blendModeMask(frag,blending,cola,colb,opac) {
		if(blending == 0) {
			return "mix(" + cola + ", " + colb + ", " + opac + ")";
		} else if(blending == 1) {
			return "mix(" + cola + ", min(" + cola + ", " + colb + "), " + opac + ")";
		} else if(blending == 2) {
			return "mix(" + cola + ", " + cola + " * " + colb + ", " + opac + ")";
		} else if(blending == 3) {
			return "mix(" + cola + ", 1.0 - (1.0 - " + cola + ") / " + colb + ", " + opac + ")";
		} else if(blending == 4) {
			return "max(" + cola + ", " + colb + " * " + opac + ")";
		} else if(blending == 5) {
			return "(1.0 - ((1.0 - " + opac + ") + " + opac + " * (1.0 - " + colb + ")) * (1.0 - " + cola + "))";
		} else if(blending == 6) {
			return "mix(" + cola + ", " + cola + " / (1.0 - " + colb + "), " + opac + ")";
		} else if(blending == 7) {
			return "mix(" + cola + ", " + cola + " + " + colb + ", " + opac + ")";
		} else if(blending == 8) {
			return "mix(" + cola + ", " + cola + " < 0.5 ? 2.0 * " + cola + " * " + colb + " : 1.0 - 2.0 * (1.0 - " + cola + ") * (1.0 - " + colb + "), " + opac + ")";
		} else if(blending == 9) {
			return "((1.0 - " + opac + ") * " + cola + " + " + opac + " * ((1.0 - " + cola + ") * " + colb + " * " + cola + " + " + cola + " * (1.0 - (1.0 - " + colb + ") * (1.0 - " + cola + "))))";
		} else if(blending == 10) {
			return "(" + cola + " + " + opac + " * (2.0 * (" + colb + " - 0.5)))";
		} else if(blending == 11) {
			return "mix(" + cola + ", abs(" + cola + " - " + colb + "), " + opac + ")";
		} else if(blending == 12) {
			return "mix(" + cola + ", " + cola + " - " + colb + ", " + opac + ")";
		} else if(blending == 13) {
			return "(1.0 - " + opac + ") * " + cola + " + " + opac + " * " + cola + " / " + colb;
		} else {
			return "mix(" + cola + ", " + colb + ", " + opac + ")";
		}
	}
}
$hxClasses["arm.node.MakeMaterial"] = arm_node_MakeMaterial;
arm_node_MakeMaterial.__name__ = "arm.node.MakeMaterial";
class arm_shader_MaterialParser {
	static getNode(id) {
		let _g = 0;
		let _g1 = arm_shader_MaterialParser.nodes;
		while(_g < _g1.length) {
			let n = _g1[_g];
			++_g;
			if(n.id == id) {
				return n;
			}
		}
		return null;
	}
	static getInputLink(inp) {
		let _g = 0;
		let _g1 = arm_shader_MaterialParser.links;
		while(_g < _g1.length) {
			let l = _g1[_g];
			++_g;
			if(l.to_id == inp.node_id) {
				let node = arm_shader_MaterialParser.getNode(inp.node_id);
				if(node.inputs.length <= l.to_socket) {
					return null;
				}
				if(node.inputs[l.to_socket] == inp) {
					return l;
				}
			}
		}
		return null;
	}
	static init() {
		arm_shader_MaterialParser.parsed = [];
		arm_shader_MaterialParser.parents = [];
		arm_shader_MaterialParser.cotangentFrameWritten = false;
		arm_shader_MaterialParser.out_normaltan = "vec3(0.5, 0.5, 1.0)";
		arm_shader_MaterialParser.script_links = null;
		arm_shader_MaterialParser.parsing_basecolor = false;
	}
	static parse(canvas,_con,_vert,_frag,_matcon) {
		arm_shader_MaterialParser.init();
		arm_shader_MaterialParser.canvases = [canvas];
		arm_shader_MaterialParser.nodes = canvas.nodes;
		arm_shader_MaterialParser.links = canvas.links;
		arm_shader_MaterialParser.con = _con;
		arm_shader_MaterialParser.vert = _vert;
		arm_shader_MaterialParser.frag = _frag;
		arm_shader_MaterialParser.curshader = arm_shader_MaterialParser.frag;
		arm_shader_MaterialParser.matcon = _matcon;
		if(arm_shader_MaterialParser.start_group != null) {
			arm_shader_MaterialParser.push_group(arm_shader_MaterialParser.start_group);
			arm_shader_MaterialParser.parents = arm_shader_MaterialParser.start_parents;
		}
		if(arm_shader_MaterialParser.start_node != null) {
			arm_shader_MaterialParser.write_result({ id : 99999, from_id : arm_shader_MaterialParser.start_node.id, from_socket : 0, to_id : -1, to_socket : -1});
			return { out_basecol : "vec3(0.0, 0.0, 0.0)", out_roughness : "0.0", out_metallic : "0.0", out_occlusion : "1.0", out_opacity : "1.0", out_height : "0.0", out_emission : "0.0", out_subsurface : "0.0"};
		}
		let output_node = arm_shader_MaterialParser.node_by_type(arm_shader_MaterialParser.nodes,"OUTPUT_MATERIAL");
		if(output_node != null) {
			return arm_shader_MaterialParser.parse_output(output_node);
		}
		output_node = arm_shader_MaterialParser.node_by_type(arm_shader_MaterialParser.nodes,"OUTPUT_MATERIAL_PBR");
		if(output_node != null) {
			return arm_shader_MaterialParser.parse_output_pbr(output_node);
		}
		return null;
	}
	static finalize(con) {
		let vert = con.vert;
		let frag = con.frag;
		if(frag.dotNV) {
			frag.vVec = true;
			frag.n = true;
		}
		if(frag.vVec) {
			vert.wposition = true;
		}
		if(frag.bposition) {
			if(arm_shader_MaterialParser.triplanar) {
				frag.write_attrib("vec3 bposition = vec3(\r\n\t\t\t\t\ttexCoord1.x * texCoordBlend.y + texCoord2.x * texCoordBlend.z,\r\n\t\t\t\t\ttexCoord.x * texCoordBlend.x + texCoord2.y * texCoordBlend.z,\r\n\t\t\t\t\ttexCoord.y * texCoordBlend.x + texCoord1.y * texCoordBlend.y);");
			} else if(frag.ndcpos) {
				vert.add_out("vec3 bposition");
				vert.write("bposition = (ndc.xyz / ndc.w);");
			} else {
				vert.add_out("vec3 bposition");
				vert.add_uniform("vec3 dim","_dim");
				vert.add_uniform("vec3 hdim","_halfDim");
				vert.write_attrib("bposition = (pos.xyz + hdim) / dim;");
			}
		}
		if(frag.wposition) {
			vert.add_uniform("mat4 W","_worldMatrix");
			vert.add_out("vec3 wposition");
			vert.write_attrib("wposition = vec4(mul(vec4(pos.xyz, 1.0), W)).xyz;");
		} else if(vert.wposition) {
			vert.add_uniform("mat4 W","_worldMatrix");
			vert.write_attrib("vec3 wposition = vec4(mul(vec4(pos.xyz, 1.0), W)).xyz;");
		}
		if(frag.vposition) {
			vert.add_uniform("mat4 WV","_worldViewMatrix");
			vert.add_out("vec3 vposition");
			vert.write_attrib("vposition = vec4(mul(vec4(pos.xyz, 1.0), WV)).xyz;");
		}
		if(frag.mposition) {
			vert.add_out("vec3 mposition");
			if(frag.ndcpos) {
				vert.write("mposition = (ndc.xyz / ndc.w);");
			} else {
				vert.write_attrib("mposition = pos.xyz;");
			}
		}
		if(frag.wtangent) {
			vert.add_out("vec3 wtangent");
			vert.write_attrib("wtangent = vec3(0.0, 0.0, 0.0);");
		}
		if(frag.vVecCam) {
			vert.add_uniform("mat4 WV","_worldViewMatrix");
			vert.add_out("vec3 eyeDirCam");
			vert.write_attrib("eyeDirCam = vec4(mul(vec4(pos.xyz, 1.0), WV)).xyz; eyeDirCam.z *= -1.0;");
			frag.write_attrib("vec3 vVecCam = normalize(eyeDirCam);");
		}
		if(frag.vVec) {
			vert.add_uniform("vec3 eye","_cameraPosition");
			vert.add_out("vec3 eyeDir");
			vert.write_attrib("eyeDir = eye - wposition;");
			frag.write_attrib("vec3 vVec = normalize(eyeDir);");
		}
		if(frag.n) {
			vert.add_uniform("mat3 N","_normalMatrix");
			vert.add_out("vec3 wnormal");
			vert.write_attrib("wnormal = mul(vec3(nor.xy, pos.w), N);");
			frag.write_attrib("vec3 n = normalize(wnormal);");
		} else if(vert.n) {
			vert.add_uniform("mat3 N","_normalMatrix");
			vert.write_attrib("vec3 wnormal = normalize(mul(vec3(nor.xy, pos.w), N));");
		}
		if(frag.nAttr) {
			vert.add_out("vec3 nAttr");
			vert.write_attrib("nAttr = vec3(nor.xy, pos.w);");
		}
		if(frag.dotNV) {
			frag.write_attrib("float dotNV = max(dot(n, vVec), 0.0);");
		}
		if(frag.wvpposition) {
			vert.add_out("vec4 wvpposition");
			vert.write_end("wvpposition = gl_Position;");
		}
		if(con.is_elem("col")) {
			vert.add_out("vec3 vcolor");
			vert.write_attrib("vcolor = col.rgb;");
		}
	}
	static parse_output(node) {
		if(arm_shader_MaterialParser.parse_surface || arm_shader_MaterialParser.parse_opacity) {
			return arm_shader_MaterialParser.parse_shader_input(node.inputs[0]);
		}
		return null;
	}
	static parse_output_pbr(node) {
		if(arm_shader_MaterialParser.parse_surface || arm_shader_MaterialParser.parse_opacity) {
			return arm_shader_MaterialParser.parse_shader(node,null);
		}
		return null;
	}
	static get_group(name) {
		let _g = 0;
		let _g1 = arm_Project.materialGroups;
		while(_g < _g1.length) {
			let g = _g1[_g];
			++_g;
			if(g.canvas.name == name) {
				return g.canvas;
			}
		}
		return null;
	}
	static push_group(g) {
		arm_shader_MaterialParser.canvases.push(g);
		arm_shader_MaterialParser.nodes = g.nodes;
		arm_shader_MaterialParser.links = g.links;
	}
	static pop_group() {
		arm_shader_MaterialParser.canvases.pop();
		let g = arm_shader_MaterialParser.canvases[arm_shader_MaterialParser.canvases.length - 1];
		arm_shader_MaterialParser.nodes = g.nodes;
		arm_shader_MaterialParser.links = g.links;
	}
	static parse_group(node,socket) {
		arm_shader_MaterialParser.parents.push(node);
		arm_shader_MaterialParser.push_group(arm_shader_MaterialParser.get_group(node.name));
		let output_node = arm_shader_MaterialParser.node_by_type(arm_shader_MaterialParser.nodes,"GROUP_OUTPUT");
		if(output_node == null) {
			return null;
		}
		let out_group = arm_shader_MaterialParser.parse_input(output_node.inputs[arm_shader_MaterialParser.socket_index(node,socket)]);
		arm_shader_MaterialParser.parents.pop();
		arm_shader_MaterialParser.pop_group();
		return out_group;
	}
	static parse_group_input(node,socket) {
		let parent = arm_shader_MaterialParser.parents.pop();
		arm_shader_MaterialParser.pop_group();
		let res = arm_shader_MaterialParser.parse_input(parent.inputs[arm_shader_MaterialParser.socket_index(node,socket)]);
		arm_shader_MaterialParser.parents.push(parent);
		arm_shader_MaterialParser.push_group(arm_shader_MaterialParser.get_group(parent.name));
		return res;
	}
	static parse_input(inp) {
		if(inp.type == "RGB") {
			return arm_shader_MaterialParser.parse_vector_input(inp);
		} else if(inp.type == "RGBA") {
			return arm_shader_MaterialParser.parse_vector_input(inp);
		} else if(inp.type == "VECTOR") {
			return arm_shader_MaterialParser.parse_vector_input(inp);
		} else if(inp.type == "VALUE") {
			return arm_shader_MaterialParser.parse_value_input(inp);
		}
		return null;
	}
	static parse_shader_input(inp) {
		while(true) {
			let l = arm_shader_MaterialParser.getInputLink(inp);
			let from_node = l != null ? arm_shader_MaterialParser.getNode(l.from_id) : null;
			if(from_node != null) {
				if(from_node.type == "REROUTE") {
					inp = from_node.inputs[0];
					continue;
				}
				return arm_shader_MaterialParser.parse_shader(from_node,from_node.outputs[l.from_socket]);
			} else {
				return { out_basecol : "vec3(0.8, 0.8, 0.8)", out_roughness : "0.0", out_metallic : "0.0", out_occlusion : "1.0", out_opacity : "1.0", out_height : "0.0", out_emission : "0.0", out_subsurface : "0.0"};
			}
		}
	}
	static parse_shader(node,socket) {
		let sout = { out_basecol : "vec3(0.8, 0.8, 0.8)", out_roughness : "0.0", out_metallic : "0.0", out_occlusion : "1.0", out_opacity : "1.0", out_height : "0.0", out_emission : "0.0", out_subsurface : "0.0"};
		if(node.type == "OUTPUT_MATERIAL_PBR") {
			if(arm_shader_MaterialParser.parse_surface) {
				arm_shader_MaterialParser.parse_normal_map_color_input(node.inputs[5]);
				arm_shader_MaterialParser.parsing_basecolor = true;
				sout.out_basecol = arm_shader_MaterialParser.parse_vector_input(node.inputs[0]);
				arm_shader_MaterialParser.parsing_basecolor = false;
				sout.out_occlusion = arm_shader_MaterialParser.parse_value_input(node.inputs[2]);
				sout.out_roughness = arm_shader_MaterialParser.parse_value_input(node.inputs[3]);
				sout.out_metallic = arm_shader_MaterialParser.parse_value_input(node.inputs[4]);
				if(arm_shader_MaterialParser.parse_emission) {
					sout.out_emission = arm_shader_MaterialParser.parse_value_input(node.inputs[6]);
				}
				if(arm_shader_MaterialParser.parse_subsurface) {
					sout.out_subsurface = arm_shader_MaterialParser.parse_value_input(node.inputs[8]);
				}
			}
			if(arm_shader_MaterialParser.parse_opacity) {
				sout.out_opacity = arm_shader_MaterialParser.parse_value_input(node.inputs[1]);
			}
			if(node.inputs.length > 7 && arm_shader_MaterialParser.parse_height) {
				if(!arm_shader_MaterialParser.parse_height_as_channel) {
					arm_shader_MaterialParser.curshader = arm_shader_MaterialParser.vert;
				}
				sout.out_height = arm_shader_MaterialParser.parse_value_input(node.inputs[7]);
				if(!arm_shader_MaterialParser.parse_height_as_channel) {
					arm_shader_MaterialParser.curshader = arm_shader_MaterialParser.frag;
				}
			}
		}
		return sout;
	}
	static parse_vector_input(inp) {
		while(true) {
			let l = arm_shader_MaterialParser.getInputLink(inp);
			let from_node = l != null ? arm_shader_MaterialParser.getNode(l.from_id) : null;
			if(from_node != null) {
				if(from_node.type == "REROUTE") {
					inp = from_node.inputs[0];
					continue;
				}
				let res_var = arm_shader_MaterialParser.write_result(l);
				let st = from_node.outputs[l.from_socket].type;
				if(st == "RGB" || st == "RGBA" || st == "VECTOR") {
					return res_var;
				} else {
					return "(" + res_var + ").xxx";
				}
			} else if(inp.type == "VALUE") {
				return "vec3(" + 0.0 + ", " + 0.0 + ", " + 0.0 + ")";
			} else {
				let v = inp.default_value;
				return "vec3(" + v[0] + ", " + v[1] + ", " + v[2] + ")";
			}
		}
	}
	static parse_vector(node,socket) {
		if(node.type == "GROUP") {
			return arm_shader_MaterialParser.parse_group(node,socket);
		} else if(node.type == "GROUP_INPUT") {
			return arm_shader_MaterialParser.parse_group_input(node,socket);
		} else if(node.type == "ATTRIBUTE") {
			if(socket == node.outputs[0]) {
				if(arm_shader_MaterialParser.curshader.context.allow_vcols) {
					arm_shader_MaterialParser.curshader.context.add_elem("col","short4norm");
					return "vcolor";
				} else {
					return "vec3(0.0, 0.0, 0.0)";
				}
			} else {
				arm_shader_MaterialParser.curshader.context.add_elem("tex","short2norm");
				return "vec3(texCoord.x, texCoord.y, 0.0)";
			}
		} else if(node.type == "VERTEX_COLOR") {
			if(arm_shader_MaterialParser.curshader.context.allow_vcols) {
				arm_shader_MaterialParser.curshader.context.add_elem("col","short4norm");
				return "vcolor";
			} else {
				return "vec3(0.0, 0.0, 0.0)";
			}
		} else if(node.type == "RGB") {
			let v = socket.default_value;
			return "vec3(" + v[0] + ", " + v[1] + ", " + v[2] + ")";
		} else if(node.type == "TEX_BRICK") {
			arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_tex_brick);
			let co = arm_shader_MaterialParser.getCoord(node);
			let col1 = arm_shader_MaterialParser.parse_vector_input(node.inputs[1]);
			let col2 = arm_shader_MaterialParser.parse_vector_input(node.inputs[2]);
			let col3 = arm_shader_MaterialParser.parse_vector_input(node.inputs[3]);
			return "tex_brick(" + co + " * " + arm_shader_MaterialParser.parse_value_input(node.inputs[4]) + ", " + col1 + ", " + col2 + ", " + col3 + ")";
		} else if(node.type == "TEX_CHECKER") {
			arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_tex_checker);
			return "tex_checker(" + arm_shader_MaterialParser.getCoord(node) + ", " + arm_shader_MaterialParser.parse_vector_input(node.inputs[1]) + ", " + arm_shader_MaterialParser.parse_vector_input(node.inputs[2]) + ", " + arm_shader_MaterialParser.parse_value_input(node.inputs[3]) + ")";
		} else if(node.type == "TEX_GRADIENT") {
			let co = arm_shader_MaterialParser.getCoord(node);
			let but = node.buttons[0];
			let grad = but.data[but.default_value].toUpperCase();
			grad = StringTools.replace(grad," ","_");
			return "(" + ("clamp(" + arm_shader_MaterialParser.getGradient(grad,co) + ", 0.0, 1.0)") + ").xxx";
		} else if(node.type == "TEX_IMAGE") {
			if(arm_shader_MaterialParser.parsed.indexOf(arm_shader_MaterialParser.res_var_name(node,node.outputs[1])) >= 0) {
				return "" + arm_shader_MaterialParser.store_var_name(node) + ".rgb";
			}
			let tex_name = arm_shader_MaterialParser.node_name(node);
			let tex = arm_shader_MaterialParser.make_texture(node,tex_name);
			if(tex != null) {
				return "" + arm_shader_MaterialParser.texture_store(node,tex,tex_name,node.buttons[1].default_value) + ".rgb";
			} else {
				let tex_store = arm_shader_MaterialParser.store_var_name(node);
				arm_shader_MaterialParser.curshader.write("vec4 " + tex_store + " = vec4(1.0, 0.0, 1.0, 1.0);");
				return "" + tex_store + ".rgb";
			}
		} else if(node.type == "TEX_MAGIC") {
			arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_tex_magic);
			return "tex_magic(" + arm_shader_MaterialParser.getCoord(node) + " * " + arm_shader_MaterialParser.parse_value_input(node.inputs[1]) + " * 4.0)";
		} else if(node.type == "TEX_NOISE") {
			arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_tex_noise);
			let co = arm_shader_MaterialParser.getCoord(node);
			let scale = arm_shader_MaterialParser.parse_value_input(node.inputs[1]);
			return "vec3(tex_noise(" + co + " * " + scale + "), tex_noise(" + co + " * " + scale + " + 0.33), tex_noise(" + co + " * " + scale + " + 0.66))";
		} else if(node.type == "TEX_VORONOI") {
			arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_tex_voronoi);
			arm_shader_MaterialParser.curshader.add_uniform("sampler2D snoise256","$noise256.k");
			let co = arm_shader_MaterialParser.getCoord(node);
			let scale = arm_shader_MaterialParser.parse_value_input(node.inputs[1]);
			let but = node.buttons[0];
			let coloring = but.data[but.default_value].toUpperCase();
			coloring = StringTools.replace(coloring," ","_");
			let res = "";
			if(coloring == "INTENSITY") {
				res = "(" + ("tex_voronoi(" + co + " * " + scale + ", texturePass(snoise256)).a") + ").xxx";
			} else {
				res = "tex_voronoi(" + co + " * " + scale + ", texturePass(snoise256)).rgb";
			}
			return res;
		} else if(node.type == "TEX_WAVE") {
			arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_tex_wave);
			return "(" + ("tex_wave_f(" + arm_shader_MaterialParser.getCoord(node) + " * " + arm_shader_MaterialParser.parse_value_input(node.inputs[1]) + ")") + ").xxx";
		} else if(node.type == "BRIGHTCONTRAST") {
			let out_col = arm_shader_MaterialParser.parse_vector_input(node.inputs[0]);
			let bright = arm_shader_MaterialParser.parse_value_input(node.inputs[1]);
			let contr = arm_shader_MaterialParser.parse_value_input(node.inputs[2]);
			arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_brightcontrast);
			return "brightcontrast(" + out_col + ", " + bright + ", " + contr + ")";
		} else if(node.type == "GAMMA") {
			return "pow(" + arm_shader_MaterialParser.parse_vector_input(node.inputs[0]) + ", " + ("(" + ("" + arm_shader_MaterialParser.parse_value_input(node.inputs[1])) + ").xxx") + ")";
		} else if(node.type == "DIRECT_WARP") {
			if(arm_shader_MaterialParser.warp_passthrough) {
				return arm_shader_MaterialParser.parse_vector_input(node.inputs[0]);
			}
			let angle = arm_shader_MaterialParser.parse_value_input(node.inputs[1],true);
			let mask = arm_shader_MaterialParser.parse_value_input(node.inputs[2],true);
			let tex_name = "texwarp_" + arm_shader_MaterialParser.node_name(node);
			arm_shader_MaterialParser.curshader.add_uniform("sampler2D " + tex_name,"_" + tex_name);
			let store = arm_shader_MaterialParser.store_var_name(node);
			arm_shader_MaterialParser.curshader.write("float " + store + "_rad = " + angle + " * (" + Math.PI + " / 180);");
			arm_shader_MaterialParser.curshader.write("float " + store + "_x = cos(" + store + "_rad);");
			arm_shader_MaterialParser.curshader.write("float " + store + "_y = sin(" + store + "_rad);");
			return "texture(" + tex_name + ", texCoord + vec2(" + store + "_x, " + store + "_y) * " + mask + ").rgb;";
		} else if(node.type == "BLUR") {
			if(arm_shader_MaterialParser.blur_passthrough) {
				return arm_shader_MaterialParser.parse_vector_input(node.inputs[0]);
			}
			let strength = arm_shader_MaterialParser.parse_value_input(node.inputs[1]);
			if(strength == "0.0") {
				return "vec3(0.0, 0.0, 0.0)";
			}
			let steps = "int(" + strength + " * 10 + 1)";
			let tex_name = "texblur_" + arm_shader_MaterialParser.node_name(node);
			arm_shader_MaterialParser.curshader.add_uniform("sampler2D " + tex_name,"_" + tex_name);
			let store = arm_shader_MaterialParser.store_var_name(node);
			arm_shader_MaterialParser.curshader.write("vec3 " + store + "_res = vec3(0.0, 0.0, 0.0);");
			arm_shader_MaterialParser.curshader.write("for (int i = -" + steps + "; i <= " + steps + "; ++i) {");
			arm_shader_MaterialParser.curshader.write("for (int j = -" + steps + "; j <= " + steps + "; ++j) {");
			arm_shader_MaterialParser.curshader.write("" + store + "_res += texture(" + tex_name + ", texCoord + vec2(i, j) / vec2(textureSize(" + tex_name + ", 0))).rgb;");
			arm_shader_MaterialParser.curshader.write("}");
			arm_shader_MaterialParser.curshader.write("}");
			arm_shader_MaterialParser.curshader.write("" + store + "_res /= (" + steps + " * 2 + 1) * (" + steps + " * 2 + 1);");
			return "" + store + "_res";
		} else if(node.type == "HUE_SAT") {
			arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_hue_sat);
			let hue = arm_shader_MaterialParser.parse_value_input(node.inputs[0]);
			let sat = arm_shader_MaterialParser.parse_value_input(node.inputs[1]);
			let val = arm_shader_MaterialParser.parse_value_input(node.inputs[2]);
			let fac = arm_shader_MaterialParser.parse_value_input(node.inputs[3]);
			return "hue_sat(" + arm_shader_MaterialParser.parse_vector_input(node.inputs[4]) + ", vec4(" + hue + "-0.5, " + sat + ", " + val + ", 1.0-" + fac + "))";
		} else if(node.type == "INVERT") {
			let fac = arm_shader_MaterialParser.parse_value_input(node.inputs[0]);
			let out_col = arm_shader_MaterialParser.parse_vector_input(node.inputs[1]);
			return "mix(" + out_col + ", vec3(1.0, 1.0, 1.0) - (" + out_col + "), " + fac + ")";
		} else if(node.type == "MIX_RGB") {
			let fac = arm_shader_MaterialParser.parse_value_input(node.inputs[0]);
			let fac_var = arm_shader_MaterialParser.node_name(node) + "_fac";
			arm_shader_MaterialParser.curshader.write("float " + fac_var + " = " + fac + ";");
			let col1 = arm_shader_MaterialParser.parse_vector_input(node.inputs[1]);
			let col2 = arm_shader_MaterialParser.parse_vector_input(node.inputs[2]);
			let but = node.buttons[0];
			let blend = but.data[but.default_value].toUpperCase();
			blend = StringTools.replace(blend," ","_");
			let use_clamp = node.buttons[1].default_value == true;
			let out_col = "";
			if(blend == "MIX") {
				out_col = "mix(" + col1 + ", " + col2 + ", " + fac_var + ")";
			} else if(blend == "DARKEN") {
				out_col = "min(" + col1 + ", " + col2 + " * " + fac_var + ")";
			} else if(blend == "MULTIPLY") {
				out_col = "mix(" + col1 + ", " + col1 + " * " + col2 + ", " + fac_var + ")";
			} else if(blend == "BURN") {
				out_col = "mix(" + col1 + ", vec3(1.0, 1.0, 1.0) - (vec3(1.0, 1.0, 1.0) - " + col1 + ") / " + col2 + ", " + fac_var + ")";
			} else if(blend == "LIGHTEN") {
				out_col = "max(" + col1 + ", " + col2 + " * " + fac_var + ")";
			} else if(blend == "SCREEN") {
				out_col = "(vec3(1.0, 1.0, 1.0) - (" + ("(" + ("1.0 - " + fac_var) + ").xxx") + (" + " + fac_var + " * (vec3(1.0, 1.0, 1.0) - " + col2 + ")) * (vec3(1.0, 1.0, 1.0) - " + col1 + "))");
			} else if(blend == "DODGE") {
				out_col = "mix(" + col1 + ", " + col1 + " / (vec3(1.0, 1.0, 1.0) - " + col2 + "), " + fac_var + ")";
			} else if(blend == "ADD") {
				out_col = "mix(" + col1 + ", " + col1 + " + " + col2 + ", " + fac_var + ")";
			} else if(blend == "OVERLAY") {
				out_col = "mix(" + col1 + ", vec3(\r\n\t\t\t\t\t" + col1 + ".r < 0.5 ? 2.0 * " + col1 + ".r * " + col2 + ".r : 1.0 - 2.0 * (1.0 - " + col1 + ".r) * (1.0 - " + col2 + ".r),\r\n\t\t\t\t\t" + col1 + ".g < 0.5 ? 2.0 * " + col1 + ".g * " + col2 + ".g : 1.0 - 2.0 * (1.0 - " + col1 + ".g) * (1.0 - " + col2 + ".g),\r\n\t\t\t\t\t" + col1 + ".b < 0.5 ? 2.0 * " + col1 + ".b * " + col2 + ".b : 1.0 - 2.0 * (1.0 - " + col1 + ".b) * (1.0 - " + col2 + ".b)\r\n\t\t\t\t), " + fac_var + ")";
			} else if(blend == "SOFT_LIGHT") {
				out_col = "((1.0 - " + fac_var + ") * " + col1 + " + " + fac_var + " * ((vec3(1.0, 1.0, 1.0) - " + col1 + ") * " + col2 + " * " + col1 + " + " + col1 + " * (vec3(1.0, 1.0, 1.0) - (vec3(1.0, 1.0, 1.0) - " + col2 + ") * (vec3(1.0, 1.0, 1.0) - " + col1 + "))))";
			} else if(blend == "LINEAR_LIGHT") {
				out_col = "(" + col1 + " + " + fac_var + " * (vec3(2.0, 2.0, 2.0) * (" + col2 + " - vec3(0.5, 0.5, 0.5))))";
			} else if(blend == "DIFFERENCE") {
				out_col = "mix(" + col1 + ", abs(" + col1 + " - " + col2 + "), " + fac_var + ")";
			} else if(blend == "SUBTRACT") {
				out_col = "mix(" + col1 + ", " + col1 + " - " + col2 + ", " + fac_var + ")";
			} else if(blend == "DIVIDE") {
				col2 = "max(" + col2 + ", vec3(" + 0.000001 + ", " + 0.000001 + ", " + 0.000001 + "))";
				out_col = "(" + ("(" + ("(1.0 - " + fac_var + ") * " + col1 + " + " + fac_var + " * " + col1 + " / " + col2) + ").xxx") + ")";
			} else if(blend == "HUE") {
				arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_hue_sat);
				out_col = "mix(" + col1 + ", hsv_to_rgb(vec3(rgb_to_hsv(" + col2 + ").r, rgb_to_hsv(" + col1 + ").g, rgb_to_hsv(" + col1 + ").b)), " + fac_var + ")";
			} else if(blend == "SATURATION") {
				arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_hue_sat);
				out_col = "mix(" + col1 + ", hsv_to_rgb(vec3(rgb_to_hsv(" + col1 + ").r, rgb_to_hsv(" + col2 + ").g, rgb_to_hsv(" + col1 + ").b)), " + fac_var + ")";
			} else if(blend == "COLOR") {
				arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_hue_sat);
				out_col = "mix(" + col1 + ", hsv_to_rgb(vec3(rgb_to_hsv(" + col2 + ").r, rgb_to_hsv(" + col2 + ").g, rgb_to_hsv(" + col1 + ").b)), " + fac_var + ")";
			} else if(blend == "VALUE") {
				arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_hue_sat);
				out_col = "mix(" + col1 + ", hsv_to_rgb(vec3(rgb_to_hsv(" + col1 + ").r, rgb_to_hsv(" + col1 + ").g, rgb_to_hsv(" + col2 + ").b)), " + fac_var + ")";
			}
			if(use_clamp) {
				return "clamp(" + out_col + ", vec3(0.0, 0.0, 0.0), vec3(1.0, 1.0, 1.0))";
			} else {
				return out_col;
			}
		} else if(node.type == "QUANTIZE") {
			let strength = arm_shader_MaterialParser.parse_value_input(node.inputs[0]);
			return "(floor(100.0 * " + strength + " * " + arm_shader_MaterialParser.parse_vector_input(node.inputs[1]) + ") / (100.0 * " + strength + "))";
		} else if(node.type == "VALTORGB") {
			let fac = arm_shader_MaterialParser.parse_value_input(node.inputs[0]);
			let interp = node.buttons[0].data == 0 ? "LINEAR" : "CONSTANT";
			let elems = node.buttons[0].default_value;
			if(elems.length == 1) {
				let v = elems[0];
				return "vec3(" + v[0] + ", " + v[1] + ", " + v[2] + ")";
			}
			let cols_var = arm_shader_MaterialParser.node_name(node) + "_cols";
			arm_shader_MaterialParser.curshader.write("vec3 " + cols_var + "[" + elems.length + "];");
			let _g = 0;
			let _g1 = elems.length;
			while(_g < _g1) {
				let i = _g++;
				let v = elems[i];
				arm_shader_MaterialParser.curshader.write("" + cols_var + "[" + i + "] = " + ("vec3(" + v[0] + ", " + v[1] + ", " + v[2] + ")") + ";");
			}
			let fac_var = arm_shader_MaterialParser.node_name(node) + "_fac";
			arm_shader_MaterialParser.curshader.write("float " + fac_var + " = " + fac + ";");
			let index = "0";
			let _g2 = 1;
			let _g3 = elems.length;
			while(_g2 < _g3) index += " + (" + fac_var + " > " + elems[_g2++][4] + " ? 1 : 0)";
			let index_var = arm_shader_MaterialParser.node_name(node) + "_i";
			arm_shader_MaterialParser.curshader.write("int " + index_var + " = " + index + ";");
			if(interp == "CONSTANT") {
				return "" + cols_var + "[" + index_var + "]";
			} else {
				let facs_var = arm_shader_MaterialParser.node_name(node) + "_facs";
				arm_shader_MaterialParser.curshader.write("float " + facs_var + "[" + elems.length + "];");
				let _g = 0;
				let _g1 = elems.length;
				while(_g < _g1) {
					let i = _g++;
					arm_shader_MaterialParser.curshader.write("" + facs_var + "[" + i + "] = " + elems[i][4] + ";");
				}
				return "mix(" + cols_var + "[" + index_var + "], " + cols_var + "[" + index_var + " + 1], (" + fac_var + " - " + facs_var + "[" + index_var + "]) * (1.0 / (" + facs_var + "[" + index_var + " + 1] - " + facs_var + "[" + index_var + "]) ))";
			}
		} else if(node.type == "CURVE_VEC") {
			let fac = arm_shader_MaterialParser.parse_value_input(node.inputs[0]);
			let vec = arm_shader_MaterialParser.parse_vector_input(node.inputs[1]);
			let curves = node.buttons[0].default_value;
			let name = arm_shader_MaterialParser.node_name(node);
			return "(vec3(" + arm_shader_MaterialParser.vector_curve(name + "0",vec + ".x",curves[0]) + ", " + arm_shader_MaterialParser.vector_curve(name + "1",vec + ".y",curves[1]) + ", " + arm_shader_MaterialParser.vector_curve(name + "2",vec + ".z",curves[2]) + ") * " + fac + ")";
		} else if(node.type == "CURVE_RGB") {
			let fac = arm_shader_MaterialParser.parse_value_input(node.inputs[0]);
			let vec = arm_shader_MaterialParser.parse_vector_input(node.inputs[1]);
			let curves = node.buttons[0].default_value;
			let name = arm_shader_MaterialParser.node_name(node);
			return "(sqrt(vec3(" + arm_shader_MaterialParser.vector_curve(name + "0",vec + ".x",curves[0]) + ", " + arm_shader_MaterialParser.vector_curve(name + "1",vec + ".y",curves[1]) + ", " + arm_shader_MaterialParser.vector_curve(name + "2",vec + ".z",curves[2]) + ") * vec3(" + arm_shader_MaterialParser.vector_curve(name + "3a",vec + ".x",curves[3]) + ", " + arm_shader_MaterialParser.vector_curve(name + "3b",vec + ".y",curves[3]) + ", " + arm_shader_MaterialParser.vector_curve(name + "3c",vec + ".z",curves[3]) + ")) * " + fac + ")";
		} else if(node.type == "COMBHSV") {
			arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_hue_sat);
			return "hsv_to_rgb(vec3(" + arm_shader_MaterialParser.parse_value_input(node.inputs[0]) + ", " + arm_shader_MaterialParser.parse_value_input(node.inputs[1]) + ", " + arm_shader_MaterialParser.parse_value_input(node.inputs[2]) + "))";
		} else if(node.type == "COMBRGB") {
			return "vec3(" + arm_shader_MaterialParser.parse_value_input(node.inputs[0]) + ", " + arm_shader_MaterialParser.parse_value_input(node.inputs[1]) + ", " + arm_shader_MaterialParser.parse_value_input(node.inputs[2]) + ")";
		} else if(node.type == "WAVELENGTH") {
			arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_wavelength_to_rgb);
			let wl = arm_shader_MaterialParser.parse_value_input(node.inputs[0]);
			arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_wavelength_to_rgb);
			return "wavelength_to_rgb((" + wl + " - 450.0) / 150.0)";
		} else if(node.type == "CAMERA") {
			arm_shader_MaterialParser.curshader.vVecCam = true;
			return "vVecCam";
		} else if(node.type == "LAYER") {
			let l = node.buttons[0].default_value;
			if(socket == node.outputs[0]) {
				arm_shader_MaterialParser.curshader.add_uniform("sampler2D texpaint" + Std.string(l),"_texpaint" + Std.string(l));
				return "texture(texpaint" + Std.string(l) + ", texCoord).rgb";
			} else if(socket == node.outputs[5]) {
				arm_shader_MaterialParser.curshader.add_uniform("sampler2D texpaint_nor" + Std.string(l),"_texpaint_nor" + Std.string(l));
				return "texture(texpaint_nor" + Std.string(l) + ", texCoord).rgb";
			}
		} else if(node.type == "MATERIAL") {
			let result = "vec3(0.0, 0.0, 0.0)";
			let mi = node.buttons[0].default_value;
			if(mi >= arm_Project.materials.length) {
				return "vec3(0.0, 0.0, 0.0)";
			}
			let m = arm_Project.materials[mi];
			let _nodes = arm_shader_MaterialParser.nodes;
			let _links = arm_shader_MaterialParser.links;
			arm_shader_MaterialParser.nodes = m.canvas.nodes;
			arm_shader_MaterialParser.links = m.canvas.links;
			arm_shader_MaterialParser.parents.push(node);
			let output_node = arm_shader_MaterialParser.node_by_type(arm_shader_MaterialParser.nodes,"OUTPUT_MATERIAL_PBR");
			if(socket == node.outputs[0]) {
				result = arm_shader_MaterialParser.parse_vector_input(output_node.inputs[0]);
			} else if(socket == node.outputs[5]) {
				result = arm_shader_MaterialParser.parse_vector_input(output_node.inputs[5]);
			}
			arm_shader_MaterialParser.nodes = _nodes;
			arm_shader_MaterialParser.links = _links;
			arm_shader_MaterialParser.parents.pop();
			return result;
		} else if(node.type == "PICKER") {
			if(socket == node.outputs[0]) {
				arm_shader_MaterialParser.curshader.add_uniform("vec3 pickerBase","_pickerBase");
				return "pickerBase";
			} else if(socket == node.outputs[5]) {
				arm_shader_MaterialParser.curshader.add_uniform("vec3 pickerNormal","_pickerNormal");
				return "pickerNormal";
			}
		} else if(node.type == "NEW_GEOMETRY") {
			if(socket == node.outputs[0]) {
				arm_shader_MaterialParser.curshader.wposition = true;
				return "wposition";
			} else if(socket == node.outputs[1]) {
				arm_shader_MaterialParser.curshader.n = true;
				return "n";
			} else if(socket == node.outputs[2]) {
				arm_shader_MaterialParser.curshader.wtangent = true;
				return "wtangent";
			} else if(socket == node.outputs[3]) {
				arm_shader_MaterialParser.curshader.n = true;
				return "n";
			} else if(socket == node.outputs[4]) {
				arm_shader_MaterialParser.curshader.vVec = true;
				return "vVec";
			} else if(socket == node.outputs[5]) {
				arm_shader_MaterialParser.curshader.mposition = true;
				return "mposition";
			}
		} else if(node.type == "OBJECT_INFO") {
			if(socket == node.outputs[0]) {
				arm_shader_MaterialParser.curshader.wposition = true;
				return "wposition";
			} else if(socket == node.outputs[1]) {
				return "vec3(0.0, 0.0, 0.0)";
			}
		} else if(node.type == "TANGENT") {
			arm_shader_MaterialParser.curshader.wtangent = true;
			return "wtangent";
		} else if(node.type == "TEX_COORD") {
			if(socket == node.outputs[0]) {
				arm_shader_MaterialParser.curshader.bposition = true;
				return "bposition";
			} else if(socket == node.outputs[1]) {
				arm_shader_MaterialParser.curshader.n = true;
				return "n";
			} else if(socket == node.outputs[2]) {
				arm_shader_MaterialParser.curshader.context.add_elem("tex","short2norm");
				return "vec3(texCoord.x, texCoord.y, 0.0)";
			} else if(socket == node.outputs[3]) {
				arm_shader_MaterialParser.curshader.mposition = true;
				return "mposition";
			} else if(socket == node.outputs[4]) {
				arm_shader_MaterialParser.curshader.vposition = true;
				return "vposition";
			} else if(socket == node.outputs[5]) {
				arm_shader_MaterialParser.curshader.wvpposition = true;
				return "wvpposition.xyz";
			} else if(socket == node.outputs[6]) {
				return "vec3(0.0, 0.0, 0.0)";
			}
		} else if(node.type == "UVMAP") {
			arm_shader_MaterialParser.curshader.context.add_elem("tex","short2norm");
			return "vec3(texCoord.x, texCoord.y, 0.0)";
		} else if(node.type == "BUMP") {
			let strength = arm_shader_MaterialParser.parse_value_input(node.inputs[0]);
			let height = arm_shader_MaterialParser.parse_value_input(node.inputs[2]);
			let nor = arm_shader_MaterialParser.parse_vector_input(node.inputs[3]);
			let sample_bump_res = arm_shader_MaterialParser.store_var_name(node) + "_bump";
			arm_shader_MaterialParser.curshader.write("float " + sample_bump_res + "_x = dFdx(float(" + height + ")) * (" + strength + ") * 16.0;");
			arm_shader_MaterialParser.curshader.write("float " + sample_bump_res + "_y = dFdy(float(" + height + ")) * (" + strength + ") * 16.0;");
			return "(normalize(vec3(" + sample_bump_res + "_x, " + sample_bump_res + "_y, 1.0) + " + nor + ") * vec3(0.5, 0.5, 0.5) + vec3(0.5, 0.5, 0.5))";
		} else if(node.type == "MAPPING") {
			let out = arm_shader_MaterialParser.parse_vector_input(node.inputs[0]);
			let node_translation = arm_shader_MaterialParser.parse_vector_input(node.inputs[1]);
			let node_rotation = arm_shader_MaterialParser.parse_vector_input(node.inputs[2]);
			let node_scale = arm_shader_MaterialParser.parse_vector_input(node.inputs[3]);
			if(node_scale != "vec3(1, 1, 1)") {
				out = "(" + out + " * " + node_scale + ")";
			}
			if(node_rotation != "vec3(0, 0, 0)") {
				let a = "" + node_rotation + ".z * (3.1415926535 / 180)";
				out = "vec3(" + out + ".x * cos(" + a + ") - " + out + ".y * sin(" + a + "), " + out + ".x * sin(" + a + ") + " + out + ".y * cos(" + a + "), 0.0)";
			}
			if(node_translation != "vec3(0, 0, 0)") {
				out = "(" + out + " + " + node_translation + ")";
			}
			return out;
		} else if(node.type == "NORMAL") {
			if(socket == node.outputs[0]) {
				let v = node.outputs[0].default_value;
				return "vec3(" + v[0] + ", " + v[1] + ", " + v[2] + ")";
			} else if(socket == node.outputs[1]) {
				let nor = arm_shader_MaterialParser.parse_vector_input(node.inputs[0]);
				let v = node.outputs[0].default_value;
				return "(" + ("dot(" + ("vec3(" + v[0] + ", " + v[1] + ", " + v[2] + ")") + ", " + nor + ")") + ").xxx";
			}
		} else if(node.type == "NORMAL_MAP") {
			let strength = arm_shader_MaterialParser.parse_value_input(node.inputs[0]);
			let norm = arm_shader_MaterialParser.parse_vector_input(node.inputs[1]);
			let store = arm_shader_MaterialParser.store_var_name(node);
			arm_shader_MaterialParser.curshader.write("vec3 " + store + "_texn = " + norm + " * 2.0 - 1.0;");
			arm_shader_MaterialParser.curshader.write("" + store + "_texn.xy = " + strength + " * " + store + "_texn.xy;");
			arm_shader_MaterialParser.curshader.write("" + store + "_texn = normalize(" + store + "_texn);");
			return "(0.5 * " + store + "_texn + 0.5)";
		} else if(node.type == "MIX_NORMAL_MAP") {
			let nm1 = arm_shader_MaterialParser.parse_vector_input(node.inputs[0]);
			let nm2 = arm_shader_MaterialParser.parse_vector_input(node.inputs[1]);
			let but = node.buttons[0];
			let blend = but.data[but.default_value].toUpperCase();
			blend = StringTools.replace(blend," ","_");
			let store = arm_shader_MaterialParser.store_var_name(node);
			if(blend == "PARTIAL_DERIVATIVE") {
				arm_shader_MaterialParser.curshader.write("vec3 " + store + "_n1 = " + nm1 + " * 2.0 - 1.0;");
				arm_shader_MaterialParser.curshader.write("vec3 " + store + "_n2 = " + nm2 + " * 2.0 - 1.0;");
				return "0.5 * normalize(vec3(" + store + "_n1.xy * " + store + "_n2.z + " + store + "_n2.xy * " + store + "_n1.z, " + store + "_n1.z * " + store + "_n2.z)) + 0.5;";
			} else if(blend == "WHITEOUT") {
				arm_shader_MaterialParser.curshader.write("vec3 " + store + "_n1 = " + nm1 + " * 2.0 - 1.0;");
				arm_shader_MaterialParser.curshader.write("vec3 " + store + "_n2 = " + nm2 + " * 2.0 - 1.0;");
				return "0.5 * normalize(vec3(" + store + "_n1.xy + " + store + "_n2.xy, " + store + "_n1.z * " + store + "_n2.z)) + 0.5;";
			} else if(blend == "REORIENTED") {
				arm_shader_MaterialParser.curshader.write("vec3 " + store + "_n1 = " + nm1 + " * 2.0 - vec3(1.0, 1.0, 0.0);");
				arm_shader_MaterialParser.curshader.write("vec3 " + store + "_n2 = " + nm2 + " * vec3(-2.0, -2.0, 2.0) - vec3(-1.0, -1.0, 1.0);");
				return "0.5 * normalize(" + store + "_n1 * dot(" + store + "_n1, " + store + "_n2) - " + store + "_n2 * " + store + "_n1.z) + 0.5";
			}
		} else if(node.type != "VECT_TRANSFORM") {
			if(node.type == "COMBXYZ") {
				return "vec3(" + arm_shader_MaterialParser.parse_value_input(node.inputs[0]) + ", " + arm_shader_MaterialParser.parse_value_input(node.inputs[1]) + ", " + arm_shader_MaterialParser.parse_value_input(node.inputs[2]) + ")";
			} else if(node.type == "VECT_MATH") {
				let vec1 = arm_shader_MaterialParser.parse_vector_input(node.inputs[0]);
				let vec2 = arm_shader_MaterialParser.parse_vector_input(node.inputs[1]);
				let but = node.buttons[0];
				let op = but.data[but.default_value].toUpperCase();
				op = StringTools.replace(op," ","_");
				if(op == "ADD") {
					return "(" + vec1 + " + " + vec2 + ")";
				} else if(op == "SUBTRACT") {
					return "(" + vec1 + " - " + vec2 + ")";
				} else if(op == "AVERAGE") {
					return "((" + vec1 + " + " + vec2 + ") / 2.0)";
				} else if(op == "DOT_PRODUCT") {
					return "(" + ("dot(" + vec1 + ", " + vec2 + ")") + ").xxx";
				} else if(op == "LENGTH") {
					return "(" + ("length(" + vec1 + ")") + ").xxx";
				} else if(op == "DISTANCE") {
					return "(" + ("distance(" + vec1 + ", " + vec2 + ")") + ").xxx";
				} else if(op == "CROSS_PRODUCT") {
					return "cross(" + vec1 + ", " + vec2 + ")";
				} else if(op == "NORMALIZE") {
					return "normalize(" + vec1 + ")";
				} else if(op == "MULTIPLY") {
					return "(" + vec1 + " * " + vec2 + ")";
				} else if(op == "DIVIDE") {
					return "vec3(" + vec1 + ".x / (" + vec2 + ".x == 0 ? 0.000001 : " + vec2 + ".x), " + vec1 + ".y / (" + vec2 + ".y == 0 ? 0.000001 : " + vec2 + ".y), " + vec1 + ".z / (" + vec2 + ".z == 0 ? 0.000001 : " + vec2 + ".z))";
				} else if(op == "PROJECT") {
					return "(dot(" + vec1 + ", " + vec2 + ") / dot(" + vec2 + ", " + vec2 + ") * " + vec2 + ")";
				} else if(op == "REFLECT") {
					return "reflect(" + vec1 + ", normalize(" + vec2 + "))";
				} else if(op == "SCALE") {
					return "(" + vec2 + ".x * " + vec1 + ")";
				} else if(op == "ABSOLUTE") {
					return "abs(" + vec1 + ")";
				} else if(op == "MINIMUM") {
					return "min(" + vec1 + ", " + vec2 + ")";
				} else if(op == "MAXIMUM") {
					return "max(" + vec1 + ", " + vec2 + ")";
				} else if(op == "FLOOR") {
					return "floor(" + vec1 + ")";
				} else if(op == "CEIL") {
					return "ceil(" + vec1 + ")";
				} else if(op == "FRACTION") {
					return "fract(" + vec1 + ")";
				} else if(op == "MODULO") {
					return "mod(" + vec1 + ", " + vec2 + ")";
				} else if(op == "SNAP") {
					return "(floor(" + vec1 + " / " + vec2 + ") * " + vec2 + ")";
				} else if(op == "SINE") {
					return "sin(" + vec1 + ")";
				} else if(op == "COSINE") {
					return "cos(" + vec1 + ")";
				} else if(op == "TANGENT") {
					return "tan(" + vec1 + ")";
				}
			} else if(node.type == "Displacement") {
				return "(" + ("" + arm_shader_MaterialParser.parse_value_input(node.inputs[0])) + ").xxx";
			} else if(arm_shader_MaterialParser.customNodes.get(node.type) != null) {
				return (arm_shader_MaterialParser.customNodes.get(node.type))(node,socket);
			}
		}
		return "vec3(0.0, 0.0, 0.0)";
	}
	static parse_normal_map_color_input(inp) {
		arm_shader_MaterialParser.frag.write_normal++;
		arm_shader_MaterialParser.out_normaltan = arm_shader_MaterialParser.parse_vector_input(inp);
		if(!arm_shader_MaterialParser.arm_export_tangents) {
			arm_shader_MaterialParser.frag.write("vec3 texn = (" + arm_shader_MaterialParser.out_normaltan + ") * 2.0 - 1.0;");
			arm_shader_MaterialParser.frag.write("texn.y = -texn.y;");
			if(!arm_shader_MaterialParser.cotangentFrameWritten) {
				arm_shader_MaterialParser.cotangentFrameWritten = true;
				arm_shader_MaterialParser.frag.add_function(arm_shader_ShaderFunctions.str_cotangentFrame);
			}
			arm_shader_MaterialParser.frag.n = true;
			arm_shader_MaterialParser.frag.write("mat3 TBN = cotangentFrame(n, vVec, texCoord);");
			arm_shader_MaterialParser.frag.write("n = mul(normalize(texn), TBN);");
		}
		arm_shader_MaterialParser.frag.write_normal--;
	}
	static parse_value_input(inp,vector_as_grayscale) {
		if(vector_as_grayscale == null) {
			vector_as_grayscale = false;
		}
		while(true) {
			let l = arm_shader_MaterialParser.getInputLink(inp);
			let from_node = l != null ? arm_shader_MaterialParser.getNode(l.from_id) : null;
			if(from_node != null) {
				if(from_node.type == "REROUTE") {
					inp = from_node.inputs[0];
					vector_as_grayscale = false;
					continue;
				}
				let res_var = arm_shader_MaterialParser.write_result(l);
				let st = from_node.outputs[l.from_socket].type;
				if(st == "RGB" || st == "RGBA" || st == "VECTOR") {
					if(vector_as_grayscale) {
						return "dot(" + res_var + ".rbg, vec3(0.299, 0.587, 0.114))";
					} else {
						return "" + res_var + ".x";
					}
				} else {
					return res_var;
				}
			} else {
				return "" + inp.default_value;
			}
		}
	}
	static parse_value(node,socket) {
		if(node.type == "GROUP") {
			return arm_shader_MaterialParser.parse_group(node,socket);
		} else if(node.type == "GROUP_INPUT") {
			return arm_shader_MaterialParser.parse_group_input(node,socket);
		} else if(node.type == "ATTRIBUTE") {
			arm_shader_MaterialParser.curshader.add_uniform("float time","_time");
			return "time";
		} else if(node.type == "VERTEX_COLOR") {
			return "1.0";
		} else if(node.type == "WIREFRAME") {
			arm_shader_MaterialParser.curshader.add_uniform("sampler2D texuvmap","_texuvmap");
			arm_shader_MaterialParser.parse_value_input(node.inputs[0]);
			return "textureLod(texuvmap, texCoord, 0.0).r";
		} else if(node.type == "CAMERA") {
			if(socket == node.outputs[1]) {
				arm_shader_MaterialParser.curshader.add_uniform("vec2 cameraProj","_cameraPlaneProj");
				arm_shader_MaterialParser.curshader.wvpposition = true;
				return "(cameraProj.y / ((wvpposition.z / wvpposition.w) - cameraProj.x))";
			} else {
				arm_shader_MaterialParser.curshader.add_uniform("vec3 eye","_cameraPosition");
				arm_shader_MaterialParser.curshader.wposition = true;
				return "distance(eye, wposition)";
			}
		} else if(node.type == "LAYER") {
			let l = node.buttons[0].default_value;
			if(socket == node.outputs[1]) {
				arm_shader_MaterialParser.curshader.add_uniform("sampler2D texpaint" + Std.string(l),"_texpaint" + Std.string(l));
				return "texture(texpaint" + Std.string(l) + ", texCoord).a";
			} else if(socket == node.outputs[2]) {
				arm_shader_MaterialParser.curshader.add_uniform("sampler2D texpaint_pack" + Std.string(l),"_texpaint_pack" + Std.string(l));
				return "texture(texpaint_pack" + Std.string(l) + ", texCoord).r";
			} else if(socket == node.outputs[3]) {
				arm_shader_MaterialParser.curshader.add_uniform("sampler2D texpaint_pack" + Std.string(l),"_texpaint_pack" + Std.string(l));
				return "texture(texpaint_pack" + Std.string(l) + ", texCoord).g";
			} else if(socket == node.outputs[4]) {
				arm_shader_MaterialParser.curshader.add_uniform("sampler2D texpaint_pack" + Std.string(l),"_texpaint_pack" + Std.string(l));
				return "texture(texpaint_pack" + Std.string(l) + ", texCoord).b";
			} else if(socket == node.outputs[7]) {
				arm_shader_MaterialParser.curshader.add_uniform("sampler2D texpaint_pack" + Std.string(l),"_texpaint_pack" + Std.string(l));
				return "texture(texpaint_pack" + Std.string(l) + ", texCoord).a";
			}
		} else if(node.type == "LAYER_MASK") {
			if(socket == node.outputs[0]) {
				let l = node.buttons[0].default_value;
				arm_shader_MaterialParser.curshader.add_uniform("sampler2D texpaint" + Std.string(l),"_texpaint" + Std.string(l));
				return "texture(texpaint" + Std.string(l) + ", texCoord).r";
			}
		} else if(node.type == "MATERIAL") {
			let result = "0.0";
			let mi = node.buttons[0].default_value;
			if(mi >= arm_Project.materials.length) {
				return "0.0";
			}
			let m = arm_Project.materials[mi];
			let _nodes = arm_shader_MaterialParser.nodes;
			let _links = arm_shader_MaterialParser.links;
			arm_shader_MaterialParser.nodes = m.canvas.nodes;
			arm_shader_MaterialParser.links = m.canvas.links;
			arm_shader_MaterialParser.parents.push(node);
			let output_node = arm_shader_MaterialParser.node_by_type(arm_shader_MaterialParser.nodes,"OUTPUT_MATERIAL_PBR");
			if(socket == node.outputs[1]) {
				result = arm_shader_MaterialParser.parse_value_input(output_node.inputs[1]);
			} else if(socket == node.outputs[2]) {
				result = arm_shader_MaterialParser.parse_value_input(output_node.inputs[2]);
			} else if(socket == node.outputs[3]) {
				result = arm_shader_MaterialParser.parse_value_input(output_node.inputs[3]);
			} else if(socket == node.outputs[4]) {
				result = arm_shader_MaterialParser.parse_value_input(output_node.inputs[4]);
			} else if(socket == node.outputs[7]) {
				result = arm_shader_MaterialParser.parse_value_input(output_node.inputs[7]);
			}
			arm_shader_MaterialParser.nodes = _nodes;
			arm_shader_MaterialParser.links = _links;
			arm_shader_MaterialParser.parents.pop();
			return result;
		} else if(node.type == "PICKER") {
			if(socket == node.outputs[1]) {
				arm_shader_MaterialParser.curshader.add_uniform("float pickerOpacity","_pickerOpacity");
				return "pickerOpacity";
			} else if(socket == node.outputs[2]) {
				arm_shader_MaterialParser.curshader.add_uniform("float pickerOcclusion","_pickerOcclusion");
				return "pickerOcclusion";
			} else if(socket == node.outputs[3]) {
				arm_shader_MaterialParser.curshader.add_uniform("float pickerRoughness","_pickerRoughness");
				return "pickerRoughness";
			} else if(socket == node.outputs[4]) {
				arm_shader_MaterialParser.curshader.add_uniform("float pickerMetallic","_pickerMetallic");
				return "pickerMetallic";
			} else if(socket == node.outputs[7]) {
				arm_shader_MaterialParser.curshader.add_uniform("float pickerHeight","_pickerHeight");
				return "pickerHeight";
			}
		} else if(node.type == "FRESNEL") {
			let ior = arm_shader_MaterialParser.parse_value_input(node.inputs[0]);
			arm_shader_MaterialParser.curshader.dotNV = true;
			return "pow(1.0 - dotNV, 7.25 / " + ior + ")";
		} else if(node.type == "NEW_GEOMETRY") {
			if(socket == node.outputs[6]) {
				return "0.0";
			} else if(socket == node.outputs[7]) {
				let store = arm_shader_MaterialParser.store_var_name(node);
				arm_shader_MaterialParser.curshader.n = true;
				arm_shader_MaterialParser.curshader.write("vec3 " + store + "_dx = dFdx(n);");
				arm_shader_MaterialParser.curshader.write("vec3 " + store + "_dy = dFdy(n);");
				arm_shader_MaterialParser.curshader.write("float " + store + "_curvature = max(dot(" + store + "_dx, " + store + "_dx), dot(" + store + "_dy, " + store + "_dy));");
				arm_shader_MaterialParser.curshader.write("" + store + "_curvature = clamp(pow(" + store + "_curvature, (1.0 / " + 1.0 + ") * 0.25) * " + 1.0 + " * 2.0 + " + 0.0 + " / 10.0, 0.0, 1.0);");
				return "" + store + "_curvature";
			} else if(socket == node.outputs[8]) {
				return "0.0";
			}
		} else if(node.type == "HAIR_INFO") {
			return "0.5";
		} else if(node.type == "LAYER_WEIGHT") {
			let blend = arm_shader_MaterialParser.parse_value_input(node.inputs[0]);
			if(socket == node.outputs[0]) {
				arm_shader_MaterialParser.curshader.dotNV = true;
				return "clamp(pow(1.0 - dotNV, (1.0 - " + blend + ") * 10.0), 0.0, 1.0)";
			} else if(socket == node.outputs[1]) {
				arm_shader_MaterialParser.curshader.dotNV = true;
				return "((1.0 - dotNV) * " + blend + ")";
			}
		} else if(node.type == "OBJECT_INFO") {
			if(socket == node.outputs[1]) {
				arm_shader_MaterialParser.curshader.add_uniform("float objectInfoIndex","_objectInfoIndex");
				return "objectInfoIndex";
			} else if(socket == node.outputs[2]) {
				arm_shader_MaterialParser.curshader.add_uniform("float objectInfoMaterialIndex","_objectInfoMaterialIndex");
				return "objectInfoMaterialIndex";
			} else if(socket == node.outputs[3]) {
				arm_shader_MaterialParser.curshader.add_uniform("float objectInfoRandom","_objectInfoRandom");
				return "objectInfoRandom";
			}
		} else if(node.type == "VALUE") {
			return "" + node.outputs[0].default_value;
		} else if(node.type == "TEX_BRICK") {
			arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_tex_brick);
			return "tex_brick_f(" + arm_shader_MaterialParser.getCoord(node) + " * " + arm_shader_MaterialParser.parse_value_input(node.inputs[4]) + ")";
		} else if(node.type == "TEX_CHECKER") {
			arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_tex_checker);
			return "tex_checker_f(" + arm_shader_MaterialParser.getCoord(node) + ", " + arm_shader_MaterialParser.parse_value_input(node.inputs[3]) + ")";
		} else if(node.type == "TEX_GRADIENT") {
			let co = arm_shader_MaterialParser.getCoord(node);
			let but = node.buttons[0];
			let grad = but.data[but.default_value].toUpperCase();
			grad = StringTools.replace(grad," ","_");
			return "(clamp(" + arm_shader_MaterialParser.getGradient(grad,co) + ", 0.0, 1.0))";
		} else if(node.type == "TEX_IMAGE") {
			if(arm_shader_MaterialParser.parsed.indexOf(arm_shader_MaterialParser.res_var_name(node,node.outputs[0])) >= 0) {
				return "" + arm_shader_MaterialParser.store_var_name(node) + ".a";
			}
			let tex_name = arm_shader_MaterialParser.node_name(node);
			let tex = arm_shader_MaterialParser.make_texture(node,tex_name);
			if(tex != null) {
				return "" + arm_shader_MaterialParser.texture_store(node,tex,tex_name,node.buttons[1].default_value) + ".a";
			}
		} else if(node.type == "TEX_MAGIC") {
			arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_tex_magic);
			return "tex_magic_f(" + arm_shader_MaterialParser.getCoord(node) + " * " + arm_shader_MaterialParser.parse_value_input(node.inputs[1]) + " * 4.0)";
		} else if(node.type == "TEX_MUSGRAVE") {
			arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_tex_musgrave);
			return "tex_musgrave_f(" + arm_shader_MaterialParser.getCoord(node) + " * " + arm_shader_MaterialParser.parse_value_input(node.inputs[1]) + " * 0.5)";
		} else if(node.type == "TEX_NOISE") {
			arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_tex_noise);
			return "tex_noise(" + arm_shader_MaterialParser.getCoord(node) + " * " + arm_shader_MaterialParser.parse_value_input(node.inputs[1]) + ")";
		} else if(node.type == "TEX_VORONOI") {
			arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_tex_voronoi);
			arm_shader_MaterialParser.curshader.add_uniform("sampler2D snoise256","$noise256.k");
			let co = arm_shader_MaterialParser.getCoord(node);
			let scale = arm_shader_MaterialParser.parse_value_input(node.inputs[1]);
			let but = node.buttons[0];
			let coloring = but.data[but.default_value].toUpperCase();
			coloring = StringTools.replace(coloring," ","_");
			let res = "";
			if(coloring == "INTENSITY") {
				res = "tex_voronoi(" + co + " * " + scale + ", texturePass(snoise256)).a";
			} else {
				res = "tex_voronoi(" + co + " * " + scale + ", texturePass(snoise256)).r";
			}
			return res;
		} else if(node.type == "TEX_WAVE") {
			arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_tex_wave);
			return "tex_wave_f(" + arm_shader_MaterialParser.getCoord(node) + " * " + arm_shader_MaterialParser.parse_value_input(node.inputs[1]) + ")";
		} else if(node.type == "BAKE_CURVATURE") {
			if(arm_shader_MaterialParser.bake_passthrough) {
				arm_shader_MaterialParser.bake_passthrough_strength = arm_shader_MaterialParser.parse_value_input(node.inputs[0]);
				arm_shader_MaterialParser.bake_passthrough_radius = arm_shader_MaterialParser.parse_value_input(node.inputs[1]);
				arm_shader_MaterialParser.bake_passthrough_offset = arm_shader_MaterialParser.parse_value_input(node.inputs[2]);
				return "0.0";
			}
			let tex_name = "texbake_" + arm_shader_MaterialParser.node_name(node);
			arm_shader_MaterialParser.curshader.add_uniform("sampler2D " + tex_name,"_" + tex_name);
			let store = arm_shader_MaterialParser.store_var_name(node);
			arm_shader_MaterialParser.curshader.write("float " + store + "_res = texture(" + tex_name + ", texCoord).r;");
			return "" + store + "_res";
		} else if(node.type == "NORMAL") {
			let nor = arm_shader_MaterialParser.parse_vector_input(node.inputs[0]);
			let v = node.outputs[0].default_value;
			return "dot(" + ("vec3(" + v[0] + ", " + v[1] + ", " + v[2] + ")") + ", " + nor + ")";
		} else if(node.type == "COLMASK") {
			return "clamp(1.0 - (distance(" + arm_shader_MaterialParser.parse_vector_input(node.inputs[0]) + ", " + arm_shader_MaterialParser.parse_vector_input(node.inputs[1]) + ") - " + arm_shader_MaterialParser.parse_value_input(node.inputs[2]) + ") / max(" + arm_shader_MaterialParser.parse_value_input(node.inputs[3]) + ", " + 0.000001 + "), 0.0, 1.0)";
		} else if(node.type == "MATH") {
			let val1 = arm_shader_MaterialParser.parse_value_input(node.inputs[0]);
			let val2 = arm_shader_MaterialParser.parse_value_input(node.inputs[1]);
			let but = node.buttons[0];
			let op = but.data[but.default_value].toUpperCase();
			op = StringTools.replace(op," ","_");
			let out_val = "";
			if(op == "ADD") {
				out_val = "(" + val1 + " + " + val2 + ")";
			} else if(op == "SUBTRACT") {
				out_val = "(" + val1 + " - " + val2 + ")";
			} else if(op == "MULTIPLY") {
				out_val = "(" + val1 + " * " + val2 + ")";
			} else if(op == "DIVIDE") {
				val2 = "(" + val2 + " == 0.0 ? " + 0.000001 + " : " + val2 + ")";
				out_val = "(" + val1 + " / " + val2 + ")";
			} else if(op == "POWER") {
				out_val = "pow(" + val1 + ", " + val2 + ")";
			} else if(op == "LOGARITHM") {
				out_val = "log(" + val1 + ")";
			} else if(op == "SQUARE_ROOT") {
				out_val = "sqrt(" + val1 + ")";
			} else if(op == "INVERSE_SQUARE_ROOT") {
				out_val = "inversesqrt(" + val1 + ")";
			} else if(op == "EXPONENT") {
				out_val = "exp(" + val1 + ")";
			} else if(op == "ABSOLUTE") {
				out_val = "abs(" + val1 + ")";
			} else if(op == "MINIMUM") {
				out_val = "min(" + val1 + ", " + val2 + ")";
			} else if(op == "MAXIMUM") {
				out_val = "max(" + val1 + ", " + val2 + ")";
			} else if(op == "LESS_THAN") {
				out_val = "float(" + val1 + " < " + val2 + ")";
			} else if(op == "GREATER_THAN") {
				out_val = "float(" + val1 + " > " + val2 + ")";
			} else if(op == "SIGN") {
				out_val = "sign(" + val1 + ")";
			} else if(op == "ROUND") {
				out_val = "floor(" + val1 + " + 0.5)";
			} else if(op == "FLOOR") {
				out_val = "floor(" + val1 + ")";
			} else if(op == "CEIL") {
				out_val = "ceil(" + val1 + ")";
			} else if(op == "SNAP") {
				out_val = "(floor(" + val1 + " / " + val2 + ") * " + val2 + ")";
			} else if(op == "TRUNCATE") {
				out_val = "trunc(" + val1 + ")";
			} else if(op == "FRACTION") {
				out_val = "fract(" + val1 + ")";
			} else if(op == "MODULO") {
				out_val = "mod(" + val1 + ", " + val2 + ")";
			} else if(op == "PING-PONG") {
				out_val = "((" + val2 + " != 0.0) ? abs(fract((" + val1 + " - " + val2 + ") / (" + val2 + " * 2.0)) * " + val2 + " * 2.0 - " + val2 + ") : 0.0)";
			} else if(op == "SINE") {
				out_val = "sin(" + val1 + ")";
			} else if(op == "COSINE") {
				out_val = "cos(" + val1 + ")";
			} else if(op == "TANGENT") {
				out_val = "tan(" + val1 + ")";
			} else if(op == "ARCSINE") {
				out_val = "asin(" + val1 + ")";
			} else if(op == "ARCCOSINE") {
				out_val = "acos(" + val1 + ")";
			} else if(op == "ARCTANGENT") {
				out_val = "atan(" + val1 + ")";
			} else if(op == "ARCTAN2") {
				out_val = "atan2(" + val1 + ", " + val2 + ")";
			} else if(op == "HYPERBOLIC_SINE") {
				out_val = "sinh(" + val1 + ")";
			} else if(op == "HYPERBOLIC_COSINE") {
				out_val = "cosh(" + val1 + ")";
			} else if(op == "HYPERBOLIC_TANGENT") {
				out_val = "tanh(" + val1 + ")";
			} else if(op == "TO_RADIANS") {
				out_val = "radians(" + val1 + ")";
			} else if(op == "TO_DEGREES") {
				out_val = "degrees(" + val1 + ")";
			}
			if(node.buttons[1].default_value == true) {
				return "clamp(" + out_val + ", 0.0, 1.0)";
			} else {
				return out_val;
			}
		} else if(node.type == "SCRIPT_CPU") {
			if(arm_shader_MaterialParser.script_links == null) {
				arm_shader_MaterialParser.script_links = new haxe_ds_StringMap();
			}
			let script = node.buttons[0].default_value;
			let link = arm_shader_MaterialParser.node_name(node);
			arm_shader_MaterialParser.script_links.h[link] = script;
			arm_shader_MaterialParser.curshader.add_uniform("float " + link,"_" + link);
			return link;
		} else if(node.type == "SHADER_GPU") {
			let shader = node.buttons[0].default_value;
			if(shader == "") {
				return "0.0";
			} else {
				return shader;
			}
		} else if(node.type == "RGBTOBW") {
			let col = arm_shader_MaterialParser.parse_vector_input(node.inputs[0]);
			return "(((" + col + ".r * 0.3 + " + col + ".g * 0.59 + " + col + ".b * 0.11) / 3.0) * 2.5)";
		} else if(node.type == "SEPHSV") {
			arm_shader_MaterialParser.curshader.add_function(arm_shader_ShaderFunctions.str_hue_sat);
			let col = arm_shader_MaterialParser.parse_vector_input(node.inputs[0]);
			if(socket == node.outputs[0]) {
				return "rgb_to_hsv(" + col + ").r";
			} else if(socket == node.outputs[1]) {
				return "rgb_to_hsv(" + col + ").g";
			} else if(socket == node.outputs[2]) {
				return "rgb_to_hsv(" + col + ").b";
			}
		} else if(node.type == "SEPRGB") {
			let col = arm_shader_MaterialParser.parse_vector_input(node.inputs[0]);
			if(socket == node.outputs[0]) {
				return "" + col + ".r";
			} else if(socket == node.outputs[1]) {
				return "" + col + ".g";
			} else if(socket == node.outputs[2]) {
				return "" + col + ".b";
			}
		} else if(node.type == "SEPXYZ") {
			let vec = arm_shader_MaterialParser.parse_vector_input(node.inputs[0]);
			if(socket == node.outputs[0]) {
				return "" + vec + ".x";
			} else if(socket == node.outputs[1]) {
				return "" + vec + ".y";
			} else if(socket == node.outputs[2]) {
				return "" + vec + ".z";
			}
		} else if(node.type == "VECT_MATH") {
			let vec1 = arm_shader_MaterialParser.parse_vector_input(node.inputs[0]);
			let vec2 = arm_shader_MaterialParser.parse_vector_input(node.inputs[1]);
			let but = node.buttons[0];
			let op = but.data[but.default_value].toUpperCase();
			op = StringTools.replace(op," ","_");
			if(op == "DOT_PRODUCT") {
				return "dot(" + vec1 + ", " + vec2 + ")";
			} else if(op == "LENGTH") {
				return "length(" + vec1 + ")";
			} else if(op == "DISTANCE") {
				return "distance(" + vec1 + ", " + vec2 + ")";
			} else {
				return "0.0";
			}
		} else if(node.type == "CLAMP") {
			let val = arm_shader_MaterialParser.parse_value_input(node.inputs[0]);
			let min = arm_shader_MaterialParser.parse_value_input(node.inputs[1]);
			let max = arm_shader_MaterialParser.parse_value_input(node.inputs[2]);
			let but = node.buttons[0];
			let op = but.data[but.default_value].toUpperCase();
			op = StringTools.replace(op," ","_");
			if(op == "MIN_MAX") {
				return "(clamp(" + val + ", " + min + ", " + max + "))";
			} else if(op == "RANGE") {
				return "(clamp(" + val + ", min(" + min + ", " + max + "), max(" + min + ", " + max + ")))";
			}
		} else if(node.type == "MAPRANGE") {
			let val = arm_shader_MaterialParser.parse_value_input(node.inputs[0]);
			let fmin = arm_shader_MaterialParser.parse_value_input(node.inputs[1]);
			let fmax = arm_shader_MaterialParser.parse_value_input(node.inputs[2]);
			let tmin = arm_shader_MaterialParser.parse_value_input(node.inputs[3]);
			let tmax = arm_shader_MaterialParser.parse_value_input(node.inputs[4]);
			let a = "((" + tmin + " - " + tmax + ") / (" + fmin + " - " + fmax + "))";
			let out_val = "(" + a + " * " + val + " + " + tmin + " - " + a + " * " + fmin + ")";
			if(node.buttons[0].default_value == true) {
				return "(clamp(" + out_val + ", " + tmin + ", " + tmax + "))";
			} else {
				return out_val;
			}
		} else if(arm_shader_MaterialParser.customNodes.get(node.type) != null) {
			return (arm_shader_MaterialParser.customNodes.get(node.type))(node,socket);
		}
		return "0.0";
	}
	static getCoord(node) {
		if(arm_shader_MaterialParser.getInputLink(node.inputs[0]) != null) {
			return arm_shader_MaterialParser.parse_vector_input(node.inputs[0]);
		} else {
			arm_shader_MaterialParser.curshader.bposition = true;
			return "bposition";
		}
	}
	static getGradient(grad,co) {
		if(grad == "LINEAR") {
			return "" + co + ".x";
		} else if(grad == "QUADRATIC") {
			return "0.0";
		} else if(grad == "EASING") {
			return "0.0";
		} else if(grad == "DIAGONAL") {
			return "(" + co + ".x + " + co + ".y) * 0.5";
		} else if(grad == "RADIAL") {
			return "atan2(" + co + ".x, " + co + ".y) / (3.141592 * 2.0) + 0.5";
		} else if(grad == "QUADRATIC_SPHERE") {
			return "0.0";
		} else {
			return "max(1.0 - sqrt(" + co + ".x * " + co + ".x + " + co + ".y * " + co + ".y + " + co + ".z * " + co + ".z), 0.0)";
		}
	}
	static vector_curve(name,fac,points) {
		let ys_var = name + "_ys";
		let num = points.length;
		arm_shader_MaterialParser.curshader.write("float " + ys_var + "[" + num + "];");
		let _g = 0;
		while(_g < num) {
			let i = _g++;
			arm_shader_MaterialParser.curshader.write("" + ys_var + "[" + i + "] = " + points[i][1] + ";");
		}
		let fac_var = name + "_fac";
		arm_shader_MaterialParser.curshader.write("float " + fac_var + " = " + fac + ";");
		let index = "0";
		let _g1 = 1;
		while(_g1 < num) index += " + (" + fac_var + " > " + points[_g1++][0] + " ? 1 : 0)";
		let index_var = name + "_i";
		arm_shader_MaterialParser.curshader.write("int " + index_var + " = " + index + ";");
		let facs_var = name + "_xs";
		arm_shader_MaterialParser.curshader.write("float " + facs_var + "[" + num + "];");
		let _g2 = 0;
		while(_g2 < num) {
			let i = _g2++;
			arm_shader_MaterialParser.curshader.write("" + facs_var + "[" + i + "] = " + points[i][0] + ";");
		}
		return "mix(" + ys_var + "[" + index_var + "], " + ys_var + "[" + index_var + " + 1], (" + fac_var + " - " + facs_var + "[" + index_var + "]) * (1.0 / (" + facs_var + "[" + index_var + " + 1] - " + facs_var + "[" + index_var + "])))";
	}
	static res_var_name(node,socket) {
		return arm_shader_MaterialParser.node_name(node) + "_" + arm_shader_MaterialParser.safesrc(socket.name) + "_res";
	}
	static write_result(l) {
		let from_node = arm_shader_MaterialParser.getNode(l.from_id);
		let from_socket = from_node.outputs[l.from_socket];
		let res_var = arm_shader_MaterialParser.res_var_name(from_node,from_socket);
		let st = from_socket.type;
		if(arm_shader_MaterialParser.parsed.indexOf(res_var) < 0) {
			arm_shader_MaterialParser.parsed.push(res_var);
			if(st == "RGB" || st == "RGBA" || st == "VECTOR") {
				let res = arm_shader_MaterialParser.parse_vector(from_node,from_socket);
				if(res == null) {
					return null;
				}
				arm_shader_MaterialParser.parsedMap.h[res_var] = res;
				arm_shader_MaterialParser.curshader.write("vec3 " + res_var + " = " + res + ";");
			} else if(st == "VALUE") {
				let res = arm_shader_MaterialParser.parse_value(from_node,from_socket);
				if(res == null) {
					return null;
				}
				arm_shader_MaterialParser.parsedMap.h[res_var] = res;
				arm_shader_MaterialParser.curshader.write("float " + res_var + " = " + res + ";");
			}
		}
		return res_var;
	}
	static store_var_name(node) {
		return arm_shader_MaterialParser.node_name(node) + "_store";
	}
	static texture_store(node,tex,tex_name,color_space) {
		arm_shader_MaterialParser.matcon.bind_textures.push(tex);
		arm_shader_MaterialParser.curshader.context.add_elem("tex","short2norm");
		arm_shader_MaterialParser.curshader.add_uniform("sampler2D " + tex_name);
		let uv_name = "";
		if(arm_shader_MaterialParser.getInputLink(node.inputs[0]) != null) {
			uv_name = arm_shader_MaterialParser.parse_vector_input(node.inputs[0]);
		} else {
			uv_name = arm_shader_MaterialParser.tex_coord;
		}
		let tex_store = arm_shader_MaterialParser.store_var_name(node);
		if(arm_shader_MaterialParser.sample_keep_aspect) {
			arm_shader_MaterialParser.curshader.write("vec2 " + tex_store + "_size = textureSize(" + tex_name + ", 0);");
			arm_shader_MaterialParser.curshader.write("float " + tex_store + "_ax = " + tex_store + "_size.x / " + tex_store + "_size.y;");
			arm_shader_MaterialParser.curshader.write("float " + tex_store + "_ay = " + tex_store + "_size.y / " + tex_store + "_size.x;");
			arm_shader_MaterialParser.curshader.write("vec2 " + tex_store + "_uv = ((" + uv_name + ".xy / " + arm_shader_MaterialParser.sample_uv_scale + " - vec2(0.5, 0.5)) * vec2(max(" + tex_store + "_ay, 1.0), max(" + tex_store + "_ax, 1.0))) + vec2(0.5, 0.5);");
			arm_shader_MaterialParser.curshader.write("if (" + tex_store + "_uv.x < 0.0 || " + tex_store + "_uv.y < 0.0 || " + tex_store + "_uv.x > 1.0 || " + tex_store + "_uv.y > 1.0) discard;");
			arm_shader_MaterialParser.curshader.write("" + tex_store + "_uv *= " + arm_shader_MaterialParser.sample_uv_scale + ";");
			uv_name = "" + tex_store + "_uv";
		}
		if(arm_shader_MaterialParser.triplanar) {
			arm_shader_MaterialParser.curshader.write("vec4 " + tex_store + " = vec4(0.0, 0.0, 0.0, 0.0);");
			arm_shader_MaterialParser.curshader.write("if (texCoordBlend.x > 0) " + tex_store + " += texture(" + tex_name + ", " + uv_name + ".xy) * texCoordBlend.x;");
			arm_shader_MaterialParser.curshader.write("if (texCoordBlend.y > 0) " + tex_store + " += texture(" + tex_name + ", " + uv_name + "1.xy) * texCoordBlend.y;");
			arm_shader_MaterialParser.curshader.write("if (texCoordBlend.z > 0) " + tex_store + " += texture(" + tex_name + ", " + uv_name + "2.xy) * texCoordBlend.z;");
		} else {
			if(arm_shader_MaterialParser.curshader == arm_shader_MaterialParser.frag) {
				arm_shader_MaterialParser.textureMap.h[tex_store] = "texture(" + tex_name + ", " + uv_name + ".xy)";
				arm_shader_MaterialParser.curshader.write("vec4 " + tex_store + " = texture(" + tex_name + ", " + uv_name + ".xy);");
			} else {
				arm_shader_MaterialParser.textureMap.h[tex_store] = "textureLod(" + tex_name + ", " + uv_name + ".xy, 0.0)";
				arm_shader_MaterialParser.curshader.write("vec4 " + tex_store + " = textureLod(" + tex_name + ", " + uv_name + ".xy, 0.0);");
			}
			if(!tex.file.endsWith(".jpg")) {
				arm_shader_MaterialParser.curshader.write("" + tex_store + ".rgb *= " + tex_store + ".a;");
			}
		}
		if(arm_shader_MaterialParser.transform_color_space) {
			if(color_space == 1 && arm_shader_MaterialParser.parsing_basecolor) {
				arm_shader_MaterialParser.curshader.write("" + tex_store + ".rgb = pow(" + tex_store + ".rgb, vec3(2.2, 2.2, 2.2));");
			} else if(color_space == 2 && !arm_shader_MaterialParser.parsing_basecolor) {
				arm_shader_MaterialParser.curshader.write("" + tex_store + ".rgb = pow(" + tex_store + ".rgb, vec3(1.0 / 2.2, 1.0 / 2.2, 1.0 / 2.2));");
			} else if(color_space == 3) {
				arm_shader_MaterialParser.curshader.write("" + tex_store + ".y = 1.0 - " + tex_store + ".y;");
			}
		}
		return tex_store;
	}
	static node_by_type(nodes,ntype) {
		let _g = 0;
		while(_g < nodes.length) {
			let n = nodes[_g];
			++_g;
			if(n.type == ntype) {
				return n;
			}
		}
		return null;
	}
	static socket_index(node,socket) {
		let _g = 0;
		let _g1 = node.outputs.length;
		while(_g < _g1) {
			let i = _g++;
			if(node.outputs[i] == socket) {
				return i;
			}
		}
		return -1;
	}
	static node_name(node,_parents) {
		if(_parents == null) {
			_parents = arm_shader_MaterialParser.parents;
		}
		let s = node.name;
		let _g = 0;
		while(_g < _parents.length) {
			let p = _parents[_g];
			++_g;
			s = p.name + p.id + "_" + s;
		}
		s = arm_shader_MaterialParser.safesrc(s) + node.id;
		return s;
	}
	static safesrc(s) {
		let _g = 0;
		let _g1 = s.length;
		while(_g < _g1) {
			let i = _g++;
			let code = HxOverrides.cca(s,i);
			let digit = code >= 48 && code <= 57;
			if(!(code >= 65 && code <= 90 || code >= 97 && code <= 122) && !digit) {
				s = StringTools.replace(s,s.charAt(i),"_");
			}
			if(i == 0 && digit) {
				s = "_" + s;
			}
		}
		return s;
	}
	static enumData(s) {
		let _g = 0;
		let _g1 = arm_Project.assets;
		while(_g < _g1.length) {
			let a = _g1[_g];
			++_g;
			if(a.name == s) {
				return a.file;
			}
		}
		return "";
	}
	static make_texture(image_node,tex_name,matname) {
		let filepath = arm_shader_MaterialParser.enumData(arm_App.enumTexts(image_node.type)[image_node.buttons[0].default_value]);
		if(filepath == "" || filepath.indexOf(".") == -1) {
			return null;
		}
		let tex = { name : tex_name, file : filepath};
		if(arm_Context.textureFilter) {
			tex.min_filter = "anisotropic";
			tex.mag_filter = "linear";
			tex.mipmap_filter = "linear";
			tex.generate_mipmaps = true;
		} else {
			tex.min_filter = "point";
			tex.mag_filter = "point";
			tex.mipmap_filter = "no";
		}
		tex.u_addressing = "repeat";
		tex.v_addressing = "repeat";
		return tex;
	}
}
$hxClasses["arm.shader.MaterialParser"] = arm_shader_MaterialParser;
arm_shader_MaterialParser.__name__ = "arm.shader.MaterialParser";
class arm_util_MeshUtil {
	static mergeMesh(paintObjects) {
		if(paintObjects == null) {
			paintObjects = arm_Project.paintObjects;
		}
		if(paintObjects.length == 0) {
			return;
		}
		arm_Context.mergedObjectIsAtlas = paintObjects.length < arm_Project.paintObjects.length;
		let vlen = 0;
		let ilen = 0;
		let maxScale = 0.0;
		let _g = 0;
		let _g1 = paintObjects.length;
		while(_g < _g1) {
			let i = _g++;
			vlen += paintObjects[i].data.raw.vertex_arrays[0].values.length;
			ilen += paintObjects[i].data.raw.index_arrays[0].values.length;
			if(paintObjects[i].data.scalePos > maxScale) {
				maxScale = paintObjects[i].data.scalePos;
			}
		}
		vlen = vlen / 4 | 0;
		let va0 = new Int16Array(vlen * 4);
		let va1 = new Int16Array(vlen * 2);
		let va2 = new Int16Array(vlen * 2);
		let va3 = paintObjects[0].data.raw.vertex_arrays.length > 3 ? new Int16Array(vlen * 3) : null;
		let ia = new Uint32Array(ilen);
		let voff = 0;
		let ioff = 0;
		let _g2 = 0;
		let _g3 = paintObjects.length;
		while(_g2 < _g3) {
			let i = _g2++;
			let vas = paintObjects[i].data.raw.vertex_arrays;
			let ias = paintObjects[i].data.raw.index_arrays;
			let scale = paintObjects[i].data.scalePos;
			let _g = 0;
			let _g1 = vas[0].values.length;
			while(_g < _g1) {
				let j = _g++;
				va0[j + voff * 4] = vas[0].values[j];
			}
			let _g3 = 0;
			let _g4 = va0.length / 4 | 0;
			while(_g3 < _g4) {
				let j = _g3++;
				va0[j * 4 + voff * 4] = va0[j * 4 + voff * 4] * scale / maxScale | 0;
				va0[j * 4 + 1 + voff * 4] = va0[j * 4 + 1 + voff * 4] * scale / maxScale | 0;
				va0[j * 4 + 2 + voff * 4] = va0[j * 4 + 2 + voff * 4] * scale / maxScale | 0;
			}
			let _g5 = 0;
			let _g6 = vas[1].values.length;
			while(_g5 < _g6) {
				let j = _g5++;
				va1[j + voff * 2] = vas[1].values[j];
			}
			let _g7 = 0;
			let _g8 = vas[2].values.length;
			while(_g7 < _g8) {
				let j = _g7++;
				va2[j + voff * 2] = vas[2].values[j];
			}
			if(va3 != null) {
				let _g = 0;
				let _g1 = vas[3].values.length;
				while(_g < _g1) {
					let j = _g++;
					va3[j + voff * 3] = vas[3].values[j];
				}
			}
			let _g9 = 0;
			let _g10 = ias[0].values.length;
			while(_g9 < _g10) {
				let j = _g9++;
				ia[j + ioff] = ias[0].values[j] + voff;
			}
			voff += vas[0].values.length / 4 | 0;
			ioff += ias[0].values.length | 0;
		}
		let raw = { name : arm_Context.paintObject.name, vertex_arrays : [{ values : va0, attrib : "pos", data : "short4norm"},{ values : va1, attrib : "nor", data : "short2norm"},{ values : va2, attrib : "tex", data : "short2norm"}], index_arrays : [{ values : ia, material : 0}], scale_pos : maxScale, scale_tex : 1.0};
		if(va3 != null) {
			raw.vertex_arrays.push({ values : va3, attrib : "col", data : "short4norm", padding : 1});
		}
		if(arm_Context.mergedObject != null) {
			arm_Context.mergedObject.remove();
			iron_data_Data.deleteMesh(arm_Context.mergedObject.data.handle);
		}
		new iron_data_MeshData(raw,function(md) {
			arm_Context.mergedObject = new iron_object_MeshObject(md,arm_Context.paintObject.materials);
			arm_Context.mergedObject.name = arm_Context.paintObject.name + "_merged";
			arm_Context.mergedObject.force_context = "paint";
			arm_Context.mergedObject.setParent(arm_Context.mainObject());
		});
	}
	static swapAxis(a,b) {
		let objects = arm_Project.paintObjects;
		let _g = 0;
		while(_g < objects.length) {
			let o = objects[_g];
			++_g;
			let vas = o.data.raw.vertex_arrays;
			let pa = vas[0].values;
			let na0 = a == 2 ? vas[0].values : vas[1].values;
			let na1 = b == 2 ? vas[0].values : vas[1].values;
			let c = a == 2 ? 3 : a;
			let d = b == 2 ? 3 : b;
			let e = a == 2 ? 4 : 2;
			let f = b == 2 ? 4 : 2;
			let _g1 = 0;
			let _g2 = pa.length / 4 | 0;
			while(_g1 < _g2) {
				let i = _g1++;
				let t = pa[i * 4 + a];
				pa[i * 4 + a] = pa[i * 4 + b];
				pa[i * 4 + b] = -t;
				t = na0[i * e + c];
				na0[i * e + c] = na1[i * f + d];
				na1[i * f + d] = -t;
			}
			let g = o.data.geom;
			let l = g.structLength;
			let vertices = g.vertexBuffer.lock();
			let _g3 = 0;
			let _g4 = vertices.byteLength / 2 / l | 0;
			while(_g3 < _g4) {
				let i = _g3++;
				vertices.setInt16(i * l * 2,vas[0].values[i * 4],kha_arrays_ByteArray.LITTLE_ENDIAN);
				vertices.setInt16((i * l + 1) * 2,vas[0].values[i * 4 + 1],kha_arrays_ByteArray.LITTLE_ENDIAN);
				vertices.setInt16((i * l + 2) * 2,vas[0].values[i * 4 + 2],kha_arrays_ByteArray.LITTLE_ENDIAN);
				vertices.setInt16((i * l + 3) * 2,vas[0].values[i * 4 + 3],kha_arrays_ByteArray.LITTLE_ENDIAN);
				vertices.setInt16((i * l + 4) * 2,vas[1].values[i * 2],kha_arrays_ByteArray.LITTLE_ENDIAN);
				vertices.setInt16((i * l + 5) * 2,vas[1].values[i * 2 + 1],kha_arrays_ByteArray.LITTLE_ENDIAN);
			}
			g.vertexBuffer.unlock();
		}
		if(arm_Context.mergedObject != null) {
			arm_Context.mergedObject.remove();
			iron_data_Data.deleteMesh(arm_Context.mergedObject.data.handle);
			arm_Context.mergedObject = null;
		}
		arm_util_MeshUtil.mergeMesh();
	}
	static flipNormals() {
		let objects = arm_Project.paintObjects;
		let _g = 0;
		while(_g < objects.length) {
			let o = objects[_g];
			++_g;
			let vas = o.data.raw.vertex_arrays;
			let va0 = vas[0].values;
			let va1 = vas[1].values;
			let g = o.data.geom;
			let l = g.structLength;
			let vertices = g.vertexBuffer.lock();
			let _g1 = 0;
			let _g2 = vertices.byteLength / 2 / l | 0;
			while(_g1 < _g2) {
				let i = _g1++;
				va0[i * 4 + 3] = -va0[i * 4 + 3];
				va1[i * 2] = -va1[i * 2];
				va1[i * 2 + 1] = -va1[i * 2 + 1];
				vertices.setInt16((i * l + 3) * 2,-vertices.getInt16((i * l + 3) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN),kha_arrays_ByteArray.LITTLE_ENDIAN);
				vertices.setInt16((i * l + 4) * 2,-vertices.getInt16((i * l + 4) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN),kha_arrays_ByteArray.LITTLE_ENDIAN);
				vertices.setInt16((i * l + 5) * 2,-vertices.getInt16((i * l + 5) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN),kha_arrays_ByteArray.LITTLE_ENDIAN);
			}
			g.vertexBuffer.unlock();
		}
	}
	static calcNormals(smooth) {
		if(smooth == null) {
			smooth = false;
		}
		let va = new iron_math_Vec4();
		let cb_x = 0.0;
		let cb_y = 0.0;
		let cb_z = 0.0;
		let ab_x = 0.0;
		let ab_y = 0.0;
		let ab_z = 0.0;
		let objects = arm_Project.paintObjects;
		let _g = 0;
		while(_g < objects.length) {
			let o = objects[_g];
			++_g;
			let g = o.data.geom;
			let l = g.structLength;
			let inda = g.indices[0];
			let vertices = g.vertexBuffer.lock();
			let _g1 = 0;
			let _g2 = inda.length / 3 | 0;
			while(_g1 < _g2) {
				let i = _g1++;
				let i1 = inda[i * 3];
				let i2 = inda[i * 3 + 1];
				let i3 = inda[i * 3 + 2];
				let y = vertices.getInt16((i1 * l + 1) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN);
				let z = vertices.getInt16((i1 * l + 2) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN);
				va.x = vertices.getInt16(i1 * l * 2,kha_arrays_ByteArray.LITTLE_ENDIAN);
				va.y = y;
				va.z = z;
				va.w = 1.0;
				let x = vertices.getInt16(i2 * l * 2,kha_arrays_ByteArray.LITTLE_ENDIAN);
				let y1 = vertices.getInt16((i2 * l + 1) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN);
				let z1 = vertices.getInt16((i2 * l + 2) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN);
				cb_x = vertices.getInt16(i3 * l * 2,kha_arrays_ByteArray.LITTLE_ENDIAN) - x;
				cb_y = vertices.getInt16((i3 * l + 1) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN) - y1;
				cb_z = vertices.getInt16((i3 * l + 2) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN) - z1;
				ab_x = va.x - x;
				ab_y = va.y - y1;
				ab_z = va.z - z1;
				let ax = cb_x;
				let ay = cb_y;
				let az = cb_z;
				let vx = ab_x;
				let vy = ab_y;
				let vz = ab_z;
				cb_x = ay * vz - az * vy;
				cb_y = az * vx - ax * vz;
				cb_z = ax * vy - ay * vx;
				let n = Math.sqrt(cb_x * cb_x + cb_y * cb_y + cb_z * cb_z);
				if(n > 0.0) {
					let invN = 1.0 / n;
					cb_x *= invN;
					cb_y *= invN;
					cb_z *= invN;
				}
				vertices.setInt16((i1 * l + 4) * 2,cb_x * 32767 | 0,kha_arrays_ByteArray.LITTLE_ENDIAN);
				vertices.setInt16((i1 * l + 5) * 2,cb_y * 32767 | 0,kha_arrays_ByteArray.LITTLE_ENDIAN);
				vertices.setInt16((i1 * l + 3) * 2,cb_z * 32767 | 0,kha_arrays_ByteArray.LITTLE_ENDIAN);
				vertices.setInt16((i2 * l + 4) * 2,cb_x * 32767 | 0,kha_arrays_ByteArray.LITTLE_ENDIAN);
				vertices.setInt16((i2 * l + 5) * 2,cb_y * 32767 | 0,kha_arrays_ByteArray.LITTLE_ENDIAN);
				vertices.setInt16((i2 * l + 3) * 2,cb_z * 32767 | 0,kha_arrays_ByteArray.LITTLE_ENDIAN);
				vertices.setInt16((i3 * l + 4) * 2,cb_x * 32767 | 0,kha_arrays_ByteArray.LITTLE_ENDIAN);
				vertices.setInt16((i3 * l + 5) * 2,cb_y * 32767 | 0,kha_arrays_ByteArray.LITTLE_ENDIAN);
				vertices.setInt16((i3 * l + 3) * 2,cb_z * 32767 | 0,kha_arrays_ByteArray.LITTLE_ENDIAN);
			}
			if(smooth) {
				let shared = new Uint32Array(1024);
				let sharedLen = 0;
				let found = [];
				let _g = 0;
				let _g1 = inda.length - 1;
				while(_g < _g1) {
					let i = _g++;
					if(found.indexOf(i) >= 0) {
						continue;
					}
					let i1 = inda[i];
					sharedLen = 0;
					sharedLen = 1;
					shared[0] = i1;
					let _g1 = i + 1;
					let _g2 = inda.length;
					while(_g1 < _g2) {
						let j = _g1++;
						let i2 = inda[j];
						let i1l = i1 * l;
						let i2l = i2 * l;
						if(vertices.getInt16(i1l * 2,kha_arrays_ByteArray.LITTLE_ENDIAN) == vertices.getInt16(i2l * 2,kha_arrays_ByteArray.LITTLE_ENDIAN) && vertices.getInt16((i1l + 1) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN) == vertices.getInt16((i2l + 1) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN) && vertices.getInt16((i1l + 2) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN) == vertices.getInt16((i2l + 2) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN)) {
							shared[sharedLen++] = i2;
							found.push(j);
							if(sharedLen >= 1024) {
								break;
							}
						}
					}
					if(sharedLen > 1) {
						va.x = 0;
						va.y = 0;
						va.z = 0;
						va.w = 1.0;
						let _g = 0;
						let _g1 = sharedLen;
						while(_g < _g1) {
							let i1l = shared[_g++] * l;
							let y = vertices.getInt16((i1l + 5) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN);
							let z = vertices.getInt16((i1l + 3) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN);
							va.x += vertices.getInt16((i1l + 4) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN);
							va.y += y;
							va.z += z;
						}
						let f = 1 / sharedLen;
						va.x *= f;
						va.y *= f;
						va.z *= f;
						let n = Math.sqrt(va.x * va.x + va.y * va.y + va.z * va.z);
						if(n > 0.0) {
							let invN = 1.0 / n;
							va.x *= invN;
							va.y *= invN;
							va.z *= invN;
						}
						let vax = va.x * 32767 | 0;
						let vay = va.y * 32767 | 0;
						let vaz = va.z * 32767 | 0;
						let _g2 = 0;
						let _g3 = sharedLen;
						while(_g2 < _g3) {
							let i1l = shared[_g2++] * l;
							vertices.setInt16((i1l + 4) * 2,vax,kha_arrays_ByteArray.LITTLE_ENDIAN);
							vertices.setInt16((i1l + 5) * 2,vay,kha_arrays_ByteArray.LITTLE_ENDIAN);
							vertices.setInt16((i1l + 3) * 2,vaz,kha_arrays_ByteArray.LITTLE_ENDIAN);
						}
					}
				}
			}
			g.vertexBuffer.unlock();
			let va0 = o.data.raw.vertex_arrays[0].values;
			let va1 = o.data.raw.vertex_arrays[1].values;
			let _g3 = 0;
			let _g4 = vertices.byteLength / 4 / l | 0;
			while(_g3 < _g4) {
				let i = _g3++;
				va1[i * 2] = vertices.getInt16((i * l + 4) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN);
				va1[i * 2 + 1] = vertices.getInt16((i * l + 5) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN);
				va0[i * 4 + 3] = vertices.getInt16((i * l + 3) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN);
			}
		}
	}
	static toOrigin() {
		let dx = 0.0;
		let dy = 0.0;
		let dz = 0.0;
		let _g = 0;
		let _g1 = arm_Project.paintObjects;
		while(_g < _g1.length) {
			let o = _g1[_g];
			++_g;
			let sc = o.data.scalePos / 32767;
			let va = o.data.raw.vertex_arrays[0].values;
			let minx = va[0];
			let maxx = va[0];
			let miny = va[1];
			let maxy = va[1];
			let minz = va[2];
			let maxz = va[2];
			let _g2 = 1;
			let _g3 = va.length / 4 | 0;
			while(_g2 < _g3) {
				let i = _g2++;
				if(va[i * 4] < minx) {
					minx = va[i * 4];
				} else if(va[i * 4] > maxx) {
					maxx = va[i * 4];
				}
				if(va[i * 4 + 1] < miny) {
					miny = va[i * 4 + 1];
				} else if(va[i * 4 + 1] > maxy) {
					maxy = va[i * 4 + 1];
				}
				if(va[i * 4 + 2] < minz) {
					minz = va[i * 4 + 2];
				} else if(va[i * 4 + 2] > maxz) {
					maxz = va[i * 4 + 2];
				}
			}
			dx += (minx + maxx) / 2 * sc;
			dy += (miny + maxy) / 2 * sc;
			dz += (minz + maxz) / 2 * sc;
		}
		dx /= arm_Project.paintObjects.length;
		dy /= arm_Project.paintObjects.length;
		dz /= arm_Project.paintObjects.length;
		let _g2 = 0;
		let _g3 = arm_Project.paintObjects;
		while(_g2 < _g3.length) {
			let o = _g3[_g2];
			++_g2;
			let g = o.data.geom;
			let sc = o.data.scalePos / 32767;
			let va = o.data.raw.vertex_arrays[0].values;
			let maxScale = 0.0;
			let _g = 0;
			let _g1 = va.length / 4 | 0;
			while(_g < _g1) {
				let i = _g++;
				if(Math.abs(va[i * 4] * sc - dx) > maxScale) {
					maxScale = Math.abs(va[i * 4] * sc - dx);
				}
				if(Math.abs(va[i * 4 + 1] * sc - dy) > maxScale) {
					maxScale = Math.abs(va[i * 4 + 1] * sc - dy);
				}
				if(Math.abs(va[i * 4 + 2] * sc - dz) > maxScale) {
					maxScale = Math.abs(va[i * 4 + 2] * sc - dz);
				}
			}
			o.transform.scaleWorld = o.data.scalePos = o.data.raw.scale_pos = maxScale;
			o.transform.buildMatrix();
			let _g4 = 0;
			let _g5 = va.length / 4 | 0;
			while(_g4 < _g5) {
				let i = _g4++;
				va[i * 4] = (va[i * 4] * sc - dx) / maxScale * 32767 | 0;
				va[i * 4 + 1] = (va[i * 4 + 1] * sc - dy) / maxScale * 32767 | 0;
				va[i * 4 + 2] = (va[i * 4 + 2] * sc - dz) / maxScale * 32767 | 0;
			}
			let l = g.structLength;
			let vertices = g.vertexBuffer.lock();
			let _g6 = 0;
			let _g7 = vertices.byteLength / 2 / l | 0;
			while(_g6 < _g7) {
				let i = _g6++;
				vertices.setInt16(i * l * 2,va[i * 4],kha_arrays_ByteArray.LITTLE_ENDIAN);
				vertices.setInt16((i * l + 1) * 2,va[i * 4 + 1],kha_arrays_ByteArray.LITTLE_ENDIAN);
				vertices.setInt16((i * l + 2) * 2,va[i * 4 + 2],kha_arrays_ByteArray.LITTLE_ENDIAN);
			}
			g.vertexBuffer.unlock();
		}
		arm_util_MeshUtil.mergeMesh();
	}
	static applyDisplacement() {
		let height = arm_Project.layers[0].texpaint_pack.getPixels();
		let res = arm_Project.layers[0].texpaint_pack.get_width();
		let o = arm_Project.paintObjects[0];
		let g = o.data.geom;
		let l = g.structLength;
		let vertices = g.vertexBuffer.lock();
		let _g = 0;
		let _g1 = vertices.byteLength / 2 / l | 0;
		while(_g < _g1) {
			let i = _g++;
			let h = (1.0 - height.b[((vertices.getInt16((i * l + 7) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN) / 32767 * res | 0) * res + (vertices.getInt16((i * l + 6) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN) / 32767 * res | 0)) * 4 + 3] / 255) * 0.1;
			vertices.setInt16(i * l * 2,vertices.getInt16(i * l * 2,kha_arrays_ByteArray.LITTLE_ENDIAN) - (vertices.getInt16((i * l + 4) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN) * h | 0),kha_arrays_ByteArray.LITTLE_ENDIAN);
			vertices.setInt16((i * l + 1) * 2,vertices.getInt16((i * l + 1) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN) - (vertices.getInt16((i * l + 5) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN) * h | 0),kha_arrays_ByteArray.LITTLE_ENDIAN);
			vertices.setInt16((i * l + 2) * 2,vertices.getInt16((i * l + 2) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN) - (vertices.getInt16((i * l + 3) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN) * h | 0),kha_arrays_ByteArray.LITTLE_ENDIAN);
		}
		g.vertexBuffer.unlock();
		let va0 = o.data.raw.vertex_arrays[0].values;
		let _g2 = 0;
		let _g3 = vertices.byteLength / 4 / l | 0;
		while(_g2 < _g3) {
			let i = _g2++;
			va0[i * 4] = vertices.getInt16(i * l * 2,kha_arrays_ByteArray.LITTLE_ENDIAN);
			va0[i * 4 + 1] = vertices.getInt16((i * l + 1) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN);
			va0[i * 4 + 2] = vertices.getInt16((i * l + 2) * 2,kha_arrays_ByteArray.LITTLE_ENDIAN);
		}
	}
	static equirectUnwrap(mesh) {
		let verts = mesh.posa.length / 4 | 0;
		mesh.texa = new Int16Array(verts * 2);
		let _this_x = 0.0;
		let _this_y = 0.0;
		let _this_z = 0.0;
		let _g = 0;
		while(_g < verts) {
			let i = _g++;
			let x = mesh.posa[i * 4] / 32767;
			let y = mesh.posa[i * 4 + 1] / 32767;
			let z = mesh.posa[i * 4 + 2] / 32767;
			_this_x = x;
			_this_y = y;
			_this_z = z;
			let n = Math.sqrt(x * x + y * y + z * z);
			if(n > 0.0) {
				let invN = 1.0 / n;
				_this_x = x * invN;
				_this_y = y * invN;
				_this_z = z * invN;
			}
			mesh.texa[i * 2] = (Math.atan2(-_this_z,_this_x) + Math.PI) / (Math.PI * 2) * 32767 | 0;
			mesh.texa[i * 2 + 1] = Math.acos(_this_y) / Math.PI * 32767 | 0;
		}
	}
}
$hxClasses["arm.util.MeshUtil"] = arm_util_MeshUtil;
arm_util_MeshUtil.__name__ = "arm.util.MeshUtil";
class arm_node_NodesBrush {
	static createNode(nodeType) {
		let _g = 0;
		let _g1 = arm_node_NodesBrush.list;
		while(_g < _g1.length) {
			let c = _g1[_g];
			++_g;
			let _g2 = 0;
			while(_g2 < c.length) {
				let n = c[_g2];
				++_g2;
				if(n.type == nodeType) {
					let canvas = arm_Context.brush.canvas;
					let node = arm_ui_UINodes.makeNode(n,arm_Context.brush.nodes,canvas);
					canvas.nodes.push(node);
					return node;
				}
			}
		}
		return null;
	}
	static f32(ar) {
		let res = new Float32Array(ar.length);
		let _g = 0;
		let _g1 = ar.length;
		while(_g < _g1) {
			let i = _g++;
			res[i] = ar[i];
		}
		return res;
	}
}
$hxClasses["arm.node.NodesBrush"] = arm_node_NodesBrush;
arm_node_NodesBrush.__name__ = "arm.node.NodesBrush";
class arm_shader_NodesMaterial {
	static vectorCurvesButton(ui,nodes,node) {
		let but = node.buttons[0];
		let nhandle = zui_Handle.global.nest(173,null).nest(node.id);
		ui.row([0.33333333333333331,0.33333333333333331,0.33333333333333331]);
		ui.radio(nhandle.nest(0).nest(1),0,"X");
		ui.radio(nhandle.nest(0).nest(1),1,"Y");
		ui.radio(nhandle.nest(0).nest(1),2,"Z");
		let axis = nhandle.nest(0).nest(1).position;
		let val = but.default_value[axis];
		let num = val.length;
		ui._y += (nodes.ELEMENT_H * (nodes.scaleFactor * nodes.zoom) | 0) * 5;
		ui.row([0.2,0.2,0.6]);
		if(ui.button("+")) {
			let f32 = new Float32Array(2);
			f32[0] = 0;
			f32[1] = 0;
			val.push(f32);
		}
		if(ui.button("-")) {
			if(val.length > 2) {
				val.pop();
			}
		}
		let ihandle = nhandle.nest(0).nest(2).nest(axis,{ position : 0});
		let i = ui.slider(ihandle,"Index",0,num - 1,false,1,true,0) | 0;
		if(i >= val.length || i < 0) {
			i = val.length - 1;
			ihandle.value = i;
		}
		ui.row([0.5,0.5]);
		nhandle.nest(0).nest(3).value = val[i][0];
		nhandle.nest(0).nest(4).value = val[i][1];
		let value = ui.slider(nhandle.nest(0).nest(3,{ value : 0}),"X",-1,1,true,100,true,0);
		val[i][0] = value;
		let value1 = ui.slider(nhandle.nest(0).nest(4,{ value : 0}),"Y",-1,1,true,100,true,0);
		val[i][1] = value1;
	}
	static colorRampButton(ui,nodes,node) {
		let but = node.buttons[0];
		let nhandle = zui_Handle.global.nest(174,null).nest(node.id);
		let nx = ui._x;
		let ny = ui._y;
		let vals = but.default_value;
		let sw = ui._w / (nodes.scaleFactor * nodes.zoom);
		let _g = 0;
		while(_g < vals.length) {
			let val = vals[_g];
			++_g;
			let pos = val[4];
			ui.fill(pos * sw,0,(1.0 - pos) * sw,(nodes.ELEMENT_H * (nodes.scaleFactor * nodes.zoom) | 0) - 2 * (nodes.scaleFactor * nodes.zoom),kha_Color.fromFloats(val[0],val[1],val[2]));
		}
		ui._y += nodes.ELEMENT_H * (nodes.scaleFactor * nodes.zoom) | 0;
		let ihandle = nhandle.nest(0).nest(2);
		ui.row([0.25,0.25,0.5]);
		if(ui.button("+")) {
			let last = vals[vals.length - 1];
			let f32 = new Float32Array(5);
			f32[0] = last[0];
			f32[1] = last[1];
			f32[2] = last[2];
			f32[3] = last[3];
			f32[4] = 1.0;
			vals.push(f32);
			ihandle.value += 1;
		}
		if(ui.button("-") && vals.length > 1) {
			vals.pop();
			ihandle.value -= 1;
		}
		but.data = ui.combo(nhandle.nest(0).nest(1,{ position : but.data}),[arm_Translator.tr("Linear"),arm_Translator.tr("Constant")],arm_Translator.tr("Interpolate"));
		ui.row([0.5,0.5]);
		let i = ui.slider(ihandle,"Index",0,vals.length - 1,false,1,true,0) | 0;
		if(i >= vals.length || i < 0) {
			i = vals.length - 1;
			ihandle.value = i;
		}
		let val = vals[i];
		nhandle.nest(0).nest(3).value = val[4];
		val[4] = ui.slider(nhandle.nest(0).nest(3),"Pos",0,1,true,100,true,0);
		if(val[4] > 1.0) {
			val[4] = 1.0;
		} else if(val[4] < 0.0) {
			val[4] = 0.0;
		}
		let chandle = nhandle.nest(0).nest(4);
		chandle.color = kha_Color.fromFloats(val[0],val[1],val[2]);
		if(ui.text("",2,chandle.color) == 1) {
			nodes._inputStarted = ui.inputStarted = false;
			nodes.rgbaPopup(ui,chandle,val,nx + ui._w - 37 * (nodes.scaleFactor * nodes.zoom) | 0,ny - 5 * (nodes.scaleFactor * nodes.zoom) + ui.t.ELEMENT_H * ui.ops.scaleFactor | 0);
		}
		val[0] = ((chandle.color & 16711680) >>> 16) * 0.00392156862745098;
		val[1] = ((chandle.color & 65280) >>> 8) * 0.00392156862745098;
		val[2] = (chandle.color & 255) * 0.00392156862745098;
	}
	static newGroupButton(ui,nodes,node) {
		if(node.name == "New Group") {
			let _g = 1;
			while(_g < 999) {
				node.name = arm_Translator.tr("Group") + " " + _g++;
				let found = false;
				let _g1 = 0;
				let _g2 = arm_Project.materialGroups;
				while(_g1 < _g2.length) if(_g2[_g1++].canvas.name == node.name) {
					found = true;
					break;
				}
				if(!found) {
					break;
				}
			}
			arm_Project.materialGroups.push({ canvas : { name : node.name, nodes : [{ id : 0, x : 50, y : 200, name : "Group Input", type : "GROUP_INPUT", inputs : [], outputs : [], buttons : [{ name : "arm.shader.NodesMaterial.groupInputButton", type : "CUSTOM", height : 1}], color : -12284819},{ id : 1, x : 450, y : 200, name : "Group Output", type : "GROUP_OUTPUT", inputs : [], outputs : [], buttons : [{ name : "arm.shader.NodesMaterial.groupOutputButton", type : "CUSTOM", height : 1}], color : -12284819}], links : []}, nodes : new zui_Nodes()});
		}
		let group = null;
		let _g = 0;
		let _g1 = arm_Project.materialGroups;
		while(_g < _g1.length) {
			let g = _g1[_g];
			++_g;
			if(g.canvas.name == node.name) {
				group = g;
				break;
			}
		}
		if(ui.button(arm_Translator.tr("Nodes"))) {
			arm_ui_UINodes.inst.groupStack.push(group);
		}
	}
	static groupInputButton(ui,nodes,node) {
		arm_shader_NodesMaterial.addSocketButton(ui,nodes,node,node.outputs);
	}
	static groupOutputButton(ui,nodes,node) {
		arm_shader_NodesMaterial.addSocketButton(ui,nodes,node,node.inputs);
	}
	static addSocketButton(ui,nodes,node,sockets) {
		if(ui.button(arm_Translator.tr("Add"))) {
			arm_ui_UIMenu.draw(function(ui) {
				ui.text(arm_Translator.tr("Socket"),2,ui.t.HIGHLIGHT_COL);
				let groupStack = arm_ui_UINodes.inst.groupStack;
				let c = groupStack[groupStack.length - 1].canvas;
				if(ui.button(arm_Translator.tr("RGBA"),0)) {
					sockets.push(arm_shader_NodesMaterial.createSocket(nodes,node,null,"RGBA",c));
					arm_shader_NodesMaterial.syncSockets(node);
				}
				if(ui.button(arm_Translator.tr("Vector"),0)) {
					sockets.push(arm_shader_NodesMaterial.createSocket(nodes,node,null,"VECTOR",c));
					arm_shader_NodesMaterial.syncSockets(node);
				}
				if(ui.button(arm_Translator.tr("Value"),0)) {
					sockets.push(arm_shader_NodesMaterial.createSocket(nodes,node,null,"VALUE",c));
					arm_shader_NodesMaterial.syncSockets(node);
				}
			},4);
		}
	}
	static syncSockets(node) {
		let groupStack = arm_ui_UINodes.inst.groupStack;
		let c = groupStack[groupStack.length - 1].canvas;
		let _g = 0;
		let _g1 = arm_Project.materials;
		while(_g < _g1.length) arm_shader_NodesMaterial.syncGroupSockets(_g1[_g++].canvas,c.name,node);
		let _g2 = 0;
		let _g3 = arm_Project.materialGroups;
		while(_g2 < _g3.length) arm_shader_NodesMaterial.syncGroupSockets(_g3[_g2++].canvas,c.name,node);
	}
	static syncGroupSockets(canvas,groupName,node) {
		let _g = 0;
		let _g1 = canvas.nodes;
		while(_g < _g1.length) {
			let n = _g1[_g];
			++_g;
			if(n.type == "GROUP" && n.name == groupName) {
				let isInputs = node.name == "Group Input";
				let oldSockets = isInputs ? n.inputs : n.outputs;
				let sockets = JSON.parse(JSON.stringify(isInputs ? node.outputs : node.inputs));
				if(isInputs) {
					n.inputs = sockets;
				} else {
					n.outputs = sockets;
				}
				let _g = 0;
				while(_g < sockets.length) sockets[_g++].node_id = n.id;
				let _g1 = 0;
				let _g2 = sockets.length < oldSockets.length ? sockets.length : oldSockets.length;
				while(_g1 < _g2) {
					let i = _g1++;
					if(sockets[i].type == oldSockets[i].type) {
						sockets[i].default_value = oldSockets[i].default_value;
					}
				}
			}
		}
	}
	static createSocket(nodes,node,name,type,canvas,min,max,default_value) {
		if(max == null) {
			max = 1.0;
		}
		if(min == null) {
			min = 0.0;
		}
		let tmp = nodes.getSocketId(canvas.nodes);
		let node1 = node.id;
		let tmp1 = default_value == null ? type == "RGBA" ? arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0]) : type == "VECTOR" ? arm_shader_NodesMaterial.f32([0.0,0.0,0.0]) : 0.0 : default_value;
		return { id : tmp, node_id : node1, name : name == null ? type == "RGBA" ? "Color" : type == "VECTOR" ? "Vector" : "Value" : name, type : type, color : type == "RGBA" ? -3684567 : type == "VECTOR" ? -10263609 : -6184543, default_value : tmp1, min : min, max : max};
	}
	static getTNode(nodeType) {
		let _g = 0;
		let _g1 = arm_shader_NodesMaterial.list;
		while(_g < _g1.length) {
			let c = _g1[_g];
			++_g;
			let _g2 = 0;
			while(_g2 < c.length) {
				let n = c[_g2];
				++_g2;
				if(n.type == nodeType) {
					return n;
				}
			}
		}
		return null;
	}
	static createNode(nodeType,group) {
		let n = arm_shader_NodesMaterial.getTNode(nodeType);
		if(n == null) {
			return null;
		}
		let canvas = group != null ? group.canvas : arm_Context.material.canvas;
		let node = arm_ui_UINodes.makeNode(n,group != null ? group.nodes : arm_Context.material.nodes,canvas);
		canvas.nodes.push(node);
		return node;
	}
	static f32(ar) {
		let res = new Float32Array(ar.length);
		let _g = 0;
		let _g1 = ar.length;
		while(_g < _g1) {
			let i = _g++;
			res[i] = ar[i];
		}
		return res;
	}
}
$hxClasses["arm.shader.NodesMaterial"] = arm_shader_NodesMaterial;
arm_shader_NodesMaterial.__name__ = "arm.shader.NodesMaterial";
class arm_sys_Path {
	static data() {
		return Krom.getFilesLocation() + arm_sys_Path.sep + iron_data_Data.dataPath;
	}
	static toRelative(from,to) {
		let a = from.split(arm_sys_Path.sep);
		let b = to.split(arm_sys_Path.sep);
		while(a[0] == b[0]) {
			a.shift();
			b.shift();
			if(a.length == 0 || b.length == 0) {
				break;
			}
		}
		let base = "";
		let _g = 0;
		let _g1 = a.length - 1;
		while(_g < _g1) {
			++_g;
			base += ".." + arm_sys_Path.sep;
		}
		base += b.join(arm_sys_Path.sep);
		return base;
	}
	static normalize(path) {
		let ar = path.split(arm_sys_Path.sep);
		let i = 0;
		while(i < ar.length) if(i > 0 && ar[i] == ".." && ar[i - 1] != "..") {
			ar.splice(i - 1,2);
			--i;
		} else {
			++i;
		}
		return ar.join(arm_sys_Path.sep);
	}
	static baseDir(path) {
		return HxOverrides.substr(path,0,path.lastIndexOf(arm_sys_Path.sep) + 1);
	}
	static workingDir() {
		if(arm_sys_Path.workingDirCache == null) {
			let save = (arm_sys_Path.isProtected() ? Krom.savePath() : arm_sys_Path.data() + arm_sys_Path.sep) + "working_dir.txt";
			Krom.sysCommand("cd" + " > \"" + save + "\"");
			arm_sys_Path.workingDirCache = StringTools.rtrim(haxe_io_Bytes.ofData(Krom.loadBlob(save)).toString());
		}
		return arm_sys_Path.workingDirCache;
	}
	static isMesh(path) {
		let p = path.toLowerCase();
		let _g = 0;
		let _g1 = arm_sys_Path.meshFormats;
		while(_g < _g1.length) if(p.endsWith("." + _g1[_g++])) {
			return true;
		}
		return false;
	}
	static isTexture(path) {
		let p = path.toLowerCase();
		let _g = 0;
		let _g1 = arm_sys_Path.textureFormats;
		while(_g < _g1.length) if(p.endsWith("." + _g1[_g++])) {
			return true;
		}
		return false;
	}
	static isFont(path) {
		let p = path.toLowerCase();
		if(!(p.endsWith(".ttf") || p.endsWith(".ttc"))) {
			return p.endsWith(".otf");
		} else {
			return true;
		}
	}
	static isProject(path) {
		return path.toLowerCase().endsWith(".arm");
	}
	static isPlugin(path) {
		return path.toLowerCase().endsWith(".js");
	}
	static isJson(path) {
		return path.toLowerCase().endsWith(".json");
	}
	static isText(path) {
		return path.toLowerCase().endsWith(".txt");
	}
	static isKnown(path) {
		if(!(arm_sys_Path.isMesh(path) || arm_sys_Path.isTexture(path) || arm_sys_Path.isFont(path) || arm_sys_Path.isProject(path) || arm_sys_Path.isPlugin(path))) {
			return arm_sys_Path.isText(path);
		} else {
			return true;
		}
	}
	static checkExt(p,exts) {
		p = StringTools.replace(p,"-","_");
		let _g = 0;
		while(_g < exts.length) {
			let ext = exts[_g];
			++_g;
			if(p.endsWith("_" + ext) || p.indexOf("_" + ext + "_") >= 0 && !p.endsWith("_preview") && !p.endsWith("_icon")) {
				return true;
			}
		}
		return false;
	}
	static isFolder(p) {
		return p.indexOf(".") == -1;
	}
	static isProtected() {
		return Krom.getFilesLocation().indexOf("Program Files") >= 0;
	}
}
$hxClasses["arm.sys.Path"] = arm_sys_Path;
arm_sys_Path.__name__ = "arm.sys.Path";
class arm_util_RenderUtil {
	static makeMaterialPreview() {
		arm_Context.materialPreview = true;
		let sphere = iron_Scene.active.getChild(".Sphere");
		sphere.visible = true;
		let meshes = iron_Scene.active.meshes;
		iron_Scene.active.meshes = [sphere];
		let painto = arm_Context.paintObject;
		arm_Context.paintObject = sphere;
		sphere.materials[0] = arm_Project.materials[0].data;
		arm_Context.material.previewReady = true;
		let _this = arm_Context.savedCamera;
		let m = iron_Scene.active.camera.transform.local;
		_this.self._00 = m.self._00;
		_this.self._01 = m.self._01;
		_this.self._02 = m.self._02;
		_this.self._03 = m.self._03;
		_this.self._10 = m.self._10;
		_this.self._11 = m.self._11;
		_this.self._12 = m.self._12;
		_this.self._13 = m.self._13;
		_this.self._20 = m.self._20;
		_this.self._21 = m.self._21;
		_this.self._22 = m.self._22;
		_this.self._23 = m.self._23;
		_this.self._30 = m.self._30;
		_this.self._31 = m.self._31;
		_this.self._32 = m.self._32;
		_this.self._33 = m.self._33;
		iron_Scene.active.camera.transform.setMatrix(new iron_math_Mat4(0.9146286343879498,-0.0032648027153306235,0.404281837254303,0.4659988049397712,0.404295023959927,0.007367569133732468,-0.9145989516155143,-1.0687517188018691,0.000007410128652369705,0.9999675337275382,0.008058532943908717,0.015935682577325486,0,0,0,1));
		let savedFov = iron_Scene.active.camera.data.raw.fov;
		iron_Scene.active.camera.data.raw.fov = 0.92;
		arm_Viewport.updateCameraType(0);
		let light = iron_Scene.active.lights[0];
		let _lightStrength = light.data.raw.strength;
		let probe = iron_Scene.active.world.probe;
		let _probeStrength = probe.raw.strength;
		light.data.raw.strength = 0;
		probe.raw.strength = 7;
		let _envmapAngle = arm_Context.envmapAngle;
		arm_Context.envmapAngle = 6.0;
		let _brushScale = arm_Context.brushScale;
		arm_Context.brushScale = 1.5;
		let _brushNodesScale = arm_Context.brushNodesScale;
		arm_Context.brushNodesScale = 1.0;
		iron_Scene.active.world.envmap = arm_Context.previewEnvmap;
		iron_RenderPath.active.lastW = 256;
		iron_RenderPath.active.lastH = 256;
		iron_Scene.active.camera.buildProjection();
		iron_Scene.active.camera.buildMatrix();
		arm_node_MakeMaterial.parseMeshPreviewMaterial();
		let _commands = iron_RenderPath.active.commands;
		iron_RenderPath.active.commands = arm_render_RenderPathPreview.commandsPreview;
		iron_RenderPath.active.renderFrame(iron_RenderPath.active.frameG);
		iron_RenderPath.active.commands = _commands;
		arm_Context.materialPreview = false;
		iron_RenderPath.active.lastW = arm_App.w();
		iron_RenderPath.active.lastH = arm_App.h();
		sphere.visible = false;
		iron_Scene.active.meshes = meshes;
		arm_Context.paintObject = painto;
		iron_Scene.active.camera.transform.setMatrix(arm_Context.savedCamera);
		arm_Viewport.updateCameraType(arm_Context.cameraType);
		iron_Scene.active.camera.data.raw.fov = savedFov;
		iron_Scene.active.camera.buildProjection();
		iron_Scene.active.camera.buildMatrix();
		light.data.raw.strength = _lightStrength;
		probe.raw.strength = _probeStrength;
		arm_Context.envmapAngle = _envmapAngle;
		arm_Context.brushScale = _brushScale;
		arm_Context.brushNodesScale = _brushNodesScale;
		iron_Scene.active.world.envmap = arm_Context.showEnvmap ? arm_Context.savedEnvmap : arm_Context.emptyEnvmap;
		arm_node_MakeMaterial.parseMeshMaterial();
		arm_Context.ddirty = 0;
	}
	static makeDecalPreview() {
		let current = kha_graphics2_Graphics.current;
		if(current != null) {
			current.end();
		}
		if(arm_Context.decalImage == null) {
			arm_Context.decalImage = kha_Image.createRenderTarget(512,512);
		}
		arm_Context.decalPreview = true;
		let plane = iron_Scene.active.getChild(".Plane");
		let _this = plane.transform.scale;
		_this.x = 1;
		_this.y = 1;
		_this.z = 1;
		_this.w = 1.0;
		let _this1 = plane.transform.rot;
		let f = -Math.PI / 2 / 2;
		let c1 = Math.cos(f);
		let s1 = Math.sin(f);
		f = 0.;
		let c2 = Math.cos(0.);
		let s2 = Math.sin(0.);
		f = 0.;
		let c3 = Math.cos(0.);
		let s3 = Math.sin(0.);
		_this1.x = s1 * c2 * c3 + c1 * s2 * s3;
		_this1.y = c1 * s2 * c3 + s1 * c2 * s3;
		_this1.z = c1 * c2 * s3 - s1 * s2 * c3;
		_this1.w = c1 * c2 * c3 - s1 * s2 * s3;
		plane.transform.buildMatrix();
		plane.visible = true;
		let meshes = iron_Scene.active.meshes;
		iron_Scene.active.meshes = [plane];
		let painto = arm_Context.paintObject;
		arm_Context.paintObject = plane;
		let _this2 = arm_Context.savedCamera;
		let m = iron_Scene.active.camera.transform.local;
		_this2.self._00 = m.self._00;
		_this2.self._01 = m.self._01;
		_this2.self._02 = m.self._02;
		_this2.self._03 = m.self._03;
		_this2.self._10 = m.self._10;
		_this2.self._11 = m.self._11;
		_this2.self._12 = m.self._12;
		_this2.self._13 = m.self._13;
		_this2.self._20 = m.self._20;
		_this2.self._21 = m.self._21;
		_this2.self._22 = m.self._22;
		_this2.self._23 = m.self._23;
		_this2.self._30 = m.self._30;
		_this2.self._31 = m.self._31;
		_this2.self._32 = m.self._32;
		_this2.self._33 = m.self._33;
		let m1 = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
		m1.self._00 += 0 * m1.self._03;
		m1.self._01 += 0 * m1.self._03;
		m1.self._02 += m1.self._03;
		m1.self._10 += 0 * m1.self._13;
		m1.self._11 += 0 * m1.self._13;
		m1.self._12 += m1.self._13;
		m1.self._20 += 0 * m1.self._23;
		m1.self._21 += 0 * m1.self._23;
		m1.self._22 += m1.self._23;
		m1.self._30 += 0 * m1.self._33;
		m1.self._31 += 0 * m1.self._33;
		m1.self._32 += m1.self._33;
		iron_Scene.active.camera.transform.setMatrix(m1);
		let savedFov = iron_Scene.active.camera.data.raw.fov;
		iron_Scene.active.camera.data.raw.fov = 0.92;
		arm_Viewport.updateCameraType(0);
		iron_Scene.active.lights[0].visible = false;
		iron_Scene.active.world.envmap = arm_Context.previewEnvmap;
		iron_RenderPath.active.lastW = 512;
		iron_RenderPath.active.lastH = 512;
		iron_Scene.active.camera.buildProjection();
		iron_Scene.active.camera.buildMatrix();
		arm_node_MakeMaterial.parseMeshPreviewMaterial();
		let _commands = iron_RenderPath.active.commands;
		iron_RenderPath.active.commands = arm_render_RenderPathPreview.commandsDecal;
		iron_RenderPath.active.renderFrame(iron_RenderPath.active.frameG);
		iron_RenderPath.active.commands = _commands;
		arm_Context.decalPreview = false;
		iron_RenderPath.active.lastW = arm_App.w();
		iron_RenderPath.active.lastH = arm_App.h();
		plane.visible = false;
		iron_Scene.active.meshes = meshes;
		arm_Context.paintObject = painto;
		iron_Scene.active.camera.transform.setMatrix(arm_Context.savedCamera);
		iron_Scene.active.camera.data.raw.fov = savedFov;
		arm_Viewport.updateCameraType(arm_Context.cameraType);
		iron_Scene.active.camera.buildProjection();
		iron_Scene.active.camera.buildMatrix();
		iron_Scene.active.lights[0].visible = true;
		iron_Scene.active.world.envmap = arm_Context.showEnvmap ? arm_Context.savedEnvmap : arm_Context.emptyEnvmap;
		arm_node_MakeMaterial.parseMeshMaterial();
		arm_Context.ddirty = 1;
		if(current != null) {
			current.begin(false);
		}
	}
	static makeTextPreview() {
		let current = kha_graphics2_Graphics.current;
		if(current != null) {
			current.end();
		}
		let text = arm_Context.textToolText;
		let font = arm_Context.font.font;
		let textW = font.width(200,text) | 0;
		let textH = font.height(200) | 0;
		let texW = textW + 32;
		if(texW < 512) {
			texW = 512;
		}
		if(arm_Context.textToolImage != null && arm_Context.textToolImage.get_width() < texW) {
			arm_Context.textToolImage.unload();
			arm_Context.textToolImage = null;
		}
		if(arm_Context.textToolImage == null) {
			arm_Context.textToolImage = kha_Image.createRenderTarget(texW,texW,1);
		}
		let g2 = arm_Context.textToolImage.get_g2();
		g2.begin(true,-16777216);
		g2.set_font(font);
		g2.set_fontSize(200);
		g2.set_color(-1);
		g2.drawString(text,texW / 2 - textW / 2,texW / 2 - textH / 2);
		g2.end();
		if(current != null) {
			current.begin(false);
		}
	}
	static makeFontPreview() {
		let current = kha_graphics2_Graphics.current;
		if(current != null) {
			current.end();
		}
		let font = arm_Context.font.font;
		let textW = (font.width(318,"Abg") | 0) + 8;
		let textH = (font.height(318) | 0) + 8;
		if(arm_Context.font.image == null) {
			arm_Context.font.image = kha_Image.createRenderTarget(512,512,0);
		}
		let g2 = arm_Context.font.image.get_g2();
		g2.begin(true,0);
		g2.set_font(font);
		g2.set_fontSize(318);
		g2.set_color(-1);
		g2.drawString("Abg",256. - textW / 2,256. - textH / 2);
		g2.end();
		arm_Context.font.previewReady = true;
		if(current != null) {
			current.begin(false);
		}
	}
	static makeBrushPreview() {
		if(arm_render_RenderPathPaint.liveLayerLocked) {
			return;
		}
		arm_Context.materialPreview = true;
		let current = kha_graphics2_Graphics.current;
		if(current != null) {
			current.end();
		}
		if(arm_render_RenderPathPaint.liveLayer == null) {
			arm_render_RenderPathPaint.liveLayer = new arm_data_LayerSlot("_live");
		}
		let l = arm_render_RenderPathPaint.liveLayer;
		l.texpaint.get_g4().begin();
		l.texpaint.get_g4().clear(kha_Color.fromFloats(0.0,0.0,0.0,0.0));
		l.texpaint.get_g4().end();
		l.texpaint_nor.get_g4().begin();
		l.texpaint_nor.get_g4().clear(kha_Color.fromFloats(0.5,0.5,1.0,0.0));
		l.texpaint_nor.get_g4().end();
		l.texpaint_pack.get_g4().begin();
		l.texpaint_pack.get_g4().clear(kha_Color.fromFloats(1.0,0.0,0.0,0.0));
		l.texpaint_pack.get_g4().end();
		if(arm_Context.brush.image == null) {
			arm_Context.brush.image = kha_Image.createRenderTarget(256,256);
			arm_Context.brush.imageIcon = kha_Image.createRenderTarget(50,50);
		}
		let _material = arm_Context.material;
		arm_Context.material = new arm_data_MaterialSlot();
		let _tool = arm_Context.tool;
		arm_Context.tool = 0;
		let _layer = arm_Context.layer;
		if(arm_Context.layer.isMask()) {
			arm_Context.layer = arm_Context.layer.parent;
		}
		let _fill_layer = arm_Context.layer.fill_layer;
		arm_Context.layer.fill_layer = null;
		arm_render_RenderPathPaint.useLiveLayer(true);
		arm_node_MakeMaterial.parsePaintMaterial(false);
		let path = iron_RenderPath.active;
		path.renderTargets.h["texpaint_undo" + (arm_History.undoI - 1 < 0 ? arm_Config.raw.undo_steps - 1 : arm_History.undoI - 1)] = path.renderTargets.h["empty_black"];
		let painto = arm_Context.paintObject;
		let visibles = [];
		let _g = 0;
		let _g1 = arm_Project.paintObjects;
		while(_g < _g1.length) {
			let p = _g1[_g];
			++_g;
			visibles.push(p.visible);
			p.visible = false;
		}
		let mergedObjectVisible = false;
		if(arm_Context.mergedObject != null) {
			mergedObjectVisible = arm_Context.mergedObject.visible;
			arm_Context.mergedObject.visible = false;
		}
		let cam = iron_Scene.active.camera;
		let _this = arm_Context.savedCamera;
		let m = cam.transform.local;
		_this.self._00 = m.self._00;
		_this.self._01 = m.self._01;
		_this.self._02 = m.self._02;
		_this.self._03 = m.self._03;
		_this.self._10 = m.self._10;
		_this.self._11 = m.self._11;
		_this.self._12 = m.self._12;
		_this.self._13 = m.self._13;
		_this.self._20 = m.self._20;
		_this.self._21 = m.self._21;
		_this.self._22 = m.self._22;
		_this.self._23 = m.self._23;
		_this.self._30 = m.self._30;
		_this.self._31 = m.self._31;
		_this.self._32 = m.self._32;
		_this.self._33 = m.self._33;
		let savedFov = cam.data.raw.fov;
		arm_Viewport.updateCameraType(0);
		let m1 = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
		m1.self._00 += 0 * m1.self._03;
		m1.self._01 += 0 * m1.self._03;
		m1.self._02 += 0.5 * m1.self._03;
		m1.self._10 += 0 * m1.self._13;
		m1.self._11 += 0 * m1.self._13;
		m1.self._12 += 0.5 * m1.self._13;
		m1.self._20 += 0 * m1.self._23;
		m1.self._21 += 0 * m1.self._23;
		m1.self._22 += 0.5 * m1.self._23;
		m1.self._30 += 0 * m1.self._33;
		m1.self._31 += 0 * m1.self._33;
		m1.self._32 += 0.5 * m1.self._33;
		cam.transform.setMatrix(m1);
		cam.data.raw.fov = 0.92;
		cam.buildProjection();
		cam.buildMatrix();
		let m2 = iron_Scene.active.camera.VP;
		let a00 = m2.self._00;
		let a01 = m2.self._01;
		let a02 = m2.self._02;
		let a03 = m2.self._03;
		let a10 = m2.self._10;
		let a11 = m2.self._11;
		let a12 = m2.self._12;
		let a13 = m2.self._13;
		let a20 = m2.self._20;
		let a21 = m2.self._21;
		let a22 = m2.self._22;
		let a23 = m2.self._23;
		let a30 = m2.self._30;
		let a31 = m2.self._31;
		let a32 = m2.self._32;
		let a33 = m2.self._33;
		let b00 = a00 * a11 - a01 * a10;
		let b01 = a00 * a12 - a02 * a10;
		let b02 = a00 * a13 - a03 * a10;
		let b03 = a01 * a12 - a02 * a11;
		let b04 = a01 * a13 - a03 * a11;
		let b05 = a02 * a13 - a03 * a12;
		let b06 = a20 * a31 - a21 * a30;
		let b07 = a20 * a32 - a22 * a30;
		let b08 = a20 * a33 - a23 * a30;
		let b09 = a21 * a32 - a22 * a31;
		let b10 = a21 * a33 - a23 * a31;
		let b11 = a22 * a33 - a23 * a32;
		let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
		if(det == 0.0) {
			m1.self._00 = 1.0;
			m1.self._01 = 0.0;
			m1.self._02 = 0.0;
			m1.self._03 = 0.0;
			m1.self._10 = 0.0;
			m1.self._11 = 1.0;
			m1.self._12 = 0.0;
			m1.self._13 = 0.0;
			m1.self._20 = 0.0;
			m1.self._21 = 0.0;
			m1.self._22 = 1.0;
			m1.self._23 = 0.0;
			m1.self._30 = 0.0;
			m1.self._31 = 0.0;
			m1.self._32 = 0.0;
			m1.self._33 = 1.0;
		} else {
			det = 1.0 / det;
			m1.self._00 = (a11 * b11 - a12 * b10 + a13 * b09) * det;
			m1.self._01 = (a02 * b10 - a01 * b11 - a03 * b09) * det;
			m1.self._02 = (a31 * b05 - a32 * b04 + a33 * b03) * det;
			m1.self._03 = (a22 * b04 - a21 * b05 - a23 * b03) * det;
			m1.self._10 = (a12 * b08 - a10 * b11 - a13 * b07) * det;
			m1.self._11 = (a00 * b11 - a02 * b08 + a03 * b07) * det;
			m1.self._12 = (a32 * b02 - a30 * b05 - a33 * b01) * det;
			m1.self._13 = (a20 * b05 - a22 * b02 + a23 * b01) * det;
			m1.self._20 = (a10 * b10 - a11 * b08 + a13 * b06) * det;
			m1.self._21 = (a01 * b08 - a00 * b10 - a03 * b06) * det;
			m1.self._22 = (a30 * b04 - a31 * b02 + a33 * b00) * det;
			m1.self._23 = (a21 * b02 - a20 * b04 - a23 * b00) * det;
			m1.self._30 = (a11 * b07 - a10 * b09 - a12 * b06) * det;
			m1.self._31 = (a00 * b09 - a01 * b07 + a02 * b06) * det;
			m1.self._32 = (a31 * b01 - a30 * b03 - a32 * b00) * det;
			m1.self._33 = (a20 * b03 - a21 * b01 + a22 * b00) * det;
		}
		let planeo = iron_Scene.active.getChild(".Plane");
		planeo.visible = true;
		arm_Context.paintObject = planeo;
		let x = m1.self._00;
		let y = m1.self._01;
		let z = m1.self._02;
		let sx = Math.sqrt(x * x + y * y + z * z);
		let _this1 = planeo.transform.rot;
		let f = -Math.PI / 2 / 2;
		let c1 = Math.cos(f);
		let s1 = Math.sin(f);
		f = 0.;
		let c2 = Math.cos(0.);
		let s2 = Math.sin(0.);
		f = 0.;
		let c3 = Math.cos(0.);
		let s3 = Math.sin(0.);
		_this1.x = s1 * c2 * c3 + c1 * s2 * s3;
		_this1.y = c1 * s2 * c3 + s1 * c2 * s3;
		_this1.z = c1 * c2 * s3 - s1 * s2 * c3;
		_this1.w = c1 * c2 * c3 - s1 * s2 * s3;
		let _this2 = planeo.transform.scale;
		_this2.x = sx;
		_this2.y = 1.0;
		_this2.z = sx;
		_this2.w = 1.0;
		let _this3 = planeo.transform.loc;
		_this3.x = m1.self._30;
		_this3.y = -m1.self._31;
		_this3.z = 0.0;
		_this3.w = 1.0;
		planeo.transform.buildMatrix();
		arm_render_RenderPathPaint.liveLayerDrawn = 0;
		arm_render_RenderPathDeferred.drawGbuffer();
		let _brushRadius = arm_Context.brushRadius;
		let _brushOpacity = arm_Context.brushOpacity;
		let _brushHardness = arm_Context.brushHardness;
		arm_Context.brushRadius = 0.33;
		arm_Context.brushOpacity = 1.0;
		arm_Context.brushHardness = 0.8;
		let _x = arm_Context.paintVec.x;
		let _y = arm_Context.paintVec.y;
		let _lastX = arm_Context.lastPaintVecX;
		let _lastY = arm_Context.lastPaintVecY;
		let _pdirty = arm_Context.pdirty;
		arm_Context.pdirty = 2;
		let pointsX = [0.2,0.2,0.35,0.5,0.5,0.5,0.65,0.8,0.8,0.8];
		let pointsY = [0.5,0.5,0.31,0.12000000000000001,0.41500000000000004,0.63,0.425,0.25,0.525,0.75];
		let _g2 = 1;
		let _g3 = pointsX.length;
		while(_g2 < _g3) {
			let i = _g2++;
			arm_Context.lastPaintVecX = pointsX[i - 1];
			arm_Context.lastPaintVecY = pointsY[i - 1];
			arm_Context.paintVec.x = pointsX[i];
			arm_Context.paintVec.y = pointsY[i];
			arm_render_RenderPathPaint.commandsPaint(false);
		}
		arm_Context.brushRadius = _brushRadius;
		arm_Context.brushOpacity = _brushOpacity;
		arm_Context.brushHardness = _brushHardness;
		arm_Context.paintVec.x = _x;
		arm_Context.paintVec.y = _y;
		arm_Context.lastPaintVecX = _lastX;
		arm_Context.lastPaintVecY = _lastY;
		arm_Context.prevPaintVecX = -1;
		arm_Context.prevPaintVecY = -1;
		arm_Context.pdirty = _pdirty;
		arm_render_RenderPathPaint.useLiveLayer(false);
		arm_Context.layer.fill_layer = _fill_layer;
		arm_Context.layer = _layer;
		arm_Context.material = _material;
		arm_Context.tool = _tool;
		iron_App.notifyOnInit(function() {
			arm_node_MakeMaterial.parsePaintMaterial(false);
		});
		arm_Context.materialPreview = false;
		planeo.visible = false;
		let _g4 = 0;
		let _g5 = arm_Project.paintObjects.length;
		while(_g4 < _g5) {
			let i = _g4++;
			arm_Project.paintObjects[i].visible = visibles[i];
		}
		if(arm_Context.mergedObject != null) {
			arm_Context.mergedObject.visible = mergedObjectVisible;
		}
		arm_Context.paintObject = painto;
		iron_Scene.active.camera.transform.setMatrix(arm_Context.savedCamera);
		iron_Scene.active.camera.data.raw.fov = savedFov;
		arm_Viewport.updateCameraType(arm_Context.cameraType);
		iron_Scene.active.camera.buildProjection();
		iron_Scene.active.camera.buildMatrix();
		if(arm_Layers.pipeMerge == null) {
			arm_Layers.makePipe();
		}
		let l1 = arm_render_RenderPathPaint.liveLayer;
		let target = arm_Context.brush.image;
		target.get_g2().begin(true,0);
		target.get_g2().set_pipeline(arm_Layers.pipeCopy);
		target.get_g2().drawScaledImage(l1.texpaint,0,0,target.get_width(),target.get_height());
		target.get_g2().set_pipeline(null);
		target.get_g2().end();
		path.renderTargets.h["texpreview"].image = arm_Context.brush.image;
		path.renderTargets.h["texpreview_icon"].image = arm_Context.brush.imageIcon;
		path.setTarget("texpreview_icon");
		path.bindTarget("texpreview","tex");
		path.drawShader("shader_datas/supersample_resolve/supersample_resolve");
		arm_Context.brush.previewReady = true;
		arm_Context.brushBlendDirty = true;
		if(current != null) {
			current.begin(false);
		}
	}
	static createScreenAlignedFullData() {
		let data = [-10922,-10922,0,32767,0,0,0,0,0,0,0,0,32767,-10922,0,32767,0,0,0,0,0,0,0,0,-10922,32767,0,32767,0,0,0,0,0,0,0,0];
		let indices = [0,1,2];
		let structure = new kha_graphics4_VertexStructure();
		structure.add("pos",27);
		structure.add("nor",23);
		structure.add("tex",23);
		structure.add("col",27);
		arm_util_RenderUtil.screenAlignedFullVB = new kha_graphics4_VertexBuffer(data.length / (structure.byteSize() / 4 | 0) | 0,structure,0);
		let vertices = arm_util_RenderUtil.screenAlignedFullVB.lock();
		let _g = 0;
		let _g1 = vertices.byteLength / 2 | 0;
		while(_g < _g1) {
			let i = _g++;
			vertices.setInt16(i * 2,data[i],kha_arrays_ByteArray.LITTLE_ENDIAN);
		}
		arm_util_RenderUtil.screenAlignedFullVB.unlock();
		arm_util_RenderUtil.screenAlignedFullIB = new kha_graphics4_IndexBuffer(indices.length,0);
		let id = arm_util_RenderUtil.screenAlignedFullIB.lock();
		let _g2 = 0;
		let _g3 = id.length;
		while(_g2 < _g3) {
			let i = _g2++;
			id[i] = indices[i];
		}
		arm_util_RenderUtil.screenAlignedFullIB.unlock();
	}
	static makeNodePreview(canvas,node,image,group,parents) {
		let res = arm_node_MakeMaterial.parseNodePreviewMaterial(node,group,parents);
		if(res == null || res.scon == null) {
			return;
		}
		let g4 = image.get_g4();
		if(arm_util_RenderUtil.screenAlignedFullVB == null) {
			arm_util_RenderUtil.createScreenAlignedFullData();
		}
		let _scaleWorld = arm_Context.paintObject.transform.scaleWorld;
		arm_Context.paintObject.transform.scaleWorld = 3.0;
		arm_Context.paintObject.transform.buildMatrix();
		g4.begin();
		g4.setPipeline(res.scon.pipeState);
		iron_object_Uniforms.setContextConstants(g4,res.scon,[""]);
		iron_object_Uniforms.setObjectConstants(g4,res.scon,arm_Context.paintObject);
		iron_object_Uniforms.setMaterialConstants(g4,res.scon,res.mcon);
		g4.setVertexBuffer(arm_util_RenderUtil.screenAlignedFullVB);
		g4.setIndexBuffer(arm_util_RenderUtil.screenAlignedFullIB);
		g4.drawIndexedVertices();
		g4.end();
		arm_Context.paintObject.transform.scaleWorld = _scaleWorld;
		arm_Context.paintObject.transform.buildMatrix();
	}
	static pickPosNorTex() {
		arm_Context.pickPosNorTex = true;
		arm_Context.pdirty = 1;
		let _tool = arm_Context.tool;
		arm_Context.tool = 9;
		arm_node_MakeMaterial.parsePaintMaterial();
		if(arm_Context.paint2d) {
			arm_render_RenderPathPaint.setPlaneMesh();
		}
		arm_render_RenderPathPaint.commandsPaint(false);
		if(arm_Context.paint2d) {
			arm_render_RenderPathPaint.restorePlaneMesh();
		}
		arm_Context.tool = _tool;
		arm_Context.pickPosNorTex = false;
		arm_node_MakeMaterial.parsePaintMaterial();
		arm_Context.pdirty = 0;
	}
	static getDecalMat() {
		arm_util_RenderUtil.pickPosNorTex();
		let decalMat = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
		let x = arm_Context.posXPicked;
		let y = arm_Context.posYPicked;
		let z = arm_Context.posZPicked;
		if(z == null) {
			z = 0.0;
		}
		if(y == null) {
			y = 0.0;
		}
		if(x == null) {
			x = 0.0;
		}
		let _this = new iron_math_Quat();
		let x1 = arm_Context.norXPicked;
		let y1 = arm_Context.norYPicked;
		let z1 = arm_Context.norZPicked;
		if(z1 == null) {
			z1 = 0.0;
		}
		if(y1 == null) {
			y1 = 0.0;
		}
		if(x1 == null) {
			x1 = 0.0;
		}
		let v2_x = x1;
		let v2_y = y1;
		let v2_z = z1;
		let a = iron_math_Quat.helpVec0;
		let dot = 0.0 * v2_x + 0.0 * v2_y + -1.0 * v2_z;
		if(dot < -0.999999) {
			let a1 = iron_math_Quat.xAxis;
			let ax = a1.x;
			let ay = a1.y;
			let az = a1.z;
			a.x = ay * -1.0 - az * 0.0;
			a.y = az * 0.0 - ax * -1.0;
			a.z = ax * 0.0 - ay * 0.0;
			if(Math.sqrt(a.x * a.x + a.y * a.y + a.z * a.z) < 0.000001) {
				let a1 = iron_math_Quat.yAxis;
				let ax = a1.x;
				let ay = a1.y;
				let az = a1.z;
				a.x = ay * -1.0 - az * 0.0;
				a.y = az * 0.0 - ax * -1.0;
				a.z = ax * 0.0 - ay * 0.0;
			}
			let n = Math.sqrt(a.x * a.x + a.y * a.y + a.z * a.z);
			if(n > 0.0) {
				let invN = 1.0 / n;
				a.x *= invN;
				a.y *= invN;
				a.z *= invN;
			}
			let angle = Math.PI;
			let s = Math.sin(angle * 0.5);
			_this.x = a.x * s;
			_this.y = a.y * s;
			_this.z = a.z * s;
			_this.w = Math.cos(angle * 0.5);
			let l = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z + _this.w * _this.w);
			if(l == 0.0) {
				_this.x = 0;
				_this.y = 0;
				_this.z = 0;
				_this.w = 0;
			} else {
				l = 1.0 / l;
				_this.x *= l;
				_this.y *= l;
				_this.z *= l;
				_this.w *= l;
			}
		} else if(dot > 0.999999) {
			_this.x = 0;
			_this.y = 0;
			_this.z = 0;
			_this.w = 1;
		} else {
			a.x = 0.0 * v2_z - -1.0 * v2_y;
			a.y = -1.0 * v2_x - 0.0 * v2_z;
			a.z = 0.0 * v2_y - 0.0 * v2_x;
			_this.x = a.x;
			_this.y = a.y;
			_this.z = a.z;
			_this.w = 1 + dot;
			let l = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z + _this.w * _this.w);
			if(l == 0.0) {
				_this.x = 0;
				_this.y = 0;
				_this.z = 0;
				_this.w = 0;
			} else {
				l = 1.0 / l;
				_this.x *= l;
				_this.y *= l;
				_this.z *= l;
				_this.w *= l;
			}
		}
		let x2 = arm_Context.brushRadius * 0.5;
		let y2 = arm_Context.brushRadius * 0.5;
		let z2 = arm_Context.brushRadius * 0.5;
		if(z2 == null) {
			z2 = 0.0;
		}
		if(y2 == null) {
			y2 = 0.0;
		}
		if(x2 == null) {
			x2 = 0.0;
		}
		let scale_x = x2;
		let scale_y = y2;
		let scale_z = z2;
		let x3 = _this.x;
		let y3 = _this.y;
		let z3 = _this.z;
		let w = _this.w;
		let x21 = x3 + x3;
		let y21 = y3 + y3;
		let z21 = z3 + z3;
		let xx = x3 * x21;
		let xy = x3 * y21;
		let xz = x3 * z21;
		let yy = y3 * y21;
		let yz = y3 * z21;
		let zz = z3 * z21;
		let wx = w * x21;
		let wy = w * y21;
		let wz = w * z21;
		decalMat.self._00 = 1.0 - (yy + zz);
		decalMat.self._10 = xy - wz;
		decalMat.self._20 = xz + wy;
		decalMat.self._01 = xy + wz;
		decalMat.self._11 = 1.0 - (xx + zz);
		decalMat.self._21 = yz - wx;
		decalMat.self._02 = xz - wy;
		decalMat.self._12 = yz + wx;
		decalMat.self._22 = 1.0 - (xx + yy);
		decalMat.self._03 = 0.0;
		decalMat.self._13 = 0.0;
		decalMat.self._23 = 0.0;
		decalMat.self._30 = 0.0;
		decalMat.self._31 = 0.0;
		decalMat.self._32 = 0.0;
		decalMat.self._33 = 1.0;
		decalMat.self._00 *= scale_x;
		decalMat.self._01 *= scale_x;
		decalMat.self._02 *= scale_x;
		decalMat.self._03 *= scale_x;
		decalMat.self._10 *= scale_y;
		decalMat.self._11 *= scale_y;
		decalMat.self._12 *= scale_y;
		decalMat.self._13 *= scale_y;
		decalMat.self._20 *= scale_z;
		decalMat.self._21 *= scale_z;
		decalMat.self._22 *= scale_z;
		decalMat.self._23 *= scale_z;
		decalMat.self._30 = x;
		decalMat.self._31 = y;
		decalMat.self._32 = z;
		return decalMat;
	}
}
$hxClasses["arm.util.RenderUtil"] = arm_util_RenderUtil;
arm_util_RenderUtil.__name__ = "arm.util.RenderUtil";
class arm_Res {
	static load(names,done) {
		let loaded = 0;
		let _g = 0;
		while(_g < names.length) {
			let s = names[_g];
			++_g;
			iron_data_Data.getImage(s,function(image) {
				arm_Res.bundled.h[s] = image;
				loaded += 1;
				if(loaded == names.length) {
					done();
				}
			});
		}
	}
	static tile50(img,x,y) {
		let size = arm_Config.raw.window_scale > 1 ? 100 : 50;
		return { x : x * size, y : y * size, w : size, h : size};
	}
	static tile18(img,x,y) {
		let size = arm_Config.raw.window_scale > 1 ? 36 : 18;
		return { x : x * size, y : img.get_height() - (y + 1) * size, w : size, h : size};
	}
}
$hxClasses["arm.Res"] = arm_Res;
arm_Res.__name__ = "arm.Res";
class arm_ui_UIBox {
	static render(g) {
		if(!arm_ui_UIMenu.show) {
			let mouse = iron_system_Input.getMouse();
			let kb = iron_system_Input.getKeyboard();
			let ui = arm_App.uiBox;
			let inUse = ui.comboSelectedHandle != null;
			let isEscape = kb.started("escape");
			if(arm_ui_UIBox.draws > 2 && (ui.inputReleased || isEscape) && !inUse && !ui.isTyping) {
				let appw = kha_System.windowWidth();
				let apph = kha_System.windowHeight();
				let mw = arm_ui_UIBox.modalW * ui.ops.scaleFactor | 0;
				let mh = arm_ui_UIBox.modalH * ui.ops.scaleFactor | 0;
				let mx = mouse.x;
				let my = mouse.y;
				if(arm_ui_UIBox.clickToHide && (mx < appw / 2 - mw / 2 + arm_ui_UIBox.hwnd.dragX || mx > appw / 2 + mw / 2 + arm_ui_UIBox.hwnd.dragX || my < apph / 2 - mh / 2 + arm_ui_UIBox.hwnd.dragY || my > apph / 2 + mh / 2 + arm_ui_UIBox.hwnd.dragY) || isEscape) {
					if(arm_ui_UIBox.modalOnHide != null) {
						arm_ui_UIBox.modalOnHide();
					}
					arm_ui_UIBox.show = false;
					arm_App.redrawUI();
				}
			}
		}
		g.end();
		let ui = arm_App.uiBox;
		let appw = kha_System.windowWidth();
		let apph = kha_System.windowHeight();
		let mw = arm_ui_UIBox.modalW * ui.ops.scaleFactor | 0;
		let mh = arm_ui_UIBox.modalH * ui.ops.scaleFactor | 0;
		let left = appw / 2 - mw / 2 | 0;
		let top = apph / 2 - mh / 2 | 0;
		if(arm_ui_UIBox.boxCommands == null) {
			ui.begin(g);
			if(ui.window(arm_ui_UIBox.hwnd,left,top,mw,mh,arm_ui_UIBox.draggable)) {
				ui._y += 10;
				if(ui.tab(zui_Handle.global.nest(171,null),arm_ui_UIBox.boxTitle)) {
					if(arm_ui_UIBox.copyable) {
						zui_Ext.textArea(ui,zui_Handle.global.nest(172,{ text : arm_ui_UIBox.boxText}),null,false);
					} else {
						ui.text(arm_ui_UIBox.boxText);
					}
					ui.endElement();
					if(arm_ui_UIBox.copyable) {
						ui.row([0.33333333333333331,0.33333333333333331,0.33333333333333331]);
					} else {
						ui.row([0.66666666666666663,0.33333333333333331]);
					}
					ui.endElement();
					if(arm_ui_UIBox.copyable && ui.button(arm_Translator.tr("Copy"))) {
						Krom.copyToClipboard(arm_ui_UIBox.boxText);
					}
					if(ui.button(arm_Translator.tr("OK"))) {
						arm_ui_UIBox.show = false;
						arm_App.redrawUI();
					}
				}
				arm_ui_UIBox.windowBorder(ui);
			}
			ui.end();
		} else {
			ui.begin(g);
			if(ui.window(arm_ui_UIBox.hwnd,left,top,mw,mh,arm_ui_UIBox.draggable)) {
				ui._y += 10;
				arm_ui_UIBox.boxCommands(ui);
				arm_ui_UIBox.windowBorder(ui);
			}
			ui.end();
		}
		g.begin(false);
		arm_ui_UIBox.draws++;
	}
	static showMessage(title,text,copyable) {
		if(copyable == null) {
			copyable = false;
		}
		arm_ui_UIBox.init();
		arm_ui_UIBox.modalW = 400;
		arm_ui_UIBox.modalH = 210;
		arm_ui_UIBox.boxTitle = title;
		arm_ui_UIBox.boxText = text;
		arm_ui_UIBox.boxCommands = null;
		arm_ui_UIBox.copyable = copyable;
		arm_ui_UIBox.draggable = true;
	}
	static showCustom(commands,mw,mh,onHide,draggable) {
		if(draggable == null) {
			draggable = true;
		}
		if(mh == null) {
			mh = 200;
		}
		if(mw == null) {
			mw = 400;
		}
		arm_ui_UIBox.init();
		arm_ui_UIBox.modalW = mw;
		arm_ui_UIBox.modalH = mh;
		arm_ui_UIBox.modalOnHide = onHide;
		arm_ui_UIBox.boxCommands = commands;
		arm_ui_UIBox.draggable = draggable;
	}
	static init() {
		arm_ui_UIBox.hwnd.redraws = 2;
		arm_ui_UIBox.hwnd.dragX = 0;
		arm_ui_UIBox.hwnd.dragY = 0;
		arm_ui_UIBox.show = true;
		arm_ui_UIBox.draws = 0;
		arm_ui_UIBox.clickToHide = true;
	}
	static windowBorder(ui) {
		if(ui.scissor) {
			ui.scissor = false;
			ui.g.disableScissor();
		}
		ui.g.set_color(ui.t.SEPARATOR_COL);
		ui.g.fillRect(0,0,1,ui._windowH);
		ui.g.fillRect(ui._windowW - 1,0,1,ui._windowH);
		ui.g.fillRect(0,ui._windowH - 1,ui._windowW,1);
	}
}
$hxClasses["arm.ui.UIBox"] = arm_ui_UIBox;
arm_ui_UIBox.__name__ = "arm.ui.UIBox";
class arm_ui_UIFiles {
	static show(filters,isSave,openMultiple,filesDone) {
		if(isSave) {
			arm_ui_UIFiles.path = Krom.saveDialog(filters,"");
			if(arm_ui_UIFiles.path != null) {
				while(arm_ui_UIFiles.path.indexOf(arm_sys_Path.sep + arm_sys_Path.sep) >= 0) arm_ui_UIFiles.path = StringTools.replace(arm_ui_UIFiles.path,arm_sys_Path.sep + arm_sys_Path.sep,arm_sys_Path.sep);
				arm_ui_UIFiles.path = StringTools.replace(arm_ui_UIFiles.path,"\r","");
				arm_ui_UIFiles.filename = HxOverrides.substr(arm_ui_UIFiles.path,arm_ui_UIFiles.path.lastIndexOf(arm_sys_Path.sep) + 1,null);
				arm_ui_UIFiles.path = HxOverrides.substr(arm_ui_UIFiles.path,0,arm_ui_UIFiles.path.lastIndexOf(arm_sys_Path.sep));
				filesDone(arm_ui_UIFiles.path);
			}
		} else {
			let paths = Krom.openDialog(filters,"",openMultiple);
			if(paths != null) {
				let _g = 0;
				while(_g < paths.length) {
					let path = paths[_g];
					++_g;
					while(path.indexOf(arm_sys_Path.sep + arm_sys_Path.sep) >= 0) path = StringTools.replace(path,arm_sys_Path.sep + arm_sys_Path.sep,arm_sys_Path.sep);
					path = StringTools.replace(path,"\r","");
					arm_ui_UIFiles.filename = HxOverrides.substr(path,path.lastIndexOf(arm_sys_Path.sep) + 1,null);
					filesDone(path);
				}
			}
		}
		arm_ui_UIFiles.releaseKeys();
	}
	static releaseKeys() {
		let kb = kha_input_Keyboard.get();
		kb.sendUpEvent(16);
		kb.sendUpEvent(17);
	}
	static fileBrowser(ui,handle,foldersOnly,dragFiles,search,refresh) {
		if(refresh == null) {
			refresh = false;
		}
		if(search == null) {
			search = "";
		}
		if(dragFiles == null) {
			dragFiles = false;
		}
		if(foldersOnly == null) {
			foldersOnly = false;
		}
		let icons = arm_Res.bundled.h["icons.k"];
		let folder = arm_Res.tile50(icons,2,1);
		let file = arm_Res.tile50(icons,3,1);
		let isCloud = handle.text.startsWith("cloud");
		if(isCloud && arm_sys_File.cloud == null) {
			arm_sys_File.initCloud(function() {
				arm_ui_UIStatus.inst.statusHandle.redraws = 3;
			});
		}
		if(isCloud && arm_sys_File.readDirectory("cloud",false).length == 0) {
			return handle.text;
		}
		if(handle.text == "") {
			handle.text = "C:\\Users";
		}
		if(handle.text != arm_ui_UIFiles.lastPath || search != arm_ui_UIFiles.lastSearch || refresh) {
			arm_ui_UIFiles.files = [];
			let i1 = handle.text.indexOf(arm_sys_Path.sep);
			let nested = i1 > -1 && handle.text.length - 1 > i1;
			nested = nested && !(handle.text.length >= 2 && handle.text.charAt(0) == arm_sys_Path.sep && handle.text.charAt(1) == arm_sys_Path.sep && handle.text.lastIndexOf(arm_sys_Path.sep) == 1);
			if(nested) {
				arm_ui_UIFiles.files.push("..");
			}
			let filesAll = arm_sys_File.readDirectory(handle.text,foldersOnly);
			let _g = 0;
			while(_g < filesAll.length) {
				let f = filesAll[_g];
				++_g;
				if(f == "" || f.charAt(0) == ".") {
					continue;
				}
				if(f.indexOf(".") > 0 && !arm_sys_Path.isKnown(f)) {
					continue;
				}
				if(isCloud && f.indexOf("_icon.") >= 0) {
					continue;
				}
				if(f.toLowerCase().indexOf(search.toLowerCase()) < 0) {
					continue;
				}
				arm_ui_UIFiles.files.push(f);
			}
		}
		arm_ui_UIFiles.lastPath = handle.text;
		arm_ui_UIFiles.lastSearch = search;
		handle.changed = false;
		let slotw = 70 * ui.ops.scaleFactor | 0;
		let num = ui._w / slotw | 0;
		let _g = 0;
		let _g1 = Math.ceil(arm_ui_UIFiles.files.length / num) | 0;
		while(_g < _g1) {
			let row = _g++;
			let _g1 = [];
			let _g2 = 0;
			let _g3 = num * 2;
			while(_g2 < _g3) {
				++_g2;
				_g1.push(1 / num);
			}
			ui.row(_g1);
			if(row > 0) {
				ui._y += ui.t.ELEMENT_OFFSET * ui.ops.scaleFactor * 14.0;
			}
			let _g4 = 0;
			while(_g4 < num) {
				let i = _g4++ + row * num;
				if(i >= arm_ui_UIFiles.files.length) {
					ui.endElement(slotw);
					ui.endElement(slotw);
					continue;
				}
				let f = arm_ui_UIFiles.files[i];
				let _x = ui._x;
				let rect = f.indexOf(".") > 0 ? file : folder;
				let col = rect == file ? ui.t.LABEL_COL : ui.t.LABEL_COL - 2105376;
				if(arm_ui_UIFiles.selected == i) {
					col = ui.t.HIGHLIGHT_COL;
				}
				let uix = ui._x += ui._w / 2 - 25 * ui.ops.scaleFactor;
				let uiy = ui._y;
				let state = 0;
				let generic = true;
				let icon = null;
				if(isCloud && f != ".." && !arm_ui_UIFiles.offline) {
					if(arm_ui_UIFiles.iconMap == null) {
						arm_ui_UIFiles.iconMap = new haxe_ds_StringMap();
					}
					icon = arm_ui_UIFiles.iconMap.h[handle.text + arm_sys_Path.sep + f];
					if(icon == null) {
						let filesAll = arm_sys_File.readDirectory(handle.text);
						let iconFile = HxOverrides.substr(f,0,f.lastIndexOf(".")) + "_icon.jpg";
						if(filesAll.indexOf(iconFile) >= 0) {
							arm_ui_UIFiles.iconMap.h[handle.text + arm_sys_Path.sep + f] = iron_RenderPath.active.renderTargets.h["empty_black"].image;
							arm_sys_File.cacheCloud(handle.text + arm_sys_Path.sep + iconFile,function(abs) {
								if(abs != null) {
									iron_data_Data.getImage(abs,function(image) {
										iron_App.notifyOnInit(function() {
											if(arm_Layers.pipeCopyRGB == null) {
												arm_Layers.makePipeCopyRGB();
											}
											icon = kha_Image.createRenderTarget(image.get_width(),image.get_height());
											if(f.endsWith(".arm")) {
												icon.get_g2().begin(false);
												icon.get_g2().drawImage(arm_Project.materials[0].image,0,0);
											} else {
												icon.get_g2().begin(true,-1);
											}
											icon.get_g2().set_pipeline(arm_Layers.pipeCopyRGB);
											icon.get_g2().drawImage(image,0,0);
											icon.get_g2().set_pipeline(null);
											icon.get_g2().end();
											arm_ui_UIFiles.iconMap.h[handle.text + arm_sys_Path.sep + f] = icon;
											arm_ui_UIStatus.inst.statusHandle.redraws = 3;
										});
									});
								} else {
									arm_ui_UIFiles.offline = true;
								}
							});
						}
					}
					if(icon != null) {
						state = ui.image(icon,-1,50 * ui.ops.scaleFactor);
						if(ui.isHovered) {
							ui.tooltipImage(icon);
							ui.tooltip(f);
						}
						generic = false;
					}
				}
				if(f.endsWith(".arm") && !isCloud) {
					if(arm_ui_UIFiles.iconMap == null) {
						arm_ui_UIFiles.iconMap = new haxe_ds_StringMap();
					}
					let key = handle.text + arm_sys_Path.sep + f;
					icon = arm_ui_UIFiles.iconMap.h[key];
					if(!Object.prototype.hasOwnProperty.call(arm_ui_UIFiles.iconMap.h,key)) {
						let i = new haxe_io_BytesInput(haxe_io_Bytes.ofData(Krom.loadBlob(key)));
						i.set_bigEndian(false);
						let raw = iron_system_ArmPack.read(i);
						if(raw.material_icons != null) {
							icon = kha_Image.fromBytes(iron_system_Lz4.decode(raw.material_icons[0],262144),256,256);
						}
						if(raw.mesh_icons != null) {
							icon = kha_Image.fromBytes(iron_system_Lz4.decode(raw.mesh_icons[0],262144),256,256);
						}
						arm_ui_UIFiles.iconMap.h[key] = icon;
					}
					if(icon != null) {
						state = ui.image(icon,-1,50 * ui.ops.scaleFactor);
						if(ui.isHovered) {
							ui.tooltipImage(icon);
							ui.tooltip(f);
						}
						generic = false;
					}
				}
				if(generic) {
					state = ui.image(icons,col,50 * ui.ops.scaleFactor,rect.x,rect.y,rect.w,rect.h);
				}
				if(state == 1) {
					if(f != ".." && dragFiles) {
						let mouse = iron_system_Input.getMouse();
						arm_App.dragOffX = -(mouse.x - uix - ui._windowX - 3);
						arm_App.dragOffY = -(mouse.y - uiy - ui._windowY + 1);
						arm_App.dragFile = handle.text;
						if(arm_App.dragFile.charAt(arm_App.dragFile.length - 1) != arm_sys_Path.sep) {
							arm_App.dragFile += arm_sys_Path.sep;
						}
						arm_App.dragFile += f;
						arm_App.dragFileIcon = icon;
					}
					arm_ui_UIFiles.selected = i;
					if(kha_Scheduler.time() - arm_Context.selectTime < 0.25) {
						arm_App.dragFile = null;
						arm_App.dragFileIcon = null;
						arm_App.isDragging = false;
						handle.changed = ui.changed = true;
						if(f == "..") {
							handle.text = handle.text.substring(0,handle.text.lastIndexOf(arm_sys_Path.sep));
							if(handle.text.length == 2 && handle.text.charAt(1) == ":") {
								handle.text += arm_sys_Path.sep;
							}
						} else {
							if(handle.text.charAt(handle.text.length - 1) != arm_sys_Path.sep) {
								handle.text += arm_sys_Path.sep;
							}
							handle.text += f;
						}
						arm_ui_UIFiles.selected = -1;
					}
					arm_Context.selectTime = kha_Scheduler.time();
				}
				ui._x = _x;
				ui._y += slotw * 0.75;
				let label0 = arm_ui_UIFiles.showExtensions || f.indexOf(".") <= 0 ? f : HxOverrides.substr(f,0,f.lastIndexOf("."));
				let label1 = "";
				while(label0.length > 0 && ui.ops.font.width(ui.fontSize,label0) > ui._w - 6) {
					label1 = label0.charAt(label0.length - 1) + label1;
					label0 = HxOverrides.substr(label0,0,label0.length - 1);
				}
				if(label1 != "") {
					ui.curRatio--;
				}
				ui.text(label0,1);
				if(ui.isHovered) {
					ui.tooltip(label0 + label1);
				}
				if(label1 != "") {
					ui._x = _x;
					ui._y += ui.ops.font.height(ui.fontSize);
					ui.text(label1,1);
					if(ui.isHovered) {
						ui.tooltip(label0 + label1);
					}
					ui._y -= ui.ops.font.height(ui.fontSize);
				}
				ui._y -= slotw * 0.75;
				if(handle.changed) {
					break;
				}
			}
			if(handle.changed) {
				break;
			}
		}
		ui._y += slotw * 0.8;
		return handle.text;
	}
}
$hxClasses["arm.ui.UIFiles"] = arm_ui_UIFiles;
arm_ui_UIFiles.__name__ = "arm.ui.UIFiles";
class arm_ui_UIMenu {
	static render(g) {
		let ui = arm_App.uiMenu;
		let _BUTTON_COL = ui.t.BUTTON_COL;
		ui.t.BUTTON_COL = ui.t.SEPARATOR_COL;
		let _ELEMENT_OFFSET = ui.t.ELEMENT_OFFSET;
		ui.t.ELEMENT_OFFSET = 0;
		let _ELEMENT_H = ui.t.ELEMENT_H;
		ui.t.ELEMENT_H = 28;
		ui.beginRegion(g,arm_ui_UIMenu.menuX,arm_ui_UIMenu.menuY,arm_ui_UIMenu.menuCommands != null ? arm_App.defaultElementW * arm_App.uiMenu.ops.scaleFactor * 2.3 | 0 : ui.t.ELEMENT_W * ui.ops.scaleFactor * 2.3 | 0);
		if(arm_ui_UIMenu.menuCommands != null) {
			ui.fill(-1,-1,ui._w / ui.ops.scaleFactor + 2,ui.t.ELEMENT_H * arm_ui_UIMenu.menuElements + 2,ui.t.ACCENT_SELECT_COL);
			ui.fill(0,0,ui._w / ui.ops.scaleFactor,ui.t.ELEMENT_H * arm_ui_UIMenu.menuElements,ui.t.SEPARATOR_COL);
			arm_ui_UIMenu.menuCommands(ui);
		} else if(arm_ui_UIMenu.menuCategory == 0) {
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("New Project..."),arm_Config.keymap.file_new)) {
				arm_Project.projectNewBox();
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Open..."),arm_Config.keymap.file_open)) {
				arm_Project.projectOpen();
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Open Recent..."),arm_Config.keymap.file_open_recent)) {
				arm_Project.projectOpenRecentBox();
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Save"),arm_Config.keymap.file_save)) {
				arm_Project.projectSave();
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Save As..."),arm_Config.keymap.file_save_as)) {
				arm_Project.projectSaveAs();
			}
			arm_ui_UIMenu.menuSeparator(ui);
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Import Texture..."),arm_Config.keymap.file_import_assets)) {
				arm_Project.importAsset(arm_sys_Path.textureFormats.join(","),false);
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Import Envmap..."))) {
				arm_ui_UIFiles.show("hdr",false,false,function(path) {
					if(!path.endsWith(".hdr")) {
						arm_Console.error("Error: .hdr file expected");
						return;
					}
					arm_io_ImportAsset.run(path);
				});
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Import Font..."))) {
				arm_Project.importAsset("ttf,ttc,otf");
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Import Material..."))) {
				arm_Project.importMaterial();
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Import Brush..."))) {
				arm_Project.importBrush();
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Import Swatches..."))) {
				arm_Project.importAsset("arm");
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Import Mesh..."))) {
				arm_Project.importMesh();
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Reimport Mesh"),arm_Config.keymap.file_reimport_mesh)) {
				arm_Project.reimportMesh();
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Reimport Textures"),arm_Config.keymap.file_reimport_textures)) {
				arm_Project.reimportTextures();
			}
			arm_ui_UIMenu.menuSeparator(ui);
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Export Textures..."),arm_Config.keymap.file_export_textures_as)) {
				arm_Context.layersExport = 0;
				arm_ui_BoxExport.showTextures();
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Export Swatches..."))) {
				arm_Project.exportSwatches();
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Export Mesh..."))) {
				arm_Context.exportMeshIndex = 0;
				arm_ui_BoxExport.showMesh();
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Bake Material..."))) {
				arm_ui_BoxExport.showBakeMaterial();
			}
			arm_ui_UIMenu.menuSeparator(ui);
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Exit"))) {
				kha_System.stop();
			}
		} else if(arm_ui_UIMenu.menuCategory == 1) {
			let stepUndo = "";
			let stepRedo = "";
			if(arm_History.undos > 0) {
				stepUndo = arm_History.steps[arm_History.steps.length - 1 - arm_History.redos].name;
			}
			if(arm_History.redos > 0) {
				stepRedo = arm_History.steps[arm_History.steps.length - arm_History.redos].name;
			}
			ui.enabled = arm_History.undos > 0;
			let _g = new haxe_ds_StringMap();
			_g.h["step"] = stepUndo;
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Undo {step}",_g),arm_Config.keymap.edit_undo)) {
				arm_History.undo();
			}
			ui.enabled = arm_History.redos > 0;
			let _g1 = new haxe_ds_StringMap();
			_g1.h["step"] = stepRedo;
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Redo {step}",_g1),arm_Config.keymap.edit_redo)) {
				arm_History.redo();
			}
			ui.enabled = true;
			arm_ui_UIMenu.menuSeparator(ui);
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Preferences..."),arm_Config.keymap.edit_prefs)) {
				arm_ui_BoxPreferences.show();
			}
		} else if(arm_ui_UIMenu.menuCategory == 2) {
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Distract Free"),arm_Config.keymap.view_distract_free)) {
				arm_ui_UISidebar.inst.toggleDistractFree();
				arm_ui_UISidebar.inst.ui.isHovered = false;
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Toggle Fullscreen"),"alt+enter")) {
				arm_App.toggleFullscreen();
			}
			ui.changed = false;
			arm_ui_UIMenu.menuFill(ui);
			let p = iron_Scene.active.world.probe;
			let envHandle = zui_Handle.global.nest(90,null);
			envHandle.value = p.raw.strength;
			arm_ui_UIMenu.menuAlign(ui);
			let tmp = arm_Translator.tr("Environment");
			p.raw.strength = ui.slider(envHandle,tmp,0.0,8.0,true);
			if(envHandle.changed) {
				arm_Context.ddirty = 2;
			}
			arm_ui_UIMenu.menuFill(ui);
			let envaHandle = zui_Handle.global.nest(91,null);
			envaHandle.value = arm_Context.envmapAngle / Math.PI * 180.0;
			if(envaHandle.value < 0) {
				envaHandle.value += ((-envaHandle.value / 360 | 0) + 1) * 360;
			} else if(envaHandle.value > 360) {
				envaHandle.value -= (envaHandle.value / 360 | 0) * 360;
			}
			arm_ui_UIMenu.menuAlign(ui);
			arm_Context.envmapAngle = ui.slider(envaHandle,arm_Translator.tr("Environment Angle"),0.0,360.0,true,1) / 180.0 * Math.PI;
			if(envaHandle.changed) {
				arm_Context.ddirty = 2;
			}
			if(iron_Scene.active.lights.length > 0) {
				let light = iron_Scene.active.lights[0];
				arm_ui_UIMenu.menuFill(ui);
				let lhandle = zui_Handle.global.nest(92,null);
				let scale = 1333;
				lhandle.value = light.data.raw.strength / scale;
				lhandle.value = (lhandle.value * 100 | 0) / 100;
				arm_ui_UIMenu.menuAlign(ui);
				let tmp = ui.slider(lhandle,arm_Translator.tr("Light"),0.0,4.0,true);
				light.data.raw.strength = tmp * scale;
				if(lhandle.changed) {
					arm_Context.ddirty = 2;
				}
				arm_ui_UIMenu.menuFill(ui);
				let light1 = iron_Scene.active.lights[0];
				let lahandle = zui_Handle.global.nest(93,null);
				if(lahandle.value < 0) {
					lahandle.value += ((-lahandle.value / 360 | 0) + 1) * 360;
				} else if(lahandle.value > 360) {
					lahandle.value -= (lahandle.value / 360 | 0) * 360;
				}
				arm_ui_UIMenu.menuAlign(ui);
				let lightAngle = lahandle.value;
				ui.slider(lahandle,arm_Translator.tr("Light Angle"),0.0,360.0,true,1);
				let ldiff = lahandle.value - lightAngle;
				if(ldiff != 0) {
					ldiff = ldiff / 180.0 * Math.PI;
					let m_self = new kha_math_FastMatrix4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
					let ca = Math.cos(ldiff);
					let sa = Math.sin(ldiff);
					m_self = new kha_math_FastMatrix4(ca,-sa,0,0,sa,ca,0,0,0,0,1,0,0,0,0,1);
					let _this = light1.transform.local;
					let a00 = _this.self._00;
					let a01 = _this.self._01;
					let a02 = _this.self._02;
					let a03 = _this.self._03;
					let a10 = _this.self._10;
					let a11 = _this.self._11;
					let a12 = _this.self._12;
					let a13 = _this.self._13;
					let a20 = _this.self._20;
					let a21 = _this.self._21;
					let a22 = _this.self._22;
					let a23 = _this.self._23;
					let a30 = _this.self._30;
					let a31 = _this.self._31;
					let a32 = _this.self._32;
					let a33 = _this.self._33;
					let b0 = m_self._00;
					let b1 = m_self._10;
					let b2 = m_self._20;
					let b3 = m_self._30;
					_this.self._00 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this.self._10 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this.self._20 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this.self._30 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					b0 = m_self._01;
					b1 = m_self._11;
					b2 = m_self._21;
					b3 = m_self._31;
					_this.self._01 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this.self._11 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this.self._21 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this.self._31 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					b0 = m_self._02;
					b1 = m_self._12;
					b2 = m_self._22;
					b3 = m_self._32;
					_this.self._02 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this.self._12 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this.self._22 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this.self._32 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					b0 = m_self._03;
					b1 = m_self._13;
					b2 = m_self._23;
					b3 = m_self._33;
					_this.self._03 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this.self._13 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this.self._23 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this.self._33 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					light1.transform.decompose();
				}
				if(lahandle.changed) {
					arm_Context.ddirty = 2;
				}
				arm_ui_UIMenu.menuFill(ui);
				let sxhandle = zui_Handle.global.nest(94,null);
				sxhandle.value = light1.data.raw.size;
				arm_ui_UIMenu.menuAlign(ui);
				let tmp1 = arm_Translator.tr("Light Size");
				light1.data.raw.size = ui.slider(sxhandle,tmp1,0.0,4.0,true);
				if(sxhandle.changed) {
					arm_Context.ddirty = 2;
				}
			}
			arm_ui_UIMenu.menuFill(ui);
			let splitViewHandle = zui_Handle.global.nest(95,{ selected : arm_Context.splitView});
			arm_Context.splitView = ui.check(splitViewHandle," " + arm_Translator.tr("Split View"));
			if(splitViewHandle.changed) {
				arm_App.resize();
			}
			arm_ui_UIMenu.menuFill(ui);
			let cullHandle = zui_Handle.global.nest(96,{ selected : arm_Context.cullBackfaces});
			arm_Context.cullBackfaces = ui.check(cullHandle," " + arm_Translator.tr("Cull Backfaces"));
			if(cullHandle.changed) {
				arm_node_MakeMaterial.parseMeshMaterial();
			}
			arm_ui_UIMenu.menuFill(ui);
			let filterHandle = zui_Handle.global.nest(97,{ selected : arm_Context.textureFilter});
			arm_Context.textureFilter = ui.check(filterHandle," " + arm_Translator.tr("Filter Textures"));
			if(filterHandle.changed) {
				arm_node_MakeMaterial.parsePaintMaterial();
				arm_node_MakeMaterial.parseMeshMaterial();
			}
			arm_ui_UIMenu.menuFill(ui);
			arm_Context.drawWireframe = ui.check(arm_Context.wireframeHandle," " + arm_Translator.tr("Wireframe"));
			if(arm_Context.wireframeHandle.changed) {
				ui.g.end();
				arm_util_UVUtil.cacheUVMap();
				ui.g.begin(false);
				arm_node_MakeMaterial.parseMeshMaterial();
			}
			arm_ui_UIMenu.menuFill(ui);
			arm_Context.drawTexels = ui.check(arm_Context.texelsHandle," " + arm_Translator.tr("Texels"));
			if(arm_Context.texelsHandle.changed) {
				arm_node_MakeMaterial.parseMeshMaterial();
			}
			arm_ui_UIMenu.menuFill(ui);
			let compassHandle = zui_Handle.global.nest(98,{ selected : arm_Context.showCompass});
			arm_Context.showCompass = ui.check(compassHandle," " + arm_Translator.tr("Compass"));
			if(compassHandle.changed) {
				arm_Context.ddirty = 2;
			}
			arm_ui_UIMenu.menuFill(ui);
			arm_Context.showEnvmap = ui.check(arm_Context.showEnvmapHandle," " + arm_Translator.tr("Envmap"));
			if(arm_Context.showEnvmapHandle.changed) {
				arm_Context.loadEnvmap();
				arm_Context.ddirty = 2;
			}
			arm_ui_UIMenu.menuFill(ui);
			arm_Context.showEnvmapBlur = ui.check(arm_Context.showEnvmapBlurHandle," " + arm_Translator.tr("Blur Envmap"));
			if(arm_Context.showEnvmapBlurHandle.changed) {
				arm_Context.ddirty = 2;
			}
			if(arm_Context.showEnvmap) {
				iron_Scene.active.world.envmap = arm_Context.showEnvmapBlur ? iron_Scene.active.world.probe.radianceMipmaps[0] : arm_Context.savedEnvmap;
			} else {
				iron_Scene.active.world.envmap = arm_Context.emptyEnvmap;
			}
			if(ui.changed) {
				arm_ui_UIMenu.keepOpen = true;
			}
		} else if(arm_ui_UIMenu.menuCategory == 3) {
			let modeHandle = zui_Handle.global.nest(99,null);
			modeHandle.position = arm_Context.viewportMode;
			let modes = [arm_Translator.tr("Lit"),arm_Translator.tr("Base Color"),arm_Translator.tr("Normal"),arm_Translator.tr("Occlusion"),arm_Translator.tr("Roughness"),arm_Translator.tr("Metallic"),arm_Translator.tr("Opacity"),arm_Translator.tr("Height"),arm_Translator.tr("TexCoord"),arm_Translator.tr("Object Normal"),arm_Translator.tr("Material ID"),arm_Translator.tr("Object ID"),arm_Translator.tr("Mask")];
			let _g = 0;
			let _g1 = modes.length;
			while(_g < _g1) {
				let i = _g++;
				arm_ui_UIMenu.menuFill(ui);
				ui.radio(modeHandle,i,modes[i]);
			}
			arm_Context.viewportMode = modeHandle.position;
			if(modeHandle.changed) {
				if(arm_Context.renderMode != 1 && (arm_Context.viewportMode == 0 || arm_Context.viewportMode == 13)) {
					iron_RenderPath.active.commands = arm_render_RenderPathDeferred.commands;
				} else {
					if(arm_render_RenderPathForward.path == null) {
						arm_render_RenderPathForward.init(iron_RenderPath.active);
					}
					iron_RenderPath.active.commands = arm_render_RenderPathForward.commands;
				}
				let _workspace = arm_ui_UIHeader.inst.worktab.position;
				arm_ui_UIHeader.inst.worktab.position = 0;
				arm_node_MakeMaterial.parseMeshMaterial();
				arm_ui_UIHeader.inst.worktab.position = _workspace;
			}
		} else if(arm_ui_UIMenu.menuCategory == 4) {
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Reset"),arm_Config.keymap.view_reset)) {
				arm_Viewport.reset();
				arm_Viewport.scaleToBounds();
			}
			arm_ui_UIMenu.menuSeparator(ui);
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Front"),arm_Config.keymap.view_front)) {
				arm_Viewport.setView(0,-1,0,Math.PI / 2,0,0);
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Back"),arm_Config.keymap.view_back)) {
				arm_Viewport.setView(0,1,0,Math.PI / 2,0,Math.PI);
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Right"),arm_Config.keymap.view_right)) {
				arm_Viewport.setView(1,0,0,Math.PI / 2,0,Math.PI / 2);
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Left"),arm_Config.keymap.view_left)) {
				arm_Viewport.setView(-1,0,0,Math.PI / 2,0,-Math.PI / 2);
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Top"),arm_Config.keymap.view_top)) {
				arm_Viewport.setView(0,0,1,0,0,0);
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Bottom"),arm_Config.keymap.view_bottom)) {
				arm_Viewport.setView(0,0,-1,Math.PI,0,Math.PI);
			}
			arm_ui_UIMenu.menuSeparator(ui);
			ui.changed = false;
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Orbit Left"),arm_Config.keymap.view_orbit_left)) {
				arm_Viewport.orbit(-Math.PI / 12,0);
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Orbit Right"),arm_Config.keymap.view_orbit_right)) {
				arm_Viewport.orbit(Math.PI / 12,0);
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Orbit Up"),arm_Config.keymap.view_orbit_up)) {
				arm_Viewport.orbit(0,-Math.PI / 12);
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Orbit Down"),arm_Config.keymap.view_orbit_down)) {
				arm_Viewport.orbit(0,Math.PI / 12);
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Orbit Opposite"),arm_Config.keymap.view_orbit_opposite)) {
				arm_Viewport.orbitOpposite();
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Zoom In"),arm_Config.keymap.view_zoom_in)) {
				arm_Viewport.zoom(0.2);
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Zoom Out"),arm_Config.keymap.view_zoom_out)) {
				arm_Viewport.zoom(-0.2);
			}
			arm_ui_UIMenu.menuFill(ui);
			let cam = iron_Scene.active.camera;
			arm_Context.fovHandle = zui_Handle.global.nest(100,{ value : (cam.data.raw.fov * 100 | 0) / 100});
			arm_ui_UIMenu.menuAlign(ui);
			let tmp = arm_Context.fovHandle;
			let tmp1 = arm_Translator.tr("FoV");
			cam.data.raw.fov = ui.slider(tmp,tmp1,0.3,2.0,true);
			if(arm_Context.fovHandle.changed) {
				arm_Viewport.updateCameraType(arm_Context.cameraType);
			}
			arm_ui_UIMenu.menuFill(ui);
			arm_ui_UIMenu.menuAlign(ui);
			arm_Context.cameraControls = zui_Ext.inlineRadio(ui,zui_Handle.global.nest(101,{ position : arm_Context.cameraControls}),[arm_Translator.tr("Orbit"),arm_Translator.tr("Rotate"),arm_Translator.tr("Fly")],0);
			arm_ui_UIMenu.menuFill(ui);
			arm_ui_UIMenu.menuAlign(ui);
			arm_Context.cameraType = zui_Ext.inlineRadio(ui,arm_Context.camHandle,[arm_Translator.tr("Perspective"),arm_Translator.tr("Orthographic")],0);
			if(ui.isHovered) {
				ui.tooltip(arm_Translator.tr("Camera Type") + (" (" + arm_Config.keymap.view_camera_type + ")"));
			}
			if(arm_Context.camHandle.changed) {
				arm_Viewport.updateCameraType(arm_Context.cameraType);
			}
			if(ui.changed) {
				arm_ui_UIMenu.keepOpen = true;
			}
		} else if(arm_ui_UIMenu.menuCategory == 5) {
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Manual"))) {
				arm_sys_File.loadUrl("https://armorpaint.org/manual");
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("What's New"))) {
				arm_sys_File.loadUrl("https://armorpaint.org/notes");
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Issue Tracker"))) {
				arm_sys_File.loadUrl("https://github.com/armory3d/armorpaint/issues");
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Report Bug"))) {
				arm_sys_File.loadUrl("https://github.com/armory3d/armorpaint/issues/new?labels=bug&template=bug_report.md&body=*ArmorPaint%20" + Main.version + "-" + Main.sha + ",%20" + kha_System.get_systemId() + "*%0A%0A**Issue description:**%0A%0A**Steps to reproduce:**%0A%0A");
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Request Feature"))) {
				arm_sys_File.loadUrl("https://github.com/armory3d/armorpaint/issues/new?labels=feature%20request&template=feature_request.md&body=*ArmorPaint%20" + Main.version + "-" + Main.sha + ",%20" + kha_System.get_systemId() + "*%0A%0A**Feature description:**%0A%0A");
			}
			arm_ui_UIMenu.menuSeparator(ui);
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("Check for Updates..."))) {
				arm_sys_File.downloadBytes("https://luboslenco.gitlab.io/armorpaint/index.html",function(bytes) {
					if(bytes != null) {
						let updateVersion = JSON.parse(bytes.toString()).version | 0;
						if(updateVersion > 0) {
							if(updateVersion > Std.parseInt(StringTools.replace(HxOverrides.substr("2022-02-27 13:33:32".split(" ")[0],2,null),"-",""))) {
								arm_ui_UIBox.showMessage(arm_Translator.tr("Update"),arm_Translator.tr("Update is available!\nPlease visit armorpaint.org to download."));
							} else {
								arm_ui_UIBox.showMessage(arm_Translator.tr("Update"),arm_Translator.tr("You are up to date!"));
							}
						}
					} else {
						arm_ui_UIBox.showMessage(arm_Translator.tr("Update"),arm_Translator.tr("Unable to check for updates.\nPlease visit armorpaint.org."));
					}
				});
			}
			if(arm_ui_UIMenu.menuButton(ui,arm_Translator.tr("About..."))) {
				let msg = "ArmorPaint.org - v" + Main.version + " (" + Main.date + ") - " + Main.sha + "\n";
				msg += kha_System.get_systemId() + " - " + "Direct3D11";
				let save = (arm_sys_Path.isProtected() ? Krom.savePath() : arm_sys_Path.data()) + arm_sys_Path.sep + "tmp.txt";
				Krom.sysCommand("wmic path win32_VideoController get name > \"" + save + "\"");
				let bytes = haxe_io_Bytes.ofData(Krom.loadBlob(save));
				let gpuRaw = "";
				let _g = 0;
				let _g1 = bytes.length / 2 | 0;
				while(_g < _g1) {
					let code = bytes.b[_g++ * 2];
					gpuRaw += String.fromCodePoint(code);
				}
				let gpus = gpuRaw.split("\n");
				gpus = gpus.splice(1,gpus.length - 2);
				let gpu = "";
				let _g2 = 0;
				while(_g2 < gpus.length) gpu += StringTools.rtrim(gpus[_g2++]) + ", ";
				gpu = HxOverrides.substr(gpu,0,gpu.length - 2);
				msg += "\n" + gpu;
				arm_ui_UIBox.showMessage(arm_Translator.tr("About"),msg,true);
			}
		}
		arm_ui_UIMenu.hideMenu = ui.comboSelectedHandle == null && !arm_ui_UIMenu.keepOpen && !arm_ui_UIMenu.showMenuFirst && (ui.changed || ui.inputReleased || ui.inputReleasedR || ui.isEscapeDown);
		arm_ui_UIMenu.showMenuFirst = false;
		arm_ui_UIMenu.keepOpen = false;
		ui.t.BUTTON_COL = _BUTTON_COL;
		ui.t.ELEMENT_OFFSET = _ELEMENT_OFFSET;
		ui.t.ELEMENT_H = _ELEMENT_H;
		ui.endRegion();
		if(arm_ui_UIMenu.hideMenu) {
			arm_ui_UIMenu.show = false;
			arm_App.redrawUI();
			arm_ui_UIMenu.showMenuFirst = true;
			arm_ui_UIMenu.menuCommands = null;
		}
	}
	static draw(commands,elements,x,y) {
		if(y == null) {
			y = -1;
		}
		if(x == null) {
			x = -1;
		}
		arm_App.uiMenu.endInput();
		arm_ui_UIMenu.show = true;
		arm_ui_UIMenu.menuCommands = commands;
		arm_ui_UIMenu.menuElements = elements;
		arm_ui_UIMenu.menuX = x > -1 ? x : iron_system_Input.getMouse().x | 0;
		arm_ui_UIMenu.menuY = y > -1 ? y : iron_system_Input.getMouse().y | 0;
		let menuW = arm_App.defaultElementW * arm_App.uiMenu.ops.scaleFactor * 2.3;
		if(arm_ui_UIMenu.menuX + menuW > kha_System.windowWidth()) {
			arm_ui_UIMenu.menuX = kha_System.windowWidth() - menuW | 0;
		}
		let menuH = arm_ui_UIMenu.menuElements * 28;
		if(arm_ui_UIMenu.menuY + menuH > kha_System.windowHeight()) {
			arm_ui_UIMenu.menuY = kha_System.windowHeight() - menuH;
			arm_ui_UIMenu.menuX += 1;
		}
	}
	static menuFill(ui) {
		ui.g.set_color(ui.t.ACCENT_SELECT_COL);
		ui.g.fillRect(ui._x - 1,ui._y,ui._w + 2,ui.t.ELEMENT_H * ui.ops.scaleFactor + 1 + 1);
		ui.g.set_color(ui.t.SEPARATOR_COL);
		ui.g.fillRect(ui._x,ui._y,ui._w,ui.t.ELEMENT_H * ui.ops.scaleFactor + 1);
		ui.g.set_color(-1);
	}
	static menuSeparator(ui) {
		ui._y++;
		ui.fill(22,0,ui._w / ui.ops.scaleFactor - 22,1,ui.t.ACCENT_SELECT_COL);
	}
	static menuButton(ui,text,label) {
		if(label == null) {
			label = "";
		}
		arm_ui_UIMenu.menuFill(ui);
		return ui.button("      " + text,0,label);
	}
	static menuAlign(ui) {
		ui.row([0.125,0.875]);
		ui.endElement();
	}
}
$hxClasses["arm.ui.UIMenu"] = arm_ui_UIMenu;
arm_ui_UIMenu.__name__ = "arm.ui.UIMenu";
class arm_ui_UINodes {
	constructor() {
		this.groupStack = [];
		this.hwnd = zui_Handle.global.nest(1,null);
		this.grid = null;
		this.isNodeMenuOperation = false;
		this.releaseLink = false;
		this.lastNodeSelected = null;
		this.lastCanvas = null;
		this.nodeSearchLast = "";
		this.nodeSearchOffset = 0;
		this.nodeSearchSpawn = null;
		this.recompileMatFinal = false;
		this.recompileMat = false;
		this.uichangedLast = false;
		this.popupY = 0.0;
		this.popupX = 0.0;
		this.menuCategory = 0;
		this.hideMenu = false;
		this.showMenuFirst = true;
		this.showMenu = false;
		this.canvasType = 0;
		this.show = false;
		arm_ui_UINodes.inst = this;
		zui_Nodes.excludeRemove.push("OUTPUT_MATERIAL_PBR");
		zui_Nodes.excludeRemove.push("GROUP_OUTPUT");
		zui_Nodes.excludeRemove.push("GROUP_INPUT");
		zui_Nodes.excludeRemove.push("BrushOutputNode");
		zui_Nodes.onLinkDrag = $bind(this,this.onLinkDrag);
		zui_Nodes.onSocketReleased = $bind(this,this.onSocketReleased);
		zui_Nodes.onCanvasReleased = $bind(this,this.onCanvasReleased);
		zui_Nodes.onNodeRemove = arm_ui_UINodes.onNodeRemove;
		zui_Nodes.onCanvasControl = $bind(this,this.onCanvasControl);
		this.ui = new zui_Zui({ theme : arm_App.theme, font : arm_App.font, color_wheel : arm_App.colorWheel, scaleFactor : arm_Config.raw.window_scale});
		this.ui.scrollEnabled = false;
	}
	onLinkDrag(linkDrag,isNewLink) {
		let _gthis = this;
		if(isNewLink) {
			let nodes = this.getNodes();
			let node = linkDrag.from_id > -1 ? linkDrag.from_id : linkDrag.to_id;
			let node1 = nodes.getNode(this.getCanvas(true).nodes,node);
			let linkX = this.ui._windowX + (node1.x * (nodes.scaleFactor * nodes.zoom) + (nodes.panX * (nodes.scaleFactor * nodes.zoom) + (1.0 - nodes.zoom) * nodes.uiw / 2.5));
			let linkY = this.ui._windowY + (node1.y * (nodes.scaleFactor * nodes.zoom) + (nodes.panY * (nodes.scaleFactor * nodes.zoom) + (1.0 - nodes.zoom) * nodes.uih / 2.5));
			if(linkDrag.from_id > -1) {
				linkX += (node1.width != null ? node1.width : 140) * (nodes.scaleFactor * nodes.zoom) | 0;
				linkY += ((nodes.ELEMENT_H * (nodes.scaleFactor * nodes.zoom) | 0) * 1.62 | 0) + nodes.OUTPUTS_H(node1.outputs,linkDrag.from_socket);
			} else {
				let canvas = this.getCanvas(true);
				linkY += ((nodes.ELEMENT_H * (nodes.scaleFactor * nodes.zoom) | 0) * 1.62 | 0) + nodes.INPUTS_H(canvas,node1.inputs,linkDrag.to_socket) + nodes.OUTPUTS_H(node1.outputs) + nodes.BUTTONS_H(node1);
			}
			let mouse = iron_system_Input.getMouse();
			if(Math.abs(mouse.x - linkX) > 5 || Math.abs(mouse.y - linkY) > 5) {
				this.nodeSearch(-1,-1,function() {
					let n = nodes.nodesSelected[0];
					if(linkDrag.to_id == -1 && n.inputs.length > 0) {
						linkDrag.to_id = n.id;
						linkDrag.to_socket = 0;
						_gthis.getCanvas(true).links.push(linkDrag);
					} else if(linkDrag.from_id == -1 && n.outputs.length > 0) {
						linkDrag.from_id = n.id;
						linkDrag.from_socket = 0;
						_gthis.getCanvas(true).links.push(linkDrag);
					}
				});
			} else if(node1 == nodes.nodesSelected[0]) {
				arm_Context.nodePreviewSocket = linkDrag.from_id > -1 ? linkDrag.from_socket : 0;
				arm_Context.nodePreviewDirty = true;
			}
		}
	}
	onSocketReleased(socket) {
		let nodes = this.getNodes();
		let canvas = this.getCanvas(true);
		let node = nodes.getNode(canvas.nodes,socket.node_id);
		let _gthis = this;
		if(this.ui.inputReleasedR) {
			if(node.type == "GROUP_INPUT" || node.type == "GROUP_OUTPUT") {
				arm_App.notifyOnNextFrame(function() {
					arm_ui_UIMenu.draw(function(ui) {
						ui.text(arm_Translator.tr("Socket"),2,ui.t.HIGHLIGHT_COL);
						if(ui.button(arm_Translator.tr("Edit"),0)) {
							let htype = zui_Handle.global.nest(106,null);
							let hname = zui_Handle.global.nest(107,null);
							let hmin = zui_Handle.global.nest(108,null);
							let hmax = zui_Handle.global.nest(109,null);
							let hval0 = zui_Handle.global.nest(110,null);
							let hval1 = zui_Handle.global.nest(111,null);
							let hval2 = zui_Handle.global.nest(112,null);
							let hval3 = zui_Handle.global.nest(113,null);
							htype.position = socket.type == "RGBA" ? 0 : socket.type == "VECTOR" ? 1 : 2;
							hname.text = socket.name;
							hmin.value = socket.min;
							hmax.value = socket.max;
							if(socket.type == "RGBA" || socket.type == "VECTOR") {
								hval0.value = socket.default_value[0];
								hval1.value = socket.default_value[1];
								hval2.value = socket.default_value[2];
								if(socket.type == "RGBA") {
									hval3.value = socket.default_value[3];
								}
							} else {
								hval0.value = socket.default_value;
							}
							arm_App.notifyOnNextFrame(function() {
								arm_App.uiBox.endInput();
								arm_ui_UIBox.showCustom(function(ui) {
									if(ui.tab(zui_Handle.global.nest(114,null),arm_Translator.tr("Socket"))) {
										let type = ui.combo(htype,[arm_Translator.tr("Color"),arm_Translator.tr("Vector"),arm_Translator.tr("Value")],arm_Translator.tr("Type"),true);
										if(htype.changed) {
											let tmp = type == 0 ? arm_Translator.tr("Color") : type == 1 ? arm_Translator.tr("Vector") : arm_Translator.tr("Value");
											hname.text = tmp;
										}
										let name = ui.textInput(hname,arm_Translator.tr("Name"));
										let min = zui_Ext.floatInput(ui,hmin,arm_Translator.tr("Min"));
										let max = zui_Ext.floatInput(ui,hmax,arm_Translator.tr("Max"));
										let default_value = null;
										if(type == 0) {
											ui.row([0.25,0.25,0.25,0.25]);
											zui_Ext.floatInput(ui,hval0,arm_Translator.tr("R"));
											zui_Ext.floatInput(ui,hval1,arm_Translator.tr("G"));
											zui_Ext.floatInput(ui,hval2,arm_Translator.tr("B"));
											zui_Ext.floatInput(ui,hval3,arm_Translator.tr("A"));
											default_value = [hval0.value,hval1.value,hval2.value,hval3.value];
										} else if(type == 1) {
											ui.row([0.33333333333333331,0.33333333333333331,0.33333333333333331]);
											let hval01 = hval0;
											let tmp = arm_Translator.tr("X");
											hval0.value = zui_Ext.floatInput(ui,hval01,tmp);
											let hval11 = hval1;
											let tmp1 = arm_Translator.tr("Y");
											hval1.value = zui_Ext.floatInput(ui,hval11,tmp1);
											let hval21 = hval2;
											let tmp2 = arm_Translator.tr("Z");
											hval2.value = zui_Ext.floatInput(ui,hval21,tmp2);
											default_value = [hval0.value,hval1.value,hval2.value];
										} else {
											default_value = zui_Ext.floatInput(ui,hval0,arm_Translator.tr("default_value"));
										}
										if(ui.button(arm_Translator.tr("OK"))) {
											socket.name = name;
											socket.type = type == 0 ? "RGBA" : type == 1 ? "VECTOR" : "VALUE";
											let type1 = socket.type;
											socket.color = type1 == "RGBA" ? -3684567 : type1 == "VECTOR" ? -10263609 : -6184543;
											socket.min = min;
											socket.max = max;
											socket.default_value = default_value;
											arm_ui_UIBox.show = false;
											arm_shader_NodesMaterial.syncSockets(node);
											_gthis.hwnd.redraws = 2;
										}
									}
								},400,250);
							});
						}
						if(ui.button(arm_Translator.tr("Delete"),0)) {
							let i = 0;
							while(i < canvas.links.length) {
								let l = canvas.links[i];
								if(l.from_id == node.id && l.from_socket == node.outputs.indexOf(socket) || l.to_id == node.id && l.to_socket == node.inputs.indexOf(socket)) {
									canvas.links.splice(i,1);
								} else {
									++i;
								}
							}
							HxOverrides.remove(node.inputs,socket);
							HxOverrides.remove(node.outputs,socket);
							arm_shader_NodesMaterial.syncSockets(node);
						}
					},3);
				});
			} else {
				this.onCanvasReleased();
			}
		} else if(node == nodes.nodesSelected[0]) {
			let i = node.outputs.indexOf(socket);
			if(i > -1) {
				arm_Context.nodePreviewSocket = i;
				arm_Context.nodePreviewDirty = true;
			}
		}
	}
	onCanvasReleased() {
		let _gthis = this;
		if(this.ui.inputReleasedR && Math.abs(this.ui.inputX - this.ui.inputStartedX) < 2 && Math.abs(this.ui.inputY - this.ui.inputStartedY) < 2) {
			let nodes = this.getNodes();
			let canvas = this.getCanvas(true);
			let selected = null;
			let _g = 0;
			let _g1 = canvas.nodes;
			while(_g < _g1.length) {
				let node = _g1[_g];
				++_g;
				if(this.ui.getInputInRect(this.ui._windowX + (node.x * (nodes.scaleFactor * nodes.zoom) + (nodes.panX * (nodes.scaleFactor * nodes.zoom) + (1.0 - nodes.zoom) * nodes.uiw / 2.5)),this.ui._windowY + (node.y * (nodes.scaleFactor * nodes.zoom) + (nodes.panY * (nodes.scaleFactor * nodes.zoom) + (1.0 - nodes.zoom) * nodes.uih / 2.5)),(node.width != null ? node.width : 140) * (nodes.scaleFactor * nodes.zoom) | 0,(nodes.ELEMENT_H * (nodes.scaleFactor * nodes.zoom) | 0) * 1.2 + nodes.INPUTS_H(canvas,node.inputs) + nodes.OUTPUTS_H(node.outputs) + nodes.BUTTONS_H(node) | 0)) {
					selected = node;
					break;
				}
			}
			if(selected == null) {
				nodes.nodesSelected = [];
			} else if(nodes.nodesSelected.indexOf(selected) == -1) {
				nodes.nodesSelected = [selected];
			}
			if(!zui_Nodes.socketReleased) {
				let numberOfEntries = 5;
				if(this.canvasType == 0) {
					numberOfEntries = 6;
				}
				if(selected != null && selected.type == "RGB") {
					++numberOfEntries;
				}
				arm_ui_UIMenu.draw(function(uiMenu) {
					uiMenu._y += 1;
					let $protected = selected == null || selected.type == "OUTPUT_MATERIAL_PBR" || selected.type == "GROUP_INPUT" || selected.type == "GROUP_OUTPUT" || selected.type == "BrushOutputNode";
					uiMenu.enabled = !$protected;
					if(arm_ui_UINodes.menuButton(uiMenu,arm_Translator.tr("Cut"),"ctrl+x")) {
						arm_App.notifyOnNextFrame(function() {
							_gthis.hwnd.redraws = 2;
							zui_Zui.isCopy = true;
							zui_Zui.isCut = true;
							_gthis.isNodeMenuOperation = true;
						});
					}
					if(arm_ui_UINodes.menuButton(uiMenu,arm_Translator.tr("Copy"),"ctrl+c")) {
						arm_App.notifyOnNextFrame(function() {
							zui_Zui.isCopy = true;
							_gthis.isNodeMenuOperation = true;
						});
					}
					uiMenu.enabled = zui_Nodes.clipboard != "";
					if(arm_ui_UINodes.menuButton(uiMenu,arm_Translator.tr("Paste"),"ctrl+v")) {
						arm_App.notifyOnNextFrame(function() {
							_gthis.hwnd.redraws = 2;
							zui_Zui.isPaste = true;
							_gthis.isNodeMenuOperation = true;
						});
					}
					uiMenu.enabled = !$protected;
					if(arm_ui_UINodes.menuButton(uiMenu,arm_Translator.tr("Delete"),"delete")) {
						arm_App.notifyOnNextFrame(function() {
							_gthis.hwnd.redraws = 2;
							_gthis.ui.isDeleteDown = true;
							_gthis.isNodeMenuOperation = true;
						});
					}
					if(arm_ui_UINodes.menuButton(uiMenu,arm_Translator.tr("Duplicate"))) {
						arm_App.notifyOnNextFrame(function() {
							_gthis.hwnd.redraws = 2;
							zui_Zui.isCopy = true;
							zui_Zui.isPaste = true;
							_gthis.isNodeMenuOperation = true;
						});
					}
					if(selected != null && selected.type == "RGB") {
						if(arm_ui_UINodes.menuButton(uiMenu,arm_Translator.tr("Add Swatch"))) {
							let color = selected.outputs[0].default_value;
							let newSwatch = arm_Project.makeSwatch(kha_Color.fromFloats(color[0],color[1],color[2],color[3]));
							arm_Context.setSwatch(newSwatch);
							arm_Project.raw.swatches.push(newSwatch);
							arm_ui_UIStatus.inst.statusHandle.redraws = 1;
						}
					}
					if(_gthis.canvasType == 0) {
						arm_ui_UINodes.menuSeparator(uiMenu);
						if(arm_ui_UINodes.menuButton(uiMenu,arm_Translator.tr("2D View"))) {
							arm_ui_UISidebar.inst.show2DView(3);
						}
					}
					uiMenu.enabled = true;
				},numberOfEntries);
			}
		}
		if(this.ui.inputReleased) {
			let nodes = this.getNodes();
			let canvas = this.getCanvas(true);
			let _g = 0;
			let _g1 = canvas.nodes;
			while(_g < _g1.length) {
				let node = _g1[_g];
				++_g;
				if(this.ui.getInputInRect(this.ui._windowX + (node.x * (nodes.scaleFactor * nodes.zoom) + (nodes.panX * (nodes.scaleFactor * nodes.zoom) + (1.0 - nodes.zoom) * nodes.uiw / 2.5)),this.ui._windowY + (node.y * (nodes.scaleFactor * nodes.zoom) + (nodes.panY * (nodes.scaleFactor * nodes.zoom) + (1.0 - nodes.zoom) * nodes.uih / 2.5)),(node.width != null ? node.width : 140) * (nodes.scaleFactor * nodes.zoom) | 0,(nodes.ELEMENT_H * (nodes.scaleFactor * nodes.zoom) | 0) * 1.2 + nodes.INPUTS_H(canvas,node.inputs) + nodes.OUTPUTS_H(node.outputs) + nodes.BUTTONS_H(node) | 0)) {
					if(node == nodes.nodesSelected[0]) {
						arm_ui_UIView2D.inst.hwnd.redraws = 2;
						if(kha_Scheduler.time() - arm_Context.selectTime < 0.25) {
							arm_ui_UISidebar.inst.show2DView(3);
						}
						arm_Context.selectTime = kha_Scheduler.time();
					}
					break;
				}
			}
		}
	}
	onCanvasControl() {
		return arm_ui_UINodes.getCanvasControl(this.ui,arm_ui_UINodes.inst);
	}
	getCanvas(groups) {
		if(groups == null) {
			groups = false;
		}
		if(this.canvasType == 0) {
			if(groups && this.groupStack.length > 0) {
				return this.groupStack[this.groupStack.length - 1].canvas;
			} else {
				return this.getCanvasMaterial();
			}
		} else {
			return arm_Context.brush.canvas;
		}
	}
	getCanvasMaterial() {
		return arm_Context.material.canvas;
	}
	getNodes() {
		if(this.canvasType == 0) {
			if(this.groupStack.length > 0) {
				return this.groupStack[this.groupStack.length - 1].nodes;
			} else {
				return arm_Context.material.nodes;
			}
		} else {
			return arm_Context.brush.nodes;
		}
	}
	update() {
		if(!this.show || !arm_App.uiEnabled) {
			return;
		}
		let mouse = iron_system_Input.getMouse();
		let kb = iron_system_Input.getKeyboard();
		this.wx = (arm_App.w() | 0) + arm_ui_UIToolbar.inst.toolbarw;
		this.wy = arm_ui_UIHeader.inst.headerh * 2;
		if(arm_ui_UIView2D.inst.show) {
			this.wy += arm_App.h() - arm_Config.raw.layout[4];
		}
		let ww = arm_Config.raw.layout[3];
		if(!arm_ui_UISidebar.inst.show) {
			ww += arm_Config.raw.layout[0] + arm_ui_UIToolbar.inst.toolbarw;
			this.wx -= arm_ui_UIToolbar.inst.toolbarw;
			this.wy = 0;
		}
		let mx = mouse.x;
		if(mx < this.wx || mx > this.wx + ww || mouse.y < this.wy) {
			return;
		}
		if(this.ui.isTyping || !this.ui.inputEnabled) {
			return;
		}
		let nodes = this.getNodes();
		if(nodes.nodesSelected.length > 0 && this.ui.isKeyPressed) {
			if(this.ui.key == 37) {
				let _g = 0;
				let _g1 = nodes.nodesSelected;
				while(_g < _g1.length) _g1[_g++].x -= 1;
			} else if(this.ui.key == 39) {
				let _g = 0;
				let _g1 = nodes.nodesSelected;
				while(_g < _g1.length) _g1[_g++].x += 1;
			}
			if(this.ui.key == 38) {
				let _g = 0;
				let _g1 = nodes.nodesSelected;
				while(_g < _g1.length) _g1[_g++].y -= 1;
			} else if(this.ui.key == 40) {
				let _g = 0;
				let _g1 = nodes.nodesSelected;
				while(_g < _g1.length) _g1[_g++].y += 1;
			}
		}
		if(kb.started(arm_Config.keymap.node_search)) {
			this.nodeSearch();
		}
		if(this.nodeSearchSpawn != null) {
			this.ui.inputX = mouse.x;
			this.ui.inputY = mouse.y;
			this.nodeSearchSpawn = null;
		}
		if(arm_Operator.shortcut(arm_Config.keymap.view_reset)) {
			nodes.panX = 0.0;
			nodes.panY = 0.0;
			nodes.zoom = 1.0;
		}
	}
	canvasChanged() {
		this.recompileMat = true;
		this.recompileMatFinal = true;
	}
	nodeSearch(x,y,done) {
		if(y == null) {
			y = -1;
		}
		if(x == null) {
			x = -1;
		}
		let kb = iron_system_Input.getKeyboard();
		let searchHandle = zui_Handle.global.nest(105,null);
		let first = true;
		let _gthis = this;
		arm_ui_UIMenu.draw(function(ui) {
			ui.fill(0,0,ui._w / ui.ops.scaleFactor,ui.t.ELEMENT_H * 8,ui.t.SEPARATOR_COL);
			ui.textInput(searchHandle,"");
			ui.changed = false;
			if(first) {
				first = false;
				ui.startTextEdit(searchHandle);
				ui.textSelected = searchHandle.text;
				searchHandle.text = "";
				_gthis.nodeSearchLast = "";
			}
			let search = searchHandle.text;
			if(ui.textSelected != "") {
				search = ui.textSelected;
			}
			if(search != _gthis.nodeSearchLast) {
				_gthis.nodeSearchOffset = 0;
				_gthis.nodeSearchLast = search;
			}
			if(ui.isKeyPressed) {
				if(ui.key == 40 && _gthis.nodeSearchOffset < 6) {
					_gthis.nodeSearchOffset++;
				}
				if(ui.key == 38 && _gthis.nodeSearchOffset > 0) {
					_gthis.nodeSearchOffset--;
				}
			}
			let enter = kb.down("enter");
			let count = 0;
			let BUTTON_COL = ui.t.BUTTON_COL;
			let nodeList = _gthis.canvasType == 0 ? arm_shader_NodesMaterial.list : arm_node_NodesBrush.list;
			let _g = 0;
			while(_g < nodeList.length) {
				let list = nodeList[_g];
				++_g;
				let _g1 = 0;
				while(_g1 < list.length) {
					let n = list[_g1];
					++_g1;
					if(arm_Translator.tr(n.name).toLowerCase().indexOf(search) >= 0) {
						ui.t.BUTTON_COL = count == _gthis.nodeSearchOffset ? ui.t.HIGHLIGHT_COL : ui.t.SEPARATOR_COL;
						if(ui.button(arm_Translator.tr(n.name),0) || enter && count == _gthis.nodeSearchOffset) {
							_gthis.pushUndo();
							let nodes = _gthis.getNodes();
							let canvas = _gthis.getCanvas(true);
							_gthis.nodeSearchSpawn = arm_ui_UINodes.makeNode(n,nodes,canvas);
							canvas.nodes.push(_gthis.nodeSearchSpawn);
							nodes.nodesSelected = [_gthis.nodeSearchSpawn];
							nodes.nodesDrag = true;
							_gthis.hwnd.redraws = 2;
							if(enter) {
								ui.changed = true;
								count = 6;
							}
							if(done != null) {
								done();
							}
						}
						if(++count > 6) {
							break;
						}
					}
				}
				if(count > 6) {
					break;
				}
			}
			if(enter && count == 0) {
				ui.changed = true;
				searchHandle.text = "";
			}
			ui.t.BUTTON_COL = BUTTON_COL;
		},8,x,y);
	}
	getNodeX() {
		let x = iron_system_Input.getMouse().x - this.wx;
		let _this = this.getNodes();
		let x1 = x - (_this.panX * (_this.scaleFactor * _this.zoom) + (1.0 - _this.zoom) * _this.uiw / 2.5);
		let _this1 = this.getNodes();
		return x1 / (_this1.scaleFactor * _this1.zoom) | 0;
	}
	getNodeY() {
		let x = iron_system_Input.getMouse().y - this.wy;
		let _this = this.getNodes();
		let x1 = x - (_this.panY * (_this.scaleFactor * _this.zoom) + (1.0 - _this.zoom) * _this.uih / 2.5);
		let _this1 = this.getNodes();
		return x1 / (_this1.scaleFactor * _this1.zoom) | 0;
	}
	drawGrid() {
		let ww = arm_Config.raw.layout[3];
		if(!arm_ui_UISidebar.inst.show) {
			ww += arm_Config.raw.layout[0] + arm_ui_UIToolbar.inst.toolbarw;
		}
		let w = ww + 200;
		let h = arm_App.h() + 200;
		if(w < 1) {
			w = 1;
		}
		if(h < 1) {
			h = 1;
		}
		this.grid = kha_Image.createRenderTarget(w,h);
		this.grid.get_g2().begin(true,this.ui.t.SEPARATOR_COL);
		this.grid.get_g2().set_color(this.ui.t.SEPARATOR_COL - 328965);
		let _g = 0;
		let _g1 = (h / 20 | 0) + 1;
		while(_g < _g1) {
			let i = _g++;
			this.grid.get_g2().drawLine(0,i * 20,w,i * 20);
		}
		let _g2 = 0;
		let _g3 = (w / 20 | 0) + 1;
		while(_g2 < _g3) {
			let i = _g2++;
			this.grid.get_g2().drawLine(i * 20,0,i * 20,h);
		}
		this.grid.get_g2().set_color(this.ui.t.SEPARATOR_COL - 592137);
		let _g4 = 0;
		let _g5 = (h / 100 | 0) + 1;
		while(_g4 < _g5) {
			let i = _g4++;
			this.grid.get_g2().drawLine(0,i * 100,w,i * 100);
		}
		let _g6 = 0;
		let _g7 = (w / 100 | 0) + 1;
		while(_g6 < _g7) {
			let i = _g6++;
			this.grid.get_g2().drawLine(i * 100,0,i * 100,h);
		}
		this.grid.get_g2().end();
	}
	render(g) {
		if(this.recompileMat) {
			if(this.canvasType == 1) {
				arm_node_MakeMaterial.parseBrush();
				arm_util_RenderUtil.makeBrushPreview();
				arm_ui_UISidebar.inst.hwnd1.redraws = 2;
			} else {
				if(arm_Layers.isFillMaterial()) {
					arm_Layers.updateFillLayers();
				} else {
					arm_util_RenderUtil.makeMaterialPreview();
				}
				if(arm_ui_UIView2D.inst.show && arm_ui_UIView2D.inst.type == 3) {
					arm_ui_UIView2D.inst.hwnd.redraws = 2;
				}
			}
			arm_ui_UISidebar.inst.hwnd1.redraws = 2;
			this.recompileMat = false;
		} else if(this.recompileMatFinal) {
			arm_node_MakeMaterial.parsePaintMaterial();
			if(this.canvasType == 0 && arm_Layers.isFillMaterial()) {
				arm_Layers.updateFillLayers();
				arm_util_RenderUtil.makeMaterialPreview();
			}
			if(arm_Context.tool == 3 || arm_Context.tool == 4) {
				arm_util_RenderUtil.makeDecalPreview();
			}
			arm_ui_UISidebar.inst.hwnd0.redraws = 2;
			this.recompileMatFinal = false;
			arm_Context.nodePreviewDirty = true;
		}
		let nodes = this.getNodes();
		if(nodes.nodesSelected.length > 0 && nodes.nodesSelected[0] != this.lastNodeSelected) {
			this.lastNodeSelected = nodes.nodesSelected[0];
			arm_Context.nodePreviewDirty = true;
			arm_Context.nodePreviewSocket = 0;
		}
		let c = this.getCanvas(true);
		if(this.releaseLink && nodes.linkDrag != null) {
			HxOverrides.remove(c.links,nodes.linkDrag);
			nodes.linkDrag = null;
		}
		this.releaseLink = this.ui.inputReleased;
		if(!this.show || kha_System.windowWidth() == 0 || kha_System.windowHeight() == 0) {
			return;
		}
		this.ui.inputEnabled = arm_App.uiEnabled;
		g.end();
		if(this.grid == null) {
			this.drawGrid();
		}
		if(arm_Config.raw.node_preview && arm_Context.nodePreviewDirty) {
			this.makeNodePreview();
		}
		this.ui.begin(g);
		this.ww = arm_Config.raw.layout[3];
		this.wx = (arm_App.w() | 0) + arm_ui_UIToolbar.inst.toolbarw;
		this.wy = arm_ui_UIHeader.inst.headerh * 2;
		if(!arm_ui_UISidebar.inst.show) {
			this.ww += arm_Config.raw.layout[0] + arm_ui_UIToolbar.inst.toolbarw;
			this.wx -= arm_ui_UIToolbar.inst.toolbarw;
			this.wy = 0;
		}
		let _this = this.ui;
		let ew = _this.t.ELEMENT_W * _this.ops.scaleFactor * 0.7 | 0;
		this.wh = arm_App.h();
		if(arm_ui_UIView2D.inst.show) {
			this.wh = arm_Config.raw.layout[4];
			this.wy = arm_App.h() - arm_Config.raw.layout[4] + arm_ui_UIHeader.inst.headerh * 2;
			if(!arm_ui_UISidebar.inst.show) {
				this.wy -= arm_ui_UIHeader.inst.headerh * 2;
			}
		}
		if(this.ui.window(this.hwnd,this.wx,this.wy,this.ww,this.wh)) {
			this.ui.g.set_color(-1);
			this.ui.g.drawImage(this.grid,nodes.panX * (nodes.scaleFactor * nodes.zoom) % 100 - 100,nodes.panY * (nodes.scaleFactor * nodes.zoom) % 100 - 100);
			if(this.ui.inputStarted || this.ui.isKeyPressed) {
				this.lastCanvas = JSON.parse(JSON.stringify(this.getCanvas(true)));
			}
			let _inputEnabled = this.ui.inputEnabled;
			this.ui.inputEnabled = _inputEnabled && !this.showMenu;
			this.ui.windowBorderRight = arm_Config.raw.layout[0];
			this.ui.windowBorderTop = arm_ui_UIHeader.inst.headerh * 2;
			this.ui.windowBorderBottom = arm_Config.raw.layout[5];
			nodes.nodeCanvas(this.ui,c);
			this.ui.inputEnabled = _inputEnabled;
			if(this.isNodeMenuOperation) {
				zui_Zui.isCopy = zui_Zui.isCut = zui_Zui.isPaste = this.ui.isDeleteDown = false;
			}
			if(zui_Zui.isPaste) {
				let nodeList = this.canvasType == 0 ? arm_shader_NodesMaterial.list : arm_node_NodesBrush.list;
				let i = 0;
				while(i++ < c.nodes.length) {
					let canvasNode = c.nodes[i - 1];
					if(zui_Nodes.excludeRemove.indexOf(canvasNode.type) >= 0) {
						continue;
					}
					let found = false;
					let _g = 0;
					while(_g < nodeList.length) {
						let list = nodeList[_g];
						++_g;
						let _g1 = 0;
						while(_g1 < list.length) if(canvasNode.type == list[_g1++].type) {
							found = true;
							break;
						}
						if(found) {
							break;
						}
					}
					if(canvasNode.type == "GROUP" && !this.canPlaceGroup(canvasNode.name)) {
						found = false;
					}
					if(!found) {
						nodes.removeNode(canvasNode,c);
						HxOverrides.remove(nodes.nodesSelected,canvasNode);
						--i;
					}
				}
			}
			if(this.ui.changed) {
				this.recompileMat = (this.ui.inputDX != 0 || this.ui.inputDY != 0 || !this.uichangedLast) && arm_Config.raw.material_live;
			} else if(this.uichangedLast) {
				this.canvasChanged();
				this.pushUndo(this.lastCanvas);
			}
			this.uichangedLast = this.ui.changed;
			if(arm_Config.raw.node_preview && nodes.nodesSelected.length > 0) {
				let img = null;
				let sel = nodes.nodesSelected[0];
				let singleChannel = sel.type == "LAYER_MASK";
				if(sel.type == "LAYER" || sel.type == "LAYER_MASK") {
					let id = sel.buttons[0].default_value;
					if(id < arm_Project.layers.length) {
						img = arm_Project.layers[id].texpaint_preview;
					}
				} else if(sel.type == "MATERIAL") {
					let id = sel.buttons[0].default_value;
					if(id < arm_Project.materials.length) {
						img = arm_Project.materials[id].image;
					}
				} else if(sel.type == "OUTPUT_MATERIAL_PBR") {
					img = arm_Context.material.image;
				} else if(sel.type == "BrushOutputNode") {
					img = arm_Context.brush.image;
				} else if(this.canvasType == 0) {
					img = arm_Context.nodePreview;
				}
				if(img != null) {
					let tw = 80 * this.ui.ops.scaleFactor;
					let th = tw * (img.get_height() / img.get_width());
					let tx = this.ww - tw - 8 * this.ui.ops.scaleFactor;
					let ty = this.wh - th - 40 * this.ui.ops.scaleFactor;
					if(singleChannel) {
						this.ui.g.set_pipeline(arm_ui_UIView2D.pipe);
						this.ui.currentWindow.texture.get_g4().setInt(arm_ui_UIView2D.channelLocation,1);
					}
					this.ui.g.set_color(-1);
					this.ui.g.drawScaledImage(img,tx,ty,tw,th);
					if(singleChannel) {
						this.ui.g.set_pipeline(null);
					}
				}
			}
			let _ACCENT_COL = this.ui.t.ACCENT_COL;
			let _BUTTON_H = this.ui.t.BUTTON_H;
			let _ELEMENT_H = this.ui.t.ELEMENT_H;
			let _FONT_SIZE = this.ui.fontSize;
			this.ui.t.ACCENT_COL = 0;
			this.ui.t.BUTTON_H = 30;
			this.ui.t.ELEMENT_H = 30;
			this.ui.fontSize = 22 * this.ui.ops.scaleFactor | 0;
			let _this = this.ui;
			this.ui._x = this.ww - _this.t.ELEMENT_W * _this.ops.scaleFactor * 1.4;
			let _this1 = this.ui;
			this.ui._y = this.wh - _this1.t.ELEMENT_H * _this1.ops.scaleFactor * 1.2;
			let _this2 = this.ui;
			this.ui._w = _this2.t.ELEMENT_W * _this2.ops.scaleFactor * 1.4 | 0;
			let h = zui_Handle.global.nest(120,null);
			h.text = c.name;
			let newName = this.ui.textInput(h,"",2);
			if(h.changed) {
				if(this.groupStack.length > 0) {
					let canRename = true;
					let _g = 0;
					let _g1 = arm_Project.materialGroups;
					while(_g < _g1.length) if(_g1[_g++].canvas.name == newName) {
						canRename = false;
					}
					if(canRename) {
						let oldName = c.name;
						c.name = newName;
						let canvases = [];
						let _g = 0;
						let _g1 = arm_Project.materials;
						while(_g < _g1.length) canvases.push(_g1[_g++].canvas);
						let _g2 = 0;
						let _g3 = arm_Project.materialGroups;
						while(_g2 < _g3.length) canvases.push(_g3[_g2++].canvas);
						let _g4 = 0;
						while(_g4 < canvases.length) {
							let _g = 0;
							let _g1 = canvases[_g4++].nodes;
							while(_g < _g1.length) {
								let n = _g1[_g];
								++_g;
								if(n.type == "GROUP" && n.name == oldName) {
									n.name = c.name;
								}
							}
						}
					}
				} else {
					c.name = newName;
				}
			}
			this.ui.t.ACCENT_COL = _ACCENT_COL;
			this.ui.t.BUTTON_H = _BUTTON_H;
			this.ui.t.ELEMENT_H = _ELEMENT_H;
			this.ui.fontSize = _FONT_SIZE;
			if(this.groupStack.length > 0) {
				this.ui._x = 5;
				let _this = this.ui;
				this.ui._y = this.wh - _this.t.ELEMENT_H * _this.ops.scaleFactor * 1.2;
				let _this1 = this.ui;
				this.ui._w = _this1.t.ELEMENT_W * _this1.ops.scaleFactor * 1.4 | 0;
				if(this.ui.button(arm_Translator.tr("Close"))) {
					this.groupStack.pop();
				}
			}
			this.ui.g.set_color(this.ui.t.SEPARATOR_COL);
			let _this3 = this.ui;
			let _this4 = this.ui;
			this.ui.g.fillRect(0,0,this.ww,_this3.t.ELEMENT_H * _this3.ops.scaleFactor + _this4.t.ELEMENT_OFFSET * _this4.ops.scaleFactor);
			this.ui.g.set_color(-1);
			this.ui._x = 0;
			this.ui._y = 0;
			this.ui._w = ew;
			let _BUTTON_COL = this.ui.t.BUTTON_COL;
			this.ui.t.BUTTON_COL = this.ui.t.SEPARATOR_COL;
			let cats = this.canvasType == 0 ? arm_shader_NodesMaterial.categories : arm_node_NodesBrush.categories;
			let _g = 0;
			let _g1 = cats.length;
			while(_g < _g1) {
				let i = _g++;
				if(this.ui.button(arm_Translator.tr(cats[i]),0) || this.ui.isHovered && this.showMenu) {
					this.showMenu = true;
					this.menuCategory = i;
					this.popupX = this.wx + this.ui._x;
					this.popupY = this.wy + this.ui._y;
				}
				if(i < cats.length - 1) {
					this.ui._x += ew + 3;
					this.ui._y = 0;
				}
			}
			this.ui._x += ew + 3;
			this.ui._y = 0;
			if(this.ui.button(arm_Translator.tr("Search"),0)) {
				this.nodeSearch(this.ui._windowX + this.ui._x | 0,this.ui._windowY + this.ui._y | 0);
			}
			if(this.ui.isHovered) {
				this.ui.tooltip(arm_Translator.tr("Search for nodes") + (" (" + arm_Config.keymap.node_search + ")"));
			}
			this.ui.t.BUTTON_COL = _BUTTON_COL;
		}
		this.ui.end(!this.showMenu);
		g.begin(false);
		if(this.showMenu) {
			let list = this.canvasType == 0 ? arm_shader_NodesMaterial.list : arm_node_NodesBrush.list;
			let isGroupCategory = this.canvasType == 0 && arm_shader_NodesMaterial.categories[this.menuCategory] == "Group";
			let py = this.popupY;
			let menuw = ew * 2.0 | 0;
			this.ui.beginRegion(g,this.popupX | 0,py | 0,menuw);
			let _BUTTON_COL = this.ui.t.BUTTON_COL;
			this.ui.t.BUTTON_COL = this.ui.t.SEPARATOR_COL;
			let _BUTTON_H = this.ui.t.BUTTON_H;
			this.ui.t.BUTTON_H = this.ui.t.ELEMENT_H;
			let _ELEMENT_OFFSET = this.ui.t.ELEMENT_OFFSET;
			this.ui.t.ELEMENT_OFFSET = 0;
			let _g = 0;
			let _g1 = list[this.menuCategory];
			while(_g < _g1.length) {
				let n = _g1[_g];
				++_g;
				this.ui.fill(0,1,this.ui._w / this.ui.ops.scaleFactor,this.ui.t.BUTTON_H + 2,this.ui.t.ACCENT_SELECT_COL);
				if(this.ui.button("      " + arm_Translator.tr(n.name),0)) {
					this.pushUndo();
					let canvas = this.getCanvas(true);
					let nodes = this.getNodes();
					let node = arm_ui_UINodes.makeNode(n,nodes,canvas);
					canvas.nodes.push(node);
					nodes.nodesSelected = [node];
					nodes.nodesDrag = true;
				}
				let _this = this.ui;
				if(this.ui._y - this.wy + _this.t.ELEMENT_H * _this.ops.scaleFactor / 2 > this.wh) {
					this.ui._x += menuw;
					this.ui._y = py;
				}
			}
			if(isGroupCategory) {
				let _g = 0;
				let _g1 = arm_Project.materialGroups;
				while(_g < _g1.length) {
					let g = _g1[_g];
					++_g;
					this.ui.fill(0,1,this.ui._w / this.ui.ops.scaleFactor,this.ui.t.BUTTON_H + 2,this.ui.t.ACCENT_SELECT_COL);
					this.ui.enabled = this.canPlaceGroup(g.canvas.name);
					if(this.ui.button("      " + g.canvas.name,0)) {
						this.pushUndo();
						let canvas = this.getCanvas(true);
						let nodes = this.getNodes();
						let node = arm_ui_UINodes.makeGroupNode(g.canvas,nodes,canvas);
						canvas.nodes.push(node);
						nodes.nodesSelected = [node];
						nodes.nodesDrag = true;
					}
					this.ui.enabled = true;
				}
			}
			this.hideMenu = this.ui.comboSelectedHandle == null && !this.showMenuFirst && (this.ui.changed || this.ui.inputReleased || this.ui.inputReleasedR || this.ui.isEscapeDown);
			this.showMenuFirst = false;
			this.ui.t.BUTTON_COL = _BUTTON_COL;
			this.ui.t.BUTTON_H = _BUTTON_H;
			this.ui.t.ELEMENT_OFFSET = _ELEMENT_OFFSET;
			this.ui.endRegion();
		}
		if(this.hideMenu) {
			this.showMenu = false;
			this.showMenuFirst = true;
		}
	}
	containsNodeGroupRecursive(group,groupName) {
		if(group.canvas.name == groupName) {
			return true;
		}
		let _g = 0;
		let _g1 = group.canvas.nodes;
		while(_g < _g1.length) {
			let n = _g1[_g];
			++_g;
			if(n.type == "GROUP") {
				let g = arm_Project.getMaterialGroupByName(n.name);
				if(g != null && this.containsNodeGroupRecursive(g,groupName)) {
					return true;
				}
			}
		}
		return false;
	}
	canPlaceGroup(groupName) {
		if(this.groupStack.length > 0) {
			let _g = 0;
			let _g1 = this.groupStack;
			while(_g < _g1.length) if(this.containsNodeGroupRecursive(arm_Project.getMaterialGroupByName(groupName),_g1[_g++].canvas.name)) {
				return false;
			}
		}
		let groupExists = false;
		let _g = 0;
		let _g1 = arm_Project.materialGroups;
		while(_g < _g1.length) if(groupName == _g1[_g++].canvas.name) {
			groupExists = true;
		}
		if(!groupExists) {
			return false;
		}
		return true;
	}
	pushUndo(lastCanvas) {
		if(lastCanvas == null) {
			lastCanvas = this.getCanvas(true);
		}
		arm_ui_UISidebar.inst.hwnd0.redraws = 2;
		arm_History.editNodes(lastCanvas,this.canvasType,this.groupStack.length > 0 ? arm_Project.materialGroups.indexOf(this.groupStack[this.groupStack.length - 1]) : null);
	}
	acceptAssetDrag(index) {
		this.pushUndo();
		let n = this.canvasType == 0 ? arm_shader_NodesMaterial.createNode("TEX_IMAGE",this.groupStack.length > 0 ? this.groupStack[this.groupStack.length - 1] : null) : arm_node_NodesBrush.createNode("TEX_IMAGE");
		n.buttons[0].default_value = index;
		this.getNodes().nodesSelected = [n];
	}
	acceptLayerDrag(index) {
		this.pushUndo();
		if(arm_Project.layers[index].isGroup()) {
			return;
		}
		let g = this.groupStack.length > 0 ? this.groupStack[this.groupStack.length - 1] : null;
		let n = arm_shader_NodesMaterial.createNode(arm_Context.layer.isMask() ? "LAYER_MASK" : "LAYER",g);
		n.buttons[0].default_value = index;
		this.getNodes().nodesSelected = [n];
	}
	acceptMaterialDrag(index) {
		this.pushUndo();
		let n = arm_shader_NodesMaterial.createNode("MATERIAL",this.groupStack.length > 0 ? this.groupStack[this.groupStack.length - 1] : null);
		n.buttons[0].default_value = index;
		this.getNodes().nodesSelected = [n];
	}
	acceptSwatchDrag(index) {
		this.pushUndo();
		let n = arm_shader_NodesMaterial.createNode("RGB",this.groupStack.length > 0 ? this.groupStack[this.groupStack.length - 1] : null);
		let color = arm_Project.raw.swatches[index].base;
		n.outputs[0].default_value = [((color & 16711680) >>> 16) * 0.00392156862745098,((color & 65280) >>> 8) * 0.00392156862745098,(color & 255) * 0.00392156862745098,(color >>> 24) * 0.00392156862745098];
		this.getNodes().nodesSelected = [n];
	}
	makeNodePreview() {
		let nodes = arm_Context.material.nodes;
		if(nodes.nodesSelected.length == 0) {
			return;
		}
		let node = nodes.nodesSelected[0];
		if(node.type == "LAYER" || node.type == "LAYER_MASK" || node.type == "MATERIAL" || node.type == "OUTPUT_MATERIAL_PBR") {
			return;
		}
		if(arm_Context.material.canvas.nodes.indexOf(node) == -1) {
			return;
		}
		if(arm_Context.nodePreview == null) {
			arm_Context.nodePreview = kha_Image.createRenderTarget(256,256);
		}
		arm_Context.nodePreviewDirty = false;
		arm_ui_UINodes.inst.hwnd.redraws = 2;
		arm_util_RenderUtil.makeNodePreview(arm_Context.material.canvas,node,arm_Context.nodePreview);
	}
	static onNodeRemove(node) {
		if(node.type == "GROUP") {
			let found = false;
			let canvases = [];
			let _g = 0;
			let _g1 = arm_Project.materials;
			while(_g < _g1.length) canvases.push(_g1[_g++].canvas);
			let _g2 = 0;
			let _g3 = arm_Project.materialGroups;
			while(_g2 < _g3.length) canvases.push(_g3[_g2++].canvas);
			let _g4 = 0;
			while(_g4 < canvases.length) {
				let _g = 0;
				let _g1 = canvases[_g4++].nodes;
				while(_g < _g1.length) {
					let n = _g1[_g];
					++_g;
					if(n.type == "GROUP" && n.name == node.name) {
						found = true;
						break;
					}
				}
			}
			if(!found) {
				let _g = 0;
				let _g1 = arm_Project.materialGroups;
				while(_g < _g1.length) {
					let g = _g1[_g];
					++_g;
					if(g.canvas.name == node.name) {
						HxOverrides.remove(arm_Project.materialGroups,g);
						break;
					}
				}
			}
		}
	}
	static getCanvasControl(ui,parent) {
		if(arm_Config.raw.wrap_mouse && parent.controlsDown) {
			if(ui.inputX < ui._windowX) {
				ui.inputX = ui._windowX + ui._windowW;
				Krom.setMousePosition(0,ui.inputX | 0,ui.inputY | 0);
			} else if(ui.inputX > ui._windowX + ui._windowW) {
				ui.inputX = ui._windowX;
				Krom.setMousePosition(0,ui.inputX | 0,ui.inputY | 0);
			} else if(ui.inputY < ui._windowY) {
				ui.inputY = ui._windowY + ui._windowH;
				Krom.setMousePosition(0,ui.inputX | 0,ui.inputY | 0);
			} else if(ui.inputY > ui._windowY + ui._windowH) {
				ui.inputY = ui._windowY;
				Krom.setMousePosition(0,ui.inputX | 0,ui.inputY | 0);
			}
		}
		if(arm_Operator.shortcut(arm_Config.keymap.action_pan,0) || arm_Operator.shortcut(arm_Config.keymap.action_zoom,0) || ui.inputStartedR || ui.inputWheelDelta != 0.0) {
			parent.controlsDown = true;
		} else if(!arm_Operator.shortcut(arm_Config.keymap.action_pan,2) && !arm_Operator.shortcut(arm_Config.keymap.action_zoom,2) && !ui.inputDownR && ui.inputWheelDelta == 0.0) {
			parent.controlsDown = false;
		}
		if(!parent.controlsDown) {
			return { panX : 0, panY : 0, zoom : 0};
		}
		let pan = ui.inputDownR || arm_Operator.shortcut(arm_Config.keymap.action_pan,2);
		let zoomDelta = arm_Operator.shortcut(arm_Config.keymap.action_zoom,2) ? arm_ui_UINodes.getZoomDelta(ui) / 100.0 : 0.0;
		let control = { panX : pan ? ui.inputDX : 0.0, panY : pan ? ui.inputDY : 0.0, zoom : ui.inputWheelDelta != 0.0 ? -ui.inputWheelDelta / 10 : zoomDelta};
		if(arm_App.isComboSelected()) {
			control.zoom = 0.0;
		}
		return control;
	}
	static getZoomDelta(ui) {
		if(arm_Config.raw.zoom_direction == 0) {
			return -ui.inputDY;
		} else if(arm_Config.raw.zoom_direction == 1) {
			return -ui.inputDY;
		} else if(arm_Config.raw.zoom_direction == 2) {
			return ui.inputDX;
		} else if(arm_Config.raw.zoom_direction == 3) {
			return ui.inputDX;
		} else {
			return -(ui.inputDY - ui.inputDX);
		}
	}
	static makeNode(n,nodes,canvas) {
		let node = JSON.parse(JSON.stringify(n));
		node.id = nodes.getNodeId(canvas.nodes);
		node.x = arm_ui_UINodes.inst.getNodeX();
		node.y = arm_ui_UINodes.inst.getNodeY();
		let _g = 0;
		let _g1 = node.inputs;
		while(_g < _g1.length) {
			let soc = _g1[_g];
			++_g;
			soc.id = nodes.getSocketId(canvas.nodes);
			soc.node_id = node.id;
		}
		let _g2 = 0;
		let _g3 = node.outputs;
		while(_g2 < _g3.length) {
			let soc = _g3[_g2];
			++_g2;
			soc.id = nodes.getSocketId(canvas.nodes);
			soc.node_id = node.id;
		}
		return node;
	}
	static makeGroupNode(groupCanvas,nodes,canvas) {
		let node = JSON.parse(JSON.stringify(arm_shader_NodesMaterial.list[5][0]));
		node.name = groupCanvas.name;
		node.id = nodes.getNodeId(canvas.nodes);
		node.x = arm_ui_UINodes.inst.getNodeX();
		node.y = arm_ui_UINodes.inst.getNodeY();
		let groupInput = null;
		let groupOutput = null;
		let _g = 0;
		let _g1 = arm_Project.materialGroups;
		while(_g < _g1.length) {
			let g = _g1[_g];
			++_g;
			if(g.canvas.name == node.name) {
				let _g = 0;
				let _g1 = g.canvas.nodes;
				while(_g < _g1.length) {
					let n = _g1[_g];
					++_g;
					if(n.type == "GROUP_INPUT") {
						groupInput = n;
					} else if(n.type == "GROUP_OUTPUT") {
						groupOutput = n;
					}
				}
				break;
			}
		}
		if(groupInput != null && groupOutput != null) {
			let _g = 0;
			let _g1 = groupInput.outputs;
			while(_g < _g1.length) {
				let soc = _g1[_g];
				++_g;
				node.inputs.push(arm_shader_NodesMaterial.createSocket(nodes,node,soc.name,soc.type,canvas,soc.min,soc.max,soc.default_value));
			}
			let _g2 = 0;
			let _g3 = groupOutput.inputs;
			while(_g2 < _g3.length) {
				let soc = _g3[_g2];
				++_g2;
				node.outputs.push(arm_shader_NodesMaterial.createSocket(nodes,node,soc.name,soc.type,canvas,soc.min,soc.max,soc.default_value));
			}
		}
		return node;
	}
	static hasGroup(c) {
		let _g = 0;
		let _g1 = c.nodes;
		while(_g < _g1.length) if(_g1[_g++].type == "GROUP") {
			return true;
		}
		return false;
	}
	static traverseGroup(mgroups,c) {
		let _g = 0;
		let _g1 = c.nodes;
		while(_g < _g1.length) {
			let n = _g1[_g];
			++_g;
			if(n.type == "GROUP") {
				if(arm_ui_UINodes.getGroup(mgroups,n.name) == null) {
					let canvases = [];
					let _g = 0;
					let _g1 = arm_Project.materialGroups;
					while(_g < _g1.length) canvases.push(_g1[_g++].canvas);
					let group = arm_ui_UINodes.getGroup(canvases,n.name);
					mgroups.push(JSON.parse(JSON.stringify(group)));
					arm_ui_UINodes.traverseGroup(mgroups,group);
				}
			}
		}
	}
	static getGroup(canvases,name) {
		let _g = 0;
		while(_g < canvases.length) {
			let c = canvases[_g];
			++_g;
			if(c.name == name) {
				return c;
			}
		}
		return null;
	}
	static menuButton(ui,text,label) {
		if(label == null) {
			label = "";
		}
		return ui.button("      " + text,0,label);
	}
	static menuSeparator(ui) {
		ui._y++;
		ui.fill(22,0,ui._w / ui.ops.scaleFactor - 22,1,ui.t.ACCENT_SELECT_COL);
	}
}
$hxClasses["arm.ui.UINodes"] = arm_ui_UINodes;
arm_ui_UINodes.__name__ = "arm.ui.UINodes";
Object.assign(arm_ui_UINodes.prototype, {
	__class__: arm_ui_UINodes
});
class arm_ui_UIView2D {
	constructor() {
		this.layerMode = 1;
		this.texType = 0;
		this.controlsDown = false;
		this.tiledShow = false;
		this.uvmapShow = false;
		this.panScale = 1.0;
		this.panY = 0.0;
		this.panX = 0.0;
		this.hwnd = zui_Handle.global.nest(5,null);
		this.type = 0;
		this.show = false;
		arm_ui_UIView2D.inst = this;
		arm_ui_UIView2D.pipe = new kha_graphics4_PipelineState();
		arm_ui_UIView2D.pipe.vertexShader = kha_Shaders.getVertex("layer_view.vert");
		arm_ui_UIView2D.pipe.fragmentShader = kha_Shaders.getFragment("layer_view.frag");
		let vs = new kha_graphics4_VertexStructure();
		vs.add("pos",2);
		vs.add("tex",1);
		vs.add("col",16);
		arm_ui_UIView2D.pipe.inputLayout = [vs];
		arm_ui_UIView2D.pipe.blendSource = 1;
		arm_ui_UIView2D.pipe.blendDestination = 2;
		arm_ui_UIView2D.pipe.colorWriteMasksAlpha[0] = false;
		arm_ui_UIView2D.pipe.compile();
		arm_ui_UIView2D.channelLocation = arm_ui_UIView2D.pipe.getConstantLocation("channel");
		this.ui = new zui_Zui({ theme : arm_App.theme, font : arm_App.font, color_wheel : arm_App.colorWheel, scaleFactor : arm_Config.raw.window_scale});
		this.ui.scrollEnabled = false;
	}
	render(g) {
		this.ww = arm_Config.raw.layout[3];
		this.wx = (arm_App.w() | 0) + arm_ui_UIToolbar.inst.toolbarw;
		this.wy = arm_ui_UIHeader.inst.headerh * 2;
		if(!arm_ui_UISidebar.inst.show) {
			this.ww += arm_Config.raw.layout[0] + arm_ui_UIToolbar.inst.toolbarw;
			this.wx -= arm_ui_UIToolbar.inst.toolbarw;
			this.wy = 0;
		}
		if(!this.show) {
			return;
		}
		if(kha_System.windowWidth() == 0 || kha_System.windowHeight() == 0) {
			return;
		}
		if(arm_Context.pdirty >= 0) {
			this.hwnd.redraws = 2;
		}
		g.end();
		if(arm_ui_UINodes.inst.grid == null) {
			arm_ui_UINodes.inst.drawGrid();
		}
		if(this.uvmapShow) {
			arm_util_UVUtil.cacheUVMap();
		}
		if(arm_Context.font.image == null) {
			arm_util_RenderUtil.makeFontPreview();
		}
		this.ui.begin(g);
		this.wh = arm_App.h();
		if(arm_ui_UINodes.inst.show) {
			this.wh -= arm_Config.raw.layout[4];
		}
		if(this.ui.window(this.hwnd,this.wx,this.wy,this.ww,this.wh)) {
			this.ui.g.set_color(-1);
			this.ui.g.drawImage(arm_ui_UINodes.inst.grid,this.panX * this.panScale % 40 - 40,this.panY * this.panScale % 40 - 40);
			let l = arm_Context.layer;
			let tex = null;
			let channel = 0;
			let tw = this.ww * 0.95 * this.panScale;
			let tx = this.ww / 2 - tw / 2 + this.panX;
			let ty = arm_App.h() / 2 - tw / 2 + this.panY;
			if(this.type == 0) {
				let layer = l;
				if(arm_Config.raw.brush_live && arm_render_RenderPathPaint.liveLayerDrawn > 0) {
					layer = arm_render_RenderPathPaint.liveLayer;
				}
				if(this.layerMode == 0) {
					let current = kha_graphics2_Graphics.current;
					if(current != null) {
						current.end();
					}
					layer = arm_Layers.flatten();
					if(current != null) {
						current.begin(false);
					}
				} else if(layer.isGroup()) {
					let current = kha_graphics2_Graphics.current;
					if(current != null) {
						current.end();
					}
					layer = arm_Layers.flatten(false,layer.getChildren());
					if(current != null) {
						current.begin(false);
					}
				}
				tex = arm_Context.layer.isMask() ? layer.texpaint : this.texType == 0 ? layer.texpaint : this.texType == 5 ? layer.texpaint : this.texType == 1 ? layer.texpaint_nor : layer.texpaint_pack;
				channel = arm_Context.layer.isMask() ? 1 : this.texType == 2 ? 1 : this.texType == 3 ? 2 : this.texType == 4 ? 3 : this.texType == 5 ? 4 : this.texType == 6 ? 4 : this.texType == 1 ? 5 : 0;
			} else if(this.type == 1) {
				tex = arm_Project.getImage(arm_Context.texture);
			} else if(this.type == 2) {
				tex = arm_Context.font.image;
			} else {
				tex = arm_Context.nodePreview;
			}
			let th = tw;
			if(tex != null) {
				th = tw * (tex.get_height() / tex.get_width());
				ty = arm_App.h() / 2 - th / 2 + this.panY;
				if(this.type == 0) {
					this.ui.g.set_pipeline(arm_ui_UIView2D.pipe);
					if(!arm_Context.textureFilter) {
						this.ui.g.set_imageScaleQuality(kha_graphics2_ImageScaleQuality.Low);
					}
					this.ui.currentWindow.texture.get_g4().setInt(arm_ui_UIView2D.channelLocation,channel);
				}
				this.ui.g.drawScaledImage(tex,tx,ty,tw,th);
				if(this.tiledShow) {
					this.ui.g.drawScaledImage(tex,tx - tw,ty,tw,th);
					this.ui.g.drawScaledImage(tex,tx - tw,ty - th,tw,th);
					this.ui.g.drawScaledImage(tex,tx - tw,ty + th,tw,th);
					this.ui.g.drawScaledImage(tex,tx + tw,ty,tw,th);
					this.ui.g.drawScaledImage(tex,tx + tw,ty - th,tw,th);
					this.ui.g.drawScaledImage(tex,tx + tw,ty + th,tw,th);
					this.ui.g.drawScaledImage(tex,tx,ty - th,tw,th);
					this.ui.g.drawScaledImage(tex,tx,ty + th,tw,th);
				}
				if(this.type == 0) {
					this.ui.g.set_pipeline(null);
					if(!arm_Context.textureFilter) {
						this.ui.g.set_imageScaleQuality(kha_graphics2_ImageScaleQuality.High);
					}
				}
			}
			if(this.type == 0 && this.uvmapShow) {
				this.ui.g.drawScaledImage(arm_util_UVUtil.uvmap,tx,ty,tw,th);
			}
			let ACCENT_COL = this.ui.t.ACCENT_COL;
			let BUTTON_H = this.ui.t.BUTTON_H;
			let ELEMENT_H = this.ui.t.ELEMENT_H;
			let FONT_SIZE = this.ui.fontSize;
			this.ui.t.ACCENT_COL = 0;
			this.ui.t.BUTTON_H = 30;
			this.ui.t.ELEMENT_H = 30;
			this.ui.fontSize = 22 * this.ui.ops.scaleFactor | 0;
			let _this = this.ui;
			this.ui._x = this.ww - _this.t.ELEMENT_W * _this.ops.scaleFactor * 1.4;
			let _this1 = this.ui;
			this.ui._y = this.wh - _this1.t.ELEMENT_H * _this1.ops.scaleFactor * 1.2;
			let _this2 = this.ui;
			this.ui._w = _this2.t.ELEMENT_W * _this2.ops.scaleFactor * 1.4 | 0;
			let h = zui_Handle.global.nest(115,null);
			if(this.type == 0) {
				h.text = l.name;
				l.name = this.ui.textInput(h,"",2);
				arm_ui_UIView2D.textInputHover = this.ui.isHovered;
			} else if(this.type == 1) {
				let asset = arm_Context.texture;
				if(asset != null) {
					let assetNames = arm_Project.assetNames;
					let i = assetNames.indexOf(asset.name);
					h.text = asset.name;
					asset.name = this.ui.textInput(h,"",2);
					assetNames[i] = asset.name;
				}
			} else if(this.type == 2) {
				h.text = arm_Context.font.name;
				arm_Context.font.name = this.ui.textInput(h,"",2);
			}
			if(h.changed) {
				arm_ui_UISidebar.inst.hwnd0.redraws = 2;
			}
			this.ui.t.ACCENT_COL = ACCENT_COL;
			this.ui.t.BUTTON_H = BUTTON_H;
			this.ui.t.ELEMENT_H = ELEMENT_H;
			this.ui.fontSize = FONT_SIZE;
			let _this3 = this.ui;
			let ew = _this3.t.ELEMENT_W * _this3.ops.scaleFactor | 0;
			this.ui.g.set_color(this.ui.t.SEPARATOR_COL);
			let _this4 = this.ui;
			let _this5 = this.ui;
			this.ui.g.fillRect(0,0,this.ww,_this4.t.ELEMENT_H * _this4.ops.scaleFactor + _this5.t.ELEMENT_OFFSET * _this5.ops.scaleFactor);
			this.ui.g.set_color(-1);
			this.ui._x = 2;
			this.ui._y = 2;
			this.ui._w = ew;
			if(this.type == 0) {
				this.layerMode = this.ui.combo(zui_Handle.global.nest(116,{ position : this.layerMode}),[arm_Translator.tr("Visible"),arm_Translator.tr("Selected")],arm_Translator.tr("Layers"));
				this.ui._x += ew + 3;
				this.ui._y = 2;
				if(!arm_Context.layer.isMask()) {
					this.texType = this.ui.combo(zui_Handle.global.nest(117,{ position : this.texType}),[arm_Translator.tr("Base Color"),arm_Translator.tr("Normal Map"),arm_Translator.tr("Occlusion"),arm_Translator.tr("Roughness"),arm_Translator.tr("Metallic"),arm_Translator.tr("Opacity"),arm_Translator.tr("Height")],arm_Translator.tr("Texture"));
					this.ui._x += ew + 3;
					this.ui._y = 2;
				}
				this.uvmapShow = this.ui.check(zui_Handle.global.nest(118,{ selected : this.uvmapShow}),arm_Translator.tr("UV Map"));
				this.ui._x += ew + 3;
				this.ui._y = 2;
			}
			this.tiledShow = this.ui.check(zui_Handle.global.nest(119,{ selected : this.tiledShow}),arm_Translator.tr("Tiled"));
			if(this.type == 1 && tex != null) {
				this.ui._x += ew + 3;
				this.ui._y = 2;
				this.ui.text(tex.get_width() + "x" + tex.get_height());
			}
			if(arm_Context.tool == 9 && (this.type == 0 || this.type == 1)) {
				let cursorImg = arm_Res.bundled.h["cursor.k"];
				let hsize = 16 * this.ui.ops.scaleFactor;
				let size = hsize * 2;
				this.ui.g.drawScaledImage(cursorImg,tx + tw * arm_Context.uvxPicked - hsize,ty + th * arm_Context.uvyPicked - hsize,size,size);
			}
		}
		this.ui.end();
		g.begin(false);
	}
	update() {
		let mouse = iron_system_Input.getMouse();
		let kb = iron_system_Input.getKeyboard();
		let _this = this.ui;
		arm_Context.paint2d = false;
		if(!arm_App.uiEnabled || !this.show || mouse.x < this.wx || mouse.x > this.wx + this.ww || mouse.y < this.wy + _this.t.ELEMENT_H * _this.ops.scaleFactor * 1.4 || mouse.y > this.wy + this.wh) {
			if(arm_ui_UIView2D.inst.controlsDown) {
				arm_ui_UINodes.getCanvasControl(this.ui,arm_ui_UIView2D.inst);
			}
			return;
		}
		let control = arm_ui_UINodes.getCanvasControl(this.ui,arm_ui_UIView2D.inst);
		this.panX += control.panX;
		this.panY += control.panY;
		if(control.zoom != 0) {
			let _panX = this.panX / this.panScale;
			let _panY = this.panY / this.panScale;
			this.panScale += control.zoom;
			if(this.panScale < 0.1) {
				this.panScale = 0.1;
			}
			if(this.panScale > 6.0) {
				this.panScale = 6.0;
			}
			this.panX = _panX * this.panScale;
			this.panY = _panY * this.panScale;
		}
		let decalMask = (arm_Context.tool == 3 || arm_Context.tool == 4) && arm_Operator.shortcut(arm_Config.keymap.decal_mask + "+" + arm_Config.keymap.action_paint,2);
		let setCloneSource = arm_Context.tool == 5 && arm_Operator.shortcut(arm_Config.keymap.set_clone_source + "+" + arm_Config.keymap.action_paint,2);
		if(this.type == 0 && !arm_ui_UIView2D.textInputHover && (arm_Operator.shortcut(arm_Config.keymap.action_paint,2) || arm_Operator.shortcut(arm_Config.keymap.brush_ruler + "+" + arm_Config.keymap.action_paint,2) || decalMask || setCloneSource || arm_Config.raw.brush_live)) {
			arm_Context.paint2d = true;
		}
		if(this.ui.isTyping) {
			return;
		}
		if(kb.started("left")) {
			this.panX -= 5;
		} else if(kb.started("right")) {
			this.panX += 5;
		}
		if(kb.started("up")) {
			this.panY -= 5;
		} else if(kb.started("down")) {
			this.panY += 5;
		}
		let tw = this.ww * 0.95 * this.panScale;
		let tx = this.ww / 2 - tw / 2 + this.panX;
		let hh = arm_App.h();
		let ty = hh / 2 - tw / 2 + this.panY;
		if(tx + 32 > this.ww) {
			this.panX = this.ww / 2 + tw / 2 - 32;
		} else if(tx - 32 < -tw) {
			this.panX = -tw / 2 - this.ww / 2 + 32;
		}
		if(ty + 32 > hh) {
			this.panY = hh / 2 + tw / 2 - 32;
		} else if(ty - 32 < -tw) {
			this.panY = -tw / 2 - hh / 2 + 32;
		}
		if(arm_Operator.shortcut(arm_Config.keymap.view_reset)) {
			this.panX = 0.0;
			this.panY = 0.0;
			this.panScale = 1.0;
		}
	}
}
$hxClasses["arm.ui.UIView2D"] = arm_ui_UIView2D;
arm_ui_UIView2D.__name__ = "arm.ui.UIView2D";
Object.assign(arm_ui_UIView2D.prototype, {
	__class__: arm_ui_UIView2D
});
class arm_util_UVUtil {
	static cacheUVMap() {
		if(arm_util_UVUtil.uvmap != null && (arm_util_UVUtil.uvmap.get_width() != arm_Config.getTextureResX() || arm_util_UVUtil.uvmap.get_height() != arm_Config.getTextureResY())) {
			arm_util_UVUtil.uvmap.unload();
			arm_util_UVUtil.uvmap = null;
			arm_util_UVUtil.uvmapCached = false;
		}
		if(arm_util_UVUtil.uvmapCached) {
			return;
		}
		let resX = arm_Config.getTextureResX();
		if(arm_util_UVUtil.uvmap == null) {
			arm_util_UVUtil.uvmap = kha_Image.createRenderTarget(resX,arm_Config.getTextureResY());
		}
		arm_util_UVUtil.uvmapCached = true;
		let merged = arm_Context.mergedObject;
		let mesh = arm_Context.layerFilter == 0 && merged != null ? merged.data.raw : arm_Context.paintObject.data.raw;
		let texa = mesh.vertex_arrays[2].values;
		let inda = mesh.index_arrays[0].values;
		arm_util_UVUtil.uvmap.get_g2().begin(true,0);
		arm_util_UVUtil.uvmap.get_g2().set_color(-3355444);
		let strength = resX > 2048 ? 2.0 : 1.0;
		let f = 3.0518509475997192e-005 * arm_util_UVUtil.uvmap.get_width();
		let _g = 0;
		let _g1 = inda.length / 3 | 0;
		while(_g < _g1) {
			let i = _g++;
			let x1 = texa[inda[i * 3] * 2] * f;
			let x2 = texa[inda[i * 3 + 1] * 2] * f;
			let x3 = texa[inda[i * 3 + 2] * 2] * f;
			let y1 = texa[inda[i * 3] * 2 + 1] * f;
			let y2 = texa[inda[i * 3 + 1] * 2 + 1] * f;
			let y3 = texa[inda[i * 3 + 2] * 2 + 1] * f;
			arm_util_UVUtil.uvmap.get_g2().drawLine(x1,y1,x2,y2,strength);
			arm_util_UVUtil.uvmap.get_g2().drawLine(x2,y2,x3,y3,strength);
			arm_util_UVUtil.uvmap.get_g2().drawLine(x3,y3,x1,y1,strength);
		}
		arm_util_UVUtil.uvmap.get_g2().end();
	}
	static cacheTriangleMap() {
		if(arm_util_UVUtil.trianglemap != null && (arm_util_UVUtil.trianglemap.get_width() != arm_Config.getTextureResX() || arm_util_UVUtil.trianglemap.get_height() != arm_Config.getTextureResY())) {
			arm_util_UVUtil.trianglemap.unload();
			arm_util_UVUtil.trianglemap = null;
			arm_util_UVUtil.trianglemapCached = false;
		}
		if(arm_util_UVUtil.trianglemapCached) {
			return;
		}
		if(arm_util_UVUtil.trianglemap == null) {
			arm_util_UVUtil.trianglemap = kha_Image.createRenderTarget(arm_Config.getTextureResX(),arm_Config.getTextureResY());
		}
		arm_util_UVUtil.trianglemapCached = true;
		let mesh = arm_Context.mergedObject != null ? arm_Context.mergedObject.data.raw : arm_Context.paintObject.data.raw;
		let texa = mesh.vertex_arrays[2].values;
		let inda = mesh.index_arrays[0].values;
		arm_util_UVUtil.trianglemap.get_g2().begin(true,-16777216);
		let f = 3.0518509475997192e-005 * arm_util_UVUtil.trianglemap.get_width();
		let color = -16777215;
		let _g = 0;
		let _g1 = inda.length / 3 | 0;
		while(_g < _g1) {
			let i = _g++;
			if(color == -1) {
				color = -16777215;
			}
			++color;
			arm_util_UVUtil.trianglemap.get_g2().set_color(color);
			let x1 = texa[inda[i * 3] * 2] * f;
			let x2 = texa[inda[i * 3 + 1] * 2] * f;
			let x3 = texa[inda[i * 3 + 2] * 2] * f;
			let y1 = texa[inda[i * 3] * 2 + 1] * f;
			let y2 = texa[inda[i * 3 + 1] * 2 + 1] * f;
			let y3 = texa[inda[i * 3 + 2] * 2 + 1] * f;
			arm_util_UVUtil.trianglemap.get_g2().fillTriangle(x1,y1,x2,y2,x3,y3);
		}
		arm_util_UVUtil.trianglemap.get_g2().end();
	}
	static cacheDilateMap() {
		if(arm_util_UVUtil.dilatemap != null && (arm_util_UVUtil.dilatemap.get_width() != arm_Config.getTextureResX() || arm_util_UVUtil.dilatemap.get_height() != arm_Config.getTextureResY())) {
			arm_util_UVUtil.dilatemap.unload();
			arm_util_UVUtil.dilatemap = null;
			arm_util_UVUtil.dilatemapCached = false;
		}
		if(arm_util_UVUtil.dilatemapCached) {
			return;
		}
		if(arm_util_UVUtil.dilatemap == null) {
			arm_util_UVUtil.dilatemap = kha_Image.createRenderTarget(arm_Config.getTextureResX(),arm_Config.getTextureResY(),1);
		}
		if(arm_util_UVUtil.pipeDilate == null) {
			arm_util_UVUtil.pipeDilate = new kha_graphics4_PipelineState();
			arm_util_UVUtil.pipeDilate.vertexShader = kha_Shaders.getVertex("dilate_map.vert");
			arm_util_UVUtil.pipeDilate.fragmentShader = kha_Shaders.getFragment("dilate_map.frag");
			let vs = new kha_graphics4_VertexStructure();
			vs.add("pos",27);
			vs.add("nor",23);
			vs.add("tex",23);
			arm_util_UVUtil.pipeDilate.inputLayout = [vs];
			arm_util_UVUtil.pipeDilate.depthWrite = false;
			arm_util_UVUtil.pipeDilate.depthMode = 0;
			arm_util_UVUtil.pipeDilate.colorAttachments[0] = 1;
			arm_util_UVUtil.pipeDilate.compile();
		}
		let mask = arm_Context.objectMaskUsed() ? arm_Context.layer.getObjectMask() : 0;
		if(arm_Context.layerFilterUsed()) {
			mask = arm_Context.layerFilter;
		}
		let geom = mask == 0 && arm_Context.mergedObject != null ? arm_Context.mergedObject.data.geom : arm_Context.paintObject.data.geom;
		let g4 = arm_util_UVUtil.dilatemap.get_g4();
		g4.begin();
		g4.clear(0);
		g4.setPipeline(arm_util_UVUtil.pipeDilate);
		g4.setVertexBuffer(geom.vertexBuffer);
		g4.setIndexBuffer(geom.indexBuffers[0]);
		g4.drawIndexedVertices();
		g4.end();
		arm_util_UVUtil.dilatemapCached = true;
		arm_util_UVUtil.dilateBytes = null;
	}
	static cacheUVIslandMap() {
		arm_util_UVUtil.cacheDilateMap();
		if(arm_util_UVUtil.dilateBytes == null) {
			arm_util_UVUtil.dilateBytes = arm_util_UVUtil.dilatemap.getPixels();
		}
		arm_util_RenderUtil.pickPosNorTex();
		let w = 2048;
		let h = 2048;
		let x = arm_Context.uvxPicked * w | 0;
		let y = arm_Context.uvyPicked * h | 0;
		let bytes = new haxe_io_Bytes(new ArrayBuffer(w * h));
		let coords = [{ x : x, y : y}];
		let r = arm_util_UVUtil.dilatemap.get_width() / w | 0;
		let check = function(c) {
			if(c.x < 0 || c.x >= w || c.y < 0 || c.y >= h) {
				return;
			}
			if(bytes.b[c.y * w + c.x] == 255) {
				return;
			}
			let _this = arm_util_UVUtil.dilateBytes;
			let pos = c.y * r * arm_util_UVUtil.dilatemap.get_width();
			if(_this.b[pos + c.x * r] == 0) {
				return;
			}
			bytes.b[c.y * w + c.x] = 255;
			coords.push({ x : c.x + 1, y : c.y});
			coords.push({ x : c.x - 1, y : c.y});
			coords.push({ x : c.x, y : c.y + 1});
			coords.push({ x : c.x, y : c.y - 1});
		};
		while(coords.length > 0) check(coords.pop());
		if(arm_util_UVUtil.uvislandmap != null) {
			arm_util_UVUtil.uvislandmap.unload();
		}
		arm_util_UVUtil.uvislandmap = kha_Image.fromBytes(bytes,w,h,1);
		arm_util_UVUtil.uvislandmapCached = true;
	}
}
$hxClasses["arm.util.UVUtil"] = arm_util_UVUtil;
arm_util_UVUtil.__name__ = "arm.util.UVUtil";
class arm_Viewport {
	static scaleToBounds() {
		let po = arm_Context.mergedObject == null ? arm_Context.mainObject() : arm_Context.mergedObject;
		let md = po.data;
		md.geom.calculateAABB();
		let r = Math.sqrt(md.geom.aabb.x * md.geom.aabb.x + md.geom.aabb.y * md.geom.aabb.y + md.geom.aabb.z * md.geom.aabb.z);
		po = arm_Context.mainObject();
		po.transform.dim.x = md.geom.aabb.x;
		po.transform.dim.y = md.geom.aabb.y;
		po.transform.dim.z = md.geom.aabb.z;
		let _this = po.transform.scale;
		_this.x = 2 / r;
		_this.y = 2 / r;
		_this.z = 2 / r;
		_this.w = 1.0;
		let _this1 = po.transform.loc;
		_this1.x = 0;
		_this1.y = 0;
		_this1.z = 0;
		_this1.w = 1.0;
		po.transform.buildMatrix();
		let _g = 0;
		let _g1 = po.children;
		while(_g < _g1.length) {
			let c = _g1[_g];
			++_g;
			let _this = c.transform.loc;
			_this.x = 0;
			_this.y = 0;
			_this.z = 0;
			_this.w = 1.0;
			c.transform.buildMatrix();
		}
	}
	static reset() {
		let cam = iron_Scene.active.camera;
		let _g = 0;
		let _g1 = iron_Scene.active.raw.objects;
		while(_g < _g1.length) {
			let o = _g1[_g];
			++_g;
			if(o.type == "camera_object") {
				let _this = cam.transform.local;
				let a = o.transform.values;
				_this.self._00 = a[0];
				_this.self._10 = a[1];
				_this.self._20 = a[2];
				_this.self._30 = a[3];
				_this.self._01 = a[4];
				_this.self._11 = a[5];
				_this.self._21 = a[6];
				_this.self._31 = a[7];
				_this.self._02 = a[8];
				_this.self._12 = a[9];
				_this.self._22 = a[10];
				_this.self._32 = a[11];
				_this.self._03 = a[12];
				_this.self._13 = a[13];
				_this.self._23 = a[14];
				_this.self._33 = a[15];
				cam.transform.decompose();
				if(arm_Context.fovHandle != null) {
					arm_Context.fovHandle.value = cam.data.raw.fov = 0.92;
				}
				arm_Context.camHandle.position = 0;
				cam.data.raw.ortho = null;
				cam.buildProjection();
				arm_Context.ddirty = 2;
				arm_Camera.inst.reset();
				break;
			}
		}
	}
	static setView(x,y,z,rx,ry,rz) {
		let _this = arm_Context.paintObject.transform.rot;
		_this.x = 0;
		_this.y = 0;
		_this.z = 0;
		_this.w = 1;
		arm_Context.paintObject.transform.dirty = true;
		let cam = iron_Scene.active.camera;
		let _this1 = cam.transform.loc;
		let dist = Math.sqrt(_this1.x * _this1.x + _this1.y * _this1.y + _this1.z * _this1.z);
		let _this2 = cam.transform.loc;
		_this2.x = x * dist;
		_this2.y = y * dist;
		_this2.z = z * dist;
		_this2.w = 1.0;
		let _this3 = cam.transform.rot;
		let f = rx / 2;
		let c1 = Math.cos(f);
		let s1 = Math.sin(f);
		f = ry / 2;
		let c2 = Math.cos(f);
		let s2 = Math.sin(f);
		f = rz / 2;
		let c3 = Math.cos(f);
		let s3 = Math.sin(f);
		_this3.x = s1 * c2 * c3 + c1 * s2 * s3;
		_this3.y = c1 * s2 * c3 + s1 * c2 * s3;
		_this3.z = c1 * c2 * s3 - s1 * s2 * c3;
		_this3.w = c1 * c2 * c3 - s1 * s2 * s3;
		cam.transform.buildMatrix();
		cam.buildProjection();
		arm_Context.ddirty = 2;
		arm_Camera.inst.reset(arm_Context.viewIndexLast);
	}
	static orbit(x,y) {
		let cam = iron_Scene.active.camera;
		let dist = arm_Camera.inst.distance();
		cam.transform.move(new iron_math_Vec4(-cam.transform.world.self._20,-cam.transform.world.self._21,-cam.transform.world.self._22),dist);
		cam.transform.rotate(new iron_math_Vec4(0,0,1),x);
		cam.transform.rotate(new iron_math_Vec4(cam.transform.world.self._00,cam.transform.world.self._01,cam.transform.world.self._02),y);
		cam.transform.move(new iron_math_Vec4(-cam.transform.world.self._20,-cam.transform.world.self._21,-cam.transform.world.self._22),-dist);
		arm_Context.ddirty = 2;
	}
	static orbitOpposite() {
		let cam = iron_Scene.active.camera;
		let x = -cam.transform.local.self._20;
		let y = -cam.transform.local.self._21;
		let z = -cam.transform.local.self._22;
		if(z == null) {
			z = 0.0;
		}
		if(y == null) {
			y = 0.0;
		}
		if(x == null) {
			x = 0.0;
		}
		let z1 = Math.abs(z) - 1.0;
		if(z1 < 0.0001 && z1 > -0.0001) {
			arm_Viewport.orbit(0,Math.PI);
		} else {
			arm_Viewport.orbit(Math.PI,0);
		}
	}
	static zoom(f) {
		let cam = iron_Scene.active.camera;
		cam.transform.move(new iron_math_Vec4(-cam.transform.local.self._20,-cam.transform.local.self._21,-cam.transform.local.self._22),f);
		arm_Context.ddirty = 2;
	}
	static updateCameraType(cameraType) {
		let cam = iron_Scene.active.cameras[0];
		let light = iron_Scene.active.lights[0];
		if(cameraType == 0) {
			cam.data.raw.ortho = null;
			light.visible = true;
		} else {
			let f32 = new Float32Array(4);
			let _this = cam.transform.world;
			let x = _this.self._30;
			let y = _this.self._31;
			let z = _this.self._32;
			let w = _this.self._33;
			if(w == null) {
				w = 1.0;
			}
			if(z == null) {
				z = 0.0;
			}
			if(y == null) {
				y = 0.0;
			}
			if(x == null) {
				x = 0.0;
			}
			let _this_x = x;
			let _this_y = y;
			let _this_z = z;
			let f = cam.data.raw.fov * Math.sqrt(_this_x * _this_x + _this_y * _this_y + _this_z * _this_z) / 2.5;
			f32[0] = -2 * f;
			f32[1] = 2 * f;
			f32[2] = -2 * f * (arm_App.h() / arm_App.w());
			f32[3] = 2 * f * (arm_App.h() / arm_App.w());
			cam.data.raw.ortho = f32;
			light.visible = false;
		}
		cam.buildProjection();
		arm_Context.ddirty = 2;
	}
}
$hxClasses["arm.Viewport"] = arm_Viewport;
arm_Viewport.__name__ = "arm.Viewport";
class arm_ArmBridge {
}
$hxClasses["arm.ArmBridge"] = $hx_exports["arm"] = arm_ArmBridge;
arm_ArmBridge.__name__ = "arm.ArmBridge";
class arm_Strings {
	static error0() {
		return arm_Translator.tr("Error: .arm file expected");
	}
	static error1() {
		return arm_Translator.tr("Error: Unknown asset format");
	}
	static error2() {
		return arm_Translator.tr("Error: Could not locate texture");
	}
	static error3() {
		return arm_Translator.tr("Error: Failed to read mesh data");
	}
	static error5() {
		return arm_Translator.tr("Error: Check internet connection to access the cloud");
	}
	static info0() {
		return arm_Translator.tr("Info: Asset already imported");
	}
}
$hxClasses["arm.Strings"] = arm_Strings;
arm_Strings.__name__ = "arm.Strings";
class arm_Translator {
	static tr(id,vars) {
		let translation = id;
		if(arm_Config.raw.locale != "en" && Object.prototype.hasOwnProperty.call(arm_Translator.translations.h,id)) {
			translation = arm_Translator.translations.h[id];
		}
		if(vars != null) {
			let h = vars.h;
			let _g_keys = Object.keys(h);
			let _g_length = _g_keys.length;
			let _g_current = 0;
			while(_g_current < _g_length) {
				let key = _g_keys[_g_current++];
				let _g1_value = h[key];
				translation = StringTools.replace(translation,"{" + key + "}",_g1_value == null ? "null" : "" + _g1_value);
			}
		}
		return translation;
	}
	static loadTranslations(newLocale) {
		if(newLocale == "system") {
			arm_Config.raw.locale = Krom.language();
		}
		if(arm_Config.raw.locale != "en" && arm_Translator.getSupportedLocales().indexOf(arm_Config.raw.locale) == -1) {
			arm_Config.raw.locale = "en";
		}
		arm_Translator.translations.h = Object.create(null);
		if(arm_Config.raw.locale == "en" && arm_Translator.lastLocale == "en") {
			return;
		}
		arm_Translator.lastLocale = arm_Config.raw.locale;
		if(arm_Config.raw.locale != "en") {
			let data = JSON.parse(haxe_io_Bytes.ofData(Krom.loadBlob("data/locale/" + arm_Config.raw.locale + ".json")).toString());
			let _g_keys = Reflect.fields(data);
			let _g_index = 0;
			while(_g_index < _g_keys.length) {
				let key = _g_keys[_g_index++];
				arm_Translator.translations.h[key == null ? "null" : "" + key] = data[key];
			}
		}
		arm_Translator.extendedGlyphs();
		let cjk = false;
		let h = arm_Translator.translations.h;
		let s_keys = Object.keys(h);
		let s_length = s_keys.length;
		let s_current = 0;
		while(s_current < s_length) {
			let s = h[s_keys[s_current++]];
			let _g = 0;
			let _g1 = s.length;
			while(_g < _g1) {
				let i = _g++;
				if(HxOverrides.cca(s,i) > 1119 && kha_graphics2_Graphics.fontGlyphs.indexOf(HxOverrides.cca(s,i)) == -1) {
					if(!cjk) {
						let _g = [];
						let _g1 = 32;
						while(_g1 < 127) _g.push(_g1++);
						kha_graphics2_Graphics.fontGlyphs = _g;
						cjk = true;
					}
					kha_graphics2_Graphics.fontGlyphs.push(HxOverrides.cca(s,i));
				}
			}
		}
		let newFont = { path : "font.ttf", scale : 1.0};
		if(cjk) {
			newFont = { path : "font_cjk.ttc", scale : 1.4};
			let cjkFontPath = arm_sys_Path.data() + arm_sys_Path.sep + newFont.path;
			if(!arm_sys_File.exists(cjkFontPath)) {
				arm_sys_File.download("https://github.com/armory3d/armorbase/raw/main/Assets/common/extra/font_cjk.ttc",cjkFontPath,function() {
					if(!arm_sys_File.exists(cjkFontPath)) {
						arm_Config.raw.locale = "en";
						arm_Translator.extendedGlyphs();
						arm_Translator.translations.h = Object.create(null);
						newFont = { path : "font.ttf", scale : 1.0};
						arm_Translator.initFont(false,newFont);
					} else {
						arm_Translator.initFont(true,newFont);
					}
				},20332392);
			} else {
				arm_Translator.initFont(true,newFont);
			}
		} else {
			arm_Translator.initFont(false,newFont);
		}
	}
	static initFont(cjk,newFont) {
		kha_graphics2_Graphics.fontGlyphs.sort(Reflect.compare);
		iron_App.notifyOnInit(function() {
			iron_data_Data.getFont(newFont.path,function(f) {
				if(cjk) {
					f.setFontIndex(Object.prototype.hasOwnProperty.call(arm_Translator.cjkFontIndices.h,arm_Config.raw.locale) ? arm_Translator.cjkFontIndices.h[arm_Config.raw.locale] : 0);
				}
				arm_App.font = f;
				arm_App.theme.FONT_SIZE = arm_App.defaultFontSize * newFont.scale | 0;
				arm_App.theme.ELEMENT_W = arm_App.defaultElementW * (arm_Config.raw.locale != "en" ? 1.4 : 1.0) | 0;
				let uis = arm_App.getUIs();
				let _g = 0;
				while(_g < uis.length) {
					let ui = uis[_g];
					++_g;
					ui.ops.font = f;
					ui.setScale(ui.ops.scaleFactor);
				}
			});
		});
	}
	static extendedGlyphs() {
		let _g = [];
		let _g1 = 32;
		while(_g1 < 383) _g.push(_g1++);
		kha_graphics2_Graphics.fontGlyphs = _g;
		let _g2 = 880;
		while(_g2 < 1023) kha_graphics2_Graphics.fontGlyphs.push(_g2++);
		let _g3 = 1024;
		while(_g3 < 1119) kha_graphics2_Graphics.fontGlyphs.push(_g3++);
	}
	static getSupportedLocales() {
		let locales = ["system","en"];
		let _g = 0;
		let _g1 = arm_sys_File.readDirectory(arm_sys_Path.data() + arm_sys_Path.sep + "locale");
		while(_g < _g1.length) locales.push(HxOverrides.substr(_g1[_g++],0,-5));
		return locales;
	}
}
$hxClasses["arm.Translator"] = arm_Translator;
arm_Translator.__name__ = "arm.Translator";
class arm_data_BrushSlot {
	constructor(c) {
		this.id = 0;
		this.previewReady = false;
		this.imageIcon = null;
		this.image = null;
		this.nodes = new zui_Nodes();
		let _g = 0;
		let _g1 = arm_Project.brushes;
		while(_g < _g1.length) {
			let brush = _g1[_g];
			++_g;
			if(brush.id >= this.id) {
				this.id = brush.id + 1;
			}
		}
		if(c == null) {
			if(arm_data_BrushSlot.defaultCanvas == null) {
				iron_data_Data.getBlob("default_brush.arm",function(b) {
					arm_data_BrushSlot.defaultCanvas = b;
				});
			}
			let i = new haxe_io_BytesInput(arm_data_BrushSlot.defaultCanvas.toBytes());
			i.set_bigEndian(false);
			this.canvas = iron_system_ArmPack.read(i);
			this.canvas.name = "Brush " + (this.id + 1);
		} else {
			this.canvas = c;
		}
	}
}
$hxClasses["arm.data.BrushSlot"] = arm_data_BrushSlot;
arm_data_BrushSlot.__name__ = "arm.data.BrushSlot";
Object.assign(arm_data_BrushSlot.prototype, {
	__class__: arm_data_BrushSlot
});
class arm_data_ConstData {
	static initLTC() {
		iron_data_Data.getBlob("ltc_mat.arm",function(ltc_mat) {
			iron_data_Data.getBlob("ltc_mag.arm",function(ltc_mag) {
				let i = new haxe_io_BytesInput(ltc_mat.toBytes());
				i.set_bigEndian(false);
				arm_data_ConstData.ltcMatTex = kha_Image.fromBytes(iron_system_ArmPack.read(i),64,64,2);
				let i1 = new haxe_io_BytesInput(ltc_mag.toBytes());
				i1.set_bigEndian(false);
				arm_data_ConstData.ltcMagTex = kha_Image.fromBytes(iron_system_ArmPack.read(i1),64,64,5);
			});
		});
	}
}
$hxClasses["arm.data.ConstData"] = arm_data_ConstData;
arm_data_ConstData.__name__ = "arm.data.ConstData";
class arm_data_FontSlot {
	constructor(name,font,file) {
		if(file == null) {
			file = "";
		}
		this.id = 0;
		this.previewReady = false;
		this.image = null;
		let _g = 0;
		let _g1 = arm_Project.fonts;
		while(_g < _g1.length) {
			let slot = _g1[_g];
			++_g;
			if(slot.id >= this.id) {
				this.id = slot.id + 1;
			}
		}
		this.name = name;
		this.font = font;
		this.file = file;
	}
}
$hxClasses["arm.data.FontSlot"] = arm_data_FontSlot;
arm_data_FontSlot.__name__ = "arm.data.FontSlot";
Object.assign(arm_data_FontSlot.prototype, {
	__class__: arm_data_FontSlot
});
class arm_data_LayerSlot {
	constructor(ext,type,parent) {
		if(type == null) {
			type = 0;
		}
		if(ext == null) {
			ext = "";
		}
		this.decalMat = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
		this.paintSubs = true;
		this.paintEmis = true;
		this.paintHeightBlend = true;
		this.paintHeight = true;
		this.paintNorBlend = true;
		this.paintNor = true;
		this.paintMet = true;
		this.paintRough = true;
		this.paintOcc = true;
		this.paintOpac = true;
		this.paintBase = true;
		this.uvType = 0;
		this.angle = 0.0;
		this.scale = 1.0;
		this.objectMask = 0;
		this.blending = 0;
		this.show_panel = true;
		this.fill_layer = null;
		this.maskOpacity = 1.0;
		this.texpaint_preview = null;
		this.texpaint_pack = null;
		this.texpaint_nor = null;
		this.texpaint = null;
		this.parent = null;
		this.visible = true;
		this.ext = "";
		this.id = 0;
		if(ext == "") {
			this.id = 0;
			let _g = 0;
			let _g1 = arm_Project.layers;
			while(_g < _g1.length) {
				let l = _g1[_g];
				++_g;
				if(l.id >= this.id) {
					this.id = l.id + 1;
				}
			}
			ext = this.id + "";
		}
		this.ext = ext;
		this.parent = parent;
		if(type == 2) {
			this.name = "Group " + (this.id + 1);
		} else if(type == 0) {
			this.name = "Layer " + (this.id + 1);
			let format = arm_App.bitsHandle.position == 0 ? "RGBA32" : arm_App.bitsHandle.position == 1 ? "RGBA64" : "RGBA128";
			let t = new iron_RenderTargetRaw();
			t.name = "texpaint" + ext;
			t.width = arm_Config.getTextureResX();
			t.height = arm_Config.getTextureResY();
			t.format = format;
			this.texpaint = iron_RenderPath.active.createRenderTarget(t).image;
			let t1 = new iron_RenderTargetRaw();
			t1.name = "texpaint_nor" + ext;
			t1.width = arm_Config.getTextureResX();
			t1.height = arm_Config.getTextureResY();
			t1.format = format;
			this.texpaint_nor = iron_RenderPath.active.createRenderTarget(t1).image;
			let t2 = new iron_RenderTargetRaw();
			t2.name = "texpaint_pack" + ext;
			t2.width = arm_Config.getTextureResX();
			t2.height = arm_Config.getTextureResY();
			t2.format = format;
			this.texpaint_pack = iron_RenderPath.active.createRenderTarget(t2).image;
			this.texpaint_preview = kha_Image.createRenderTarget(200,200,0);
		} else {
			this.name = "Mask " + (this.id + 1);
			this.blending = 7;
			let t = new iron_RenderTargetRaw();
			t.name = "texpaint" + ext;
			t.width = arm_Config.getTextureResX();
			t.height = arm_Config.getTextureResY();
			t.format = "RGBA32";
			this.texpaint = iron_RenderPath.active.createRenderTarget(t).image;
			this.texpaint_preview = kha_Image.createRenderTarget(200,200,0);
		}
	}
	delete() {
		this.unload();
		let masks = this.getMasks();
		if(masks != null) {
			let _g = 0;
			while(_g < masks.length) masks[_g++].delete();
		}
		let children = this.getChildren();
		if(children != null) {
			let _g = 0;
			while(_g < children.length) children[_g++].parent = null;
		}
		let lpos = arm_Project.layers.indexOf(this);
		HxOverrides.remove(arm_Project.layers,this);
		if(arm_Project.layers.length > 0) {
			arm_Context.setLayer(arm_Project.layers[lpos > 0 ? lpos - 1 : 0]);
		}
	}
	unload() {
		if(this.isGroup()) {
			return;
		}
		let _texpaint = this.texpaint;
		let _texpaint_nor = this.texpaint_nor;
		let _texpaint_pack = this.texpaint_pack;
		let _texpaint_preview = this.texpaint_preview;
		arm_App.notifyOnNextFrame(function() {
			_texpaint.unload();
			if(_texpaint_nor != null) {
				_texpaint_nor.unload();
			}
			if(_texpaint_pack != null) {
				_texpaint_pack.unload();
			}
			_texpaint_preview.unload();
		});
		let key = "texpaint" + this.ext;
		let _this = iron_RenderPath.active.renderTargets;
		if(Object.prototype.hasOwnProperty.call(_this.h,key)) {
			delete(_this.h[key]);
		}
		if(this.isLayer()) {
			let key = "texpaint_nor" + this.ext;
			let _this = iron_RenderPath.active.renderTargets;
			if(Object.prototype.hasOwnProperty.call(_this.h,key)) {
				delete(_this.h[key]);
			}
			let key1 = "texpaint_pack" + this.ext;
			let _this1 = iron_RenderPath.active.renderTargets;
			if(Object.prototype.hasOwnProperty.call(_this1.h,key1)) {
				delete(_this1.h[key1]);
			}
		}
	}
	swap(other) {
		iron_RenderPath.active.renderTargets.h["texpaint" + this.ext].image = other.texpaint;
		iron_RenderPath.active.renderTargets.h["texpaint" + other.ext].image = this.texpaint;
		let _texpaint = this.texpaint;
		this.texpaint = other.texpaint;
		other.texpaint = _texpaint;
		let _texpaint_preview = this.texpaint_preview;
		this.texpaint_preview = other.texpaint_preview;
		other.texpaint_preview = _texpaint_preview;
		if(this.isLayer() && other.isLayer()) {
			iron_RenderPath.active.renderTargets.h["texpaint_nor" + this.ext].image = other.texpaint_nor;
			iron_RenderPath.active.renderTargets.h["texpaint_pack" + this.ext].image = other.texpaint_pack;
			iron_RenderPath.active.renderTargets.h["texpaint_nor" + other.ext].image = this.texpaint_nor;
			iron_RenderPath.active.renderTargets.h["texpaint_pack" + other.ext].image = this.texpaint_pack;
			let _texpaint_nor = this.texpaint_nor;
			let _texpaint_pack = this.texpaint_pack;
			this.texpaint_nor = other.texpaint_nor;
			this.texpaint_pack = other.texpaint_pack;
			other.texpaint_nor = _texpaint_nor;
			other.texpaint_pack = _texpaint_pack;
		}
	}
	clear(baseColor,baseImage) {
		if(baseColor == null) {
			baseColor = 0;
		}
		this.texpaint.get_g4().begin();
		this.texpaint.get_g4().clear(baseColor);
		this.texpaint.get_g4().end();
		if(baseImage != null) {
			this.texpaint.get_g2().begin(false);
			this.texpaint.get_g2().drawScaledImage(baseImage,0,0,this.texpaint.get_width(),this.texpaint.get_height());
			this.texpaint.get_g2().end();
		}
		if(this.isLayer()) {
			this.texpaint_nor.get_g4().begin();
			this.texpaint_nor.get_g4().clear(kha_Color.fromFloats(0.5,0.5,1.0,0.0));
			this.texpaint_nor.get_g4().end();
			this.texpaint_pack.get_g4().begin();
			this.texpaint_pack.get_g4().clear(kha_Color.fromFloats(1.0,0.4,0.0,0.0));
			this.texpaint_pack.get_g4().end();
		}
		arm_Context.layerPreviewDirty = true;
		arm_Context.ddirty = 3;
	}
	invertMask() {
		if(arm_Layers.pipeInvert8 == null) {
			arm_Layers.makePipe();
		}
		let inverted = kha_Image.createRenderTarget(this.texpaint.get_width(),this.texpaint.get_height(),0);
		inverted.get_g2().begin(false);
		inverted.get_g2().set_pipeline(arm_Layers.pipeInvert8);
		inverted.get_g2().drawImage(this.texpaint,0,0);
		inverted.get_g2().set_pipeline(null);
		inverted.get_g2().end();
		let _texpaint = this.texpaint;
		arm_App.notifyOnNextFrame(function() {
			_texpaint.unload();
		});
		this.texpaint = iron_RenderPath.active.renderTargets.h["texpaint" + this.id].image = inverted;
		arm_Context.layerPreviewDirty = true;
		arm_Context.ddirty = 3;
	}
	applyMask() {
		if(this.parent.fill_layer != null) {
			this.parent.toPaintLayer();
		}
		if(this.parent.isGroup()) {
			let _g = 0;
			let _g1 = this.parent.getChildren();
			while(_g < _g1.length) arm_Layers.applyMask(_g1[_g++],this);
		} else {
			arm_Layers.applyMask(this.parent,this);
		}
		this.delete();
	}
	duplicate() {
		let layers = arm_Project.layers;
		let i = layers.indexOf(this) + 1;
		let l = new arm_data_LayerSlot("",this.isLayer() ? 0 : this.isMask() ? 1 : 2,this.parent);
		layers.splice(i,0,l);
		if(arm_Layers.pipeMerge == null) {
			arm_Layers.makePipe();
		}
		if(this.isLayer()) {
			l.texpaint.get_g2().begin(false);
			l.texpaint.get_g2().set_pipeline(arm_Layers.pipeCopy);
			l.texpaint.get_g2().drawImage(this.texpaint,0,0);
			l.texpaint.get_g2().set_pipeline(null);
			l.texpaint.get_g2().end();
			l.texpaint_nor.get_g2().begin(false);
			l.texpaint_nor.get_g2().set_pipeline(arm_Layers.pipeCopy);
			l.texpaint_nor.get_g2().drawImage(this.texpaint_nor,0,0);
			l.texpaint_nor.get_g2().set_pipeline(null);
			l.texpaint_nor.get_g2().end();
			l.texpaint_pack.get_g2().begin(false);
			l.texpaint_pack.get_g2().set_pipeline(arm_Layers.pipeCopy);
			l.texpaint_pack.get_g2().drawImage(this.texpaint_pack,0,0);
			l.texpaint_pack.get_g2().set_pipeline(null);
			l.texpaint_pack.get_g2().end();
		} else if(this.isMask()) {
			l.texpaint.get_g2().begin(false);
			l.texpaint.get_g2().set_pipeline(arm_Layers.pipeCopy8);
			l.texpaint.get_g2().drawImage(this.texpaint,0,0);
			l.texpaint.get_g2().set_pipeline(null);
			l.texpaint.get_g2().end();
		}
		l.texpaint_preview.get_g2().begin(true,0);
		l.texpaint_preview.get_g2().set_pipeline(arm_Layers.pipeCopy);
		l.texpaint_preview.get_g2().drawScaledImage(this.texpaint_preview,0,0,this.texpaint_preview.get_width(),this.texpaint_preview.get_height());
		l.texpaint_preview.get_g2().set_pipeline(null);
		l.texpaint_preview.get_g2().end();
		l.visible = this.visible;
		l.maskOpacity = this.maskOpacity;
		l.fill_layer = this.fill_layer;
		l.objectMask = this.objectMask;
		l.blending = this.blending;
		l.uvType = this.uvType;
		l.paintBase = this.paintBase;
		l.paintOpac = this.paintOpac;
		l.paintOcc = this.paintOcc;
		l.paintRough = this.paintRough;
		l.paintMet = this.paintMet;
		l.paintNor = this.paintNor;
		l.paintHeight = this.paintHeight;
		l.paintEmis = this.paintEmis;
		l.paintSubs = this.paintSubs;
		return l;
	}
	resizeAndSetBits() {
		let resX = arm_Config.getTextureResX();
		let resY = arm_Config.getTextureResY();
		let rts = iron_RenderPath.active.renderTargets;
		if(arm_Layers.pipeMerge == null) {
			arm_Layers.makePipe();
		}
		if(this.isLayer()) {
			let format = arm_App.bitsHandle.position == 0 ? 0 : arm_App.bitsHandle.position == 1 ? 4 : 2;
			let _texpaint = this.texpaint;
			let _texpaint_nor = this.texpaint_nor;
			let _texpaint_pack = this.texpaint_pack;
			this.texpaint = kha_Image.createRenderTarget(resX,resY,format);
			this.texpaint_nor = kha_Image.createRenderTarget(resX,resY,format);
			this.texpaint_pack = kha_Image.createRenderTarget(resX,resY,format);
			this.texpaint.get_g2().begin(false);
			this.texpaint.get_g2().set_pipeline(arm_Layers.pipeCopy);
			this.texpaint.get_g2().drawScaledImage(_texpaint,0,0,resX,resY);
			this.texpaint.get_g2().set_pipeline(null);
			this.texpaint.get_g2().end();
			this.texpaint_nor.get_g2().begin(false);
			this.texpaint_nor.get_g2().set_pipeline(arm_Layers.pipeCopy);
			this.texpaint_nor.get_g2().drawScaledImage(_texpaint_nor,0,0,resX,resY);
			this.texpaint_nor.get_g2().set_pipeline(null);
			this.texpaint_nor.get_g2().end();
			this.texpaint_pack.get_g2().begin(false);
			this.texpaint_pack.get_g2().set_pipeline(arm_Layers.pipeCopy);
			this.texpaint_pack.get_g2().drawScaledImage(_texpaint_pack,0,0,resX,resY);
			this.texpaint_pack.get_g2().set_pipeline(null);
			this.texpaint_pack.get_g2().end();
			arm_App.notifyOnNextFrame(function() {
				_texpaint.unload();
				_texpaint_nor.unload();
				_texpaint_pack.unload();
			});
			rts.h["texpaint" + this.ext].image = this.texpaint;
			rts.h["texpaint_nor" + this.ext].image = this.texpaint_nor;
			rts.h["texpaint_pack" + this.ext].image = this.texpaint_pack;
		} else if(this.isMask()) {
			let _texpaint = this.texpaint;
			this.texpaint = kha_Image.createRenderTarget(resX,resY,0);
			this.texpaint.get_g2().begin(false);
			this.texpaint.get_g2().set_pipeline(arm_Layers.pipeCopy8);
			this.texpaint.get_g2().drawScaledImage(_texpaint,0,0,resX,resY);
			this.texpaint.get_g2().set_pipeline(null);
			this.texpaint.get_g2().end();
			arm_App.notifyOnNextFrame(function() {
				_texpaint.unload();
			});
			rts.h["texpaint" + this.ext].image = this.texpaint;
		}
	}
	toFillLayer() {
		arm_Context.setLayer(this);
		this.fill_layer = arm_Context.material;
		arm_Layers.updateFillLayer();
		arm_App.notifyOnNextFrame(function() {
			arm_node_MakeMaterial.parsePaintMaterial();
			arm_Context.layerPreviewDirty = true;
			arm_ui_UISidebar.inst.hwnd0.redraws = 2;
		});
	}
	toPaintLayer() {
		arm_Context.setLayer(this);
		this.fill_layer = null;
		arm_node_MakeMaterial.parsePaintMaterial();
		arm_Context.layerPreviewDirty = true;
		arm_ui_UISidebar.inst.hwnd0.redraws = 2;
	}
	isVisible() {
		if(this.visible) {
			if(this.parent != null) {
				return this.parent.visible;
			} else {
				return true;
			}
		} else {
			return false;
		}
	}
	getChildren() {
		let children = null;
		let _g = 0;
		let _g1 = arm_Project.layers;
		while(_g < _g1.length) {
			let l = _g1[_g];
			++_g;
			if(l.parent == this && l.isLayer()) {
				if(children == null) {
					children = [];
				}
				children.push(l);
			}
		}
		return children;
	}
	getMasks(includeGroupMasks) {
		if(includeGroupMasks == null) {
			includeGroupMasks = true;
		}
		if(this.isMask()) {
			return null;
		}
		let children = null;
		let _g = 0;
		let _g1 = arm_Project.layers;
		while(_g < _g1.length) {
			let l = _g1[_g];
			++_g;
			if(l.parent == this && l.isMask()) {
				if(children == null) {
					children = [];
				}
				children.push(l);
			}
		}
		if(includeGroupMasks) {
			if(this.parent != null && this.parent.isGroup()) {
				let _g = 0;
				let _g1 = arm_Project.layers;
				while(_g < _g1.length) {
					let l = _g1[_g];
					++_g;
					if(l.parent == this.parent && l.isMask()) {
						if(children == null) {
							children = [];
						}
						children.push(l);
					}
				}
			}
		}
		return children;
	}
	hasMasks() {
		let _g = 0;
		let _g1 = arm_Project.layers;
		while(_g < _g1.length) {
			let l = _g1[_g];
			++_g;
			if(l.parent == this && l.isMask()) {
				return true;
			}
		}
		if(this.parent != null && this.parent.isGroup()) {
			let _g = 0;
			let _g1 = arm_Project.layers;
			while(_g < _g1.length) {
				let l = _g1[_g];
				++_g;
				if(l.parent == this.parent && l.isMask()) {
					return true;
				}
			}
		}
		return false;
	}
	getOpacity() {
		let f = this.maskOpacity;
		if(this.isLayer() && this.parent != null) {
			f *= this.parent.maskOpacity;
		}
		return f;
	}
	getObjectMask() {
		if(this.isMask()) {
			return this.parent.objectMask;
		} else {
			return this.objectMask;
		}
	}
	isLayer() {
		if(this.texpaint != null) {
			return this.texpaint_nor != null;
		} else {
			return false;
		}
	}
	isGroup() {
		return this.texpaint == null;
	}
	isMask() {
		if(this.texpaint != null) {
			return this.texpaint_nor == null;
		} else {
			return false;
		}
	}
	canMove(to) {
		let i = arm_Project.layers.indexOf(this);
		let delta = to - i;
		if(i + delta < 0 || i + delta > arm_Project.layers.length - 1 || delta == 0) {
			return false;
		}
		let isGroup = this.isGroup();
		let isMask = this.isMask();
		let isLayer = this.isLayer();
		let j = delta > 0 ? to : to == 0 ? 0 : to - 1;
		let k = delta > 0 ? to + 1 : to;
		let jParent = j >= 0 ? arm_Project.layers[j].parent : null;
		let kIsGroup = k < arm_Project.layers.length && arm_Project.layers[k].isGroup();
		let kIsMask = k < arm_Project.layers.length && arm_Project.layers[k].isMask();
		let jIsMask = j < arm_Project.layers.length && arm_Project.layers[j].isMask();
		if(isGroup && jParent != null && jParent.show_panel) {
			return false;
		}
		if(isMask && kIsGroup) {
			return false;
		}
		if(isMask && i + delta == arm_Project.layers.length - 1) {
			return false;
		}
		if(isGroup && kIsMask) {
			return false;
		}
		if(isLayer && kIsMask) {
			return false;
		}
		if(isLayer && jIsMask) {
			return false;
		}
		return true;
	}
	move(to) {
		if(!this.canMove(to)) {
			return;
		}
		let i = arm_Project.layers.indexOf(this);
		let delta = to - i;
		let pointers = arm_ui_TabLayers.initLayerMap();
		let isGroup = this.isGroup();
		let isMask = this.isMask();
		let j = delta > 0 ? to : to == 0 ? 0 : to - 1;
		let k = delta > 0 ? to + 1 : to;
		let jParent = j >= 0 ? arm_Project.layers[j].parent : null;
		let kParent = k < arm_Project.layers.length ? arm_Project.layers[k].parent : null;
		let kIsGroup = k < arm_Project.layers.length && arm_Project.layers[k].isGroup();
		let kIsMask = k < arm_Project.layers.length && arm_Project.layers[k].isMask();
		let kIsLayer = k < arm_Project.layers.length && arm_Project.layers[k].isLayer();
		let kLayer = k < arm_Project.layers.length ? arm_Project.layers[k] : null;
		if(kIsGroup && !kLayer.show_panel) {
			delta -= kLayer.getChildren().length;
		}
		if(kIsLayer && kLayer.getMasks() != null && !kLayer.show_panel) {
			delta -= kLayer.getMasks().length;
		}
		arm_Context.setLayer(this);
		arm_History.orderLayers(i + delta);
		arm_ui_UISidebar.inst.hwnd0.redraws = 2;
		HxOverrides.remove(arm_Project.layers,this);
		arm_Project.layers.splice(i + delta,0,this);
		if(isGroup) {
			let children = this.getChildren();
			let _g = 0;
			let _g1 = children.length;
			while(_g < _g1) {
				let l = _g++;
				let c = children[delta > 0 ? l : children.length - 1 - l];
				HxOverrides.remove(arm_Project.layers,c);
				arm_Project.layers.splice(delta > 0 ? i + delta - 1 : i + delta,0,c);
				let lmasks = c.getMasks();
				if(lmasks != null) {
					let _g = 0;
					let _g1 = lmasks.length;
					while(_g < _g1) {
						let m = _g++;
						let mc = lmasks[delta > 0 ? m : lmasks.length - 1 - m];
						HxOverrides.remove(arm_Project.layers,mc);
						arm_Project.layers.splice(delta > 0 ? i + delta - 2 : i + delta,0,mc);
					}
				}
			}
		} else if(isMask) {
			if(kIsMask && kParent != this.parent) {
				this.parent = kParent;
			}
			if(kIsLayer && kLayer != this.parent) {
				this.parent = kLayer;
			}
		} else {
			if(this.parent == null && jParent != null && jParent.show_panel) {
				this.parent = jParent;
			}
			let oldParent = null;
			if(this.parent != null && kParent == null && !kIsGroup) {
				oldParent = this.parent;
				this.parent = null;
			}
			if(this.parent != null && (kParent != null && kParent.show_panel || kIsGroup)) {
				oldParent = this.parent;
				this.parent = kIsGroup ? kLayer : kParent;
			}
			let lmasks = this.getMasks();
			if(lmasks != null) {
				let _g = 0;
				let _g1 = lmasks.length;
				while(_g < _g1) {
					let m = _g++;
					let mc = lmasks[delta > 0 ? m : lmasks.length - 1 - m];
					HxOverrides.remove(arm_Project.layers,mc);
					arm_Project.layers.splice(delta > 0 ? i + delta - 1 : i + delta,0,mc);
				}
			}
			if(oldParent != null && oldParent.getChildren() == null) {
				oldParent.delete();
			}
		}
		let _g = 0;
		let _g1 = arm_Project.materials;
		while(_g < _g1.length) arm_ui_TabLayers.remapLayerPointers(_g1[_g++].canvas.nodes,arm_ui_TabLayers.fillLayerMap(pointers));
	}
}
$hxClasses["arm.data.LayerSlot"] = arm_data_LayerSlot;
arm_data_LayerSlot.__name__ = "arm.data.LayerSlot";
Object.assign(arm_data_LayerSlot.prototype, {
	__class__: arm_data_LayerSlot
});
class arm_data_MaterialSlot {
	constructor(m,c) {
		this.paintSubs = true;
		this.paintEmis = true;
		this.paintHeight = true;
		this.paintNor = true;
		this.paintMet = true;
		this.paintRough = true;
		this.paintOcc = true;
		this.paintOpac = true;
		this.paintBase = true;
		this.id = 0;
		this.previewReady = false;
		this.imageIcon = null;
		this.image = null;
		this.nodes = new zui_Nodes();
		let _g = 0;
		let _g1 = arm_Project.materials;
		while(_g < _g1.length) {
			let mat = _g1[_g];
			++_g;
			if(mat.id >= this.id) {
				this.id = mat.id + 1;
			}
		}
		this.data = m;
		this.image = kha_Image.createRenderTarget(256,256);
		this.imageIcon = kha_Image.createRenderTarget(50,50);
		if(c == null) {
			if(arm_data_MaterialSlot.defaultCanvas == null) {
				iron_data_Data.getBlob("default_material.arm",function(b) {
					arm_data_MaterialSlot.defaultCanvas = b;
				});
			}
			let i = new haxe_io_BytesInput(arm_data_MaterialSlot.defaultCanvas.toBytes());
			i.set_bigEndian(false);
			this.canvas = iron_system_ArmPack.read(i);
			this.canvas.name = "Material " + (this.id + 1);
		} else {
			this.canvas = c;
		}
	}
	unload() {
		let _gthis = this;
		arm_App.notifyOnNextFrame(function() {
			_gthis.image.unload();
			_gthis.imageIcon.unload();
		});
	}
	delete() {
		this.unload();
		let mpos = arm_Project.materials.indexOf(this);
		HxOverrides.remove(arm_Project.materials,this);
		if(arm_Project.materials.length > 0) {
			arm_Context.setMaterial(arm_Project.materials[mpos > 0 ? mpos - 1 : 0]);
		}
	}
}
$hxClasses["arm.data.MaterialSlot"] = arm_data_MaterialSlot;
arm_data_MaterialSlot.__name__ = "arm.data.MaterialSlot";
Object.assign(arm_data_MaterialSlot.prototype, {
	__class__: arm_data_MaterialSlot
});
class arm_format_BlendParser {
	constructor(blob) {
		this.map = new haxe_ds_IntMap();
		this.dna = null;
		this.blocks = [];
		this.blob = blob;
		this.pos = 0;
		if(this.readChars(7) != "BLENDER") {
			this.blob = kha_Blob.fromBytes(haxe_io_Bytes.ofData(Krom.inflate(blob.toBytes().b.bufferValue,false)));
			this.pos = 0;
			if(this.readChars(7) != "BLENDER") {
				return;
			}
		}
		this.parse();
	}
	get(type) {
		if(this.dna == null) {
			return null;
		}
		let typeIndex = arm_format_BlendParser.getTypeIndex(this.dna,type);
		if(typeIndex == -1) {
			return null;
		}
		let ds = arm_format_BlendParser.getStruct(this.dna,typeIndex);
		let handles = [];
		let _g = 0;
		let _g1 = this.blocks;
		while(_g < _g1.length) {
			let b = _g1[_g];
			++_g;
			if(this.dna.structs[b.sdnaIndex].type == typeIndex) {
				let h = new arm_format_Handle();
				handles.push(h);
				h.block = b;
				h.ds = ds;
			}
		}
		return handles;
	}
	parse() {
		this.pointerSize = this.readChar() == "_" ? 4 : 8;
		this.littleEndian = this.readChar() == "v";
		if(this.littleEndian) {
			this.read16 = $bind(this,this.read16LE);
			this.read32 = $bind(this,this.read32LE);
			this.read64 = $bind(this,this.read64LE);
			this.readf32 = $bind(this,this.readf32LE);
		} else {
			this.read16 = $bind(this,this.read16BE);
			this.read32 = $bind(this,this.read32BE);
			this.read64 = $bind(this,this.read64BE);
			this.readf32 = $bind(this,this.readf32BE);
		}
		this.version = this.readChars(3);
		while(this.pos < this.blob.get_length()) {
			this.align();
			let b = new arm_format_Block();
			b.code = this.readChars(4);
			if(b.code == "ENDB") {
				break;
			}
			this.blocks.push(b);
			b.blend = this;
			b.size = this.read32();
			let addr = this.readPointer();
			if(!this.map.h.hasOwnProperty(addr.high)) {
				this.map.h[addr.high] = new haxe_ds_IntMap();
			}
			this.map.h[addr.high].h[addr.low] = b;
			b.sdnaIndex = this.read32();
			b.count = this.read32();
			b.pos = this.pos;
			if(b.code == "DNA1") {
				this.dna = new arm_format_Dna();
				this.readChars(4);
				this.readChars(4);
				let namesCount = this.read32();
				let _g = 0;
				while(_g < namesCount) {
					++_g;
					this.dna.names.push(this.readString());
				}
				this.align();
				this.readChars(4);
				let typesCount = this.read32();
				let _g1 = 0;
				while(_g1 < typesCount) {
					++_g1;
					this.dna.types.push(this.readString());
				}
				this.align();
				this.readChars(4);
				let _g2 = 0;
				while(_g2 < typesCount) {
					++_g2;
					this.dna.typesLength.push(this.read16());
				}
				this.align();
				this.readChars(4);
				let structCount = this.read32();
				let _g3 = 0;
				while(_g3 < structCount) {
					++_g3;
					let ds = new arm_format_DnaStruct();
					this.dna.structs.push(ds);
					ds.dna = this.dna;
					ds.type = this.read16();
					let fieldCount = this.read16();
					if(fieldCount > 0) {
						ds.fieldTypes = [];
						ds.fieldNames = [];
						let _g = 0;
						while(_g < fieldCount) {
							++_g;
							ds.fieldTypes.push(this.read16());
							ds.fieldNames.push(this.read16());
						}
					}
				}
			} else {
				this.pos += b.size;
			}
		}
	}
	align() {
		let mod = this.pos % 4;
		if(mod > 0) {
			this.pos += 4 - mod;
		}
	}
	read8() {
		let i = this.blob.readU8(this.pos);
		this.pos += 1;
		return i;
	}
	read16LE() {
		let i = this.blob.readS16LE(this.pos);
		this.pos += 2;
		return i;
	}
	read32LE() {
		let i = this.blob.readS32LE(this.pos);
		this.pos += 4;
		return i;
	}
	read64LE() {
		return new haxe__$Int64__$_$_$Int64(this.read32(),this.read32());
	}
	readf32LE() {
		let f = this.blob.readF32LE(this.pos);
		this.pos += 4;
		return f;
	}
	read16BE() {
		let i = this.blob.readS16BE(this.pos);
		this.pos += 2;
		return i;
	}
	read32BE() {
		let i = this.blob.readS32BE(this.pos);
		this.pos += 4;
		return i;
	}
	read64BE() {
		return new haxe__$Int64__$_$_$Int64(this.read32(),this.read32());
	}
	readf32BE() {
		let f = this.blob.readF32BE(this.pos);
		this.pos += 4;
		return f;
	}
	read8array(len) {
		let ar = new Int32Array(len);
		let _g = 0;
		while(_g < len) ar[_g++] = this.read8();
		return ar;
	}
	read16array(len) {
		let ar = new Int32Array(len);
		let _g = 0;
		while(_g < len) ar[_g++] = this.read16();
		return ar;
	}
	read32array(len) {
		let ar = new Int32Array(len);
		let _g = 0;
		while(_g < len) ar[_g++] = this.read32();
		return ar;
	}
	readf32array(len) {
		let ar = new Float32Array(len);
		let _g = 0;
		while(_g < len) ar[_g++] = this.readf32();
		return ar;
	}
	readString() {
		let s = "";
		while(true) {
			let ch = this.read8();
			if(ch == 0) {
				break;
			}
			s += String.fromCodePoint(ch);
		}
		return s;
	}
	readChars(len) {
		let s = "";
		let _g = 0;
		while(_g < len) {
			++_g;
			s += this.readChar();
		}
		return s;
	}
	readChar() {
		let code = this.read8();
		return String.fromCodePoint(code);
	}
	readPointer() {
		if(this.pointerSize == 4) {
			let x = this.read32();
			return new haxe__$Int64__$_$_$Int64(x >> 31,x);
		} else {
			return this.read64();
		}
	}
	static getStruct(dna,typeIndex) {
		let _g = 0;
		let _g1 = dna.structs;
		while(_g < _g1.length) {
			let ds = _g1[_g];
			++_g;
			if(ds.type == typeIndex) {
				return ds;
			}
		}
		return null;
	}
	static getTypeIndex(dna,type) {
		let _g = 0;
		let _g1 = dna.types.length;
		while(_g < _g1) {
			let i = _g++;
			if(type == dna.types[i]) {
				return i;
			}
		}
		return -1;
	}
}
$hxClasses["arm.format.BlendParser"] = arm_format_BlendParser;
arm_format_BlendParser.__name__ = "arm.format.BlendParser";
Object.assign(arm_format_BlendParser.prototype, {
	__class__: arm_format_BlendParser
});
class arm_format_Block {
	constructor() {
	}
}
$hxClasses["arm.format.Block"] = arm_format_Block;
arm_format_Block.__name__ = "arm.format.Block";
Object.assign(arm_format_Block.prototype, {
	__class__: arm_format_Block
});
class arm_format_Dna {
	constructor() {
		this.structs = [];
		this.typesLength = [];
		this.types = [];
		this.names = [];
	}
}
$hxClasses["arm.format.Dna"] = arm_format_Dna;
arm_format_Dna.__name__ = "arm.format.Dna";
Object.assign(arm_format_Dna.prototype, {
	__class__: arm_format_Dna
});
class arm_format_DnaStruct {
	constructor() {
	}
}
$hxClasses["arm.format.DnaStruct"] = arm_format_DnaStruct;
arm_format_DnaStruct.__name__ = "arm.format.DnaStruct";
Object.assign(arm_format_DnaStruct.prototype, {
	__class__: arm_format_DnaStruct
});
class arm_format_Handle {
	constructor() {
		this.offset = 0;
	}
	getSize(index) {
		let dna = this.ds.dna;
		let n = dna.names[this.ds.fieldNames[index]];
		let size = 0;
		if(n.indexOf("*") >= 0) {
			size = this.block.blend.pointerSize;
		} else {
			size = dna.typesLength[this.ds.fieldTypes[index]];
		}
		if(n.indexOf("[") > 0) {
			size *= this.getArrayLen(n);
		}
		return size;
	}
	baseName(s) {
		while(s.charAt(0) == "*") s = s.substring(1,s.length);
		if(s.charAt(s.length - 1) == "]") {
			s = s.substring(0,s.indexOf("["));
		}
		return s;
	}
	getArrayLen(s) {
		return Std.parseInt(s.substring(s.indexOf("[") + 1,s.indexOf("]")));
	}
	get(name,index,asType,arrayLen) {
		if(arrayLen == null) {
			arrayLen = 0;
		}
		if(index == null) {
			index = 0;
		}
		let dna = this.ds.dna;
		let _g = 0;
		let _g1 = this.ds.fieldNames.length;
		while(_g < _g1) {
			let i = _g++;
			let dnaName = dna.names[this.ds.fieldNames[i]];
			if(name == this.baseName(dnaName)) {
				let typeIndex = this.ds.fieldTypes[i];
				let type = dna.types[typeIndex];
				let newOffset = this.offset;
				let _g = 0;
				while(_g < i) newOffset += this.getSize(_g++);
				if(asType != null) {
					let _g = 0;
					let _g1 = dna.types.length;
					while(_g < _g1) {
						let i = _g++;
						if(dna.types[i] == asType) {
							typeIndex = i;
							break;
						}
					}
				}
				if(typeIndex < 12) {
					let blend = this.block.blend;
					blend.pos = this.block.pos + newOffset;
					let isArray = dnaName.charAt(dnaName.length - 1) == "]";
					let len = isArray ? arrayLen > 0 ? arrayLen : this.getArrayLen(dnaName) : 1;
					switch(type) {
					case "char":
						if(isArray) {
							return blend.readString();
						} else {
							return blend.read8();
						}
						break;
					case "double":
						return 0;
					case "float":
						if(isArray) {
							return blend.readf32array(len);
						} else {
							return blend.readf32();
						}
						break;
					case "int":
						if(isArray) {
							return blend.read32array(len);
						} else {
							return blend.read32();
						}
						break;
					case "int64_t":
						return blend.read64();
					case "long":
						if(isArray) {
							return blend.read32array(len);
						} else {
							return blend.read32();
						}
						break;
					case "short":
						if(isArray) {
							return blend.read16array(len);
						} else {
							return blend.read16();
						}
						break;
					case "uchar":
						if(isArray) {
							return blend.read8array(len);
						} else {
							return blend.read8();
						}
						break;
					case "uint64_t":
						return blend.read64();
					case "ulong":
						if(isArray) {
							return blend.read32array(len);
						} else {
							return blend.read32();
						}
						break;
					case "ushort":
						if(isArray) {
							return blend.read16array(len);
						} else {
							return blend.read16();
						}
						break;
					case "void":
						return 0;
					}
				}
				let h = new arm_format_Handle();
				h.ds = arm_format_BlendParser.getStruct(dna,typeIndex);
				if(dnaName.charAt(0) == "*") {
					this.block.blend.pos = this.block.pos + newOffset;
					let addr = this.block.blend.readPointer();
					if(this.block.blend.map.h.hasOwnProperty(addr.high)) {
						h.block = this.block.blend.map.h[addr.high].h[addr.low];
					} else {
						h.block = this.block;
					}
					h.offset = 0;
				} else {
					h.block = this.block;
					h.offset = newOffset;
				}
				h.offset += dna.typesLength[typeIndex] * index;
				return h;
			}
		}
		return null;
	}
}
$hxClasses["arm.format.Handle"] = arm_format_Handle;
arm_format_Handle.__name__ = "arm.format.Handle";
Object.assign(arm_format_Handle.prototype, {
	__class__: arm_format_Handle
});
class arm_format_ExrWriter {
	constructor(out,width,height,src,bits,type,off) {
		if(off == null) {
			off = 0;
		}
		if(type == null) {
			type = 1;
		}
		if(bits == null) {
			bits = 16;
		}
		out.writeByte(118);
		out.writeByte(47);
		out.writeByte(49);
		out.writeByte(1);
		out.writeByte(2);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeString("channels");
		out.writeByte(0);
		out.writeString("chlist");
		out.writeByte(0);
		out.writeByte(55);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		let attrib = bits == 16 ? 1 : 2;
		out.writeByte(66);
		out.writeByte(0);
		out.writeByte(attrib);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(1);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(1);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(71);
		out.writeByte(0);
		out.writeByte(attrib);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(1);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(1);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(82);
		out.writeByte(0);
		out.writeByte(attrib);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(1);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(1);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeString("compression");
		out.writeByte(0);
		out.writeString("compression");
		out.writeByte(0);
		out.writeByte(1);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeString("dataWindow");
		out.writeByte(0);
		out.writeString("box2i");
		out.writeByte(0);
		out.writeByte(16);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		let ww = width - 1;
		let hh = height - 1;
		out.writeByte(ww & 255);
		out.writeByte(ww >> 8 & 255);
		out.writeByte(ww >> 16 & 255);
		out.writeByte(ww >> 24 & 255);
		out.writeByte(hh & 255);
		out.writeByte(hh >> 8 & 255);
		out.writeByte(hh >> 16 & 255);
		out.writeByte(hh >> 24 & 255);
		out.writeString("displayWindow");
		out.writeByte(0);
		out.writeString("box2i");
		out.writeByte(0);
		out.writeByte(16);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(ww & 255);
		out.writeByte(ww >> 8 & 255);
		out.writeByte(ww >> 16 & 255);
		out.writeByte(ww >> 24 & 255);
		out.writeByte(hh & 255);
		out.writeByte(hh >> 8 & 255);
		out.writeByte(hh >> 16 & 255);
		out.writeByte(hh >> 24 & 255);
		out.writeString("lineOrder");
		out.writeByte(0);
		out.writeString("lineOrder");
		out.writeByte(0);
		out.writeByte(1);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeString("pixelAspectRatio");
		out.writeByte(0);
		out.writeString("float");
		out.writeByte(0);
		out.writeByte(4);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(128);
		out.writeByte(63);
		out.writeString("screenWindowCenter");
		out.writeByte(0);
		out.writeString("v2f");
		out.writeByte(0);
		out.writeByte(8);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeString("screenWindowWidth");
		out.writeByte(0);
		out.writeString("float");
		out.writeByte(0);
		out.writeByte(4);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(0);
		out.writeByte(128);
		out.writeByte(63);
		out.writeByte(0);
		let byteSize = bits == 16 ? 2 : 4;
		let pixelRowSize = width * 3 * byteSize;
		let fullRowSize = pixelRowSize + 8;
		let ofs = out.b.pos + 8 * height;
		let _g = 0;
		while(_g < height) {
			++_g;
			out.writeByte(ofs & 255);
			out.writeByte(ofs >> 8 & 255);
			out.writeByte(ofs >> 16 & 255);
			out.writeByte(ofs >> 24 & 255);
			out.writeByte(0);
			out.writeByte(0);
			out.writeByte(0);
			out.writeByte(0);
			ofs += fullRowSize;
		}
		let stride = 4 * byteSize;
		let pos = 0;
		let writeLine16 = function(bytePos) {
			let _g = 0;
			let _g1 = width;
			while(_g < _g1) {
				++_g;
				out.writeByte(src.b[bytePos]);
				out.writeByte(src.b[bytePos + 1]);
				bytePos += stride;
			}
		};
		let writeLine32 = function(bytePos) {
			let _g = 0;
			let _g1 = width;
			while(_g < _g1) {
				++_g;
				out.writeByte(src.b[bytePos]);
				out.writeByte(src.b[bytePos + 1]);
				out.writeByte(src.b[bytePos + 2]);
				out.writeByte(src.b[bytePos + 3]);
				bytePos += stride;
			}
		};
		let writeLine = bits == 16 ? writeLine16 : writeLine32;
		let writeBGR = function(off) {
			writeLine(pos + byteSize * 2);
			writeLine(pos + byteSize);
			writeLine(pos);
		};
		let writeSingle = function(off) {
			writeLine(pos + off * byteSize);
			writeLine(pos + off * byteSize);
			writeLine(pos + off * byteSize);
		};
		let writeData = type == 1 ? writeBGR : writeSingle;
		let _g1 = 0;
		while(_g1 < height) {
			let y = _g1++;
			out.writeByte(y & 255);
			out.writeByte(y >> 8 & 255);
			out.writeByte(y >> 16 & 255);
			out.writeByte(y >> 24 & 255);
			out.writeByte(pixelRowSize & 255);
			out.writeByte(pixelRowSize >> 8 & 255);
			out.writeByte(pixelRowSize >> 16 & 255);
			out.writeByte(pixelRowSize >> 24 & 255);
			writeData(off);
			pos += width * stride;
		}
	}
}
$hxClasses["arm.format.ExrWriter"] = arm_format_ExrWriter;
arm_format_ExrWriter.__name__ = "arm.format.ExrWriter";
Object.assign(arm_format_ExrWriter.prototype, {
	__class__: arm_format_ExrWriter
});
class arm_format_FbxBinaryParser {
	constructor(blob) {
		this.blob = blob;
		this.pos = 0;
		if(this.readChars("Kaydara FBX Binary  \x00\x1A\x00".length) != "Kaydara FBX Binary  \x00\x1A\x00") {
			return;
		}
		this.is64 = this.read32() >= 7500;
		this.root = { name : "Root", props : [arm_format_FbxProp.PInt(0),arm_format_FbxProp.PString("Root"),arm_format_FbxProp.PString("Root")], childs : this.parseNodes()};
	}
	parseArray(readVal,isFloat) {
		if(isFloat == null) {
			isFloat = false;
		}
		let len = this.read32();
		let encoding = this.read32();
		let compressedLen = this.read32();
		let endPos = this.pos + compressedLen;
		let _blob = this.blob;
		if(encoding != 0) {
			this.pos += 2;
			this.blob = kha_Blob.fromBytes(haxe_io_Bytes.ofData(Krom.inflate(this.blob.sub(this.pos,compressedLen).toBytes().b.bufferValue,true)));
			this.pos = 0;
		}
		let res = isFloat ? this.parseArrayf(readVal,len) : this.parseArrayi(readVal,len);
		if(encoding != 0) {
			this.pos = endPos;
			this.blob = _blob;
		}
		return res;
	}
	parseArrayf(readVal,len) {
		let res = [];
		let _g = 0;
		while(_g < len) {
			++_g;
			res.push(readVal());
		}
		return arm_format_FbxProp.PFloats(res);
	}
	parseArrayi(readVal,len) {
		let res = [];
		let _g = 0;
		while(_g < len) {
			++_g;
			res.push(readVal());
		}
		return arm_format_FbxProp.PInts(res);
	}
	parseProp() {
		switch(this.readChar()) {
		case "C":
			return arm_format_FbxProp.PString(this.readChar());
		case "D":
			return arm_format_FbxProp.PFloat(this.readf64());
		case "F":
			return arm_format_FbxProp.PFloat(this.readf32());
		case "I":
			return arm_format_FbxProp.PInt(this.read32());
		case "L":
			return arm_format_FbxProp.PInt(this.read64());
		case "R":
			this.readBytes(this.read32());
			return null;
		case "S":
			return arm_format_FbxProp.PString(this.readChars(this.read32()));
		case "Y":
			return arm_format_FbxProp.PInt(this.read16());
		case "b":
			return this.parseArray($bind(this,this.readBool));
		case "d":
			return this.parseArray($bind(this,this.readf64),true);
		case "f":
			return this.parseArray($bind(this,this.readf32),true);
		case "i":
			return this.parseArray($bind(this,this.read32));
		case "l":
			return this.parseArray($bind(this,this.read64));
		default:
			return null;
		}
	}
	parseNode() {
		let endPos = 0;
		let numProps = 0;
		if(this.is64) {
			endPos = this.read64();
			numProps = this.read64();
			this.read64();
		} else {
			endPos = this.read32();
			numProps = this.read32();
			this.read32();
		}
		let nameLen = this.read8();
		let name = nameLen == 0 ? "" : this.readChars(nameLen);
		if(endPos == 0) {
			return null;
		}
		let props = null;
		if(numProps > 0) {
			props = [];
		}
		let _g = 0;
		let _g1 = numProps;
		while(_g < _g1) {
			++_g;
			props.push(this.parseProp());
		}
		let childs = null;
		if(endPos - this.pos > 0) {
			childs = [];
			while(true) {
				let nested = this.parseNode();
				if(nested == null) {
					break;
				} else {
					childs.push(nested);
				}
			}
		}
		return { name : name, props : props, childs : childs};
	}
	parseNodes() {
		let nodes = [];
		while(true) {
			let n = this.parseNode();
			if(n == null) {
				break;
			} else {
				nodes.push(n);
			}
		}
		return nodes;
	}
	read8() {
		let i = this.blob.readU8(this.pos);
		this.pos += 1;
		return i;
	}
	read16() {
		let i = this.blob.readS16LE(this.pos);
		this.pos += 2;
		return i;
	}
	read32() {
		let i = this.blob.bytes.getInt32(this.pos);
		this.pos += 4;
		return i;
	}
	read64() {
		let i1 = this.read32();
		this.read32();
		return i1;
	}
	readf32() {
		let f = this.blob.readF32LE(this.pos);
		this.pos += 4;
		return f;
	}
	readf64() {
		return haxe_io_FPHelper.i64ToDouble(this.read32(),this.read32());
	}
	readChars(len) {
		let s = "";
		let _g = 0;
		while(_g < len) {
			++_g;
			s += this.readChar();
		}
		return s;
	}
	readChar() {
		let code = this.read8();
		return String.fromCodePoint(code);
	}
	readBool() {
		return this.read8();
	}
	readBytes(len) {
		let b = this.blob.sub(this.pos,len);
		this.pos += len;
		return b;
	}
	static parse(blob) {
		return new arm_format_FbxBinaryParser(blob).root;
	}
}
$hxClasses["arm.format.FbxBinaryParser"] = arm_format_FbxBinaryParser;
arm_format_FbxBinaryParser.__name__ = "arm.format.FbxBinaryParser";
Object.assign(arm_format_FbxBinaryParser.prototype, {
	__class__: arm_format_FbxBinaryParser
});
var arm_format_FbxProp = $hxEnums["arm.format.FbxProp"] = { __ename__:true,__constructs__:null
	,PInt: ($_=function(v) { return {_hx_index:0,v:v,__enum__:"arm.format.FbxProp",toString:$estr}; },$_._hx_name="PInt",$_.__params__ = ["v"],$_)
	,PFloat: ($_=function(v) { return {_hx_index:1,v:v,__enum__:"arm.format.FbxProp",toString:$estr}; },$_._hx_name="PFloat",$_.__params__ = ["v"],$_)
	,PString: ($_=function(v) { return {_hx_index:2,v:v,__enum__:"arm.format.FbxProp",toString:$estr}; },$_._hx_name="PString",$_.__params__ = ["v"],$_)
	,PIdent: ($_=function(i) { return {_hx_index:3,i:i,__enum__:"arm.format.FbxProp",toString:$estr}; },$_._hx_name="PIdent",$_.__params__ = ["i"],$_)
	,PInts: ($_=function(v) { return {_hx_index:4,v:v,__enum__:"arm.format.FbxProp",toString:$estr}; },$_._hx_name="PInts",$_.__params__ = ["v"],$_)
	,PFloats: ($_=function(v) { return {_hx_index:5,v:v,__enum__:"arm.format.FbxProp",toString:$estr}; },$_._hx_name="PFloats",$_.__params__ = ["v"],$_)
};
arm_format_FbxProp.__constructs__ = [arm_format_FbxProp.PInt,arm_format_FbxProp.PFloat,arm_format_FbxProp.PString,arm_format_FbxProp.PIdent,arm_format_FbxProp.PInts,arm_format_FbxProp.PFloats];
class arm_format_FbxTools {
	static get(n,path,opt) {
		if(opt == null) {
			opt = false;
		}
		let parts = path.split(".");
		let cur = n;
		let _g = 0;
		while(_g < parts.length) {
			let p = parts[_g];
			++_g;
			let found = false;
			let _g1 = 0;
			let _g2 = cur.childs;
			while(_g1 < _g2.length) {
				let c = _g2[_g1];
				++_g1;
				if(c.name == p) {
					cur = c;
					found = true;
					break;
				}
			}
			if(!found) {
				if(opt) {
					return null;
				}
				throw haxe_Exception.thrown(n.name + " does not have " + path + " (" + p + " not found)");
			}
		}
		return cur;
	}
	static getAll(n,path) {
		let parts = path.split(".");
		let cur = [n];
		let _g = 0;
		while(_g < parts.length) {
			let p = parts[_g++];
			let out = [];
			let _g1 = 0;
			while(_g1 < cur.length) {
				let _g = 0;
				let _g2 = cur[_g1++].childs;
				while(_g < _g2.length) {
					let c = _g2[_g];
					++_g;
					if(c.name == p) {
						out.push(c);
					}
				}
			}
			cur = out;
			if(out.length == 0) {
				return out;
			}
		}
		return cur;
	}
	static getInts(n) {
		if(n.props.length != 1) {
			throw haxe_Exception.thrown(n.name + " has " + Std.string(n.props) + " props");
		}
		let _g = n.props[0];
		if(_g._hx_index == 4) {
			return _g.v;
		} else {
			throw haxe_Exception.thrown(n.name + " has " + Std.string(n.props) + " props");
		}
	}
	static getFloats(n) {
		if(n.props.length != 1) {
			throw haxe_Exception.thrown(n.name + " has " + Std.string(n.props) + " props");
		}
		let _g = n.props[0];
		switch(_g._hx_index) {
		case 4:
			let _g1 = _g.v;
			let fl = [];
			let _g2 = 0;
			while(_g2 < _g1.length) fl.push(_g1[_g2++]);
			n.props[0] = arm_format_FbxProp.PFloats(fl);
			return fl;
		case 5:
			return _g.v;
		default:
			throw haxe_Exception.thrown(n.name + " has " + Std.string(n.props) + " props");
		}
	}
	static toInt(n) {
		if(n == null) {
			throw haxe_Exception.thrown("null prop");
		}
		switch(n._hx_index) {
		case 0:
			return n.v;
		case 1:
			return n.v | 0;
		default:
			throw haxe_Exception.thrown("Invalid prop " + Std.string(n));
		}
	}
	static toFloat(n) {
		if(n == null) {
			throw haxe_Exception.thrown("null prop");
		}
		switch(n._hx_index) {
		case 0:
			return n.v * 1.0;
		case 1:
			return n.v;
		default:
			throw haxe_Exception.thrown("Invalid prop " + Std.string(n));
		}
	}
	static toString(n) {
		if(n == null) {
			throw haxe_Exception.thrown("null prop");
		}
		if(n._hx_index == 2) {
			return n.v;
		} else {
			throw haxe_Exception.thrown("Invalid prop " + Std.string(n));
		}
	}
	static getId(n) {
		if(n.props.length != 3) {
			throw haxe_Exception.thrown(n.name + " is not an object");
		}
		let _g = n.props[0];
		switch(_g._hx_index) {
		case 0:
			return _g.v;
		case 1:
			return _g.v | 0;
		default:
			throw haxe_Exception.thrown(n.name + " is not an object " + Std.string(n.props));
		}
	}
	static getName(n) {
		if(n.props.length != 3) {
			throw haxe_Exception.thrown(n.name + " is not an object");
		}
		let _g = n.props[1];
		if(_g._hx_index == 2) {
			return _g.v.split("::").pop();
		} else {
			throw haxe_Exception.thrown(n.name + " is not an object");
		}
	}
}
$hxClasses["arm.format.FbxTools"] = arm_format_FbxTools;
arm_format_FbxTools.__name__ = "arm.format.FbxTools";
var arm_format__$FbxLibrary_Token = $hxEnums["arm.format._FbxLibrary.Token"] = { __ename__:true,__constructs__:null
	,TIdent: ($_=function(s) { return {_hx_index:0,s:s,__enum__:"arm.format._FbxLibrary.Token",toString:$estr}; },$_._hx_name="TIdent",$_.__params__ = ["s"],$_)
	,TNode: ($_=function(s) { return {_hx_index:1,s:s,__enum__:"arm.format._FbxLibrary.Token",toString:$estr}; },$_._hx_name="TNode",$_.__params__ = ["s"],$_)
	,TInt: ($_=function(s) { return {_hx_index:2,s:s,__enum__:"arm.format._FbxLibrary.Token",toString:$estr}; },$_._hx_name="TInt",$_.__params__ = ["s"],$_)
	,TFloat: ($_=function(s) { return {_hx_index:3,s:s,__enum__:"arm.format._FbxLibrary.Token",toString:$estr}; },$_._hx_name="TFloat",$_.__params__ = ["s"],$_)
	,TString: ($_=function(s) { return {_hx_index:4,s:s,__enum__:"arm.format._FbxLibrary.Token",toString:$estr}; },$_._hx_name="TString",$_.__params__ = ["s"],$_)
	,TLength: ($_=function(v) { return {_hx_index:5,v:v,__enum__:"arm.format._FbxLibrary.Token",toString:$estr}; },$_._hx_name="TLength",$_.__params__ = ["v"],$_)
	,TBraceOpen: {_hx_name:"TBraceOpen",_hx_index:6,__enum__:"arm.format._FbxLibrary.Token",toString:$estr}
	,TBraceClose: {_hx_name:"TBraceClose",_hx_index:7,__enum__:"arm.format._FbxLibrary.Token",toString:$estr}
	,TColon: {_hx_name:"TColon",_hx_index:8,__enum__:"arm.format._FbxLibrary.Token",toString:$estr}
	,TEof: {_hx_name:"TEof",_hx_index:9,__enum__:"arm.format._FbxLibrary.Token",toString:$estr}
};
arm_format__$FbxLibrary_Token.__constructs__ = [arm_format__$FbxLibrary_Token.TIdent,arm_format__$FbxLibrary_Token.TNode,arm_format__$FbxLibrary_Token.TInt,arm_format__$FbxLibrary_Token.TFloat,arm_format__$FbxLibrary_Token.TString,arm_format__$FbxLibrary_Token.TLength,arm_format__$FbxLibrary_Token.TBraceOpen,arm_format__$FbxLibrary_Token.TBraceClose,arm_format__$FbxLibrary_Token.TColon,arm_format__$FbxLibrary_Token.TEof];
class arm_format_Parser {
	constructor() {
	}
	parseText(str) {
		this.buf = str;
		this.pos = 0;
		this.line = 1;
		this.token = null;
		return { name : "Root", props : [arm_format_FbxProp.PInt(0),arm_format_FbxProp.PString("Root"),arm_format_FbxProp.PString("Root")], childs : this.parseNodes()};
	}
	parseNodes() {
		let nodes = [];
		while(true) {
			let _g = this.peek();
			if(_g != null) {
				switch(_g._hx_index) {
				case 7:case 9:
					return nodes;
				default:
				}
			}
			nodes.push(this.parseNode());
		}
	}
	parseNode() {
		let t = this.next();
		let name = t._hx_index == 1 ? t.s : this.unexpected(t);
		let props = [];
		let childs = null;
		_hx_loop1: while(true) {
			t = this.next();
			switch(t._hx_index) {
			case 0:
				props.push(arm_format_FbxProp.PIdent(t.s));
				break;
			case 1:
				this.token = t;
				break;
			case 2:
				props.push(arm_format_FbxProp.PInt(Std.parseInt(t.s)));
				break;
			case 3:
				props.push(arm_format_FbxProp.PFloat(parseFloat(t.s)));
				break;
			case 4:
				props.push(arm_format_FbxProp.PString(t.s));
				break;
			case 5:
				let _g = t.v;
				this.except(arm_format__$FbxLibrary_Token.TBraceOpen);
				this.except(arm_format__$FbxLibrary_Token.TNode("a"));
				let ints = [];
				let floats = null;
				let i = 0;
				while(i < _g) {
					t = this.next();
					switch(t._hx_index) {
					case 2:
						let _g = t.s;
						++i;
						if(floats == null) {
							ints.push(Std.parseInt(_g));
						} else {
							floats.push(Std.parseInt(_g));
						}
						break;
					case 3:
						let _g1 = t.s;
						++i;
						if(floats == null) {
							floats = [];
							let _g = 0;
							while(_g < ints.length) floats.push(ints[_g++]);
							ints = null;
						}
						floats.push(parseFloat(_g1));
						break;
					case 8:
						continue;
					default:
						this.unexpected(t);
					}
				}
				props.push(floats == null ? arm_format_FbxProp.PInts(ints) : arm_format_FbxProp.PFloats(floats));
				this.except(arm_format__$FbxLibrary_Token.TBraceClose);
				break _hx_loop1;
			case 6:case 7:
				this.token = t;
				break;
			default:
				this.unexpected(t);
			}
			t = this.next();
			switch(t._hx_index) {
			case 1:
				this.token = t;
				break _hx_loop1;
			case 6:
				childs = this.parseNodes();
				this.except(arm_format__$FbxLibrary_Token.TBraceClose);
				break _hx_loop1;
			case 7:
				this.token = t;
				break _hx_loop1;
			case 8:
				break;
			default:
				this.unexpected(t);
			}
		}
		if(childs == null) {
			childs = [];
		}
		return { name : name, props : props, childs : childs};
	}
	except(except) {
		let t = this.next();
		if(!Type.enumEq(t,except)) {
			this.error("Unexpected '" + this.tokenStr(t) + "' (" + this.tokenStr(except) + " expected)");
		}
	}
	peek() {
		if(this.token == null) {
			this.token = this.nextToken();
		}
		return this.token;
	}
	next() {
		if(this.token == null) {
			return this.nextToken();
		}
		let tmp = this.token;
		this.token = null;
		return tmp;
	}
	error(msg) {
		throw haxe_Exception.thrown(msg + " (line " + this.line + ")");
	}
	unexpected(t) {
		return this.error("Unexpected " + this.tokenStr(t));
	}
	tokenStr(t) {
		switch(t._hx_index) {
		case 0:
			return t.s;
		case 1:
			return t.s + ":";
		case 2:
			return t.s;
		case 3:
			return t.s;
		case 4:
			return "\"" + t.s + "\"";
		case 5:
			return "*" + t.v;
		case 6:
			return "{";
		case 7:
			return "}";
		case 8:
			return ",";
		case 9:
			return "<eof>";
		}
	}
	nextToken() {
		let start = this.pos;
		while(true) {
			let c = this.buf.charCodeAt(this.pos++);
			switch(c) {
			case 10:
				this.line++;
				++start;
				break;
			case 9:case 13:case 32:
				++start;
				break;
			case 34:
				start = this.pos;
				while(true) {
					c = this.buf.charCodeAt(this.pos++);
					if(c == 34) {
						break;
					}
					if(c != c || c == 10) {
						this.error("Unclosed string");
					}
				}
				return arm_format__$FbxLibrary_Token.TString(HxOverrides.substr(this.buf,start,this.pos - start - 1));
			case 42:
				start = this.pos;
				while(true) {
					c = this.buf.charCodeAt(this.pos++);
					if(!(c >= 48 && c <= 57)) {
						break;
					}
				}
				this.pos--;
				return arm_format__$FbxLibrary_Token.TLength(Std.parseInt(HxOverrides.substr(this.buf,start,this.pos - start)));
			case 44:
				return arm_format__$FbxLibrary_Token.TColon;
			case 59:
				while(true) {
					let c = this.buf.charCodeAt(this.pos++);
					if(c != c || c == 10) {
						this.pos--;
						break;
					}
				}
				start = this.pos;
				break;
			case 123:
				return arm_format__$FbxLibrary_Token.TBraceOpen;
			case 125:
				return arm_format__$FbxLibrary_Token.TBraceClose;
			default:
				if(c >= 97 && c <= 122 || c >= 65 && c <= 90 || c == 95) {
					while(true) {
						c = this.buf.charCodeAt(this.pos++);
						if(!(c >= 97 && c <= 122 || c >= 65 && c <= 90 || c >= 48 && c <= 57 || c == 95 || c == 45)) {
							break;
						}
					}
					if(c == 58) {
						return arm_format__$FbxLibrary_Token.TNode(HxOverrides.substr(this.buf,start,this.pos - start - 1));
					}
					this.pos--;
					return arm_format__$FbxLibrary_Token.TIdent(HxOverrides.substr(this.buf,start,this.pos - start));
				}
				if(c >= 48 && c <= 57 || c == 45) {
					while(true) {
						c = this.buf.charCodeAt(this.pos++);
						if(!(c >= 48 && c <= 57)) {
							break;
						}
					}
					if(c != 46 && c != 69 && c != 101 && this.pos - start < 10) {
						this.pos--;
						return arm_format__$FbxLibrary_Token.TInt(HxOverrides.substr(this.buf,start,this.pos - start));
					}
					if(c == 46) {
						while(true) {
							c = this.buf.charCodeAt(this.pos++);
							if(!(c >= 48 && c <= 57)) {
								break;
							}
						}
					}
					if(c == 101 || c == 69) {
						c = this.buf.charCodeAt(this.pos++);
						if(c != 45 && c != 43) {
							this.pos--;
						}
						while(true) {
							c = this.buf.charCodeAt(this.pos++);
							if(!(c >= 48 && c <= 57)) {
								break;
							}
						}
					}
					this.pos--;
					return arm_format__$FbxLibrary_Token.TFloat(HxOverrides.substr(this.buf,start,this.pos - start));
				}
				if(c != c) {
					this.pos--;
					return arm_format__$FbxLibrary_Token.TEof;
				}
				this.error("Unexpected char '" + String.fromCodePoint(c) + "'");
			}
		}
	}
	static parse(text) {
		return new arm_format_Parser().parseText(text);
	}
}
$hxClasses["arm.format.Parser"] = arm_format_Parser;
arm_format_Parser.__name__ = "arm.format.Parser";
Object.assign(arm_format_Parser.prototype, {
	__class__: arm_format_Parser
});
class arm_format_FbxLibrary {
	constructor() {
		this.version = 0.;
		this.root = { name : "Root", props : [], childs : []};
		this.reset();
	}
	reset() {
		this.ids = new haxe_ds_IntMap();
		this.connect = new haxe_ds_IntMap();
		this.namedConnect = new haxe_ds_IntMap();
		this.invConnect = new haxe_ds_IntMap();
	}
	load(root) {
		this.reset();
		this.root = root;
		this.version = arm_format_FbxTools.toInt(arm_format_FbxTools.get(root,"FBXHeaderExtension.FBXVersion").props[0]) / 1000;
		if((this.version | 0) != 7) {
			throw haxe_Exception.thrown("FBX Version 7.x required : use FBX 2010 export");
		}
		let _g = 0;
		let _g1 = root.childs;
		while(_g < _g1.length) this.init(_g1[_g++]);
	}
	init(n) {
		switch(n.name) {
		case "Connections":
			let _g = 0;
			let _g1 = n.childs;
			while(_g < _g1.length) {
				let c = _g1[_g];
				++_g;
				if(c.name != "C") {
					continue;
				}
				let child = arm_format_FbxTools.toInt(c.props[1]);
				let parent = arm_format_FbxTools.toInt(c.props[2]);
				if(this.ids.h[child] == null || this.ids.h[parent] == null) {
					continue;
				}
				let name = c.props[3];
				if(name != null) {
					let name1 = arm_format_FbxTools.toString(name);
					let nc = this.namedConnect.h[parent];
					if(nc == null) {
						nc = new haxe_ds_StringMap();
						this.namedConnect.h[parent] = nc;
					}
					nc.h[name1] = child;
					if(name1 == "LookAtProperty") {
						continue;
					}
				}
				let c1 = this.connect.h[parent];
				if(c1 == null) {
					c1 = [];
					this.connect.h[parent] = c1;
				}
				c1.push(child);
				if(parent == 0) {
					continue;
				}
				let c2 = this.invConnect.h[child];
				if(c2 == null) {
					c2 = [];
					this.invConnect.h[child] = c2;
				}
				c2.push(parent);
			}
			break;
		case "Objects":
			let _g2 = 0;
			let _g3 = n.childs;
			while(_g2 < _g3.length) {
				let c = _g3[_g2];
				++_g2;
				let this1 = this.ids;
				let key = arm_format_FbxTools.getId(c);
				this1.h[key] = c;
			}
			break;
		default:
		}
	}
	getAllGeometries() {
		let geoms = arm_format_FbxTools.getAll(this.root,"Objects.Geometry");
		let res = [];
		let _g = 0;
		while(_g < geoms.length) res.push(new arm_format_Geometry(this,geoms[_g++]));
		return res;
	}
}
$hxClasses["arm.format.FbxLibrary"] = arm_format_FbxLibrary;
arm_format_FbxLibrary.__name__ = "arm.format.FbxLibrary";
Object.assign(arm_format_FbxLibrary.prototype, {
	__class__: arm_format_FbxLibrary
});
class arm_format_Geometry {
	constructor(l,root) {
		this.lib = l;
		this.root = root;
	}
	getRoot() {
		return this.root;
	}
	getVertices() {
		return arm_format_FbxTools.getFloats(arm_format_FbxTools.get(this.root,"Vertices"));
	}
	getPolygons() {
		return arm_format_FbxTools.getInts(arm_format_FbxTools.get(this.root,"PolygonVertexIndex"));
	}
	getNormals() {
		return this.processVectors("LayerElementNormal","Normals");
	}
	processVectors(layer,name,opt) {
		if(opt == null) {
			opt = false;
		}
		let vect = arm_format_FbxTools.get(this.root,layer + "." + name,opt);
		if(vect == null) {
			return null;
		}
		let nrm = arm_format_FbxTools.getFloats(vect);
		if(arm_format_FbxTools.toString(arm_format_FbxTools.get(this.root,layer + ".MappingInformationType").props[0]) == "ByVertice") {
			let nout = [];
			let _g = 0;
			let _g1 = this.getPolygons();
			while(_g < _g1.length) {
				let i = _g1[_g];
				++_g;
				let vid = i;
				if(i < 0) {
					vid = -i - 1;
				}
				nout.push(nrm[vid * 3]);
				nout.push(nrm[vid * 3 + 1]);
				nout.push(nrm[vid * 3 + 2]);
			}
			nrm = nout;
		}
		return nrm;
	}
	getColors() {
		let color = arm_format_FbxTools.get(this.root,"LayerElementColor",true);
		if(color == null) {
			return null;
		} else {
			return { values : arm_format_FbxTools.getFloats(arm_format_FbxTools.get(color,"Colors")), index : arm_format_FbxTools.getInts(arm_format_FbxTools.get(color,"ColorIndex"))};
		}
	}
	getUVs() {
		let uvs = [];
		let _g = 0;
		let _g1 = arm_format_FbxTools.getAll(this.root,"LayerElementUV");
		while(_g < _g1.length) {
			let v = _g1[_g];
			++_g;
			let index = arm_format_FbxTools.get(v,"UVIndex",true);
			let values = arm_format_FbxTools.getFloats(arm_format_FbxTools.get(v,"UV"));
			let index1;
			if(index == null) {
				let _g = [];
				let _g1 = 0;
				let _g2 = this.getPolygons();
				while(_g1 < _g2.length) {
					let i = _g2[_g1];
					++_g1;
					if(i < 0) {
						_g.push(-i - 1);
					} else {
						_g.push(i);
					}
				}
				index1 = _g;
			} else {
				index1 = arm_format_FbxTools.getInts(index);
			}
			uvs.push({ values : values, index : index1});
		}
		return uvs;
	}
	getBuffers(binary,p) {
		let pbuf = this.getVertices();
		let nbuf = this.getNormals();
		let tbuf = this.getUVs()[0];
		let cbuf = arm_format_FbxParser.parseVCols ? this.getColors() : null;
		let polys = this.getPolygons();
		if(arm_format_FbxParser.parseTransform) {
			let m_self__00 = 1.0;
			let m_self__10 = 0.0;
			let m_self__20 = 0.0;
			let m_self__30 = 0.0;
			let m_self__01 = 0.0;
			let m_self__11 = 1.0;
			let m_self__21 = 0.0;
			let m_self__31 = 0.0;
			let m_self__02 = 0.0;
			let m_self__12 = 0.0;
			let m_self__22 = 1.0;
			let m_self__32 = 0.0;
			let x = p.tx;
			let y = p.ty;
			let z = p.tz;
			if(z == null) {
				z = 0.0;
			}
			if(y == null) {
				y = 0.0;
			}
			if(x == null) {
				x = 0.0;
			}
			let v_x = x;
			let v_y = y;
			let v_z = z;
			let q_x = 0.0;
			let q_y = 0.0;
			let q_z = 0.0;
			let q_w = 1.0;
			let f = p.rx / 2;
			let c1 = Math.cos(f);
			let s1 = Math.sin(f);
			f = p.ry / 2;
			let c2 = Math.cos(f);
			let s2 = Math.sin(f);
			f = p.rz / 2;
			let c3 = Math.cos(f);
			let s3 = Math.sin(f);
			q_x = s1 * c2 * c3 + c1 * s2 * s3;
			q_y = c1 * s2 * c3 + s1 * c2 * s3;
			q_z = c1 * c2 * s3 - s1 * s2 * c3;
			q_w = c1 * c2 * c3 - s1 * s2 * s3;
			let x1 = p.sx;
			let y1 = p.sy;
			let z1 = p.sz;
			if(z1 == null) {
				z1 = 0.0;
			}
			if(y1 == null) {
				y1 = 0.0;
			}
			if(x1 == null) {
				x1 = 0.0;
			}
			let sc_x = x1;
			let sc_y = y1;
			let sc_z = z1;
			let x2 = q_x;
			let y2 = q_y;
			let z2 = q_z;
			let w = q_w;
			let x21 = x2 + x2;
			let y21 = y2 + y2;
			let z21 = z2 + z2;
			let xx = x2 * x21;
			let xy = x2 * y21;
			let xz = x2 * z21;
			let yy = y2 * y21;
			let yz = y2 * z21;
			let zz = z2 * z21;
			let wx = w * x21;
			let wy = w * y21;
			let wz = w * z21;
			m_self__00 = 1.0 - (yy + zz);
			m_self__10 = xy - wz;
			m_self__20 = xz + wy;
			m_self__01 = xy + wz;
			m_self__11 = 1.0 - (xx + zz);
			m_self__21 = yz - wx;
			m_self__02 = xz - wy;
			m_self__12 = yz + wx;
			m_self__22 = 1.0 - (xx + yy);
			m_self__30 = 0.0;
			m_self__31 = 0.0;
			m_self__32 = 0.0;
			m_self__00 *= sc_x;
			m_self__01 *= sc_x;
			m_self__02 *= sc_x;
			m_self__10 *= sc_y;
			m_self__11 *= sc_y;
			m_self__12 *= sc_y;
			m_self__20 *= sc_z;
			m_self__21 *= sc_z;
			m_self__22 *= sc_z;
			m_self__30 = v_x;
			m_self__31 = v_y;
			m_self__32 = v_z;
			let _g = 0;
			let _g1 = pbuf.length / 3 | 0;
			while(_g < _g1) {
				let i = _g++;
				v_x = pbuf[i * 3];
				v_y = pbuf[i * 3 + 1];
				v_z = pbuf[i * 3 + 2];
				let x = v_x;
				let y = v_y;
				let z = v_z;
				v_x = m_self__00 * x + m_self__10 * y + m_self__20 * z + m_self__30;
				v_y = m_self__01 * x + m_self__11 * y + m_self__21 * z + m_self__31;
				v_z = m_self__02 * x + m_self__12 * y + m_self__22 * z + m_self__32;
				pbuf[i * 3] = v_x;
				pbuf[i * 3 + 1] = v_y;
				pbuf[i * 3 + 2] = v_z;
			}
			let _g2 = 0;
			let _g3 = nbuf.length / 3 | 0;
			while(_g2 < _g3) {
				let i = _g2++;
				v_x = nbuf[i * 3];
				v_y = nbuf[i * 3 + 1];
				v_z = nbuf[i * 3 + 2];
				let ix = q_w * v_x + q_y * v_z - q_z * v_y;
				let iy = q_w * v_y + q_z * v_x - q_x * v_z;
				let iz = q_w * v_z + q_x * v_y - q_y * v_x;
				let iw = -q_x * v_x - q_y * v_y - q_z * v_z;
				v_x = ix * q_w + iw * -q_x + iy * -q_z - iz * -q_y;
				v_y = iy * q_w + iw * -q_y + iz * -q_x - ix * -q_z;
				v_z = iz * q_w + iw * -q_z + ix * -q_y - iy * -q_x;
				nbuf[i * 3] = v_x;
				nbuf[i * 3 + 1] = v_y;
				nbuf[i * 3 + 2] = v_z;
			}
		}
		let scalePos = 0.0;
		let _g = 0;
		while(_g < pbuf.length) {
			let f = Math.abs(pbuf[_g++]);
			if(scalePos < f) {
				scalePos = f;
			}
		}
		let inv = 32767 * (1 / scalePos);
		let pos = 0;
		let count = 0;
		let vlen = 0;
		let ilen = 0;
		let _g1 = 0;
		while(_g1 < polys.length) {
			++count;
			if(polys[_g1++] < 0) {
				let _g = 0;
				let _g1 = count;
				while(_g < _g1) {
					++_g;
					++vlen;
				}
				let _g2 = 0;
				let _g3 = count - 2;
				while(_g2 < _g3) {
					++_g2;
					ilen += 3;
				}
				count = 0;
			}
			++pos;
		}
		let posa = new Int16Array(vlen * 4);
		let nora = new Int16Array(vlen * 2);
		let texa = tbuf != null ? new Int16Array(vlen * 2) : null;
		let cola = cbuf != null ? new Int16Array(vlen * 3) : null;
		let inda = new Uint32Array(ilen);
		pos = 0;
		count = 0;
		vlen = 0;
		ilen = 0;
		let _g2 = 0;
		while(_g2 < polys.length) {
			let i = polys[_g2];
			++_g2;
			++count;
			if(i < 0) {
				polys[pos] = -i - 1;
				let start = pos - count + 1;
				let _g = 0;
				let _g1 = count;
				while(_g < _g1) {
					let k = _g++ + start;
					let vidx = polys[k];
					posa[vlen * 4] = pbuf[vidx * 3] * inv | 0;
					posa[vlen * 4 + 1] = pbuf[vidx * 3 + 1] * inv | 0;
					posa[vlen * 4 + 2] = pbuf[vidx * 3 + 2] * inv | 0;
					posa[vlen * 4 + 3] = nbuf[k * 3 + 2] * 32767 | 0;
					nora[vlen * 2] = nbuf[k * 3] * 32767 | 0;
					nora[vlen * 2 + 1] = nbuf[k * 3 + 1] * 32767 | 0;
					if(tbuf != null) {
						let iuv = tbuf.index[k];
						let uvx = tbuf.values[iuv * 2];
						if(uvx > 1.000030518509476) {
							uvx -= uvx | 0;
						}
						let uvy = tbuf.values[iuv * 2 + 1];
						if(uvy > 1.000030518509476) {
							uvy -= uvy | 0;
						}
						texa[vlen * 2] = uvx * 32767 | 0;
						texa[vlen * 2 + 1] = (1.0 - uvy) * 32767 | 0;
					}
					if(cbuf != null) {
						let icol = cbuf.index[k];
						cola[vlen * 3] = cbuf.values[icol * 4] * 32767 | 0;
						cola[vlen * 3 + 1] = cbuf.values[icol * 4 + 1] * 32767 | 0;
						cola[vlen * 3 + 2] = cbuf.values[icol * 4 + 2] * 32767 | 0;
					}
					++vlen;
				}
				if(count <= 4) {
					let _g = 0;
					let _g1 = count - 2;
					while(_g < _g1) {
						let n = _g++;
						inda[ilen + 2] = start + n;
						inda[ilen + 1] = start + count - 1;
						inda[ilen] = start + n + 1;
						ilen += 3;
					}
				} else {
					let va = [];
					let _g = 0;
					let _g1 = count;
					while(_g < _g1) va.push(start + _g++);
					let nx = nbuf[start * 3];
					let ny = nbuf[start * 3 + 1];
					let nz = nbuf[start * 3 + 2];
					let nxabs = Math.abs(nx);
					let nyabs = Math.abs(ny);
					let nzabs = Math.abs(nz);
					let flip = nx + ny + nz > 0;
					let axis = nxabs > nyabs && nxabs > nzabs ? 0 : nyabs > nxabs && nyabs > nzabs ? 1 : 2;
					let axis0 = axis == 0 ? flip ? 2 : 1 : axis == 1 ? flip ? 0 : 2 : flip ? 1 : 0;
					let axis1 = axis == 0 ? flip ? 1 : 2 : axis == 1 ? flip ? 2 : 0 : flip ? 0 : 1;
					let vi = count;
					let loops = 0;
					let i = -1;
					while(vi > 3 && loops++ < vi) {
						i = (i + 1) % vi;
						let i1 = (i + 1) % vi;
						let i2 = (i + 2) % vi;
						let vi0 = polys[va[i]] * 3;
						let vi1 = polys[va[i1]] * 3;
						let vi2 = polys[va[i2]] * 3;
						let v0x = pbuf[vi0 + axis0];
						let v0y = pbuf[vi0 + axis1];
						let v1x = pbuf[vi1 + axis0];
						let v1y = pbuf[vi1 + axis1];
						let v2x = pbuf[vi2 + axis0];
						let v2y = pbuf[vi2 + axis1];
						if((v0x - v1x) * (v2y - v1y) - (v0y - v1y) * (v2x - v1x) <= 0) {
							continue;
						}
						let overlap = false;
						let _g = 0;
						let _g1 = vi - 3;
						while(_g < _g1) {
							let j0 = polys[va[(i + 3 + _g++) % vi]] * 3;
							if(arm_format_MeshParser.pnpoly(v0x,v0y,v1x,v1y,v2x,v2y,pbuf[j0 + axis0],pbuf[j0 + axis1])) {
								overlap = true;
								break;
							}
						}
						if(overlap) {
							continue;
						}
						inda[ilen++] = va[i];
						inda[ilen++] = va[i1];
						inda[ilen++] = va[i2];
						let _g2 = (i + 1) % vi;
						let _g3 = vi - 1;
						while(_g2 < _g3) {
							let j = _g2++;
							va[j] = va[j + 1];
						}
						--vi;
						--i;
						loops = 0;
					}
					inda[ilen++] = va[0];
					inda[ilen++] = va[1];
					inda[ilen++] = va[2];
				}
				polys[pos] = i;
				count = 0;
			}
			++pos;
		}
		return { posa : posa, nora : nora, texa : texa, cola : cola, inda : inda, scalePos : scalePos};
	}
}
$hxClasses["arm.format.Geometry"] = arm_format_Geometry;
arm_format_Geometry.__name__ = "arm.format.Geometry";
Object.assign(arm_format_Geometry.prototype, {
	__class__: arm_format_Geometry
});
class arm_format_FbxParser {
	constructor(blob) {
		this.binary = true;
		this.current = 0;
		this.sz = 1.0;
		this.sy = 1.0;
		this.sx = 1.0;
		this.rz = 0.0;
		this.ry = 0.0;
		this.rx = 0.0;
		this.tz = 0.0;
		this.ty = 0.0;
		this.tx = 0.0;
		this.name = "";
		this.scalePos = 1.0;
		this.inda = null;
		this.cola = null;
		this.texa = null;
		this.nora = null;
		this.posa = null;
		let magic = "Kaydara FBX Binary  \x00\x1A\x00";
		let s = "";
		let _g = 0;
		let _g1 = magic.length;
		while(_g < _g1) {
			let code = blob.readU8(_g++);
			s += String.fromCodePoint(code);
		}
		this.binary = s == magic;
		let fbx = this.binary ? arm_format_FbxBinaryParser.parse(blob) : arm_format_Parser.parse(blob.toString());
		let lib = new arm_format_FbxLibrary();
		try {
			lib.load(fbx);
		} catch( _g ) {
			haxe_Log.trace(haxe_Exception.caught(_g).unwrap(),{ fileName : "Sources/arm/format/FbxParser.hx", lineNumber : 48, className : "arm.format.FbxParser", methodName : "new"});
		}
		this.geoms = lib.getAllGeometries();
		this.next();
	}
	next() {
		if(this.current >= this.geoms.length) {
			return false;
		}
		let geom = this.geoms[this.current];
		let lib = geom.lib;
		this.tx = this.ty = this.tz = 0;
		this.rx = this.ry = this.rz = 0;
		this.sx = this.sy = this.sz = 1;
		if(arm_format_FbxParser.parseTransform) {
			let this1 = lib.invConnect;
			let key = arm_format_FbxTools.getId(geom.getRoot());
			let connects = this1.h[key];
			let _g = 0;
			while(_g < connects.length) {
				let _g1 = 0;
				let _g2 = arm_format_FbxTools.getAll(lib.ids.h[connects[_g++]],"Properties70.P");
				while(_g1 < _g2.length) {
					let p = _g2[_g1];
					++_g1;
					switch(arm_format_FbxTools.toString(p.props[0])) {
					case "Lcl Rotation":
						this.rx = arm_format_FbxTools.toFloat(p.props[4]) * Math.PI / 180;
						this.ry = arm_format_FbxTools.toFloat(p.props[5]) * Math.PI / 180;
						this.rz = arm_format_FbxTools.toFloat(p.props[6]) * Math.PI / 180;
						break;
					case "Lcl Scaling":
						this.sx = arm_format_FbxTools.toFloat(p.props[4]);
						this.sy = arm_format_FbxTools.toFloat(p.props[5]);
						this.sz = arm_format_FbxTools.toFloat(p.props[6]);
						break;
					case "Lcl Translation":
						this.tx = arm_format_FbxTools.toFloat(p.props[4]);
						this.ty = arm_format_FbxTools.toFloat(p.props[5]);
						this.tz = arm_format_FbxTools.toFloat(p.props[6]);
						break;
					}
				}
			}
		}
		let res = geom.getBuffers(this.binary,this);
		this.scalePos = res.scalePos;
		this.posa = res.posa;
		this.nora = res.nora;
		this.texa = res.texa;
		this.cola = res.cola;
		this.inda = res.inda;
		this.name = arm_format_FbxTools.getName(geom.getRoot());
		if(HxOverrides.cca(this.name,0) == 0) {
			this.name = this.name.substring(1);
		}
		if(HxOverrides.cca(this.name,0) == 1) {
			this.name = this.name.substring(1);
		}
		if(this.name == "Geometry") {
			this.name = "Object -Geometry";
		}
		this.name = this.name.substring(0,this.name.length - 10);
		this.current++;
		return true;
	}
}
$hxClasses["arm.format.FbxParser"] = arm_format_FbxParser;
arm_format_FbxParser.__name__ = "arm.format.FbxParser";
Object.assign(arm_format_FbxParser.prototype, {
	__class__: arm_format_FbxParser
});
class arm_format_MeshParser {
	static pnpoly(v0x,v0y,v1x,v1y,v2x,v2y,px,py) {
		let c = false;
		if(v0y > py != v2y > py && px < (v2x - v0x) * (py - v0y) / (v2y - v0y) + v0x) {
			c = true;
		}
		if(v1y > py != v0y > py && px < (v0x - v1x) * (py - v1y) / (v0y - v1y) + v1x) {
			c = !c;
		}
		if(v2y > py != v1y > py && px < (v1x - v2x) * (py - v2y) / (v1y - v2y) + v2x) {
			c = !c;
		}
		return c;
	}
	static calcNormal(p0,p1,p2) {
		let _this = new iron_math_Vec4();
		_this.x = p2.x - p1.x;
		_this.y = p2.y - p1.y;
		_this.z = p2.z - p1.z;
		let ab_x = 0.0;
		let ab_y = 0.0;
		let ab_z = 0.0;
		ab_x = p0.x - p1.x;
		ab_y = p0.y - p1.y;
		ab_z = p0.z - p1.z;
		let ax = _this.x;
		let ay = _this.y;
		let az = _this.z;
		let vx = ab_x;
		let vy = ab_y;
		let vz = ab_z;
		_this.x = ay * vz - az * vy;
		_this.y = az * vx - ax * vz;
		_this.z = ax * vy - ay * vx;
		let n = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z);
		if(n > 0.0) {
			let invN = 1.0 / n;
			_this.x *= invN;
			_this.y *= invN;
			_this.z *= invN;
		}
		return _this;
	}
}
$hxClasses["arm.format.MeshParser"] = arm_format_MeshParser;
arm_format_MeshParser.__name__ = "arm.format.MeshParser";
class arm_format_ObjParser {
	constructor(blob,startPos,udim) {
		if(udim == null) {
			udim = false;
		}
		if(startPos == null) {
			startPos = 0;
		}
		this.buf = null;
		this.ni = 0;
		this.ui = 0;
		this.vi = 0;
		this.pos = 0;
		this.hasNext = false;
		this.name = "";
		this.scalePos = 1.0;
		this.udimsU = 1;
		this.udims = null;
		this.inda = null;
		this.texa = null;
		this.nora = null;
		this.posa = null;
		this.pos = startPos;
		let posIndices = [];
		let uvIndices = [];
		let norIndices = [];
		let readingFaces = false;
		let readingObject = false;
		let fullAttrib = false;
		arm_format_ObjParser.bytes = blob.bytes;
		this.posTemp = [];
		this.uvTemp = [];
		this.norTemp = [];
		this.va = new Uint32Array(60);
		this.ua = new Uint32Array(60);
		this.na = new Uint32Array(60);
		this.buf = new Uint8Array(64);
		if(startPos == 0) {
			arm_format_ObjParser.vindOff = arm_format_ObjParser.tindOff = arm_format_ObjParser.nindOff = 0;
		}
		if(arm_format_ObjParser.splitCode == 117 && startPos > 0) {
			this.posTemp = arm_format_ObjParser.posFirst;
			this.norTemp = arm_format_ObjParser.norFirst;
			this.uvTemp = arm_format_ObjParser.uvFirst;
		}
		while(this.pos < arm_format_ObjParser.bytes.length) {
			let c0 = arm_format_ObjParser.bytes.b[this.pos++];
			if(readingObject && readingFaces && (c0 == 118 || c0 == arm_format_ObjParser.splitCode)) {
				this.pos--;
				this.hasNext = true;
				break;
			}
			if(c0 == 118) {
				let c1 = arm_format_ObjParser.bytes.b[this.pos++];
				if(c1 == 32) {
					if(arm_format_ObjParser.bytes.b[this.pos] == 32) {
						this.pos++;
					}
					this.posTemp.push(this.readFloat());
					this.pos++;
					this.posTemp.push(this.readFloat());
					this.pos++;
					this.posTemp.push(this.readFloat());
				} else if(c1 == 116) {
					this.pos++;
					this.uvTemp.push(this.readFloat());
					this.pos++;
					this.uvTemp.push(this.readFloat());
					if(this.norTemp.length > 0) {
						fullAttrib = true;
					}
				} else if(c1 == 110) {
					this.pos++;
					this.norTemp.push(this.readFloat());
					this.pos++;
					this.norTemp.push(this.readFloat());
					this.pos++;
					this.norTemp.push(this.readFloat());
					if(this.uvTemp.length > 0) {
						fullAttrib = true;
					}
				}
			} else if(c0 == 102) {
				this.pos++;
				if(arm_format_ObjParser.bytes.b[this.pos] == 32) {
					this.pos++;
				}
				readingFaces = true;
				this.vi = this.ui = this.ni = 0;
				if(fullAttrib) {
					this.readFaceFast();
				} else {
					this.readFace();
				}
				if(this.vi <= 4) {
					posIndices.push(this.va[0]);
					posIndices.push(this.va[1]);
					posIndices.push(this.va[2]);
					let _g = 3;
					let _g1 = this.vi;
					while(_g < _g1) {
						let i = _g++;
						posIndices.push(this.va[0]);
						posIndices.push(this.va[i - 1]);
						posIndices.push(this.va[i]);
					}
					if(this.uvTemp.length > 0) {
						uvIndices.push(this.ua[0]);
						uvIndices.push(this.ua[1]);
						uvIndices.push(this.ua[2]);
						let _g = 3;
						let _g1 = this.ui;
						while(_g < _g1) {
							let i = _g++;
							uvIndices.push(this.ua[0]);
							uvIndices.push(this.ua[i - 1]);
							uvIndices.push(this.ua[i]);
						}
					}
					if(this.norTemp.length > 0) {
						norIndices.push(this.na[0]);
						norIndices.push(this.na[1]);
						norIndices.push(this.na[2]);
						let _g = 3;
						let _g1 = this.ni;
						while(_g < _g1) {
							let i = _g++;
							norIndices.push(this.na[0]);
							norIndices.push(this.na[i - 1]);
							norIndices.push(this.na[i]);
						}
					}
				} else {
					let vindOff = arm_format_ObjParser.splitCode == 117 ? 0 : arm_format_ObjParser.vindOff;
					let nindOff = arm_format_ObjParser.splitCode == 117 ? 0 : arm_format_ObjParser.nindOff;
					let nx = 0.0;
					let ny = 0.0;
					let nz = 0.0;
					if(this.norTemp.length > 0) {
						nx = this.norTemp[(this.na[0] - nindOff) * 3];
						ny = this.norTemp[(this.na[0] - nindOff) * 3 + 1];
						nz = this.norTemp[(this.na[0] - nindOff) * 3 + 2];
					} else {
						let n = arm_format_MeshParser.calcNormal(new iron_math_Vec4(this.posTemp[(this.va[0] - vindOff) * 3],this.posTemp[(this.va[0] - vindOff) * 3 + 1],this.posTemp[(this.va[0] - vindOff) * 3 + 2]),new iron_math_Vec4(this.posTemp[(this.va[1] - vindOff) * 3],this.posTemp[(this.va[1] - vindOff) * 3 + 1],this.posTemp[(this.va[1] - vindOff) * 3 + 2]),new iron_math_Vec4(this.posTemp[(this.va[2] - vindOff) * 3],this.posTemp[(this.va[2] - vindOff) * 3 + 1],this.posTemp[(this.va[2] - vindOff) * 3 + 2]));
						nx = n.x;
						ny = n.y;
						nz = n.z;
					}
					let nxabs = Math.abs(nx);
					let nyabs = Math.abs(ny);
					let nzabs = Math.abs(nz);
					let flip = nx + ny + nz > 0;
					let axis = nxabs > nyabs && nxabs > nzabs ? 0 : nyabs > nxabs && nyabs > nzabs ? 1 : 2;
					let axis0 = axis == 0 ? flip ? 2 : 1 : axis == 1 ? flip ? 0 : 2 : flip ? 1 : 0;
					let axis1 = axis == 0 ? flip ? 1 : 2 : axis == 1 ? flip ? 2 : 0 : flip ? 0 : 1;
					let loops = 0;
					let i = -1;
					while(this.vi > 3 && loops++ < this.vi) {
						i = (i + 1) % this.vi;
						let i1 = (i + 1) % this.vi;
						let i2 = (i + 2) % this.vi;
						let vi0 = (this.va[i] - vindOff) * 3;
						let vi1 = (this.va[i1] - vindOff) * 3;
						let vi2 = (this.va[i2] - vindOff) * 3;
						let v0x = this.posTemp[vi0 + axis0];
						let v0y = this.posTemp[vi0 + axis1];
						let v1x = this.posTemp[vi1 + axis0];
						let v1y = this.posTemp[vi1 + axis1];
						let v2x = this.posTemp[vi2 + axis0];
						let v2y = this.posTemp[vi2 + axis1];
						if((v0x - v1x) * (v2y - v1y) - (v0y - v1y) * (v2x - v1x) <= 0) {
							continue;
						}
						let overlap = false;
						let _g = 0;
						let _g1 = this.vi - 3;
						while(_g < _g1) {
							let j0 = (this.va[(i + 3 + _g++) % this.vi] - vindOff) * 3;
							if(arm_format_MeshParser.pnpoly(v0x,v0y,v1x,v1y,v2x,v2y,this.posTemp[j0 + axis0],this.posTemp[j0 + axis1])) {
								overlap = true;
								break;
							}
						}
						if(overlap) {
							continue;
						}
						posIndices.push(this.va[i]);
						posIndices.push(this.va[i1]);
						posIndices.push(this.va[i2]);
						if(this.uvTemp.length > 0) {
							uvIndices.push(this.ua[i]);
							uvIndices.push(this.ua[i1]);
							uvIndices.push(this.ua[i2]);
						}
						if(this.norTemp.length > 0) {
							norIndices.push(this.na[i]);
							norIndices.push(this.na[i1]);
							norIndices.push(this.na[i2]);
						}
						let _g2 = (i + 1) % this.vi;
						let _g3 = this.vi - 1;
						while(_g2 < _g3) {
							let j = _g2++;
							this.va[j] = this.va[j + 1];
							this.ua[j] = this.ua[j + 1];
							this.na[j] = this.na[j + 1];
						}
						this.vi--;
						--i;
						loops = 0;
					}
					posIndices.push(this.va[0]);
					posIndices.push(this.va[1]);
					posIndices.push(this.va[2]);
					if(this.uvTemp.length > 0) {
						uvIndices.push(this.ua[0]);
						uvIndices.push(this.ua[1]);
						uvIndices.push(this.ua[2]);
					}
					if(this.norTemp.length > 0) {
						norIndices.push(this.na[0]);
						norIndices.push(this.na[1]);
						norIndices.push(this.na[2]);
					}
				}
			} else if(c0 == arm_format_ObjParser.splitCode) {
				if(arm_format_ObjParser.splitCode == 117) {
					this.pos += 5;
				}
				this.pos++;
				if(!udim) {
					readingObject = true;
				}
				this.name = this.readString();
			}
			this.nextLine();
		}
		if(startPos > 0) {
			if(arm_format_ObjParser.splitCode != 117) {
				let _g = 0;
				let _g1 = posIndices.length;
				while(_g < _g1) posIndices[_g++] -= arm_format_ObjParser.vindOff;
				let _g2 = 0;
				let _g3 = uvIndices.length;
				while(_g2 < _g3) uvIndices[_g2++] -= arm_format_ObjParser.tindOff;
				let _g4 = 0;
				let _g5 = norIndices.length;
				while(_g4 < _g5) norIndices[_g4++] -= arm_format_ObjParser.nindOff;
			}
		} else if(arm_format_ObjParser.splitCode == 117) {
			arm_format_ObjParser.posFirst = this.posTemp;
			arm_format_ObjParser.norFirst = this.norTemp;
			arm_format_ObjParser.uvFirst = this.uvTemp;
		}
		arm_format_ObjParser.vindOff += this.posTemp.length / 3 | 0;
		arm_format_ObjParser.tindOff += this.uvTemp.length / 2 | 0;
		arm_format_ObjParser.nindOff += this.norTemp.length / 3 | 0;
		this.scalePos = 0.0;
		let _g = 0;
		let _g1 = this.posTemp.length;
		while(_g < _g1) {
			let f = Math.abs(this.posTemp[_g++]);
			if(this.scalePos < f) {
				this.scalePos = f;
			}
		}
		let inv = 32767 * (1 / this.scalePos);
		this.posa = new Int16Array(posIndices.length * 4);
		this.inda = new Uint32Array(posIndices.length);
		let _g2 = 0;
		let _g3 = posIndices.length;
		while(_g2 < _g3) {
			let i = _g2++;
			this.posa[i * 4] = this.posTemp[posIndices[i] * 3] * inv | 0;
			this.posa[i * 4 + 1] = -this.posTemp[posIndices[i] * 3 + 2] * inv | 0;
			this.posa[i * 4 + 2] = this.posTemp[posIndices[i] * 3 + 1] * inv | 0;
			this.inda[i] = i;
		}
		if(norIndices.length > 0) {
			this.nora = new Int16Array(norIndices.length * 2);
			let _g = 0;
			let _g1 = posIndices.length;
			while(_g < _g1) {
				let i = _g++;
				this.nora[i * 2] = this.norTemp[norIndices[i] * 3] * 32767 | 0;
				this.nora[i * 2 + 1] = -this.norTemp[norIndices[i] * 3 + 2] * 32767 | 0;
				this.posa[i * 4 + 3] = this.norTemp[norIndices[i] * 3 + 1] * 32767 | 0;
			}
		} else {
			this.nora = new Int16Array(this.inda.length * 2);
			let cb_x = 0.0;
			let cb_y = 0.0;
			let cb_z = 0.0;
			let ab_x = 0.0;
			let ab_y = 0.0;
			let ab_z = 0.0;
			let _g = 0;
			let _g1 = this.inda.length / 3 | 0;
			while(_g < _g1) {
				let i = _g++;
				let i1 = this.inda[i * 3];
				let i2 = this.inda[i * 3 + 1];
				let i3 = this.inda[i * 3 + 2];
				let x = this.posa[i2 * 4];
				let y = this.posa[i2 * 4 + 1];
				let z = this.posa[i2 * 4 + 2];
				cb_x = this.posa[i3 * 4] - x;
				cb_y = this.posa[i3 * 4 + 1] - y;
				cb_z = this.posa[i3 * 4 + 2] - z;
				ab_x = this.posa[i1 * 4] - x;
				ab_y = this.posa[i1 * 4 + 1] - y;
				ab_z = this.posa[i1 * 4 + 2] - z;
				let ax = cb_x;
				let ay = cb_y;
				let az = cb_z;
				let vx = ab_x;
				let vy = ab_y;
				let vz = ab_z;
				cb_x = ay * vz - az * vy;
				cb_y = az * vx - ax * vz;
				cb_z = ax * vy - ay * vx;
				let n = Math.sqrt(cb_x * cb_x + cb_y * cb_y + cb_z * cb_z);
				if(n > 0.0) {
					let invN = 1.0 / n;
					cb_x *= invN;
					cb_y *= invN;
					cb_z *= invN;
				}
				this.nora[i1 * 2] = cb_x * 32767 | 0;
				this.nora[i1 * 2 + 1] = cb_y * 32767 | 0;
				this.posa[i1 * 4 + 3] = cb_z * 32767 | 0;
				this.nora[i2 * 2] = cb_x * 32767 | 0;
				this.nora[i2 * 2 + 1] = cb_y * 32767 | 0;
				this.posa[i2 * 4 + 3] = cb_z * 32767 | 0;
				this.nora[i3 * 2] = cb_x * 32767 | 0;
				this.nora[i3 * 2 + 1] = cb_y * 32767 | 0;
				this.posa[i3 * 4 + 3] = cb_z * 32767 | 0;
			}
		}
		let _gthis = this;
		if(uvIndices.length > 0) {
			if(udim) {
				let tilesU = 1;
				let tilesV = 1;
				let _g = 0;
				let _g1 = this.uvTemp.length / 2 | 0;
				while(_g < _g1) {
					let i = _g++;
					while(this.uvTemp[i * 2] > tilesU) tilesU += 1;
					while(this.uvTemp[i * 2 + 1] > tilesV) ++tilesV;
				}
				let getTile = function(i1,i2,i3) {
					return ((_gthis.uvTemp[uvIndices[i1] * 2] + _gthis.uvTemp[uvIndices[i2] * 2] + _gthis.uvTemp[uvIndices[i3] * 2]) / 3 | 0) + ((_gthis.uvTemp[uvIndices[i1] * 2 + 1] + _gthis.uvTemp[uvIndices[i2] * 2 + 1] + _gthis.uvTemp[uvIndices[i3] * 2 + 1]) / 3 | 0) * tilesU;
				};
				let num = new Uint32Array(tilesU * tilesV);
				let _g2 = 0;
				let _g3 = this.inda.length / 3 | 0;
				while(_g2 < _g3) {
					let i = _g2++;
					num[getTile(this.inda[i * 3],this.inda[i * 3 + 1],this.inda[i * 3 + 2])] += 3;
				}
				this.udims = [];
				this.udimsU = tilesU;
				let _g4 = 0;
				let _g5 = tilesU * tilesV;
				while(_g4 < _g5) {
					let i = _g4++;
					this.udims.push(new Uint32Array(num[i]));
					num[i] = 0;
				}
				let _g6 = 0;
				let _g7 = this.inda.length / 3 | 0;
				while(_g6 < _g7) {
					let i = _g6++;
					let i1 = this.inda[i * 3];
					let i2 = this.inda[i * 3 + 1];
					let i3 = this.inda[i * 3 + 2];
					let tile = getTile(i1,i2,i3);
					let this1 = this.udims[tile];
					let tmp = num[tile];
					num[tile] = tmp + 1;
					this1[tmp] = i1;
					let this2 = this.udims[tile];
					let tmp1 = num[tile];
					num[tile] = tmp1 + 1;
					this2[tmp1] = i2;
					let this3 = this.udims[tile];
					let tmp2 = num[tile];
					num[tile] = tmp2 + 1;
					this3[tmp2] = i3;
				}
				let uvtiles = new Int16Array(this.uvTemp.length);
				let _g8 = 0;
				let _g9 = this.inda.length / 3 | 0;
				while(_g8 < _g9) {
					let i = _g8++;
					let i1 = this.inda[i * 3];
					let i2 = this.inda[i * 3 + 1];
					let i3 = this.inda[i * 3 + 2];
					let tile = getTile(i1,i2,i3);
					let tileU = tile % tilesU;
					let tileV = tile / tilesU | 0;
					uvtiles[uvIndices[i1] * 2] = tileU;
					uvtiles[uvIndices[i1] * 2 + 1] = tileV;
					uvtiles[uvIndices[i2] * 2] = tileU;
					uvtiles[uvIndices[i2] * 2 + 1] = tileV;
					uvtiles[uvIndices[i3] * 2] = tileU;
					uvtiles[uvIndices[i3] * 2 + 1] = tileV;
				}
				let _g10 = 0;
				let _g11 = uvtiles.length;
				while(_g10 < _g11) {
					let i = _g10++;
					this.uvTemp[i] -= uvtiles[i];
				}
			}
			this.texa = new Int16Array(uvIndices.length * 2);
			let _g = 0;
			let _g1 = posIndices.length;
			while(_g < _g1) {
				let i = _g++;
				let uvx = this.uvTemp[uvIndices[i] * 2];
				if(uvx > 1.0) {
					uvx -= uvx | 0;
				}
				let uvy = this.uvTemp[uvIndices[i] * 2 + 1];
				if(uvy > 1.0) {
					uvy -= uvy | 0;
				}
				this.texa[i * 2] = uvx * 32767 | 0;
				this.texa[i * 2 + 1] = (1.0 - uvy) * 32767 | 0;
			}
		}
		arm_format_ObjParser.bytes = null;
		if(!this.hasNext) {
			arm_format_ObjParser.posFirst = arm_format_ObjParser.norFirst = arm_format_ObjParser.uvFirst = null;
		}
	}
	readFaceFast() {
		while(true) {
			this.va[this.vi++] = this.readInt() - 1;
			this.pos++;
			this.ua[this.ui++] = this.readInt() - 1;
			this.pos++;
			this.na[this.ni++] = this.readInt() - 1;
			if(arm_format_ObjParser.bytes.b[this.pos] == 10 || arm_format_ObjParser.bytes.b[this.pos] == 13) {
				break;
			}
			this.pos++;
			if(this.vi >= 3 && (arm_format_ObjParser.bytes.b[this.pos] == 10 || arm_format_ObjParser.bytes.b[this.pos] == 13)) {
				break;
			}
		}
	}
	readFace() {
		while(true) {
			this.va[this.vi++] = this.readInt() - 1;
			if(this.uvTemp.length > 0 || this.norTemp.length > 0) {
				this.pos++;
			}
			if(this.uvTemp.length > 0) {
				this.ua[this.ui++] = this.readInt() - 1;
			}
			if(this.norTemp.length > 0) {
				this.pos++;
				this.na[this.ni++] = this.readInt() - 1;
			}
			if(arm_format_ObjParser.bytes.b[this.pos] == 10 || arm_format_ObjParser.bytes.b[this.pos] == 13) {
				break;
			}
			this.pos++;
			if(this.vi >= 3 && (arm_format_ObjParser.bytes.b[this.pos] == 10 || arm_format_ObjParser.bytes.b[this.pos] == 13)) {
				break;
			}
		}
	}
	readFloat() {
		let bi = 0;
		while(true) {
			let c = arm_format_ObjParser.bytes.b[this.pos];
			if(c == 32 || c == 10 || c == 13) {
				break;
			}
			if(c == 69 || c == 101) {
				this.pos++;
				let first = this.buf[0] == 45 ? -(this.buf[1] - 48) : this.buf[0] - 48;
				let exp = this.readInt();
				let dec = 1;
				let _g = 0;
				let _g1 = exp > 0 ? exp : -exp;
				while(_g < _g1) {
					++_g;
					dec *= 10;
				}
				if(exp > 0) {
					return first * dec;
				} else {
					return first / dec;
				}
			}
			this.pos++;
			this.buf[bi++] = c;
		}
		let res = 0.0;
		let dot = 1;
		let dec = 1;
		let off = this.buf[0] == 45 ? 1 : 0;
		let len = bi - 1;
		let _g = 0;
		let _g1 = bi - off;
		while(_g < _g1) {
			let c = this.buf[len - _g++];
			if(c == 46) {
				dot = dec;
				continue;
			}
			res += (c - 48) * dec;
			dec *= 10;
		}
		if(off > 0) {
			res /= -dot;
		} else {
			res /= dot;
		}
		return res;
	}
	readInt() {
		let bi = 0;
		while(true) {
			let c = arm_format_ObjParser.bytes.b[this.pos];
			if(c == 47 || c == 10 || c == 13 || c == 32) {
				break;
			}
			this.pos++;
			this.buf[bi++] = c;
		}
		let res = 0;
		let dec = 1;
		let off = this.buf[0] == 45 ? 1 : 0;
		let len = bi - 1;
		let _g = 0;
		let _g1 = bi - off;
		while(_g < _g1) {
			res += (this.buf[len - _g++] - 48) * dec;
			dec *= 10;
		}
		if(off > 0) {
			res *= -1;
		}
		return res;
	}
	readString() {
		let begin = this.pos;
		while(true) {
			let c = arm_format_ObjParser.bytes.b[this.pos];
			if(c == 10 || c == 13 || c == 32) {
				break;
			}
			this.pos++;
		}
		return arm_format_ObjParser.bytes.getString(begin,this.pos - begin);
	}
	nextLine() {
		while(!(arm_format_ObjParser.bytes.b[this.pos++] == 10 || this.pos >= arm_format_ObjParser.bytes.length)) {
		}
	}
}
$hxClasses["arm.format.ObjParser"] = arm_format_ObjParser;
arm_format_ObjParser.__name__ = "arm.format.ObjParser";
Object.assign(arm_format_ObjParser.prototype, {
	__class__: arm_format_ObjParser
});
class arm_geom_Plane {
	constructor(sizeX,sizeY,vertsX,vertsY,uvScale) {
		if(uvScale == null) {
			uvScale = 1.0;
		}
		if(vertsY == null) {
			vertsY = 2;
		}
		if(vertsX == null) {
			vertsX = 2;
		}
		if(sizeY == null) {
			sizeY = 1.0;
		}
		if(sizeX == null) {
			sizeX = 1.0;
		}
		this.scalePos = 1.0;
		this.inda = null;
		this.texa = null;
		this.nora = null;
		this.posa = null;
		let halfX = sizeX / 2;
		let halfY = sizeY / 2;
		this.scalePos = Math.max(halfX,halfY);
		let inv = 1 / this.scalePos * 32767;
		this.posa = new Int16Array(vertsX * vertsY * 4);
		this.nora = new Int16Array(vertsX * vertsY * 2);
		this.texa = new Int16Array(vertsX * vertsY * 2);
		this.inda = new Uint32Array((vertsX - 1) * (vertsY - 1) * 6);
		let stepX = sizeX / (vertsX - 1);
		let stepY = sizeY / (vertsY - 1);
		let _g = 0;
		let _g1 = vertsX * vertsY;
		while(_g < _g1) {
			let i = _g++;
			let x = i % vertsX * stepX - halfX;
			let y = (i / vertsX | 0) * stepY - halfY;
			this.posa[i * 4] = x * inv | 0;
			this.posa[i * 4 + 1] = y * inv | 0;
			this.posa[i * 4 + 2] = 0;
			this.nora[i * 2] = 0;
			this.nora[i * 2 + 1] = 0;
			this.posa[i * 4 + 3] = 32767;
			x = i % vertsX / (vertsX - 1);
			y = (i / vertsX | 0) / (vertsY - 1);
			this.texa[i * 2] = (x * 32767 * uvScale | 0) % 32767;
			this.texa[i * 2 + 1] = (y * 32767 * uvScale | 0) % 32767;
		}
		let _g2 = 0;
		let _g3 = (vertsX - 1) * (vertsY - 1);
		while(_g2 < _g3) {
			let i = _g2++;
			let x = i % (vertsX - 1);
			let y = i / (vertsY - 1) | 0;
			this.inda[i * 6] = y * vertsX + x;
			this.inda[i * 6 + 1] = y * vertsX + x + 1;
			this.inda[i * 6 + 2] = (y + 1) * vertsX + x;
			this.inda[i * 6 + 3] = y * vertsX + x + 1;
			this.inda[i * 6 + 4] = (y + 1) * vertsX + x + 1;
			this.inda[i * 6 + 5] = (y + 1) * vertsX + x;
		}
	}
}
$hxClasses["arm.geom.Plane"] = arm_geom_Plane;
arm_geom_Plane.__name__ = "arm.geom.Plane";
Object.assign(arm_geom_Plane.prototype, {
	__class__: arm_geom_Plane
});
class arm_geom_Sphere {
	constructor(radius,widthSegments,heightSegments,stretchUV,uvScale) {
		if(uvScale == null) {
			uvScale = 1.0;
		}
		if(stretchUV == null) {
			stretchUV = true;
		}
		if(heightSegments == null) {
			heightSegments = 16;
		}
		if(widthSegments == null) {
			widthSegments = 32;
		}
		if(radius == null) {
			radius = 1.0;
		}
		this.scalePos = 1.0;
		this.inda = null;
		this.texa = null;
		this.nora = null;
		this.posa = null;
		this.scalePos = radius;
		let inv = 1 / this.scalePos * 32767;
		let pi2 = Math.PI * 2;
		let widthVerts = widthSegments + 1;
		let heightVerts = heightSegments + 1;
		this.posa = new Int16Array(widthVerts * heightVerts * 4);
		this.nora = new Int16Array(widthVerts * heightVerts * 2);
		this.texa = new Int16Array(widthVerts * heightVerts * 2);
		this.inda = new Uint32Array(widthSegments * heightSegments * 6 - widthSegments * 6);
		let _this_x = 0.0;
		let _this_y = 0.0;
		let _this_z = 0.0;
		let pos = 0;
		let _g = 0;
		while(_g < heightVerts) {
			let y = _g++;
			let v = y / heightSegments;
			let vFlip = 1.0 - v;
			if(!stretchUV) {
				vFlip /= 2;
			}
			let uOff = y == 0 ? 0.5 / widthSegments : y == heightSegments ? -0.5 / widthSegments : 0.0;
			let _g1 = 0;
			while(_g1 < widthVerts) {
				let u = _g1++ / widthSegments;
				let uPI2 = u * pi2;
				let vPI = v * Math.PI;
				let vPIsin = Math.sin(vPI);
				let vx = -radius * Math.cos(uPI2) * vPIsin;
				let vy = radius * Math.cos(vPI);
				let vz = radius * Math.sin(uPI2) * vPIsin;
				let i4 = pos * 4;
				let i2 = pos * 2;
				this.posa[i4] = vx * inv | 0;
				this.posa[i4 + 1] = vy * inv | 0;
				this.posa[i4 + 2] = vz * inv | 0;
				_this_x = vx;
				_this_y = vy;
				_this_z = vz;
				let n = Math.sqrt(vx * vx + vy * vy + vz * vz);
				if(n > 0.0) {
					let invN = 1.0 / n;
					_this_x = vx * invN;
					_this_y = vy * invN;
					_this_z = vz * invN;
				}
				this.posa[i4 + 3] = _this_z * 32767 | 0;
				this.nora[i2] = _this_x * 32767 | 0;
				this.nora[i2 + 1] = _this_y * 32767 | 0;
				this.texa[i2] = ((u + uOff) * 32767 * uvScale | 0) % 32767;
				this.texa[i2 + 1] = (vFlip * 32767 * uvScale | 0) % 32767;
				++pos;
			}
		}
		pos = 0;
		let heightSegments1 = heightSegments - 1;
		let _g1 = 0;
		while(_g1 < heightSegments) {
			let y = _g1++;
			let _g = 0;
			while(_g < widthSegments) {
				let x = _g++;
				let x1 = x + 1;
				let y1 = y + 1;
				let b = y * widthVerts + x;
				let d = y1 * widthVerts + x1;
				if(y > 0) {
					this.inda[pos++] = y * widthVerts + x1;
					this.inda[pos++] = b;
					this.inda[pos++] = d;
				}
				if(y < heightSegments1) {
					this.inda[pos++] = b;
					this.inda[pos++] = y1 * widthVerts + x;
					this.inda[pos++] = d;
				}
			}
		}
	}
}
$hxClasses["arm.geom.Sphere"] = arm_geom_Sphere;
arm_geom_Sphere.__name__ = "arm.geom.Sphere";
Object.assign(arm_geom_Sphere.prototype, {
	__class__: arm_geom_Sphere
});
class arm_io_ExportArm {
	static runMesh(path,paintObjects) {
		let mesh_datas = [];
		let _g = 0;
		while(_g < paintObjects.length) mesh_datas.push(paintObjects[_g++].data.raw);
		let o = new haxe_io_BytesOutput();
		o.set_bigEndian(false);
		iron_system_ArmPack.write(o,{ mesh_datas : mesh_datas});
		let b = o.getBytes();
		if(!path.endsWith(".arm")) {
			path += ".arm";
		}
		Krom.fileSaveBytes(path,b.b.bufferValue,b.length + 1);
	}
	static runProject() {
		let mnodes = [];
		let _g = 0;
		let _g1 = arm_Project.materials;
		while(_g < _g1.length) {
			let c = JSON.parse(JSON.stringify(_g1[_g++].canvas));
			let _g2 = 0;
			let _g3 = c.nodes;
			while(_g2 < _g3.length) arm_io_ExportArm.exportNode(_g3[_g2++]);
			mnodes.push(c);
		}
		let bnodes = [];
		let _g2 = 0;
		let _g3 = arm_Project.brushes;
		while(_g2 < _g3.length) bnodes.push(_g3[_g2++].canvas);
		let mgroups = null;
		if(arm_Project.materialGroups.length > 0) {
			mgroups = [];
			let _g = 0;
			let _g1 = arm_Project.materialGroups;
			while(_g < _g1.length) {
				let c = JSON.parse(JSON.stringify(_g1[_g++].canvas));
				let _g2 = 0;
				let _g3 = c.nodes;
				while(_g2 < _g3.length) arm_io_ExportArm.exportNode(_g3[_g2++]);
				mgroups.push(c);
			}
		}
		let md = [];
		let _g4 = 0;
		let _g5 = arm_Project.paintObjects;
		while(_g4 < _g5.length) md.push(_g5[_g4++].data.raw);
		let texture_files = arm_io_ExportArm.assetsToFiles(arm_Project.filepath,arm_Project.assets);
		let font_files = arm_io_ExportArm.fontsToFiles(arm_Project.filepath,arm_Project.fonts);
		let mesh_files = arm_io_ExportArm.meshesToFiles(arm_Project.filepath);
		let bitsPos = arm_App.bitsHandle.position;
		let bpp = bitsPos == 0 ? 8 : bitsPos == 1 ? 16 : 32;
		let ld = [];
		let _g6 = 0;
		let _g7 = arm_Project.layers;
		while(_g6 < _g7.length) {
			let l = _g7[_g6];
			++_g6;
			ld.push({ name : l.name, res : l.texpaint != null ? l.texpaint.get_width() : arm_Project.layers[0].texpaint.get_width(), bpp : bpp, texpaint : l.texpaint != null ? iron_system_Lz4.encode(l.texpaint.getPixels()) : null, texpaint_nor : l.texpaint_nor != null ? iron_system_Lz4.encode(l.texpaint_nor.getPixels()) : null, texpaint_pack : l.texpaint_pack != null ? iron_system_Lz4.encode(l.texpaint_pack.getPixels()) : null, uv_scale : l.scale, uv_rot : l.angle, uv_type : l.uvType, decal_mat : l.uvType == 2 ? l.decalMat.toFloat32Array() : null, opacity_mask : l.maskOpacity, fill_layer : l.fill_layer != null ? arm_Project.materials.indexOf(l.fill_layer) : -1, object_mask : l.objectMask, blending : l.blending, parent : l.parent != null ? arm_Project.layers.indexOf(l.parent) : -1, visible : l.visible, paint_base : l.paintBase, paint_opac : l.paintOpac, paint_occ : l.paintOcc, paint_rough : l.paintRough, paint_met : l.paintMet, paint_nor : l.paintNor, paint_nor_blend : l.paintNorBlend, paint_height : l.paintHeight, paint_height_blend : l.paintHeightBlend, paint_emis : l.paintEmis, paint_subs : l.paintSubs});
		}
		arm_Project.raw = { version : Main.version, material_nodes : mnodes, material_groups : mgroups, brush_nodes : bnodes, mesh_datas : md, layer_datas : ld, assets : texture_files, font_assets : font_files, mesh_assets : mesh_files, atlas_objects : arm_Project.atlasObjects, atlas_names : arm_Project.atlasNames, swatches : arm_Project.raw.swatches, packed_assets : arm_Project.raw.packed_assets == null || arm_Project.raw.packed_assets.length == 0 ? null : arm_Project.raw.packed_assets, envmap : arm_Project.raw.envmap != null ? (arm_Project.raw.envmap != null ? arm_Project.filepath.charAt(0) == arm_Project.raw.envmap.charAt(0) : true) ? arm_sys_Path.toRelative(arm_Project.filepath,arm_Project.raw.envmap) : arm_Project.raw.envmap : null, envmap_strength : iron_Scene.active.world.probe.raw.strength, camera_world : iron_Scene.active.camera.transform.local.toFloat32Array(), camera_origin : arm_io_ExportArm.vec3f32(arm_Camera.inst.origins[0]), camera_fov : iron_Scene.active.camera.data.raw.fov, is_bgra : false};
		if(arm_Project.filepath.endsWith("_packed_.arm")) {
			arm_io_ExportArm.packAssets(arm_Project.raw,arm_Project.assets);
		}
		let d = arm_Project.raw;
		let o = new haxe_io_BytesOutput();
		o.set_bigEndian(false);
		iron_system_ArmPack.write(o,d);
		let bytes = o.getBytes();
		Krom.fileSaveBytes(arm_Project.filepath,bytes.b.bufferValue,bytes.length + 1);
		let recent_path = arm_Project.filepath;
		let recent = arm_Config.raw.recent_projects;
		HxOverrides.remove(recent,recent_path);
		recent.unshift(recent_path);
		arm_Config.save();
		arm_Console.info("Project saved.");
	}
	static exportNode(n,assets) {
		if(n.type == "TEX_IMAGE") {
			let index = n.buttons[0].default_value;
			let tmp = arm_App.enumTexts(n.type);
			n.buttons[0].data = tmp[index];
			if(assets != null) {
				let asset = arm_Project.assets[index];
				if(assets.indexOf(asset) == -1) {
					assets.push(asset);
				}
			}
		}
		if(n.color > 0) {
			n.color -= 4294967296;
		}
		let _g = 0;
		let _g1 = n.inputs;
		while(_g < _g1.length) {
			let inp = _g1[_g];
			++_g;
			if(inp.color > 0) {
				inp.color -= 4294967296;
			}
		}
		let _g2 = 0;
		let _g3 = n.outputs;
		while(_g2 < _g3.length) {
			let out = _g3[_g2];
			++_g2;
			if(out.color > 0) {
				out.color -= 4294967296;
			}
		}
	}
	static runMaterial(path) {
		if(!path.endsWith(".arm")) {
			path += ".arm";
		}
		let mnodes = [];
		let mgroups = null;
		let m = arm_Context.material;
		let c = JSON.parse(JSON.stringify(m.canvas));
		let assets = [];
		if(arm_ui_UINodes.hasGroup(c)) {
			mgroups = [];
			arm_ui_UINodes.traverseGroup(mgroups,c);
			let _g = 0;
			while(_g < mgroups.length) {
				let _g1 = 0;
				let _g2 = mgroups[_g++].nodes;
				while(_g1 < _g2.length) arm_io_ExportArm.exportNode(_g2[_g1++],assets);
			}
		}
		let _g = 0;
		let _g1 = c.nodes;
		while(_g < _g1.length) arm_io_ExportArm.exportNode(_g1[_g++],assets);
		mnodes.push(c);
		let texture_files = arm_io_ExportArm.assetsToFiles(path,assets);
		let isCloud = path.endsWith("_cloud_.arm");
		if(isCloud) {
			path = StringTools.replace(path,"_cloud_","");
		}
		let packed_assets = null;
		if(!arm_Context.packAssetsOnExport) {
			packed_assets = arm_io_ExportArm.getPackedAssets(path,texture_files);
		}
		let raw = { version : Main.version, material_nodes : mnodes, material_groups : mgroups, material_icons : isCloud ? null : [iron_system_Lz4.encode(m.image.getPixels())], assets : texture_files, packed_assets : packed_assets};
		if(arm_Context.writeIconOnExport) {
			Krom.writePng(HxOverrides.substr(path,0,path.length - 4) + "_icon.png",m.image.getPixels().b.bufferValue,m.image.get_width(),m.image.get_height(),0);
			if(isCloud) {
				Krom.writeJpg(HxOverrides.substr(path,0,path.length - 4) + "_icon.jpg",m.image.getPixels().b.bufferValue,m.image.get_width(),m.image.get_height(),0,50);
			}
		}
		if(arm_Context.packAssetsOnExport) {
			arm_io_ExportArm.packAssets(raw,assets);
		}
		let o = new haxe_io_BytesOutput();
		o.set_bigEndian(false);
		iron_system_ArmPack.write(o,raw);
		let bytes = o.getBytes();
		Krom.fileSaveBytes(path,bytes.b.bufferValue,bytes.length + 1);
	}
	static runBrush(path) {
		if(!path.endsWith(".arm")) {
			path += ".arm";
		}
		let bnodes = [];
		let b = arm_Context.brush;
		let c = JSON.parse(JSON.stringify(b.canvas));
		let assets = [];
		let _g = 0;
		let _g1 = c.nodes;
		while(_g < _g1.length) arm_io_ExportArm.exportNode(_g1[_g++],assets);
		bnodes.push(c);
		let texture_files = arm_io_ExportArm.assetsToFiles(path,assets);
		let isCloud = path.endsWith("_cloud_.arm");
		if(isCloud) {
			path = StringTools.replace(path,"_cloud_","");
		}
		let packed_assets = null;
		if(!arm_Context.packAssetsOnExport) {
			packed_assets = arm_io_ExportArm.getPackedAssets(path,texture_files);
		}
		let raw = { version : Main.version, brush_nodes : bnodes, brush_icons : isCloud ? null : [iron_system_Lz4.encode(b.image.getPixels())], assets : texture_files, packed_assets : packed_assets};
		if(arm_Context.writeIconOnExport) {
			Krom.writePng(HxOverrides.substr(path,0,path.length - 4) + "_icon.png",b.image.getPixels().b.bufferValue,b.image.get_width(),b.image.get_height(),0);
		}
		if(arm_Context.packAssetsOnExport) {
			arm_io_ExportArm.packAssets(raw,assets);
		}
		let o = new haxe_io_BytesOutput();
		o.set_bigEndian(false);
		iron_system_ArmPack.write(o,raw);
		let bytes = o.getBytes();
		Krom.fileSaveBytes(path,bytes.b.bufferValue,bytes.length + 1);
	}
	static assetsToFiles(projectPath,assets) {
		let texture_files = [];
		let _g = 0;
		while(_g < assets.length) {
			let a = assets[_g];
			++_g;
			if(projectPath.charAt(0) == a.file.charAt(0)) {
				texture_files.push(arm_sys_Path.toRelative(projectPath,a.file));
			} else {
				texture_files.push(a.file);
			}
		}
		return texture_files;
	}
	static meshesToFiles(projectPath) {
		let mesh_files = [];
		let _g = 0;
		let _g1 = arm_Project.meshAssets;
		while(_g < _g1.length) {
			let file = _g1[_g];
			++_g;
			if(projectPath.charAt(0) == file.charAt(0)) {
				mesh_files.push(arm_sys_Path.toRelative(projectPath,file));
			} else {
				mesh_files.push(file);
			}
		}
		return mesh_files;
	}
	static fontsToFiles(projectPath,fonts) {
		let font_files = [];
		let _g = 1;
		let _g1 = fonts.length;
		while(_g < _g1) {
			let f = fonts[_g++];
			if(projectPath.charAt(0) == f.file.charAt(0)) {
				font_files.push(arm_sys_Path.toRelative(projectPath,f.file));
			} else {
				font_files.push(f.file);
			}
		}
		return font_files;
	}
	static getPackedAssets(projectPath,texture_files) {
		let packed_assets = null;
		if(arm_Project.raw.packed_assets != null) {
			let _g = 0;
			let _g1 = arm_Project.raw.packed_assets;
			while(_g < _g1.length) {
				let pa = _g1[_g];
				++_g;
				pa.name = projectPath.charAt(0) == pa.name.charAt(0) ? arm_sys_Path.toRelative(projectPath,pa.name) : pa.name;
				let _g2 = 0;
				while(_g2 < texture_files.length) if(pa.name == texture_files[_g2++]) {
					if(packed_assets == null) {
						packed_assets = [];
					}
					packed_assets.push(pa);
					break;
				}
			}
		}
		return packed_assets;
	}
	static packAssets(raw,assets) {
		if(raw.packed_assets == null) {
			raw.packed_assets = [];
		}
		let tempImages = [];
		let _g = 0;
		let _g1 = assets.length;
		while(_g < _g1) {
			let i = _g++;
			if(!arm_Project.packedAssetExists(raw.packed_assets,assets[i].file)) {
				let image = arm_Project.getImage(assets[i]);
				let temp = kha_Image.createRenderTarget(image.get_width(),image.get_height());
				temp.get_g2().begin(false);
				temp.get_g2().drawImage(image,0,0);
				temp.get_g2().end();
				tempImages.push(temp);
				raw.packed_assets.push({ name : assets[i].file, bytes : haxe_io_Bytes.ofData(assets[i].file.endsWith(".jpg") ? Krom.encodeJpg(temp.getPixels().b.bufferValue,temp.get_width(),temp.get_height(),0,80) : Krom.encodePng(temp.getPixels().b.bufferValue,temp.get_width(),temp.get_height(),0))});
			}
		}
		arm_App.notifyOnNextFrame(function() {
			let _g = 0;
			while(_g < tempImages.length) tempImages[_g++].unload();
		});
	}
	static runSwatches(path) {
		if(!path.endsWith(".arm")) {
			path += ".arm";
		}
		let raw = { version : Main.version, swatches : arm_Project.raw.swatches};
		let o = new haxe_io_BytesOutput();
		o.set_bigEndian(false);
		iron_system_ArmPack.write(o,raw);
		let bytes = o.getBytes();
		Krom.fileSaveBytes(path,bytes.b.bufferValue,bytes.length + 1);
	}
	static vec3f32(v) {
		let res = new Float32Array(3);
		res[0] = v.x;
		res[1] = v.y;
		res[2] = v.z;
		return res;
	}
}
$hxClasses["arm.io.ExportArm"] = arm_io_ExportArm;
arm_io_ExportArm.__name__ = "arm.io.ExportArm";
class arm_io_ExportMesh {
	static run(path,paintObjects,applyDisplacement) {
		if(applyDisplacement == null) {
			applyDisplacement = false;
		}
		if(paintObjects == null) {
			paintObjects = arm_Project.paintObjects;
		}
		if(arm_Context.exportMeshFormat == 0) {
			arm_io_ExportObj.run(path,paintObjects,applyDisplacement);
		} else {
			arm_io_ExportArm.runMesh(path,paintObjects);
		}
	}
}
$hxClasses["arm.io.ExportMesh"] = arm_io_ExportMesh;
arm_io_ExportMesh.__name__ = "arm.io.ExportMesh";
class arm_io_ExportObj {
	static run(path,paintObjects,applyDisplacement) {
		if(applyDisplacement == null) {
			applyDisplacement = false;
		}
		let o = new haxe_io_BytesOutput();
		o.set_bigEndian(false);
		o.writeString("# armorpaint.org\n");
		let poff = 0;
		let noff = 0;
		let toff = 0;
		let _g = 0;
		while(_g < paintObjects.length) {
			let p = paintObjects[_g];
			++_g;
			let mesh = p.data.raw;
			let sc = p.data.scalePos * 3.0518509475997192e-005;
			let posa = mesh.vertex_arrays[0].values;
			let nora = mesh.vertex_arrays[1].values;
			let texa = mesh.vertex_arrays[2].values;
			let len = posa.length / 4 | 0;
			let posa2 = new Int16Array(len * 3);
			let nora2 = new Int16Array(len * 3);
			let texa2 = new Int16Array(len * 2);
			let posmap_h = { };
			let normap_h = { };
			let texmap_h = { };
			let pi = 0;
			let ni = 0;
			let ti = 0;
			let _g1 = 0;
			while(_g1 < len) {
				let i = _g1++;
				let found = false;
				let _g = 0;
				let _g2 = pi;
				while(_g < _g2) {
					let j = _g++;
					if(posa2[j * 3] == posa[i * 4] && posa2[j * 3 + 1] == posa[i * 4 + 1] && posa2[j * 3 + 2] == posa[i * 4 + 2]) {
						posmap_h[i] = j;
						found = true;
						break;
					}
				}
				if(!found) {
					posmap_h[i] = pi;
					posa2[pi * 3] = posa[i * 4];
					posa2[pi * 3 + 1] = posa[i * 4 + 1];
					posa2[pi * 3 + 2] = posa[i * 4 + 2];
					++pi;
				}
				found = false;
				let _g3 = 0;
				let _g4 = ni;
				while(_g3 < _g4) {
					let j = _g3++;
					if(nora2[j * 3] == nora[i * 2] && nora2[j * 3 + 1] == nora[i * 2 + 1] && nora2[j * 3 + 2] == posa[i * 4 + 3]) {
						normap_h[i] = j;
						found = true;
						break;
					}
				}
				if(!found) {
					normap_h[i] = ni;
					nora2[ni * 3] = nora[i * 2];
					nora2[ni * 3 + 1] = nora[i * 2 + 1];
					nora2[ni * 3 + 2] = posa[i * 4 + 3];
					++ni;
				}
				found = false;
				let _g5 = 0;
				let _g6 = ti;
				while(_g5 < _g6) {
					let j = _g5++;
					if(texa2[j * 2] == texa[i * 2] && texa2[j * 2 + 1] == texa[i * 2 + 1]) {
						texmap_h[i] = j;
						found = true;
						break;
					}
				}
				if(!found) {
					texmap_h[i] = ti;
					texa2[ti * 2] = texa[i * 2];
					texa2[ti * 2 + 1] = texa[i * 2 + 1];
					++ti;
				}
			}
			o.writeString("o " + p.name + "\n");
			let _g2 = 0;
			let _g3 = pi;
			while(_g2 < _g3) {
				let i = _g2++;
				o.writeString("v ");
				o.writeString(posa2[i * 3] * sc + "");
				o.writeString(" ");
				o.writeString(posa2[i * 3 + 2] * sc + "");
				o.writeString(" ");
				o.writeString(-posa2[i * 3 + 1] * sc + "");
				o.writeString("\n");
			}
			let _g4 = 0;
			let _g5 = ni;
			while(_g4 < _g5) {
				let i = _g4++;
				o.writeString("vn ");
				o.writeString(nora2[i * 3] * 3.0518509475997192e-005 + "");
				o.writeString(" ");
				o.writeString(nora2[i * 3 + 2] * 3.0518509475997192e-005 + "");
				o.writeString(" ");
				o.writeString(-nora2[i * 3 + 1] * 3.0518509475997192e-005 + "");
				o.writeString("\n");
			}
			let _g6 = 0;
			let _g7 = ti;
			while(_g6 < _g7) {
				let i = _g6++;
				o.writeString("vt ");
				o.writeString(texa2[i * 2] * 3.0518509475997192e-005 + "");
				o.writeString(" ");
				o.writeString(1.0 - texa2[i * 2 + 1] * 3.0518509475997192e-005 + "");
				o.writeString("\n");
			}
			let inda = mesh.index_arrays[0].values;
			let _g8 = 0;
			let _g9 = inda.length / 3 | 0;
			while(_g8 < _g9) {
				let i = _g8++;
				let pi1 = posmap_h[inda[i * 3]] + 1 + poff;
				let pi2 = posmap_h[inda[i * 3 + 1]] + 1 + poff;
				let pi3 = posmap_h[inda[i * 3 + 2]] + 1 + poff;
				let ni1 = normap_h[inda[i * 3]] + 1 + noff;
				let ni2 = normap_h[inda[i * 3 + 1]] + 1 + noff;
				let ni3 = normap_h[inda[i * 3 + 2]] + 1 + noff;
				let ti1 = texmap_h[inda[i * 3]] + 1 + toff;
				let ti2 = texmap_h[inda[i * 3 + 1]] + 1 + toff;
				let ti3 = texmap_h[inda[i * 3 + 2]] + 1 + toff;
				o.writeString("f ");
				o.writeString(pi1 + "");
				o.writeString("/");
				o.writeString(ti1 + "");
				o.writeString("/");
				o.writeString(ni1 + "");
				o.writeString(" ");
				o.writeString(pi2 + "");
				o.writeString("/");
				o.writeString(ti2 + "");
				o.writeString("/");
				o.writeString(ni2 + "");
				o.writeString(" ");
				o.writeString(pi3 + "");
				o.writeString("/");
				o.writeString(ti3 + "");
				o.writeString("/");
				o.writeString(ni3 + "");
				o.writeString("\n");
			}
			poff += pi;
			noff += ni;
			toff += ti;
		}
		if(!path.endsWith(".obj")) {
			path += ".obj";
		}
		Krom.fileSaveBytes(path,o.getBytes().b.bufferValue,o.getBytes().length);
	}
}
$hxClasses["arm.io.ExportObj"] = arm_io_ExportObj;
arm_io_ExportObj.__name__ = "arm.io.ExportObj";
class arm_io_ExportTexture {
	static run(path,bakeMaterial) {
		if(bakeMaterial == null) {
			bakeMaterial = false;
		}
		if(bakeMaterial) {
			arm_io_ExportTexture.runBakeMaterial(path);
		} else if(arm_Context.layersExport == 3) {
			let udimTiles = [];
			let _g = 0;
			let _g1 = arm_Project.layers;
			while(_g < _g1.length) {
				let l = _g1[_g];
				++_g;
				if(l.getObjectMask() > 0) {
					let name = arm_Project.paintObjects[l.getObjectMask() - 1].name;
					if(HxOverrides.substr(name,name.length - 5,2) == ".1") {
						udimTiles.push(HxOverrides.substr(name,name.length - 5,null));
					}
				}
			}
			if(udimTiles.length > 0) {
				let _g = 0;
				while(_g < udimTiles.length) arm_io_ExportTexture.runLayers(path,arm_Project.layers,udimTiles[_g++]);
			} else {
				arm_io_ExportTexture.runLayers(path,arm_Project.layers);
			}
		} else if(arm_Context.layersExport == 2) {
			let objectNames = [];
			let _g = 0;
			let _g1 = arm_Project.layers;
			while(_g < _g1.length) {
				let l = _g1[_g];
				++_g;
				if(l.getObjectMask() > 0) {
					let name = arm_Project.paintObjects[l.getObjectMask() - 1].name;
					if(objectNames.indexOf(name) == -1) {
						objectNames.push(name);
					}
				}
			}
			if(objectNames.length > 0) {
				let _g = 0;
				while(_g < objectNames.length) arm_io_ExportTexture.runLayers(path,arm_Project.layers,objectNames[_g++]);
			} else {
				arm_io_ExportTexture.runLayers(path,arm_Project.layers);
			}
		} else {
			let atlasExport = false;
			if(arm_Project.atlasObjects != null) {
				let _g = 1;
				let _g1 = arm_Project.atlasObjects.length;
				while(_g < _g1) {
					let i = _g++;
					if(arm_Project.atlasObjects[i - 1] != arm_Project.atlasObjects[i]) {
						atlasExport = true;
						break;
					}
				}
			}
			if(atlasExport) {
				let _g = 0;
				let _g1 = arm_Project.atlasObjects.length;
				while(_g < _g1) {
					let atlasIndex = _g++;
					let layers = [];
					let _g1 = 0;
					let _g2 = arm_Project.atlasObjects.length;
					while(_g1 < _g2) {
						let objectIndex = _g1++;
						if(arm_Project.atlasObjects[objectIndex] == atlasIndex) {
							let _g = 0;
							let _g1 = arm_Project.layers;
							while(_g < _g1.length) {
								let l = _g1[_g];
								++_g;
								if(l.getObjectMask() == 0 || l.getObjectMask() - 1 == objectIndex) {
									layers.push(l);
								}
							}
						}
					}
					if(layers.length > 0) {
						arm_io_ExportTexture.runLayers(path,layers,arm_Project.atlasNames[atlasIndex]);
					}
				}
			} else {
				arm_io_ExportTexture.runLayers(path,arm_Context.layersExport == 1 ? arm_Context.layer.isGroup() ? arm_Context.layer.getChildren() : [arm_Context.layer] : arm_Project.layers);
			}
		}
		arm_Console.info(arm_Translator.tr("Textures exported."));
		arm_ui_UIFiles.lastPath = "";
	}
	static runBakeMaterial(path) {
		if(arm_render_RenderPathPaint.liveLayer == null) {
			arm_render_RenderPathPaint.liveLayer = new arm_data_LayerSlot("_live");
		}
		let _space = arm_ui_UIHeader.inst.worktab.position;
		let _tool = arm_Context.tool;
		arm_ui_UIHeader.inst.worktab.position = 0;
		arm_Context.tool = 2;
		arm_node_MakeMaterial.parsePaintMaterial();
		let _paintObject = arm_Context.paintObject;
		let planeo = iron_Scene.active.getChild(".Plane");
		planeo.visible = true;
		arm_Context.paintObject = planeo;
		arm_Context.pdirty = 1;
		arm_render_RenderPathPaint.useLiveLayer(true);
		arm_render_RenderPathPaint.commandsPaint(false);
		arm_render_RenderPathPaint.useLiveLayer(false);
		arm_Context.tool = _tool;
		arm_node_MakeMaterial.parsePaintMaterial();
		arm_Context.pdirty = 0;
		arm_ui_UIHeader.inst.worktab.position = _space;
		planeo.visible = false;
		arm_Context.paintObject = _paintObject;
		arm_io_ExportTexture.runLayers(path,[arm_render_RenderPathPaint.liveLayer],"",true);
	}
	static runLayers(path,layers,objectName,bakeMaterial) {
		if(bakeMaterial == null) {
			bakeMaterial = false;
		}
		if(objectName == null) {
			objectName = "";
		}
		let textureSizeX = arm_Config.getTextureResX();
		let textureSizeY = arm_Config.getTextureResY();
		let formatQuality = arm_Context.formatQuality;
		let f = arm_ui_UIFiles.filename;
		if(f == "") {
			f = arm_Translator.tr("untitled");
		}
		let formatType = arm_Context.formatType;
		let bits = arm_App.bitsHandle.position == 0 ? 8 : 16;
		let ext = bits == 16 ? ".exr" : formatType == 0 ? ".png" : ".jpg";
		if(f.endsWith(ext)) {
			f = HxOverrides.substr(f,0,f.length - 4);
		}
		let isUdim = arm_Context.layersExport == 3;
		if(isUdim) {
			ext = objectName + ext;
		}
		arm_Layers.makeTempImg();
		arm_Layers.makeExportImg();
		if(arm_Layers.pipeMerge == null) {
			arm_Layers.makePipe();
		}
		if(iron_data_ConstData.screenAlignedVB == null) {
			iron_data_ConstData.createScreenAlignedData();
		}
		let empty = iron_RenderPath.active.renderTargets.h["empty_white"].image;
		let exportSelected = arm_Context.layersExport == 1;
		if(exportSelected && layers[0].getObjectMask() > 0) {
			f += "_" + arm_Project.paintObjects[layers[0].getObjectMask() - 1].name;
		}
		if(!isUdim && !exportSelected && objectName != "") {
			f += "_" + objectName;
		}
		arm_Layers.expa.get_g4().begin();
		arm_Layers.expa.get_g4().clear(kha_Color.fromFloats(0.0,0.0,0.0,0.0));
		arm_Layers.expa.get_g4().end();
		arm_Layers.expb.get_g4().begin();
		arm_Layers.expb.get_g4().clear(kha_Color.fromFloats(0.5,0.5,1.0,0.0));
		arm_Layers.expb.get_g4().end();
		arm_Layers.expc.get_g4().begin();
		arm_Layers.expc.get_g4().clear(kha_Color.fromFloats(1.0,0.0,0.0,0.0));
		arm_Layers.expc.get_g4().end();
		let _g = 0;
		while(_g < layers.length) {
			let l1 = layers[_g];
			++_g;
			if(!exportSelected && !l1.isVisible()) {
				continue;
			}
			if(!l1.isLayer()) {
				continue;
			}
			if(objectName != "" && l1.getObjectMask() > 0) {
				if(isUdim && !arm_Project.paintObjects[l1.getObjectMask() - 1].name.endsWith(objectName)) {
					continue;
				}
				let perObject = arm_Context.layersExport == 2;
				if(perObject && arm_Project.paintObjects[l1.getObjectMask() - 1].name != objectName) {
					continue;
				}
			}
			let mask = empty;
			let l1masks = l1.getMasks();
			if(l1masks != null && !bakeMaterial) {
				if(l1masks.length > 1) {
					arm_Layers.makeTempMaskImg();
					arm_Layers.tempMaskImage.get_g2().begin(true,0);
					arm_Layers.tempMaskImage.get_g2().end();
					let l1 = { texpaint : arm_Layers.tempMaskImage};
					let _g = 0;
					let _g1 = l1masks.length;
					while(_g < _g1) {
						let i = _g++;
						arm_Layers.mergeLayer(l1,l1masks[i]);
					}
					mask = arm_Layers.tempMaskImage;
				} else {
					mask = l1masks[0].texpaint;
				}
			}
			if(l1.paintBase) {
				arm_Layers.tempImage.get_g2().begin(false);
				arm_Layers.tempImage.get_g2().set_pipeline(arm_Layers.pipeCopy);
				arm_Layers.tempImage.get_g2().drawImage(arm_Layers.expa,0,0);
				arm_Layers.tempImage.get_g2().set_pipeline(null);
				arm_Layers.tempImage.get_g2().end();
				arm_Layers.expa.get_g4().begin();
				arm_Layers.expa.get_g4().setPipeline(arm_Layers.pipeMerge);
				arm_Layers.expa.get_g4().setTexture(arm_Layers.tex0,l1.texpaint);
				arm_Layers.expa.get_g4().setTexture(arm_Layers.tex1,empty);
				arm_Layers.expa.get_g4().setTexture(arm_Layers.texmask,mask);
				arm_Layers.expa.get_g4().setTexture(arm_Layers.texa,arm_Layers.tempImage);
				arm_Layers.expa.get_g4().setFloat(arm_Layers.opac,l1.getOpacity());
				let tmp = layers.length > 1 ? l1.blending : 0;
				arm_Layers.expa.get_g4().setInt(arm_Layers.blending,tmp);
				arm_Layers.expa.get_g4().setVertexBuffer(iron_data_ConstData.screenAlignedVB);
				arm_Layers.expa.get_g4().setIndexBuffer(iron_data_ConstData.screenAlignedIB);
				arm_Layers.expa.get_g4().drawIndexedVertices();
				arm_Layers.expa.get_g4().end();
			}
			if(l1.paintNor) {
				arm_Layers.tempImage.get_g2().begin(false);
				arm_Layers.tempImage.get_g2().set_pipeline(arm_Layers.pipeCopy);
				arm_Layers.tempImage.get_g2().drawImage(arm_Layers.expb,0,0);
				arm_Layers.tempImage.get_g2().set_pipeline(null);
				arm_Layers.tempImage.get_g2().end();
				arm_Layers.expb.get_g4().begin();
				arm_Layers.expb.get_g4().setPipeline(arm_Layers.pipeMerge);
				arm_Layers.expb.get_g4().setTexture(arm_Layers.tex0,l1.texpaint);
				arm_Layers.expb.get_g4().setTexture(arm_Layers.tex1,l1.texpaint_nor);
				arm_Layers.expb.get_g4().setTexture(arm_Layers.texmask,mask);
				arm_Layers.expb.get_g4().setTexture(arm_Layers.texa,arm_Layers.tempImage);
				arm_Layers.expb.get_g4().setFloat(arm_Layers.opac,l1.getOpacity());
				let tmp = l1.paintNorBlend ? -2 : -1;
				arm_Layers.expb.get_g4().setInt(arm_Layers.blending,tmp);
				arm_Layers.expb.get_g4().setVertexBuffer(iron_data_ConstData.screenAlignedVB);
				arm_Layers.expb.get_g4().setIndexBuffer(iron_data_ConstData.screenAlignedIB);
				arm_Layers.expb.get_g4().drawIndexedVertices();
				arm_Layers.expb.get_g4().end();
			}
			if(l1.paintOcc || l1.paintRough || l1.paintMet || l1.paintHeight) {
				arm_Layers.tempImage.get_g2().begin(false);
				arm_Layers.tempImage.get_g2().set_pipeline(arm_Layers.pipeCopy);
				arm_Layers.tempImage.get_g2().drawImage(arm_Layers.expc,0,0);
				arm_Layers.tempImage.get_g2().set_pipeline(null);
				arm_Layers.tempImage.get_g2().end();
				if(l1.paintOcc && l1.paintRough && l1.paintMet && l1.paintHeight) {
					arm_Layers.commandsMergePack(arm_Layers.pipeMerge,arm_Layers.expc,l1.texpaint,l1.texpaint_pack,l1.getOpacity(),mask,l1.paintHeightBlend ? -3 : -1);
				} else {
					if(l1.paintOcc) {
						arm_Layers.commandsMergePack(arm_Layers.pipeMergeR,arm_Layers.expc,l1.texpaint,l1.texpaint_pack,l1.getOpacity(),mask);
					}
					if(l1.paintRough) {
						arm_Layers.commandsMergePack(arm_Layers.pipeMergeG,arm_Layers.expc,l1.texpaint,l1.texpaint_pack,l1.getOpacity(),mask);
					}
					if(l1.paintMet) {
						arm_Layers.commandsMergePack(arm_Layers.pipeMergeB,arm_Layers.expc,l1.texpaint,l1.texpaint_pack,l1.getOpacity(),mask);
					}
				}
			}
		}
		let texpaint = arm_Layers.expa;
		let texpaint_nor = arm_Layers.expb;
		let texpaint_pack = arm_Layers.expc;
		let pixpaint = null;
		let pixpaint_nor = null;
		let pixpaint_pack = null;
		let preset = arm_ui_BoxExport.preset;
		let pix = null;
		let _g1 = 0;
		let _g2 = preset.textures;
		while(_g1 < _g2.length) {
			let t = _g2[_g1];
			++_g1;
			let _g = 0;
			let _g3 = t.channels;
			while(_g < _g3.length) {
				let c = _g3[_g];
				++_g;
				if((c == "base_r" || c == "base_g" || c == "base_b" || c == "opac") && pixpaint == null) {
					pixpaint = texpaint.getPixels();
				} else if((c == "nor_r" || c == "nor_g" || c == "nor_g_directx" || c == "nor_b" || c == "emis" || c == "subs") && pixpaint_nor == null) {
					pixpaint_nor = texpaint_nor.getPixels();
				} else if((c == "occ" || c == "rough" || c == "metal" || c == "height" || c == "smooth") && pixpaint_pack == null) {
					pixpaint_pack = texpaint_pack.getPixels();
				}
			}
		}
		let _g3 = 0;
		let _g4 = preset.textures;
		while(_g3 < _g4.length) {
			let t = _g4[_g3];
			++_g3;
			let c = t.channels;
			let tex_name = t.name != "" ? "_" + t.name : "";
			let singleChannel = c[0] == c[1] && c[1] == c[2] && c[3] == "1.0";
			if(c[0] == "base_r" && c[1] == "base_g" && c[2] == "base_b" && c[3] == "1.0" && t.color_space == "linear") {
				arm_io_ExportTexture.writeTexture(path + arm_sys_Path.sep + f + tex_name + ext,pixpaint,1);
			} else if(c[0] == "nor_r" && c[1] == "nor_g" && c[2] == "nor_b" && c[3] == "1.0" && t.color_space == "linear") {
				arm_io_ExportTexture.writeTexture(path + arm_sys_Path.sep + f + tex_name + ext,pixpaint_nor,1);
			} else if(c[0] == "occ" && c[1] == "rough" && c[2] == "metal" && c[3] == "1.0" && t.color_space == "linear") {
				arm_io_ExportTexture.writeTexture(path + arm_sys_Path.sep + f + tex_name + ext,pixpaint_pack,1);
			} else if(singleChannel && c[0] == "occ" && t.color_space == "linear") {
				arm_io_ExportTexture.writeTexture(path + arm_sys_Path.sep + f + tex_name + ext,pixpaint_pack,2,0);
			} else if(singleChannel && c[0] == "rough" && t.color_space == "linear") {
				arm_io_ExportTexture.writeTexture(path + arm_sys_Path.sep + f + tex_name + ext,pixpaint_pack,2,1);
			} else if(singleChannel && c[0] == "metal" && t.color_space == "linear") {
				arm_io_ExportTexture.writeTexture(path + arm_sys_Path.sep + f + tex_name + ext,pixpaint_pack,2,2);
			} else if(singleChannel && c[0] == "height" && t.color_space == "linear") {
				arm_io_ExportTexture.writeTexture(path + arm_sys_Path.sep + f + tex_name + ext,pixpaint_pack,2,3);
			} else if(singleChannel && c[0] == "opac" && t.color_space == "linear") {
				arm_io_ExportTexture.writeTexture(path + arm_sys_Path.sep + f + tex_name + ext,pixpaint,2,3);
			} else {
				if(pix == null) {
					pix = new haxe_io_Bytes(new ArrayBuffer(textureSizeX * textureSizeY * 4 * (bits / 8 | 0)));
				}
				let _g = 0;
				while(_g < 4) {
					let i = _g++;
					let c = t.channels[i];
					if(c == "base_r") {
						arm_io_ExportTexture.copyChannel(pixpaint,0,pix,i,t.color_space == "linear");
					} else if(c == "base_g") {
						arm_io_ExportTexture.copyChannel(pixpaint,1,pix,i,t.color_space == "linear");
					} else if(c == "base_b") {
						arm_io_ExportTexture.copyChannel(pixpaint,2,pix,i,t.color_space == "linear");
					} else if(c == "height") {
						arm_io_ExportTexture.copyChannel(pixpaint_pack,3,pix,i,t.color_space == "linear");
					} else if(c == "metal") {
						arm_io_ExportTexture.copyChannel(pixpaint_pack,2,pix,i,t.color_space == "linear");
					} else if(c == "nor_r") {
						arm_io_ExportTexture.copyChannel(pixpaint_nor,0,pix,i,t.color_space == "linear");
					} else if(c == "nor_g") {
						arm_io_ExportTexture.copyChannel(pixpaint_nor,1,pix,i,t.color_space == "linear");
					} else if(c == "nor_g_directx") {
						arm_io_ExportTexture.copyChannelInv(pixpaint_nor,1,pix,i,t.color_space == "linear");
					} else if(c == "nor_b") {
						arm_io_ExportTexture.copyChannel(pixpaint_nor,2,pix,i,t.color_space == "linear");
					} else if(c == "occ") {
						arm_io_ExportTexture.copyChannel(pixpaint_pack,0,pix,i,t.color_space == "linear");
					} else if(c == "opac") {
						arm_io_ExportTexture.copyChannel(pixpaint,3,pix,i,t.color_space == "linear");
					} else if(c == "rough") {
						arm_io_ExportTexture.copyChannel(pixpaint_pack,1,pix,i,t.color_space == "linear");
					} else if(c == "smooth") {
						arm_io_ExportTexture.copyChannelInv(pixpaint_pack,1,pix,i,t.color_space == "linear");
					} else if(c == "emis") {
						arm_io_ExportTexture.extractChannel(pixpaint_nor,3,pix,i,255,t.color_space == "linear");
					} else if(c == "subs") {
						arm_io_ExportTexture.extractChannel(pixpaint_nor,3,pix,i,254,t.color_space == "linear");
					} else if(c == "0.0") {
						arm_io_ExportTexture.setChannel(0,pix,i);
					} else if(c == "1.0") {
						arm_io_ExportTexture.setChannel(255,pix,i);
					}
				}
				arm_io_ExportTexture.writeTexture(path + arm_sys_Path.sep + f + tex_name + ext,pix,3);
			}
		}
	}
	static writeTexture(file,pixels,type,off) {
		if(off == null) {
			off = 0;
		}
		if(type == null) {
			type = 1;
		}
		let resX = arm_Config.getTextureResX();
		let resY = arm_Config.getTextureResY();
		let bitsHandle = arm_App.bitsHandle.position;
		let bits = bitsHandle == 0 ? 8 : bitsHandle == 1 ? 16 : 32;
		let format = 0;
		if(type == 1) {
			format = 2;
		}
		if(type == 2 && off == 0) {
			format = 3;
		}
		if(type == 2 && off == 1) {
			format = 4;
		}
		if(type == 2 && off == 2) {
			format = 5;
		}
		if(type == 2 && off == 3) {
			format = 6;
		}
		if(arm_Context.layersDestination == 1) {
			let image = kha_Image.fromBytes(pixels,resX,resY);
			iron_data_Data.cachedImages.h[file] = image;
			let ar = file.split(arm_sys_Path.sep);
			let asset = { name : ar[ar.length - 1], file : file, id : arm_Project.assetId++};
			arm_Project.assets.push(asset);
			if(arm_Project.raw.assets == null) {
				arm_Project.raw.assets = [];
			}
			arm_Project.raw.assets.push(asset.file);
			arm_Project.assetNames.push(asset.name);
			arm_Project.assetMap.h[asset.id] = image;
			arm_io_ExportArm.packAssets(arm_Project.raw,[asset]);
			return;
		}
		if(bits == 8 && arm_Context.formatType == 0) {
			Krom.writePng(file,pixels.b.bufferValue,resX,resY,format);
		} else if(bits == 8 && arm_Context.formatType == 1) {
			Krom.writeJpg(file,pixels.b.bufferValue,resX,resY,format,arm_Context.formatQuality | 0);
		} else {
			let out = new haxe_io_BytesOutput();
			new arm_format_ExrWriter(out,resX,resY,pixels,bits,type,off);
			Krom.fileSaveBytes(file,out.getBytes().b.bufferValue,out.getBytes().length);
		}
	}
	static copyChannel(from,fromChannel,to,toChannel,linear) {
		if(linear == null) {
			linear = true;
		}
		let _g = 0;
		let _g1 = to.length / 4 | 0;
		while(_g < _g1) {
			let i = _g++;
			to.b[i * 4 + toChannel] = from.b[i * 4 + fromChannel];
		}
		if(!linear) {
			arm_io_ExportTexture.toSrgb(to,toChannel);
		}
	}
	static copyChannelInv(from,fromChannel,to,toChannel,linear) {
		if(linear == null) {
			linear = true;
		}
		let _g = 0;
		let _g1 = to.length / 4 | 0;
		while(_g < _g1) {
			let i = _g++;
			to.b[i * 4 + toChannel] = 255 - from.b[i * 4 + fromChannel];
		}
		if(!linear) {
			arm_io_ExportTexture.toSrgb(to,toChannel);
		}
	}
	static extractChannel(from,fromChannel,to,toChannel,mask,linear) {
		if(linear == null) {
			linear = true;
		}
		let _g = 0;
		let _g1 = to.length / 4 | 0;
		while(_g < _g1) {
			let i = _g++;
			to.b[i * 4 + toChannel] = from.b[i * 4 + fromChannel] == mask ? 255 : 0;
		}
		if(!linear) {
			arm_io_ExportTexture.toSrgb(to,toChannel);
		}
	}
	static setChannel(value,to,toChannel,linear) {
		if(linear == null) {
			linear = true;
		}
		let _g = 0;
		let _g1 = to.length / 4 | 0;
		while(_g < _g1) to.b[_g++ * 4 + toChannel] = value;
		if(!linear) {
			arm_io_ExportTexture.toSrgb(to,toChannel);
		}
	}
	static toSrgb(to,toChannel) {
		let _g = 0;
		let _g1 = to.length / 4 | 0;
		while(_g < _g1) {
			let i = _g++;
			to.b[i * 4 + toChannel] = Math.pow(to.b[i * 4 + toChannel] / 255,0.45454545454545453) * 255 | 0;
		}
	}
}
$hxClasses["arm.io.ExportTexture"] = arm_io_ExportTexture;
arm_io_ExportTexture.__name__ = "arm.io.ExportTexture";
class arm_io_ImportArm {
	static runMesh(raw) {
		arm_Project.paintObjects = [];
		let _g = 0;
		let _g1 = raw.mesh_datas.length;
		while(_g < _g1) {
			let i = _g++;
			new iron_data_MeshData(raw.mesh_datas[i],function(md) {
				let object = null;
				if(i == 0) {
					arm_Context.paintObject.setData(md);
					object = arm_Context.paintObject;
				} else {
					object = iron_Scene.active.addMeshObject(md,arm_Context.paintObject.materials,arm_Context.paintObject);
					object.name = md.name;
					object.skip_context = "paint";
					md.handle = md.name;
					iron_data_Data.cachedMeshes.h[md.handle] = md;
				}
				let _this = object.transform.scale;
				_this.x = 1;
				_this.y = 1;
				_this.z = 1;
				_this.w = 1.0;
				object.transform.buildMatrix();
				object.name = md.name;
				arm_Project.paintObjects.push(object);
				arm_util_MeshUtil.mergeMesh();
				arm_Viewport.scaleToBounds();
			});
		}
		iron_App.notifyOnInit(arm_Layers.initLayers);
		arm_History.reset();
	}
	static runProject(path) {
		iron_data_Data.getBlob(path,function(b) {
			let i = new haxe_io_BytesInput(b.toBytes());
			i.set_bigEndian(false);
			let project = iron_system_ArmPack.read(i);
			if(project.version != null && project.layer_datas == null) {
				if(project.material_nodes != null) {
					arm_io_ImportArm.runMaterialFromProject(project,path);
				} else if(project.brush_nodes != null) {
					arm_io_ImportArm.runBrushFromProject(project,path);
				} else if(project.swatches != null) {
					arm_io_ImportArm.runSwatchesFromProject(project,path);
				}
				return;
			}
			let importAsMesh = project.version == null;
			arm_Context.layersPreviewDirty = true;
			arm_Context.layerFilter = 0;
			arm_Project.projectNew(importAsMesh);
			arm_Project.filepath = path;
			arm_ui_UIFiles.filename = path.substring(path.lastIndexOf(arm_sys_Path.sep) + 1,path.lastIndexOf("."));
			kha_Window.get(0).set_title(arm_ui_UIFiles.filename + " - " + "ArmorPaint");
			if(importAsMesh) {
				arm_io_ImportArm.runMesh(project);
				return;
			}
			let recent_path = path;
			let recent = arm_Config.raw.recent_projects;
			HxOverrides.remove(recent,recent_path);
			recent.unshift(recent_path);
			arm_Config.save();
			arm_Project.raw = project;
			let l0 = project.layer_datas[0];
			arm_App.resHandle.position = arm_Config.getTextureResPos(l0.res);
			let bitsPos = l0.bpp == 8 ? 0 : l0.bpp == 16 ? 1 : 2;
			arm_App.bitsHandle.position = bitsPos;
			let bytesPerPixel = l0.bpp / 8 | 0;
			let format = l0.bpp == 8 ? 0 : l0.bpp == 16 ? 4 : 2;
			let base = arm_sys_Path.baseDir(path);
			if(arm_Project.raw.envmap != null) {
				let tmp = iron_data_Data.isAbsolute(arm_Project.raw.envmap) ? arm_Project.raw.envmap : base + arm_Project.raw.envmap;
				arm_Project.raw.envmap = tmp;
			}
			if(arm_Project.raw.envmap_strength != null) {
				iron_Scene.active.world.probe.raw.strength = arm_Project.raw.envmap_strength;
			}
			if(arm_Project.raw.camera_world != null) {
				let a = arm_Project.raw.camera_world;
				iron_Scene.active.camera.transform.local = new iron_math_Mat4(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15]);
				iron_Scene.active.camera.transform.decompose();
				iron_Scene.active.camera.data.raw.fov = arm_Project.raw.camera_fov;
				iron_Scene.active.camera.buildProjection();
				let origin = arm_Project.raw.camera_origin;
				arm_Camera.inst.origins[0].x = origin[0];
				arm_Camera.inst.origins[0].y = origin[1];
				arm_Camera.inst.origins[0].z = origin[2];
			}
			let _g = 0;
			let _g1 = project.assets;
			while(_g < _g1.length) {
				let file = _g1[_g];
				++_g;
				file = StringTools.replace(file,"/","\\");
				let abs = iron_data_Data.isAbsolute(file) ? file : base + file;
				if(project.packed_assets != null) {
					abs = arm_sys_Path.normalize(abs);
					arm_io_ImportArm.unpackAsset(project,abs,file);
				}
				if(iron_data_Data.cachedImages.h[abs] == null && !arm_sys_File.exists(abs)) {
					arm_io_ImportArm.makePink(abs);
				}
				let hdrAsEnvmap = abs.endsWith(".hdr") && arm_Project.raw.envmap == abs;
				arm_io_ImportTexture.run(abs,hdrAsEnvmap);
			}
			if(project.font_assets != null) {
				let _g = 0;
				let _g1 = project.font_assets;
				while(_g < _g1.length) {
					let file = _g1[_g];
					++_g;
					file = StringTools.replace(file,"/","\\");
					let abs = iron_data_Data.isAbsolute(file) ? file : base + file;
					if(arm_sys_File.exists(abs)) {
						arm_io_ImportFont.run(abs);
					}
				}
			}
			new iron_data_MeshData(project.mesh_datas[0],function(md) {
				arm_Context.paintObject.setData(md);
				let _this = arm_Context.paintObject.transform.scale;
				_this.x = 1;
				_this.y = 1;
				_this.z = 1;
				_this.w = 1.0;
				arm_Context.paintObject.transform.buildMatrix();
				arm_Context.paintObject.name = md.name;
				arm_Project.paintObjects = [arm_Context.paintObject];
			});
			let _g2 = 1;
			let _g3 = project.mesh_datas.length;
			while(_g2 < _g3) {
				let i = _g2++;
				let raw = project.mesh_datas[i];
				new iron_data_MeshData(raw,function(md) {
					let object = iron_Scene.active.addMeshObject(md,arm_Context.paintObject.materials,arm_Context.paintObject);
					object.name = md.name;
					object.skip_context = "paint";
					arm_Project.paintObjects.push(object);
				});
			}
			if(project.mesh_assets != null && project.mesh_assets.length > 0) {
				let file = project.mesh_assets[0];
				let abs = iron_data_Data.isAbsolute(file) ? file : base + file;
				arm_Project.meshAssets = [abs];
			}
			if(project.atlas_objects != null) {
				arm_Project.atlasObjects = project.atlas_objects;
			}
			if(project.atlas_names != null) {
				arm_Project.atlasNames = project.atlas_names;
			}
			if(arm_Context.mergedObject == null) {
				arm_util_MeshUtil.mergeMesh();
			}
			arm_Context.selectPaintObject(arm_Context.mainObject());
			arm_Viewport.scaleToBounds();
			arm_Context.paintObject.skip_context = "paint";
			arm_Context.mergedObject.visible = true;
			let tex = arm_Project.layers[0].texpaint;
			if(tex.get_width() != arm_Config.getTextureResX() || tex.get_height() != arm_Config.getTextureResY()) {
				if(arm_History.undoLayers != null) {
					let _g = 0;
					let _g1 = arm_History.undoLayers;
					while(_g < _g1.length) {
						let l = _g1[_g];
						++_g;
						l.resizeAndSetBits();
					}
				}
				let rts = iron_RenderPath.active.renderTargets;
				let _texpaint_blend0 = rts.h["texpaint_blend0"].image;
				arm_App.notifyOnNextFrame(function() {
					_texpaint_blend0.unload();
				});
				rts.h["texpaint_blend0"].raw.width = arm_Config.getTextureResX();
				rts.h["texpaint_blend0"].raw.height = arm_Config.getTextureResY();
				rts.h["texpaint_blend0"].image = kha_Image.createRenderTarget(arm_Config.getTextureResX(),arm_Config.getTextureResY(),1,0);
				let _texpaint_blend1 = rts.h["texpaint_blend1"].image;
				arm_App.notifyOnNextFrame(function() {
					_texpaint_blend1.unload();
				});
				rts.h["texpaint_blend1"].raw.width = arm_Config.getTextureResX();
				rts.h["texpaint_blend1"].raw.height = arm_Config.getTextureResY();
				rts.h["texpaint_blend1"].image = kha_Image.createRenderTarget(arm_Config.getTextureResX(),arm_Config.getTextureResY(),1,0);
				arm_Context.brushBlendDirty = true;
			}
			let _g4 = 0;
			let _g5 = arm_Project.layers;
			while(_g4 < _g5.length) {
				let l = _g5[_g4];
				++_g4;
				l.unload();
			}
			arm_Project.layers = [];
			let _g6 = 0;
			let _g7 = project.layer_datas.length;
			while(_g6 < _g7) {
				let i = _g6++;
				let ld = project.layer_datas[i];
				let isGroup = ld.texpaint == null;
				let isMask = ld.texpaint != null && ld.texpaint_nor == null;
				let l = new arm_data_LayerSlot("",isGroup ? 2 : isMask ? 1 : 0);
				if(ld.name != null) {
					l.name = ld.name;
				}
				l.visible = ld.visible;
				arm_Project.layers.push(l);
				if(!isGroup) {
					if(arm_Layers.pipeMerge == null) {
						arm_Layers.makePipe();
					}
					let _texpaint = null;
					let _texpaint_nor = null;
					let _texpaint_pack = null;
					if(isMask) {
						_texpaint = kha_Image.fromBytes(iron_system_Lz4.decode(ld.texpaint,ld.res * ld.res * 4),ld.res,ld.res,0);
						l.texpaint.get_g2().begin(false);
						l.texpaint.get_g2().set_pipeline(arm_Layers.pipeCopy8);
						l.texpaint.get_g2().drawImage(_texpaint,0,0);
						l.texpaint.get_g2().set_pipeline(null);
						l.texpaint.get_g2().end();
					} else {
						_texpaint = kha_Image.fromBytes(iron_system_Lz4.decode(ld.texpaint,ld.res * ld.res * 4 * bytesPerPixel),ld.res,ld.res,format);
						l.texpaint.get_g2().begin(false);
						let tmp = project.is_bgra ? arm_Layers.pipeCopyBGRA : arm_Layers.pipeCopy;
						l.texpaint.get_g2().set_pipeline(tmp);
						l.texpaint.get_g2().drawImage(_texpaint,0,0);
						l.texpaint.get_g2().set_pipeline(null);
						l.texpaint.get_g2().end();
						_texpaint_nor = kha_Image.fromBytes(iron_system_Lz4.decode(ld.texpaint_nor,ld.res * ld.res * 4 * bytesPerPixel),ld.res,ld.res,format);
						l.texpaint_nor.get_g2().begin(false);
						let tmp1 = project.is_bgra ? arm_Layers.pipeCopyBGRA : arm_Layers.pipeCopy;
						l.texpaint_nor.get_g2().set_pipeline(tmp1);
						l.texpaint_nor.get_g2().drawImage(_texpaint_nor,0,0);
						l.texpaint_nor.get_g2().set_pipeline(null);
						l.texpaint_nor.get_g2().end();
						_texpaint_pack = kha_Image.fromBytes(iron_system_Lz4.decode(ld.texpaint_pack,ld.res * ld.res * 4 * bytesPerPixel),ld.res,ld.res,format);
						l.texpaint_pack.get_g2().begin(false);
						let tmp2 = project.is_bgra ? arm_Layers.pipeCopyBGRA : arm_Layers.pipeCopy;
						l.texpaint_pack.get_g2().set_pipeline(tmp2);
						l.texpaint_pack.get_g2().drawImage(_texpaint_pack,0,0);
						l.texpaint_pack.get_g2().set_pipeline(null);
						l.texpaint_pack.get_g2().end();
					}
					l.scale = ld.uv_scale;
					l.angle = ld.uv_rot;
					l.uvType = ld.uv_type;
					if(ld.decal_mat != null) {
						let a = ld.decal_mat;
						l.decalMat = new iron_math_Mat4(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15]);
					}
					l.maskOpacity = ld.opacity_mask;
					l.objectMask = ld.object_mask;
					l.blending = ld.blending;
					l.paintBase = ld.paint_base;
					l.paintOpac = ld.paint_opac;
					l.paintOcc = ld.paint_occ;
					l.paintRough = ld.paint_rough;
					l.paintMet = ld.paint_met;
					l.paintNor = ld.paint_nor;
					l.paintNorBlend = ld.paint_nor_blend != null ? ld.paint_nor_blend : true;
					l.paintHeight = ld.paint_height;
					l.paintHeightBlend = ld.paint_height_blend != null ? ld.paint_height_blend : true;
					l.paintEmis = ld.paint_emis;
					l.paintSubs = ld.paint_subs;
					arm_App.notifyOnNextFrame(function() {
						_texpaint.unload();
						if(_texpaint_nor != null) {
							_texpaint_nor.unload();
						}
						if(_texpaint_pack != null) {
							_texpaint_pack.unload();
						}
					});
				}
			}
			let _g8 = 0;
			let _g9 = project.layer_datas.length;
			while(_g8 < _g9) {
				let i = _g8++;
				let ld = project.layer_datas[i];
				if(ld.parent >= 0) {
					arm_Project.layers[i].parent = arm_Project.layers[ld.parent];
				}
			}
			arm_Context.setLayer(arm_Project.layers[0]);
			let m0 = null;
			iron_data_Data.getMaterial("Scene","Material",function(m) {
				m0 = m;
			});
			arm_Project.materials = [];
			let _g10 = 0;
			let _g11 = project.material_nodes;
			while(_g10 < _g11.length) {
				let n = _g11[_g10];
				++_g10;
				arm_io_ImportArm.initNodes(n.nodes);
				arm_Context.material = new arm_data_MaterialSlot(m0,n);
				arm_Project.materials.push(arm_Context.material);
			}
			arm_ui_UINodes.inst.hwnd.redraws = 2;
			arm_ui_UINodes.inst.groupStack = [];
			arm_Project.materialGroups = [];
			if(project.material_groups != null) {
				let _g = 0;
				let _g1 = project.material_groups;
				while(_g < _g1.length) {
					let g = _g1[_g];
					++_g;
					arm_Project.materialGroups.push({ canvas : g, nodes : new zui_Nodes()});
				}
			}
			let _g12 = 0;
			let _g13 = arm_Project.materials;
			while(_g12 < _g13.length) {
				let m = _g13[_g12];
				++_g12;
				arm_Context.material = m;
				arm_node_MakeMaterial.parsePaintMaterial();
				arm_util_RenderUtil.makeMaterialPreview();
			}
			arm_Project.brushes = [];
			let _g14 = 0;
			let _g15 = project.brush_nodes;
			while(_g14 < _g15.length) {
				let n = _g15[_g14];
				++_g14;
				arm_io_ImportArm.initNodes(n.nodes);
				arm_Context.brush = new arm_data_BrushSlot(n);
				arm_Project.brushes.push(arm_Context.brush);
				arm_node_MakeMaterial.parseBrush();
				arm_util_RenderUtil.makeBrushPreview();
			}
			let _g16 = 0;
			let _g17 = project.layer_datas.length;
			while(_g16 < _g17) {
				let i = _g16++;
				let ld = project.layer_datas[i];
				let l = arm_Project.layers[i];
				let isGroup = ld.texpaint == null;
				if(!isGroup) {
					l.fill_layer = ld.fill_layer > -1 ? arm_Project.materials[ld.fill_layer] : null;
				}
			}
			arm_Context.ddirty = 4;
			arm_ui_UISidebar.inst.hwnd0.redraws = 2;
			arm_ui_UISidebar.inst.hwnd1.redraws = 2;
			iron_data_Data.deleteBlob(path);
		});
	}
	static runMaterial(path) {
		iron_data_Data.getBlob(path,function(b) {
			let i = new haxe_io_BytesInput(b.toBytes());
			i.set_bigEndian(false);
			let project = iron_system_ArmPack.read(i);
			if(project.version == null) {
				iron_data_Data.deleteBlob(path);
				return;
			}
			arm_io_ImportArm.runMaterialFromProject(project,path);
		});
	}
	static runMaterialFromProject(project,path) {
		let base = arm_sys_Path.baseDir(path);
		let _g = 0;
		let _g1 = project.assets;
		while(_g < _g1.length) {
			let file = _g1[_g];
			++_g;
			file = StringTools.replace(file,"/","\\");
			let abs = iron_data_Data.isAbsolute(file) ? file : base + file;
			if(project.packed_assets != null) {
				arm_io_ImportArm.unpackAsset(project,abs,file);
			}
			if(iron_data_Data.cachedImages.h[abs] == null && !arm_sys_File.exists(abs)) {
				arm_io_ImportArm.makePink(abs);
			}
			arm_io_ImportTexture.run(abs);
		}
		let m0 = null;
		iron_data_Data.getMaterial("Scene","Material",function(m) {
			m0 = m;
		});
		let imported = [];
		let _g2 = 0;
		let _g3 = project.material_nodes;
		while(_g2 < _g3.length) {
			let c = _g3[_g2];
			++_g2;
			arm_io_ImportArm.initNodes(c.nodes);
			arm_Context.material = new arm_data_MaterialSlot(m0,c);
			arm_Project.materials.push(arm_Context.material);
			imported.push(arm_Context.material);
			arm_History.newMaterial();
		}
		if(project.material_groups != null) {
			let _g = 0;
			let _g1 = project.material_groups;
			while(_g < _g1.length) {
				let c = _g1[_g];
				++_g;
				while(arm_io_ImportArm.groupExists(c)) arm_io_ImportArm.renameGroup(c.name,imported,project.material_groups);
				arm_io_ImportArm.initNodes(c.nodes);
				arm_Project.materialGroups.push({ canvas : c, nodes : new zui_Nodes()});
			}
		}
		iron_App.notifyOnInit(function() {
			let _g = 0;
			while(_g < imported.length) {
				arm_Context.setMaterial(imported[_g++]);
				arm_node_MakeMaterial.parsePaintMaterial();
				arm_util_RenderUtil.makeMaterialPreview();
			}
		});
		arm_ui_UINodes.inst.groupStack = [];
		arm_ui_UISidebar.inst.hwnd1.redraws = 2;
		iron_data_Data.deleteBlob(path);
	}
	static groupExists(c) {
		let _g = 0;
		let _g1 = arm_Project.materialGroups;
		while(_g < _g1.length) if(_g1[_g++].canvas.name == c.name) {
			return true;
		}
		return false;
	}
	static renameGroup(name,materials,groups) {
		let _g = 0;
		while(_g < materials.length) {
			let _g1 = 0;
			let _g2 = materials[_g++].canvas.nodes;
			while(_g1 < _g2.length) {
				let n = _g2[_g1];
				++_g1;
				if(n.type == "GROUP" && n.name == name) {
					n.name += ".1";
				}
			}
		}
		let _g1 = 0;
		while(_g1 < groups.length) {
			let c = groups[_g1];
			++_g1;
			if(c.name == name) {
				c.name += ".1";
			}
			let _g = 0;
			let _g2 = c.nodes;
			while(_g < _g2.length) {
				let n = _g2[_g];
				++_g;
				if(n.type == "GROUP" && n.name == name) {
					n.name += ".1";
				}
			}
		}
	}
	static runBrush(path) {
		iron_data_Data.getBlob(path,function(b) {
			let i = new haxe_io_BytesInput(b.toBytes());
			i.set_bigEndian(false);
			let project = iron_system_ArmPack.read(i);
			if(project.version == null) {
				iron_data_Data.deleteBlob(path);
				return;
			}
			arm_io_ImportArm.runBrushFromProject(project,path);
		});
	}
	static runBrushFromProject(project,path) {
		let base = arm_sys_Path.baseDir(path);
		let _g = 0;
		let _g1 = project.assets;
		while(_g < _g1.length) {
			let file = _g1[_g];
			++_g;
			file = StringTools.replace(file,"/","\\");
			let abs = iron_data_Data.isAbsolute(file) ? file : base + file;
			if(project.packed_assets != null) {
				arm_io_ImportArm.unpackAsset(project,abs,file);
			}
			if(iron_data_Data.cachedImages.h[abs] == null && !arm_sys_File.exists(abs)) {
				arm_io_ImportArm.makePink(abs);
			}
			arm_io_ImportTexture.run(abs);
		}
		let imported = [];
		let _g2 = 0;
		let _g3 = project.brush_nodes;
		while(_g2 < _g3.length) {
			let n = _g3[_g2];
			++_g2;
			arm_io_ImportArm.initNodes(n.nodes);
			arm_Context.brush = new arm_data_BrushSlot(n);
			arm_Project.brushes.push(arm_Context.brush);
			imported.push(arm_Context.brush);
		}
		iron_App.notifyOnInit(function() {
			let _g = 0;
			while(_g < imported.length) {
				arm_Context.setBrush(imported[_g++]);
				arm_util_RenderUtil.makeBrushPreview();
			}
		});
		arm_ui_UISidebar.inst.hwnd1.redraws = 2;
		iron_data_Data.deleteBlob(path);
	}
	static runSwatches(path,replaceExisting) {
		if(replaceExisting == null) {
			replaceExisting = false;
		}
		iron_data_Data.getBlob(path,function(b) {
			let i = new haxe_io_BytesInput(b.toBytes());
			i.set_bigEndian(false);
			let project = iron_system_ArmPack.read(i);
			if(project.version == null) {
				iron_data_Data.deleteBlob(path);
				return;
			}
			arm_io_ImportArm.runSwatchesFromProject(project,path,replaceExisting);
		});
	}
	static runSwatchesFromProject(project,path,replaceExisting) {
		if(replaceExisting == null) {
			replaceExisting = false;
		}
		if(replaceExisting) {
			arm_Project.raw.swatches = [];
			if(project.swatches == null) {
				arm_Project.raw.swatches.push(arm_Project.makeSwatch());
			}
		}
		if(project.swatches != null) {
			let _g = 0;
			let _g1 = project.swatches;
			while(_g < _g1.length) arm_Project.raw.swatches.push(_g1[_g++]);
		}
		arm_ui_UIStatus.inst.statusHandle.redraws = 2;
		iron_data_Data.deleteBlob(path);
	}
	static makePink(abs) {
		arm_Console.error(arm_Strings.error2() + " " + abs);
		let b = new haxe_io_Bytes(new ArrayBuffer(4));
		b.b[0] = 255;
		b.b[1] = 0;
		b.b[2] = 255;
		b.b[3] = 255;
		let pink = kha_Image.fromBytes(b,1,1);
		iron_data_Data.cachedImages.h[abs] = pink;
	}
	static initNodes(nodes) {
		let _g = 0;
		while(_g < nodes.length) {
			let node = nodes[_g];
			++_g;
			if(node.type == "TEX_IMAGE") {
				node.buttons[0].default_value = arm_App.getAssetIndex(node.buttons[0].data);
				if(node.buttons[1].data.length == 2) {
					let tmp = arm_Translator.tr("Auto");
					let tmp1 = arm_Translator.tr("Linear");
					let tmp2 = arm_Translator.tr("sRGB");
					let tmp3 = arm_Translator.tr("DirectX Normal Map");
					node.buttons[1].data = [tmp,tmp1,tmp2,tmp3];
				}
			} else if(node.type == "VALTORGB") {
				let but = node.buttons[0];
				if(but.type != "CUSTOM") {
					but.type = "CUSTOM";
					but.name = "arm.shader.NodesMaterial.colorRampButton";
					but.height = 4.5;
				}
			} else if(node.type == "MAPPING") {
				if(node.inputs.length < 4) {
					node.inputs = JSON.parse(JSON.stringify(arm_shader_NodesMaterial.getTNode("MAPPING"))).inputs;
					let _g = 0;
					let _g1 = node.inputs;
					while(_g < _g1.length) _g1[_g++].node_id = node.id;
					let _g2 = 0;
					let _g3 = node.buttons.length;
					while(_g2 < _g3) {
						let i = _g2++;
						node.inputs[i + 1].default_value = node.buttons[i].default_value;
					}
					node.buttons = [];
				}
			}
		}
	}
	static unpackAsset(project,abs,file) {
		if(arm_Project.raw.packed_assets == null) {
			arm_Project.raw.packed_assets = [];
		}
		let _g = 0;
		let _g1 = project.packed_assets;
		while(_g < _g1.length) {
			let pa = _g1[_g];
			++_g;
			pa.name = StringTools.replace(pa.name,"/","\\");
			pa.name = arm_sys_Path.normalize(pa.name);
			if(pa.name == file) {
				pa.name = abs;
			}
			if(pa.name == abs) {
				if(!arm_Project.packedAssetExists(arm_Project.raw.packed_assets,pa.name)) {
					arm_Project.raw.packed_assets.push(pa);
				}
				kha_Image.fromEncodedBytes(pa.bytes,pa.name.endsWith(".jpg") ? ".jpg" : ".png",function(image) {
					iron_data_Data.cachedImages.h[abs] = image;
				},null,false);
				break;
			}
		}
	}
}
$hxClasses["arm.io.ImportArm"] = arm_io_ImportArm;
arm_io_ImportArm.__name__ = "arm.io.ImportArm";
class arm_io_ImportAsset {
	static run(path,dropX,dropY,showBox,hdrAsEnvmap,done) {
		if(hdrAsEnvmap == null) {
			hdrAsEnvmap = true;
		}
		if(showBox == null) {
			showBox = true;
		}
		if(dropY == null) {
			dropY = -1.0;
		}
		if(dropX == null) {
			dropX = -1.0;
		}
		if(path.startsWith("cloud")) {
			arm_sys_File.cacheCloud(path,function(abs) {
				if(abs == null) {
					return;
				}
				arm_io_ImportAsset.run(abs,dropX,dropY,showBox,hdrAsEnvmap,done);
			});
			return;
		}
		if(arm_sys_Path.isMesh(path)) {
			if(showBox) {
				arm_Project.importMeshBox(path);
			} else {
				arm_io_ImportMesh.run(path);
			}
			if(dropX > 0) {
				arm_ui_UIBox.clickToHide = false;
			}
		} else if(arm_sys_Path.isTexture(path)) {
			arm_io_ImportTexture.run(path,hdrAsEnvmap);
			if(arm_ui_UINodes.inst.show && dropX > arm_ui_UINodes.inst.wx && dropX < arm_ui_UINodes.inst.wx + arm_ui_UINodes.inst.ww) {
				let assetIndex = 0;
				let _g = 0;
				let _g1 = arm_Project.assets.length;
				while(_g < _g1) {
					let i = _g++;
					if(arm_Project.assets[i].file == path) {
						assetIndex = i;
						break;
					}
				}
				arm_ui_UINodes.inst.acceptAssetDrag(assetIndex);
				arm_ui_UINodes.inst.getNodes().nodesDrag = false;
				arm_ui_UINodes.inst.hwnd.redraws = 2;
			}
		} else if(arm_sys_Path.isFont(path)) {
			arm_io_ImportFont.run(path);
		} else if(arm_sys_Path.isProject(path)) {
			arm_io_ImportArm.runProject(path);
		} else if(arm_sys_Path.isPlugin(path)) {
			arm_io_ImportPlugin.run(path);
		} else if(arm_sys_Path.isFolder(path)) {
			arm_io_ImportFolder.run(path);
		} else if(arm_Context.enableImportPlugin(path)) {
			arm_io_ImportAsset.run(path,dropX,dropY,showBox);
		} else {
			arm_Console.error(arm_Strings.error1());
		}
		if(done != null) {
			done();
		}
	}
}
$hxClasses["arm.io.ImportAsset"] = arm_io_ImportAsset;
arm_io_ImportAsset.__name__ = "arm.io.ImportAsset";
class arm_io_ImportBlend {
	static run(path,replaceExisting) {
		if(replaceExisting == null) {
			replaceExisting = true;
		}
		iron_data_Data.getBlob(path,function(b) {
			let bl = new arm_format_BlendParser(b);
			if(bl.dna == null) {
				arm_Console.error(arm_Strings.error3());
				return;
			}
			let obs = bl.get("Object");
			if(obs == null || obs.length == 0) {
				arm_io_ImportMesh.makeMesh(null,path);
				return;
			}
			let first = true;
			let _g = 0;
			while(_g < obs.length) {
				let ob = obs[_g];
				++_g;
				if(ob.get("type") != 1) {
					continue;
				}
				let name = ob.get("id").get("name");
				name = name.substring(2,name.length);
				let m = ob.get("data",0,"Mesh");
				if(m == null) {
					continue;
				}
				let totpoly = m.get("totpoly");
				if(totpoly == 0) {
					continue;
				}
				let numtri = 0;
				let _g1 = 0;
				while(_g1 < totpoly) numtri += m.get("mpoly",_g1++).get("totloop") - 2;
				let inda = new Uint32Array(numtri * 3);
				let _g2 = 0;
				let _g3 = inda.length;
				while(_g2 < _g3) {
					let i = _g2++;
					inda[i] = i;
				}
				let posa32 = new Float32Array(numtri * 3 * 4);
				let posa = new Int16Array(numtri * 3 * 4);
				let nora = new Int16Array(numtri * 3 * 2);
				let hasuv = m.get("mloopuv") != null;
				let texa = hasuv ? new Int16Array(numtri * 3 * 2) : null;
				let hascol = arm_Context.parseVCols && m.get("mloopcol") != null;
				let cola = hascol ? new Int16Array(numtri * 3 * 3) : null;
				let tri = 0;
				let vec0 = new iron_math_Vec4();
				let vec1 = new iron_math_Vec4();
				let vec2 = new iron_math_Vec4();
				let _g4 = 0;
				while(_g4 < totpoly) {
					let poly = m.get("mpoly",_g4++);
					let smooth = (poly.get("flag") & 1) == 1;
					let loopstart = poly.get("loopstart");
					let totloop = poly.get("totloop");
					if(totloop <= 4) {
						let v0 = m.get("mvert",m.get("mloop",loopstart + totloop - 1).get("v"));
						let v1 = m.get("mvert",m.get("mloop",loopstart).get("v"));
						let co0 = v0.get("co");
						let co1 = v1.get("co");
						let no0 = v0.get("no");
						let no1 = v1.get("no");
						if(smooth) {
							vec0.x = no0[0] / 32767;
							vec0.y = no0[1] / 32767;
							vec0.z = no0[2] / 32767;
							vec0.w = 1.0;
							let n = Math.sqrt(vec0.x * vec0.x + vec0.y * vec0.y + vec0.z * vec0.z);
							if(n > 0.0) {
								let invN = 1.0 / n;
								vec0.x *= invN;
								vec0.y *= invN;
								vec0.z *= invN;
							}
							vec1.x = no1[0] / 32767;
							vec1.y = no1[1] / 32767;
							vec1.z = no1[2] / 32767;
							vec1.w = 1.0;
							let n1 = Math.sqrt(vec1.x * vec1.x + vec1.y * vec1.y + vec1.z * vec1.z);
							if(n1 > 0.0) {
								let invN = 1.0 / n1;
								vec1.x *= invN;
								vec1.y *= invN;
								vec1.z *= invN;
							}
						}
						let uv0 = null;
						let uv1 = null;
						let uv2 = null;
						if(hasuv) {
							uv0 = m.get("mloopuv",loopstart + totloop - 1).get("uv");
							if(uv0[0] > 1.000030518509476) {
								uv0[0] -= uv0[0] | 0;
							}
							if(uv0[1] > 1.000030518509476) {
								uv0[1] -= uv0[1] | 0;
							}
							uv1 = m.get("mloopuv",loopstart).get("uv");
							if(uv1[0] > 1.000030518509476) {
								uv1[0] -= uv1[0] | 0;
							}
							if(uv1[1] > 1.000030518509476) {
								uv1[1] -= uv1[1] | 0;
							}
						}
						let col0r = 0;
						let col0g = 0;
						let col0b = 0;
						let col1r = 0;
						let col1g = 0;
						let col1b = 0;
						let col2r = 0;
						let col2g = 0;
						let col2b = 0;
						if(hascol) {
							let loop = m.get("mloopcol",loopstart + totloop - 1);
							col0r = loop.get("r");
							col0g = loop.get("g");
							col0b = loop.get("b");
							loop = m.get("mloopcol",loopstart);
							col1r = loop.get("r");
							col1g = loop.get("g");
							col1b = loop.get("b");
						}
						let _g = 0;
						let _g1 = totloop - 2;
						while(_g < _g1) {
							let j = _g++;
							let v2 = m.get("mvert",m.get("mloop",loopstart + j + 1).get("v"));
							let co2 = v2.get("co");
							let no2 = v2.get("no");
							if(smooth) {
								vec2.x = no2[0] / 32767;
								vec2.y = no2[1] / 32767;
								vec2.z = no2[2] / 32767;
								vec2.w = 1.0;
								let n = Math.sqrt(vec2.x * vec2.x + vec2.y * vec2.y + vec2.z * vec2.z);
								if(n > 0.0) {
									let invN = 1.0 / n;
									vec2.x *= invN;
									vec2.y *= invN;
									vec2.z *= invN;
								}
							} else {
								vec2.x = co2[0];
								vec2.y = co2[1];
								vec2.z = co2[2];
								vec2.w = 1.0;
								vec1.x = co1[0];
								vec1.y = co1[1];
								vec1.z = co1[2];
								vec1.w = 1.0;
								vec0.x = vec2.x - vec1.x;
								vec0.y = vec2.y - vec1.y;
								vec0.z = vec2.z - vec1.z;
								vec2.x = co0[0];
								vec2.y = co0[1];
								vec2.z = co0[2];
								vec2.w = 1.0;
								vec1.x = vec2.x - vec1.x;
								vec1.y = vec2.y - vec1.y;
								vec1.z = vec2.z - vec1.z;
								let ax = vec0.x;
								let ay = vec0.y;
								let az = vec0.z;
								let vx = vec1.x;
								let vy = vec1.y;
								let vz = vec1.z;
								vec0.x = ay * vz - az * vy;
								vec0.y = az * vx - ax * vz;
								vec0.z = ax * vy - ay * vx;
								let n = Math.sqrt(vec0.x * vec0.x + vec0.y * vec0.y + vec0.z * vec0.z);
								if(n > 0.0) {
									let invN = 1.0 / n;
									vec0.x *= invN;
									vec0.y *= invN;
									vec0.z *= invN;
								}
							}
							posa32[tri * 9] = co0[0];
							posa32[tri * 9 + 1] = co0[1];
							posa32[tri * 9 + 2] = co0[2];
							posa32[tri * 9 + 3] = co1[0];
							posa32[tri * 9 + 4] = co1[1];
							posa32[tri * 9 + 5] = co1[2];
							posa32[tri * 9 + 6] = co2[0];
							posa32[tri * 9 + 7] = co2[1];
							posa32[tri * 9 + 8] = co2[2];
							posa[tri * 12 + 3] = vec0.z * 32767 | 0;
							posa[tri * 12 + 7] = (smooth ? vec1.z : vec0.z) * 32767 | 0;
							posa[tri * 12 + 11] = (smooth ? vec2.z : vec0.z) * 32767 | 0;
							nora[tri * 6] = vec0.x * 32767 | 0;
							nora[tri * 6 + 1] = vec0.y * 32767 | 0;
							nora[tri * 6 + 2] = (smooth ? vec1.x : vec0.x) * 32767 | 0;
							nora[tri * 6 + 3] = (smooth ? vec1.y : vec0.y) * 32767 | 0;
							nora[tri * 6 + 4] = (smooth ? vec2.x : vec0.x) * 32767 | 0;
							nora[tri * 6 + 5] = (smooth ? vec2.y : vec0.y) * 32767 | 0;
							co1 = co2;
							no1 = no2;
							vec1.x = vec2.x;
							vec1.y = vec2.y;
							vec1.z = vec2.z;
							vec1.w = vec2.w;
							if(hasuv) {
								uv2 = m.get("mloopuv",loopstart + j + 1).get("uv");
								if(uv2[0] > 1.000030518509476) {
									uv2[0] -= uv2[0] | 0;
								}
								if(uv2[1] > 1.000030518509476) {
									uv2[1] -= uv2[1] | 0;
								}
								texa[tri * 6] = uv0[0] * 32767 | 0;
								texa[tri * 6 + 1] = (1.0 - uv0[1]) * 32767 | 0;
								texa[tri * 6 + 2] = uv1[0] * 32767 | 0;
								texa[tri * 6 + 3] = (1.0 - uv1[1]) * 32767 | 0;
								texa[tri * 6 + 4] = uv2[0] * 32767 | 0;
								texa[tri * 6 + 5] = (1.0 - uv2[1]) * 32767 | 0;
								uv1 = uv2;
							}
							if(hascol) {
								let loop = m.get("mloopcol",loopstart + j + 1);
								col2r = loop.get("r");
								col2g = loop.get("g");
								col2b = loop.get("b");
								cola[tri * 9] = col0r * 128;
								cola[tri * 9 + 1] = col0g * 128;
								cola[tri * 9 + 2] = col0b * 128;
								cola[tri * 9 + 3] = col1r * 128;
								cola[tri * 9 + 4] = col1g * 128;
								cola[tri * 9 + 5] = col1b * 128;
								cola[tri * 9 + 6] = col2r * 128;
								cola[tri * 9 + 7] = col2g * 128;
								cola[tri * 9 + 8] = col2b * 128;
								col1r = col2r;
								col1g = col2g;
								col1b = col2b;
							}
							++tri;
						}
					} else {
						let va = [];
						let _g = 0;
						while(_g < totloop) va.push(loopstart + _g++);
						let co0 = m.get("mvert",m.get("mloop",loopstart).get("v")).get("co");
						let co1 = m.get("mvert",m.get("mloop",loopstart + 1).get("v")).get("co");
						let co2 = m.get("mvert",m.get("mloop",loopstart + 2).get("v")).get("co");
						vec2.x = co2[0];
						vec2.y = co2[1];
						vec2.z = co2[2];
						vec2.w = 1.0;
						vec1.x = co1[0];
						vec1.y = co1[1];
						vec1.z = co1[2];
						vec1.w = 1.0;
						vec0.x = vec2.x - vec1.x;
						vec0.y = vec2.y - vec1.y;
						vec0.z = vec2.z - vec1.z;
						vec2.x = co0[0];
						vec2.y = co0[1];
						vec2.z = co0[2];
						vec2.w = 1.0;
						vec1.x = vec2.x - vec1.x;
						vec1.y = vec2.y - vec1.y;
						vec1.z = vec2.z - vec1.z;
						let ax = vec0.x;
						let ay = vec0.y;
						let az = vec0.z;
						let vx = vec1.x;
						let vy = vec1.y;
						let vz = vec1.z;
						vec0.x = ay * vz - az * vy;
						vec0.y = az * vx - ax * vz;
						vec0.z = ax * vy - ay * vx;
						let n = Math.sqrt(vec0.x * vec0.x + vec0.y * vec0.y + vec0.z * vec0.z);
						if(n > 0.0) {
							let invN = 1.0 / n;
							vec0.x *= invN;
							vec0.y *= invN;
							vec0.z *= invN;
						}
						let nx = vec0.x;
						let ny = vec0.y;
						let nz = vec0.z;
						let nxabs = Math.abs(nx);
						let nyabs = Math.abs(ny);
						let nzabs = Math.abs(nz);
						let flip = nx + ny + nz > 0;
						let axis = nxabs > nyabs && nxabs > nzabs ? 0 : nyabs > nxabs && nyabs > nzabs ? 1 : 2;
						let axis0 = axis == 0 ? flip ? 2 : 1 : axis == 1 ? flip ? 0 : 2 : flip ? 1 : 0;
						let axis1 = axis == 0 ? flip ? 1 : 2 : axis == 1 ? flip ? 2 : 0 : flip ? 0 : 1;
						let winding = 0.0;
						let _g1 = 0;
						while(_g1 < totloop) {
							let i = _g1++;
							let co0 = m.get("mvert",m.get("mloop",loopstart + i).get("v")).get("co");
							let co1 = m.get("mvert",m.get("mloop",loopstart + (i + 1) % totloop).get("v")).get("co");
							winding += (co1[axis0] - co0[axis0]) * (co1[axis1] + co0[axis1]);
						}
						let flip1 = winding > 0 ? nx + ny + nz > 0 : nx + ny + nz < 0;
						let axis01 = axis == 0 ? flip1 ? 2 : 1 : axis == 1 ? flip1 ? 0 : 2 : flip1 ? 1 : 0;
						let axis11 = axis == 0 ? flip1 ? 1 : 2 : axis == 1 ? flip1 ? 2 : 0 : flip1 ? 0 : 1;
						let vi = totloop;
						let loops = 0;
						let i = -1;
						while(vi > 2 && loops++ < vi) {
							i = (i + 1) % vi;
							let i1 = (i + 1) % vi;
							let i2 = (i + 2) % vi;
							let v0 = m.get("mvert",m.get("mloop",va[i]).get("v"));
							let v1 = m.get("mvert",m.get("mloop",va[i1]).get("v"));
							let v2 = m.get("mvert",m.get("mloop",va[i2]).get("v"));
							let co0 = v0.get("co");
							let co1 = v1.get("co");
							let co2 = v2.get("co");
							let v0x = co0[axis01];
							let v0y = co0[axis11];
							let v1x = co1[axis01];
							let v1y = co1[axis11];
							let v2x = co2[axis01];
							let v2y = co2[axis11];
							if((v0x - v1x) * (v2y - v1y) - (v0y - v1y) * (v2x - v1x) <= 0) {
								continue;
							}
							let overlap = false;
							let _g = 0;
							let _g1 = vi - 3;
							while(_g < _g1) {
								let co = m.get("mvert",m.get("mloop",va[(i + 3 + _g++) % vi]).get("v")).get("co");
								if(arm_format_MeshParser.pnpoly(v0x,v0y,v1x,v1y,v2x,v2y,co[axis01],co[axis11])) {
									overlap = true;
									break;
								}
							}
							if(overlap) {
								continue;
							}
							let no0 = v0.get("no");
							let no1 = v1.get("no");
							let no2 = v2.get("no");
							if(smooth) {
								vec0.x = no0[0] / 32767;
								vec0.y = no0[1] / 32767;
								vec0.z = no0[2] / 32767;
								vec0.w = 1.0;
								let n = Math.sqrt(vec0.x * vec0.x + vec0.y * vec0.y + vec0.z * vec0.z);
								if(n > 0.0) {
									let invN = 1.0 / n;
									vec0.x *= invN;
									vec0.y *= invN;
									vec0.z *= invN;
								}
								vec1.x = no1[0] / 32767;
								vec1.y = no1[1] / 32767;
								vec1.z = no1[2] / 32767;
								vec1.w = 1.0;
								let n1 = Math.sqrt(vec1.x * vec1.x + vec1.y * vec1.y + vec1.z * vec1.z);
								if(n1 > 0.0) {
									let invN = 1.0 / n1;
									vec1.x *= invN;
									vec1.y *= invN;
									vec1.z *= invN;
								}
								vec2.x = no2[0] / 32767;
								vec2.y = no2[1] / 32767;
								vec2.z = no2[2] / 32767;
								vec2.w = 1.0;
								let n2 = Math.sqrt(vec2.x * vec2.x + vec2.y * vec2.y + vec2.z * vec2.z);
								if(n2 > 0.0) {
									let invN = 1.0 / n2;
									vec2.x *= invN;
									vec2.y *= invN;
									vec2.z *= invN;
								}
							} else {
								vec2.x = co2[0];
								vec2.y = co2[1];
								vec2.z = co2[2];
								vec2.w = 1.0;
								vec1.x = co1[0];
								vec1.y = co1[1];
								vec1.z = co1[2];
								vec1.w = 1.0;
								vec0.x = vec2.x - vec1.x;
								vec0.y = vec2.y - vec1.y;
								vec0.z = vec2.z - vec1.z;
								vec2.x = co0[0];
								vec2.y = co0[1];
								vec2.z = co0[2];
								vec2.w = 1.0;
								vec1.x = vec2.x - vec1.x;
								vec1.y = vec2.y - vec1.y;
								vec1.z = vec2.z - vec1.z;
								let ax = vec0.x;
								let ay = vec0.y;
								let az = vec0.z;
								let vx = vec1.x;
								let vy = vec1.y;
								let vz = vec1.z;
								vec0.x = ay * vz - az * vy;
								vec0.y = az * vx - ax * vz;
								vec0.z = ax * vy - ay * vx;
								let n = Math.sqrt(vec0.x * vec0.x + vec0.y * vec0.y + vec0.z * vec0.z);
								if(n > 0.0) {
									let invN = 1.0 / n;
									vec0.x *= invN;
									vec0.y *= invN;
									vec0.z *= invN;
								}
							}
							let uv0 = null;
							let uv1 = null;
							let uv2 = null;
							if(hasuv) {
								uv0 = m.get("mloopuv",va[i]).get("uv");
								if(uv0[0] > 1.000030518509476) {
									uv0[0] -= uv0[0] | 0;
								}
								if(uv0[1] > 1.000030518509476) {
									uv0[1] -= uv0[1] | 0;
								}
								uv1 = m.get("mloopuv",va[i1]).get("uv");
								if(uv1[0] > 1.000030518509476) {
									uv1[0] -= uv1[0] | 0;
								}
								if(uv1[1] > 1.000030518509476) {
									uv1[1] -= uv1[1] | 0;
								}
								uv2 = m.get("mloopuv",va[i2]).get("uv");
								if(uv2[0] > 1.000030518509476) {
									uv2[0] -= uv2[0] | 0;
								}
								if(uv2[1] > 1.000030518509476) {
									uv2[1] -= uv2[1] | 0;
								}
							}
							let col0r = 0;
							let col0g = 0;
							let col0b = 0;
							let col1r = 0;
							let col1g = 0;
							let col1b = 0;
							let col2r = 0;
							let col2g = 0;
							let col2b = 0;
							if(hascol) {
								let loop = m.get("mloopcol",va[i]);
								col0r = loop.get("r");
								col0g = loop.get("g");
								col0b = loop.get("b");
								loop = m.get("mloopcol",va[i1]);
								col1r = loop.get("r");
								col1g = loop.get("g");
								col1b = loop.get("b");
								loop = m.get("mloopcol",va[i2]);
								col2r = loop.get("r");
								col2g = loop.get("g");
								col2b = loop.get("b");
							}
							posa32[tri * 9] = co0[0];
							posa32[tri * 9 + 1] = co0[1];
							posa32[tri * 9 + 2] = co0[2];
							posa32[tri * 9 + 3] = co1[0];
							posa32[tri * 9 + 4] = co1[1];
							posa32[tri * 9 + 5] = co1[2];
							posa32[tri * 9 + 6] = co2[0];
							posa32[tri * 9 + 7] = co2[1];
							posa32[tri * 9 + 8] = co2[2];
							posa[tri * 12 + 3] = vec0.z * 32767 | 0;
							posa[tri * 12 + 7] = (smooth ? vec1.z : vec0.z) * 32767 | 0;
							posa[tri * 12 + 11] = (smooth ? vec2.z : vec0.z) * 32767 | 0;
							nora[tri * 6] = vec0.x * 32767 | 0;
							nora[tri * 6 + 1] = vec0.y * 32767 | 0;
							nora[tri * 6 + 2] = (smooth ? vec1.x : vec0.x) * 32767 | 0;
							nora[tri * 6 + 3] = (smooth ? vec1.y : vec0.y) * 32767 | 0;
							nora[tri * 6 + 4] = (smooth ? vec2.x : vec0.x) * 32767 | 0;
							nora[tri * 6 + 5] = (smooth ? vec2.y : vec0.y) * 32767 | 0;
							if(hasuv) {
								texa[tri * 6] = uv0[0] * 32767 | 0;
								texa[tri * 6 + 1] = (1.0 - uv0[1]) * 32767 | 0;
								texa[tri * 6 + 2] = uv1[0] * 32767 | 0;
								texa[tri * 6 + 3] = (1.0 - uv1[1]) * 32767 | 0;
								texa[tri * 6 + 4] = uv2[0] * 32767 | 0;
								texa[tri * 6 + 5] = (1.0 - uv2[1]) * 32767 | 0;
							}
							if(hascol) {
								cola[tri * 9] = col0r * 128;
								cola[tri * 9 + 1] = col0g * 128;
								cola[tri * 9 + 2] = col0b * 128;
								cola[tri * 9 + 3] = col1r * 128;
								cola[tri * 9 + 4] = col1g * 128;
								cola[tri * 9 + 5] = col1b * 128;
								cola[tri * 9 + 6] = col2r * 128;
								cola[tri * 9 + 7] = col2g * 128;
								cola[tri * 9 + 8] = col2b * 128;
							}
							++tri;
							let _g2 = (i + 1) % vi;
							let _g3 = vi - 1;
							while(_g2 < _g3) {
								let j = _g2++;
								va[j] = va[j + 1];
							}
							--vi;
							--i;
							loops = 0;
						}
					}
				}
				let obmat = ob.get("obmat",0,"float",16);
				let _this = new iron_math_Mat4(obmat[0],obmat[1],obmat[2],obmat[3],obmat[4],obmat[5],obmat[6],obmat[7],obmat[8],obmat[9],obmat[10],obmat[11],obmat[12],obmat[13],obmat[14],obmat[15]);
				let f = _this.self._01;
				_this.self._01 = _this.self._10;
				_this.self._10 = f;
				f = _this.self._02;
				_this.self._02 = _this.self._20;
				_this.self._20 = f;
				f = _this.self._03;
				_this.self._03 = _this.self._30;
				_this.self._30 = f;
				f = _this.self._12;
				_this.self._12 = _this.self._21;
				_this.self._21 = f;
				f = _this.self._13;
				_this.self._13 = _this.self._31;
				_this.self._31 = f;
				f = _this.self._23;
				_this.self._23 = _this.self._32;
				_this.self._32 = f;
				let v_x = 0.0;
				let v_y = 0.0;
				let v_z = 0.0;
				let _g5 = 0;
				let _g6 = posa32.length / 3 | 0;
				while(_g5 < _g6) {
					let i = _g5++;
					v_x = posa32[i * 3];
					v_y = posa32[i * 3 + 1];
					v_z = posa32[i * 3 + 2];
					let x = v_x;
					let y = v_y;
					let z = v_z;
					v_x = _this.self._00 * x + _this.self._10 * y + _this.self._20 * z + _this.self._30;
					v_y = _this.self._01 * x + _this.self._11 * y + _this.self._21 * z + _this.self._31;
					v_z = _this.self._02 * x + _this.self._12 * y + _this.self._22 * z + _this.self._32;
					posa32[i * 3] = v_x;
					posa32[i * 3 + 1] = v_y;
					posa32[i * 3 + 2] = v_z;
				}
				let a00 = _this.self._00;
				let a01 = _this.self._01;
				let a02 = _this.self._02;
				let a03 = _this.self._03;
				let a10 = _this.self._10;
				let a11 = _this.self._11;
				let a12 = _this.self._12;
				let a13 = _this.self._13;
				let a20 = _this.self._20;
				let a21 = _this.self._21;
				let a22 = _this.self._22;
				let a23 = _this.self._23;
				let a30 = _this.self._30;
				let a31 = _this.self._31;
				let a32 = _this.self._32;
				let a33 = _this.self._33;
				let b00 = a00 * a11 - a01 * a10;
				let b01 = a00 * a12 - a02 * a10;
				let b02 = a00 * a13 - a03 * a10;
				let b03 = a01 * a12 - a02 * a11;
				let b04 = a01 * a13 - a03 * a11;
				let b05 = a02 * a13 - a03 * a12;
				let b06 = a20 * a31 - a21 * a30;
				let b07 = a20 * a32 - a22 * a30;
				let b08 = a20 * a33 - a23 * a30;
				let b09 = a21 * a32 - a22 * a31;
				let b10 = a21 * a33 - a23 * a31;
				let b11 = a22 * a33 - a23 * a32;
				let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
				if(det == 0.0) {
					_this.self._00 = 1.0;
					_this.self._01 = 0.0;
					_this.self._02 = 0.0;
					_this.self._03 = 0.0;
					_this.self._10 = 0.0;
					_this.self._11 = 1.0;
					_this.self._12 = 0.0;
					_this.self._13 = 0.0;
					_this.self._20 = 0.0;
					_this.self._21 = 0.0;
					_this.self._22 = 1.0;
					_this.self._23 = 0.0;
					_this.self._30 = 0.0;
					_this.self._31 = 0.0;
					_this.self._32 = 0.0;
					_this.self._33 = 1.0;
				} else {
					det = 1.0 / det;
					_this.self._00 = (a11 * b11 - a12 * b10 + a13 * b09) * det;
					_this.self._01 = (a02 * b10 - a01 * b11 - a03 * b09) * det;
					_this.self._02 = (a31 * b05 - a32 * b04 + a33 * b03) * det;
					_this.self._03 = (a22 * b04 - a21 * b05 - a23 * b03) * det;
					_this.self._10 = (a12 * b08 - a10 * b11 - a13 * b07) * det;
					_this.self._11 = (a00 * b11 - a02 * b08 + a03 * b07) * det;
					_this.self._12 = (a32 * b02 - a30 * b05 - a33 * b01) * det;
					_this.self._13 = (a20 * b05 - a22 * b02 + a23 * b01) * det;
					_this.self._20 = (a10 * b10 - a11 * b08 + a13 * b06) * det;
					_this.self._21 = (a01 * b08 - a00 * b10 - a03 * b06) * det;
					_this.self._22 = (a30 * b04 - a31 * b02 + a33 * b00) * det;
					_this.self._23 = (a21 * b02 - a20 * b04 - a23 * b00) * det;
					_this.self._30 = (a11 * b07 - a10 * b09 - a12 * b06) * det;
					_this.self._31 = (a00 * b09 - a01 * b07 + a02 * b06) * det;
					_this.self._32 = (a31 * b01 - a30 * b03 - a32 * b00) * det;
					_this.self._33 = (a20 * b03 - a21 * b01 + a22 * b00) * det;
				}
				let f1 = _this.self._01;
				_this.self._01 = _this.self._10;
				_this.self._10 = f1;
				f1 = _this.self._02;
				_this.self._02 = _this.self._20;
				_this.self._20 = f1;
				f1 = _this.self._12;
				_this.self._12 = _this.self._21;
				_this.self._21 = f1;
				_this.self._30 = _this.self._31 = _this.self._32 = _this.self._33 = 0;
				let _g7 = 0;
				let _g8 = nora.length / 2 | 0;
				while(_g7 < _g8) {
					let i = _g7++;
					v_x = nora[i * 2] / 32767;
					v_y = nora[i * 2 + 1] / 32767;
					v_z = posa[i * 4 + 3] / 32767;
					let x = v_x;
					let y = v_y;
					let z = v_z;
					v_x = _this.self._00 * x + _this.self._10 * y + _this.self._20 * z + _this.self._30;
					v_y = _this.self._01 * x + _this.self._11 * y + _this.self._21 * z + _this.self._31;
					v_z = _this.self._02 * x + _this.self._12 * y + _this.self._22 * z + _this.self._32;
					let n = Math.sqrt(v_x * v_x + v_y * v_y + v_z * v_z);
					if(n > 0.0) {
						let invN = 1.0 / n;
						v_x *= invN;
						v_y *= invN;
						v_z *= invN;
					}
					nora[i * 2] = v_x * 32767 | 0;
					nora[i * 2 + 1] = v_y * 32767 | 0;
					posa[i * 4 + 3] = v_z * 32767 | 0;
				}
				let scalePos = 0.0;
				let _g9 = 0;
				let _g10 = posa32.length;
				while(_g9 < _g10) {
					let f = Math.abs(posa32[_g9++]);
					if(scalePos < f) {
						scalePos = f;
					}
				}
				let inv = 1 / scalePos;
				let _g11 = 0;
				let _g12 = posa32.length / 3 | 0;
				while(_g11 < _g12) {
					let i = _g11++;
					posa[i * 4] = posa32[i * 3] * 32767 * inv | 0;
					posa[i * 4 + 1] = posa32[i * 3 + 1] * 32767 * inv | 0;
					posa[i * 4 + 2] = posa32[i * 3 + 2] * 32767 * inv | 0;
				}
				let obj = { posa : posa, nora : nora, texa : texa, cola : cola, inda : inda, name : name, scalePos : scalePos, scaleTes : 1.0};
				if(first && replaceExisting) {
					arm_io_ImportMesh.makeMesh(obj,path);
				} else {
					arm_io_ImportMesh.addMesh(obj);
				}
				first = false;
			}
			iron_data_Data.deleteBlob(path);
		});
	}
	static runMaterial(path) {
		iron_data_Data.getBlob(path,function(b) {
			let bl = new arm_format_BlendParser(b);
			if(bl.dna == null) {
				arm_Console.error(arm_Strings.error3());
				return;
			}
			let mats = bl.get("Material");
			if(mats.length == 0) {
				arm_Console.error("Error: No materials found");
				return;
			}
			let imported = [];
			let _g = 0;
			while(_g < mats.length) {
				let mat = mats[_g];
				++_g;
				arm_Context.material = new arm_data_MaterialSlot(arm_Project.materials[0].data);
				arm_Project.materials.push(arm_Context.material);
				imported.push(arm_Context.material);
				let nodes = arm_Context.material.nodes;
				let canvas = arm_Context.material.canvas;
				canvas.name = mat.get("id").get("name").substr(2);
				let nout = null;
				let _g1 = 0;
				let _g2 = canvas.nodes;
				while(_g1 < _g2.length) {
					let n = _g2[_g1];
					++_g1;
					if(n.type == "OUTPUT_MATERIAL_PBR") {
						nout = n;
						break;
					}
				}
				let _g3 = 0;
				let _g4 = canvas.nodes;
				while(_g3 < _g4.length) {
					let n = _g4[_g3];
					++_g3;
					if(n.name == "RGB") {
						nodes.removeNode(n,canvas);
						break;
					}
				}
				let nodetree = mat.get("nodetree");
				let blnodes = nodetree.get("nodes");
				let bllinks = nodetree.get("links");
				let node = blnodes.get("first",0,"bNode");
				let last = blnodes.get("last",0,"bNode");
				while(node.get("idname") != "ShaderNodeBsdfPrincipled") {
					if(node.get("name") == last.get("name")) {
						break;
					}
					node = node.get("next");
				}
				if(node.get("idname") != "ShaderNodeBsdfPrincipled") {
					arm_Console.error("Error: No Principled BSDF node found");
					continue;
				}
				nout.name = node.get("name");
				nout.x = node.get("locx") + 400;
				nout.y = -node.get("locy") + 400;
				let node1 = blnodes.get("first",0,"bNode");
				while(true) {
					let search = node1.get("idname").substr(10).toLowerCase();
					let base = null;
					let _g = 0;
					let _g1 = arm_shader_NodesMaterial.list;
					while(_g < _g1.length) {
						let list = _g1[_g];
						++_g;
						let found = false;
						let _g2 = 0;
						while(_g2 < list.length) {
							let n = list[_g2];
							++_g2;
							if(search == StringTools.replace(n.type,"_","").toLowerCase()) {
								base = n;
								found = true;
								break;
							}
						}
						if(found) {
							break;
						}
					}
					if(base != null) {
						let n = arm_ui_UINodes.makeNode(base,nodes,canvas);
						n.x = node1.get("locx") + 400;
						n.y = -node1.get("locy") + 400;
						n.name = node1.get("name");
						let sock = node1.get("inputs").get("first",0,"bNodeSocket");
						let pos = 0;
						while(pos < n.inputs.length) {
							n.inputs[pos].default_value = arm_io_ImportBlend.readBlendSocket(sock);
							let last = sock;
							sock = sock.get("next");
							if(last.block == sock.block) {
								break;
							}
							++pos;
						}
						if(search == "teximage") {
							let file = node1.get("id",0,"Image").get("name").substr(2);
							file = arm_sys_Path.baseDir(path) + file;
							arm_io_ImportTexture.run(file);
							let ar = file.split(arm_sys_Path.sep);
							n.buttons[0].default_value = arm_App.getAssetIndex(ar[ar.length - 1]);
						} else if(search == "valtorgb") {
							let ramp = node1.get("storage",0,"ColorBand");
							let tmp = ramp.get("ipotype") == 0 ? 0 : 1;
							n.buttons[0].data = tmp;
							let elems = n.buttons[0].default_value;
							let _g = 0;
							let _g1 = ramp.get("tot");
							while(_g < _g1) {
								let i = _g++;
								if(i >= elems.length) {
									elems.push([1.0,1.0,1.0,1.0,0.0]);
								}
								let cbdata = ramp.get("data",i,"CBData");
								elems[i][0] = (cbdata.get("r") * 100 | 0) / 100;
								elems[i][1] = (cbdata.get("g") * 100 | 0) / 100;
								elems[i][2] = (cbdata.get("b") * 100 | 0) / 100;
								elems[i][3] = (cbdata.get("a") * 100 | 0) / 100;
								elems[i][4] = (cbdata.get("pos") * 100 | 0) / 100;
							}
						} else if(search == "mixrgb" || search == "math") {
							n.buttons[0].default_value = node1.get("custom1");
							let tmp = node1.get("custom2");
							n.buttons[1].default_value = tmp & 2;
						} else if(search == "mapping") {
							let storage = node1.get("storage",0,"TexMapping");
							n.buttons[0].default_value = storage.get("loc");
							n.buttons[1].default_value = storage.get("rot");
							n.buttons[2].default_value = storage.get("size");
						}
						let sock1 = node1.get("outputs").get("first",0,"bNodeSocket");
						let pos1 = 0;
						while(pos1 < n.outputs.length) {
							n.outputs[pos1].default_value = arm_io_ImportBlend.readBlendSocket(sock1);
							let last = sock1;
							sock1 = sock1.get("next");
							if(last.block == sock1.block) {
								break;
							}
							++pos1;
						}
						canvas.nodes.push(n);
					}
					if(node1.get("name") == last.get("name")) {
						break;
					}
					node1 = node1.get("next");
				}
				let link = bllinks.get("first",0,"bNodeLink");
				while(true) {
					let fromnode = link.get("fromnode").get("name");
					let tonode = link.get("tonode").get("name");
					let fromsock = link.get("fromsock");
					let tosock = link.get("tosock");
					let from_id = -1;
					let to_id = -1;
					let _g = 0;
					let _g1 = canvas.nodes;
					while(_g < _g1.length) {
						let n = _g1[_g];
						++_g;
						if(n.name == fromnode) {
							from_id = n.id;
							break;
						}
					}
					let _g2 = 0;
					let _g3 = canvas.nodes;
					while(_g2 < _g3.length) {
						let n = _g3[_g2];
						++_g2;
						if(n.name == tonode) {
							to_id = n.id;
							break;
						}
					}
					if(from_id >= 0 && to_id >= 0) {
						let from_socket = 0;
						let sock = fromsock;
						while(true) {
							let last = sock;
							sock = sock.get("prev");
							if(last.block == sock.block) {
								break;
							}
							++from_socket;
						}
						let to_socket = 0;
						let sock1 = tosock;
						while(true) {
							let last = sock1;
							sock1 = sock1.get("prev");
							if(last.block == sock1.block) {
								break;
							}
							++to_socket;
						}
						let valid = true;
						if(tonode == nout.name) {
							if(to_socket == 0) {
								to_socket = 0;
							} else if(to_socket == 18) {
								to_socket = 1;
							} else if(to_socket == 7) {
								to_socket = 3;
							} else if(to_socket == 4) {
								to_socket = 4;
							} else if(to_socket == 19) {
								to_socket = 5;
							} else if(to_socket == 17) {
								to_socket = 6;
							} else if(to_socket == 1) {
								to_socket = 8;
							} else {
								valid = false;
							}
						}
						if(valid) {
							let raw = { id : nodes.getLinkId(canvas.links), from_id : from_id, from_socket : from_socket, to_id : to_id, to_socket : to_socket};
							canvas.links.push(raw);
						}
					}
					let last = link;
					link = link.get("next");
					if(last.block == link.block) {
						break;
					}
				}
				arm_History.newMaterial();
			}
			iron_App.notifyOnInit(function() {
				let _g = 0;
				while(_g < imported.length) {
					arm_Context.setMaterial(imported[_g++]);
					arm_node_MakeMaterial.parsePaintMaterial();
					arm_util_RenderUtil.makeMaterialPreview();
				}
			});
			arm_ui_UISidebar.inst.hwnd1.redraws = 2;
			iron_data_Data.deleteBlob(path);
		});
	}
	static readBlendSocket(sock) {
		let idname = sock.get("idname");
		if(idname.startsWith("NodeSocketVector")) {
			let v = sock.get("default_value",0,"bNodeSocketValueVector").get("value");
			v[0] = (v[0] * 100 | 0) / 100;
			v[1] = (v[1] * 100 | 0) / 100;
			v[2] = (v[2] * 100 | 0) / 100;
			return v;
		} else if(idname.startsWith("NodeSocketColor")) {
			let v = sock.get("default_value",0,"bNodeSocketValueRGBA").get("value");
			v[0] = (v[0] * 100 | 0) / 100;
			v[1] = (v[1] * 100 | 0) / 100;
			v[2] = (v[2] * 100 | 0) / 100;
			v[3] = (v[3] * 100 | 0) / 100;
			return v;
		} else if(idname.startsWith("NodeSocketFloat")) {
			let v = sock.get("default_value",0,"bNodeSocketValueFloat").get("value");
			v = (v * 100 | 0) / 100;
			return v;
		} else if(idname.startsWith("NodeSocketInt")) {
			return sock.get("default_value",0,"bNodeSocketValueInt").get("value");
		} else if(idname.startsWith("NodeSocketBoolean")) {
			return sock.get("default_value",0,"bNodeSocketValueBoolean").get("value");
		} else if(idname.startsWith("NodeSocketString")) {
			return sock.get("default_value",0,"bNodeSocketValueString").get("value");
		}
		return null;
	}
}
$hxClasses["arm.io.ImportBlend"] = arm_io_ImportBlend;
arm_io_ImportBlend.__name__ = "arm.io.ImportBlend";
class arm_io_ImportEnvmap {
	static run(path,image) {
		if(arm_io_ImportEnvmap.pipeline == null) {
			arm_io_ImportEnvmap.pipeline = new kha_graphics4_PipelineState();
			arm_io_ImportEnvmap.pipeline.vertexShader = kha_Shaders.getVertex("pass.vert");
			arm_io_ImportEnvmap.pipeline.fragmentShader = kha_Shaders.getFragment("prefilter_envmap.frag");
			let vs = new kha_graphics4_VertexStructure();
			vs.add("pos",1);
			arm_io_ImportEnvmap.pipeline.inputLayout = [vs];
			arm_io_ImportEnvmap.pipeline.colorAttachmentCount = 1;
			arm_io_ImportEnvmap.pipeline.colorAttachments[0] = 2;
			arm_io_ImportEnvmap.pipeline.compile();
			arm_io_ImportEnvmap.paramsLocation = arm_io_ImportEnvmap.pipeline.getConstantLocation("params");
			arm_io_ImportEnvmap.radianceLocation = arm_io_ImportEnvmap.pipeline.getTextureUnit("radiance");
			arm_io_ImportEnvmap.radiance = kha_Image.createRenderTarget(1024,512,2);
			arm_io_ImportEnvmap.mips = [];
			let w = 512;
			let _g = 0;
			while(_g < 10) {
				++_g;
				arm_io_ImportEnvmap.mips.push(kha_Image.createRenderTarget(w,w > 1 ? w / 2 | 0 : 1,2));
				w = w / 2 | 0;
			}
			if(iron_data_ConstData.screenAlignedVB == null) {
				iron_data_ConstData.createScreenAlignedData();
			}
		}
		arm_io_ImportEnvmap.radiance.get_g2().begin(false);
		arm_io_ImportEnvmap.radiance.get_g2().set_pipeline(arm_Layers.pipeCopy128);
		arm_io_ImportEnvmap.radiance.get_g2().drawScaledImage(image,0,0,1024,512);
		arm_io_ImportEnvmap.radiance.get_g2().set_pipeline(null);
		arm_io_ImportEnvmap.radiance.get_g2().end();
		let radiancePixels = arm_io_ImportEnvmap.radiance.getPixels();
		if(arm_io_ImportEnvmap.radianceCpu != null) {
			arm_io_ImportEnvmap.radianceCpu.unload();
		}
		arm_io_ImportEnvmap.radianceCpu = kha_Image.fromBytes(radiancePixels,arm_io_ImportEnvmap.radiance.get_width(),arm_io_ImportEnvmap.radiance.get_height(),2,1);
		if(arm_io_ImportEnvmap.mipsCpu != null) {
			let _g = 0;
			let _g1 = arm_io_ImportEnvmap.mipsCpu;
			while(_g < _g1.length) _g1[_g++].unload();
		}
		arm_io_ImportEnvmap.mipsCpu = [];
		let _g = 0;
		let _g1 = arm_io_ImportEnvmap.mips.length;
		while(_g < _g1) {
			let i = _g++;
			arm_io_ImportEnvmap.getRadianceMip(arm_io_ImportEnvmap.mips[i],i,arm_io_ImportEnvmap.radiance);
			arm_io_ImportEnvmap.mipsCpu.push(kha_Image.fromBytes(arm_io_ImportEnvmap.mips[i].getPixels(),arm_io_ImportEnvmap.mips[i].get_width(),arm_io_ImportEnvmap.mips[i].get_height(),2,1));
		}
		arm_io_ImportEnvmap.radianceCpu.setMipmaps(arm_io_ImportEnvmap.mipsCpu);
		let tmp = arm_io_ImportEnvmap.radiance.get_width();
		let tmp1 = arm_io_ImportEnvmap.radiance.get_height();
		iron_Scene.active.world.probe.irradiance = arm_io_ImportEnvmap.getSphericalHarmonics(radiancePixels,tmp,tmp1);
		iron_Scene.active.world.probe.raw.strength = 1.0;
		iron_Scene.active.world.probe.raw.radiance_mipmaps = arm_io_ImportEnvmap.mipsCpu.length - 2;
		iron_Scene.active.world.envmap = image;
		iron_Scene.active.world.raw.envmap = path;
		iron_Scene.active.world.probe.radiance = arm_io_ImportEnvmap.radianceCpu;
		iron_Scene.active.world.probe.radianceMipmaps = arm_io_ImportEnvmap.mipsCpu;
		arm_Context.savedEnvmap = image;
		arm_Context.showEnvmapHandle.selected = arm_Context.showEnvmap = true;
		if(arm_Context.showEnvmapBlur) {
			iron_Scene.active.world.envmap = iron_Scene.active.world.probe.radianceMipmaps[0];
		}
		arm_Context.ddirty = 2;
		arm_Project.raw.envmap = path;
	}
	static getRadianceMip(mip,level,radiance) {
		mip.get_g4().begin();
		mip.get_g4().setVertexBuffer(iron_data_ConstData.screenAlignedVB);
		mip.get_g4().setIndexBuffer(iron_data_ConstData.screenAlignedIB);
		mip.get_g4().setPipeline(arm_io_ImportEnvmap.pipeline);
		arm_io_ImportEnvmap.params.x = 0.1 + level / 8;
		mip.get_g4().setFloat4(arm_io_ImportEnvmap.paramsLocation,arm_io_ImportEnvmap.params.x,arm_io_ImportEnvmap.params.y,arm_io_ImportEnvmap.params.z,arm_io_ImportEnvmap.params.w);
		mip.get_g4().setTexture(arm_io_ImportEnvmap.radianceLocation,radiance);
		mip.get_g4().drawIndexedVertices();
		mip.get_g4().end();
	}
	static reverseEquirect(x,y) {
		let theta = x * Math.PI * 2 - Math.PI;
		let phi = y * Math.PI;
		let _this = arm_io_ImportEnvmap.n;
		let y1 = Math.sin(phi) * Math.cos(theta);
		let z = -(Math.sin(phi) * Math.sin(theta));
		_this.x = -Math.cos(phi);
		_this.y = y1;
		_this.z = z;
		_this.w = 1.0;
		return _this;
	}
	static getSphericalHarmonics(source,sourceWidth,sourceHeight) {
		let sh = new Float32Array(28);
		let accum = 0.0;
		let _g = 0;
		while(_g < sourceWidth) {
			let x = _g++;
			let _g1 = 0;
			while(_g1 < sourceHeight) {
				let y = _g1++;
				arm_io_ImportEnvmap.n = arm_io_ImportEnvmap.reverseEquirect(x / sourceWidth,y / sourceHeight);
				let _g = 0;
				while(_g < 3) {
					let i = _g++;
					let value = source.getFloat((x + y * sourceWidth) * 16 + i * 4);
					value = Math.pow(value,0.45454545454545453);
					sh[i] += value * 0.23529411764705882;
					sh[3 + i] += value * 0.47058823529411764 * arm_io_ImportEnvmap.n.x;
					sh[6 + i] += value * 0.47058823529411764 * arm_io_ImportEnvmap.n.y;
					sh[9 + i] += value * 0.47058823529411764 * arm_io_ImportEnvmap.n.z;
					sh[12 + i] += value * 0.88235294117647056 * arm_io_ImportEnvmap.n.x * arm_io_ImportEnvmap.n.z;
					sh[15 + i] += value * 0.88235294117647056 * arm_io_ImportEnvmap.n.z * arm_io_ImportEnvmap.n.y;
					sh[18 + i] += value * 0.88235294117647056 * arm_io_ImportEnvmap.n.y * arm_io_ImportEnvmap.n.x;
					sh[21 + i] += value * 0.073529411764705885 * (3.0 * arm_io_ImportEnvmap.n.z * arm_io_ImportEnvmap.n.z - 1.0);
					sh[24 + i] += value * 0.22058823529411764 * (arm_io_ImportEnvmap.n.x * arm_io_ImportEnvmap.n.x - arm_io_ImportEnvmap.n.y * arm_io_ImportEnvmap.n.y);
					accum += 1.0;
				}
			}
		}
		let _g1 = 0;
		let _g2 = sh.length;
		while(_g1 < _g2) sh[_g1++] /= accum / 16;
		return sh;
	}
}
$hxClasses["arm.io.ImportEnvmap"] = arm_io_ImportEnvmap;
arm_io_ImportEnvmap.__name__ = "arm.io.ImportEnvmap";
class arm_io_ImportFbx {
	static run(path,replaceExisting) {
		if(replaceExisting == null) {
			replaceExisting = true;
		}
		iron_data_Data.getBlob(path,function(b) {
			arm_format_FbxParser.parseTransform = arm_Context.parseTransform;
			arm_format_FbxParser.parseVCols = arm_Context.parseVCols;
			let obj = new arm_format_FbxParser(b);
			if(replaceExisting) {
				arm_io_ImportMesh.makeMesh(obj,path);
			} else {
				arm_io_ImportMesh.addMesh(obj);
			}
			while(obj.next()) arm_io_ImportMesh.addMesh(obj);
			iron_data_Data.deleteBlob(path);
		});
	}
}
$hxClasses["arm.io.ImportFbx"] = arm_io_ImportFbx;
arm_io_ImportFbx.__name__ = "arm.io.ImportFbx";
class arm_io_ImportFolder {
	static run(path) {
		let files = arm_sys_File.readDirectory(path);
		let mapbase = "";
		let mapopac = "";
		let mapnor = "";
		let mapocc = "";
		let maprough = "";
		let mapmet = "";
		let mapheight = "";
		let _g = 0;
		while(_g < files.length) {
			let f = files[_g];
			++_g;
			if(!arm_sys_Path.isTexture(f)) {
				continue;
			}
			let base = HxOverrides.substr(f,0,f.lastIndexOf(".")).toLowerCase();
			let valid = false;
			if(mapbase == "" && arm_sys_Path.checkExt(base,arm_sys_Path.baseColorExt)) {
				mapbase = f;
				valid = true;
			}
			if(mapopac == "" && arm_sys_Path.checkExt(base,arm_sys_Path.opacityExt)) {
				mapopac = f;
				valid = true;
			}
			if(mapnor == "" && arm_sys_Path.checkExt(base,arm_sys_Path.normalMapExt)) {
				mapnor = f;
				valid = true;
			}
			if(mapocc == "" && arm_sys_Path.checkExt(base,arm_sys_Path.occlusionExt)) {
				mapocc = f;
				valid = true;
			}
			if(maprough == "" && arm_sys_Path.checkExt(base,arm_sys_Path.roughnessExt)) {
				maprough = f;
				valid = true;
			}
			if(mapmet == "" && arm_sys_Path.checkExt(base,arm_sys_Path.metallicExt)) {
				mapmet = f;
				valid = true;
			}
			if(mapheight == "" && arm_sys_Path.checkExt(base,arm_sys_Path.displacementExt)) {
				mapheight = f;
				valid = true;
			}
			if(valid) {
				arm_io_ImportTexture.run(path + arm_sys_Path.sep + f);
			}
		}
		arm_Context.material = new arm_data_MaterialSlot(arm_Project.materials[0].data);
		arm_Project.materials.push(arm_Context.material);
		let nodes = arm_Context.material.nodes;
		let canvas = arm_Context.material.canvas;
		let dirs = path.split(arm_sys_Path.sep);
		canvas.name = dirs[dirs.length - 1];
		let nout = null;
		let _g1 = 0;
		let _g2 = canvas.nodes;
		while(_g1 < _g2.length) {
			let n = _g2[_g1];
			++_g1;
			if(n.type == "OUTPUT_MATERIAL_PBR") {
				nout = n;
				break;
			}
		}
		let _g3 = 0;
		let _g4 = canvas.nodes;
		while(_g3 < _g4.length) {
			let n = _g4[_g3];
			++_g3;
			if(n.name == "RGB") {
				nodes.removeNode(n,canvas);
				break;
			}
		}
		let pos = 0;
		if(mapbase != "") {
			arm_io_ImportFolder.placeImageNode(nodes,canvas,mapbase,100,nout.id,0);
			pos = 1;
		}
		if(mapopac != "") {
			arm_io_ImportFolder.placeImageNode(nodes,canvas,mapopac,100 + 164 * pos,nout.id,1);
			++pos;
		}
		if(mapocc != "") {
			arm_io_ImportFolder.placeImageNode(nodes,canvas,mapocc,100 + 164 * pos,nout.id,2);
			++pos;
		}
		if(maprough != "") {
			arm_io_ImportFolder.placeImageNode(nodes,canvas,maprough,100 + 164 * pos,nout.id,3);
			++pos;
		}
		if(mapmet != "") {
			arm_io_ImportFolder.placeImageNode(nodes,canvas,mapmet,100 + 164 * pos,nout.id,4);
			++pos;
		}
		if(mapnor != "") {
			arm_io_ImportFolder.placeImageNode(nodes,canvas,mapnor,100 + 164 * pos,nout.id,5);
			++pos;
		}
		if(mapheight != "") {
			arm_io_ImportFolder.placeImageNode(nodes,canvas,mapheight,100 + 164 * pos,nout.id,7);
			++pos;
		}
		arm_node_MakeMaterial.parsePaintMaterial();
		arm_util_RenderUtil.makeMaterialPreview();
		arm_ui_UISidebar.inst.hwnd1.redraws = 2;
		arm_History.newMaterial();
	}
	static placeImageNode(nodes,canvas,asset,ny,to_id,to_socket) {
		let n = arm_shader_NodesMaterial.createNode("TEX_IMAGE");
		n.buttons[0].default_value = arm_App.getAssetIndex(asset);
		n.x = 72;
		n.y = ny;
		let l = { id : nodes.getLinkId(canvas.links), from_id : n.id, from_socket : 0, to_id : to_id, to_socket : to_socket};
		canvas.links.push(l);
	}
}
$hxClasses["arm.io.ImportFolder"] = arm_io_ImportFolder;
arm_io_ImportFolder.__name__ = "arm.io.ImportFolder";
class arm_io_ImportFont {
	static run(path) {
		let _g = 0;
		let _g1 = arm_Project.fonts;
		while(_g < _g1.length) if(_g1[_g++].file == path) {
			arm_Console.info(arm_Strings.info0());
			return;
		}
		iron_data_Data.getFont(path,function(font) {
			let fn = font.getFontNames();
			let fontSlots = [];
			let _g = 0;
			let _g1 = fn.length;
			while(_g < _g1) {
				let i = _g++;
				let ar = path.split(arm_sys_Path.sep);
				let name = fn[i] != null ? fn[i] : ar[ar.length - 1];
				let f = font.clone();
				f.setFontIndex(i);
				fontSlots.push(new arm_data_FontSlot(name,f,path));
			}
			iron_App.notifyOnInit(function() {
				let _g = 0;
				while(_g < fontSlots.length) {
					let f = fontSlots[_g];
					++_g;
					arm_Context.font = f;
					arm_Project.fonts.push(f);
					arm_util_RenderUtil.makeFontPreview();
				}
			});
			arm_ui_UIStatus.inst.statusHandle.redraws = 2;
		});
	}
}
$hxClasses["arm.io.ImportFont"] = arm_io_ImportFont;
arm_io_ImportFont.__name__ = "arm.io.ImportFont";
class arm_io_ImportKeymap {
	static run(path) {
		if(!arm_sys_Path.isJson(path)) {
			arm_Console.error(arm_Strings.error1());
			return;
		}
		let filename = HxOverrides.substr(path,path.lastIndexOf(arm_sys_Path.sep) + 1,null);
		arm_sys_File.copy(path,arm_sys_Path.data() + arm_sys_Path.sep + "keymap_presets" + arm_sys_Path.sep + filename);
		arm_ui_BoxPreferences.fetchKeymaps();
		arm_ui_BoxPreferences.presetHandle.position = arm_ui_BoxPreferences.getPresetIndex();
		arm_Console.info(arm_Translator.tr("Keymap imported:") + " " + filename);
	}
}
$hxClasses["arm.io.ImportKeymap"] = arm_io_ImportKeymap;
arm_io_ImportKeymap.__name__ = "arm.io.ImportKeymap";
class arm_io_ImportMesh {
	static run(path,_clearLayers,replaceExisting) {
		if(replaceExisting == null) {
			replaceExisting = true;
		}
		if(_clearLayers == null) {
			_clearLayers = true;
		}
		if(!arm_sys_Path.isMesh(path)) {
			if(!arm_Context.enableImportPlugin(path)) {
				arm_Console.error(arm_Strings.error1());
				return;
			}
		}
		arm_io_ImportMesh.clearLayers = _clearLayers;
		arm_Context.layerFilter = 0;
		let p = path.toLowerCase();
		if(p.endsWith(".obj")) {
			arm_io_ImportObj.run(path,replaceExisting);
		} else if(p.endsWith(".fbx")) {
			arm_io_ImportFbx.run(path,replaceExisting);
		} else if(p.endsWith(".blend")) {
			arm_io_ImportBlend.run(path,replaceExisting);
		} else {
			arm_sys_Path.meshImporters.h[HxOverrides.substr(path,path.lastIndexOf(".") + 1,null)](path,function(mesh) {
				if(replaceExisting) {
					arm_io_ImportMesh.makeMesh(mesh,path);
				} else {
					arm_io_ImportMesh.addMesh(mesh);
				}
			});
		}
		arm_Project.meshAssets = [path];
	}
	static finishImport() {
		if(arm_Context.mergedObject != null) {
			arm_Context.mergedObject.remove();
			iron_data_Data.deleteMesh(arm_Context.mergedObject.data.handle);
			arm_Context.mergedObject = null;
		}
		arm_Context.selectPaintObject(arm_Context.mainObject());
		if(arm_Project.paintObjects.length > 1) {
			arm_Project.paintObjects.sort(function(a,b) {
				if(a.name < b.name) {
					return -1;
				} else if(a.name > b.name) {
					return 1;
				}
				return 0;
			});
			let _g = 0;
			let _g1 = arm_Project.paintObjects;
			while(_g < _g1.length) _g1[_g++].visible = true;
			if(arm_Context.mergedObject == null) {
				arm_util_MeshUtil.mergeMesh();
			}
			arm_Context.paintObject.skip_context = "paint";
			arm_Context.mergedObject.visible = true;
		}
		arm_Viewport.scaleToBounds();
		if(arm_Context.paintObject.name == "") {
			arm_Context.paintObject.name = "Object";
		}
		arm_node_MakeMaterial.parsePaintMaterial();
		arm_node_MakeMaterial.parseMeshMaterial();
		arm_ui_UIView2D.inst.hwnd.redraws = 2;
	}
	static makeMesh(mesh,path) {
		if(mesh == null || mesh.posa == null || mesh.nora == null || mesh.inda == null || mesh.posa.length == 0) {
			arm_Console.error(arm_Strings.error3());
			return;
		}
		let _makeMesh = function() {
			let raw = arm_io_ImportMesh.rawMesh(mesh);
			if(mesh.cola != null) {
				raw.vertex_arrays.push({ values : mesh.cola, attrib : "col", data : "short4norm", padding : 1});
			}
			new iron_data_MeshData(raw,function(md) {
				arm_Context.paintObject = arm_Context.mainObject();
				arm_Context.selectPaintObject(arm_Context.mainObject());
				let _g = 0;
				let _g1 = arm_Project.paintObjects.length;
				while(_g < _g1) {
					let p = arm_Project.paintObjects[_g++];
					if(p == arm_Context.paintObject) {
						continue;
					}
					iron_data_Data.deleteMesh(p.data.handle);
					p.remove();
				}
				let handle = arm_Context.paintObject.data.handle;
				if(handle != "SceneSphere" && handle != "ScenePlane") {
					iron_data_Data.deleteMesh(handle);
				}
				if(arm_io_ImportMesh.clearLayers) {
					while(arm_Project.layers.length > 0) arm_Project.layers.pop().unload();
					arm_Layers.newLayer(false);
					iron_App.notifyOnInit(arm_Layers.initLayers);
					arm_History.reset();
				}
				arm_Context.paintObject.setData(md);
				arm_Context.paintObject.name = mesh.name;
				arm_Project.paintObjects = [arm_Context.paintObject];
				md.handle = raw.name;
				iron_data_Data.cachedMeshes.h[md.handle] = md;
				arm_Context.ddirty = 4;
				arm_ui_UISidebar.inst.hwnd0.redraws = 2;
				arm_ui_UISidebar.inst.hwnd1.redraws = 2;
				arm_util_UVUtil.uvmapCached = false;
				arm_util_UVUtil.trianglemapCached = false;
				arm_util_UVUtil.dilatemapCached = false;
				iron_App.notifyOnInit(arm_io_ImportMesh.finishImport);
			});
		};
		if(mesh.texa == null) {
			arm_Project.unwrapMeshBox(mesh,_makeMesh);
		} else {
			_makeMesh();
		}
	}
	static addMesh(mesh) {
		let _addMesh = function() {
			let raw = arm_io_ImportMesh.rawMesh(mesh);
			if(mesh.cola != null) {
				raw.vertex_arrays.push({ values : mesh.cola, attrib : "col", data : "short4norm", padding : 1});
			}
			new iron_data_MeshData(raw,function(md) {
				let object = iron_Scene.active.addMeshObject(md,arm_Context.paintObject.materials,arm_Context.paintObject);
				object.name = mesh.name;
				object.skip_context = "paint";
				let _g = 0;
				let _g1 = arm_Project.paintObjects;
				while(_g < _g1.length) {
					let p = _g1[_g];
					++_g;
					if(p.name == object.name) {
						p.name += ".001";
						p.data.handle += ".001";
						iron_data_Data.cachedMeshes.h[p.data.handle] = p.data;
					}
				}
				arm_Project.paintObjects.push(object);
				md.handle = raw.name;
				iron_data_Data.cachedMeshes.h[md.handle] = md;
				arm_Context.ddirty = 4;
				arm_ui_UISidebar.inst.hwnd0.redraws = 2;
				arm_util_UVUtil.uvmapCached = false;
				arm_util_UVUtil.trianglemapCached = false;
				arm_util_UVUtil.dilatemapCached = false;
			});
		};
		if(mesh.texa == null) {
			arm_Project.unwrapMeshBox(mesh,_addMesh);
		} else {
			_addMesh();
		}
	}
	static rawMesh(mesh) {
		return { name : mesh.name, vertex_arrays : [{ values : mesh.posa, attrib : "pos", data : "short4norm"},{ values : mesh.nora, attrib : "nor", data : "short2norm"},{ values : mesh.texa, attrib : "tex", data : "short2norm"}], index_arrays : [{ values : mesh.inda, material : 0}], scale_pos : mesh.scalePos, scale_tex : mesh.scaleTex};
	}
}
$hxClasses["arm.io.ImportMesh"] = arm_io_ImportMesh;
arm_io_ImportMesh.__name__ = "arm.io.ImportMesh";
class arm_io_ImportObj {
	static run(path,replaceExisting) {
		if(replaceExisting == null) {
			replaceExisting = true;
		}
		let i = arm_Context.splitBy;
		let isUdim = i == 3;
		arm_format_ObjParser.splitCode = i == 0 || isUdim ? 111 : i == 1 ? 103 : 117;
		iron_data_Data.getBlob(path,function(b) {
			if(isUdim) {
				let obj = new arm_format_ObjParser(b,0,isUdim);
				let name = obj.name;
				let _g = 0;
				let _g1 = obj.udims.length;
				while(_g < _g1) {
					let i = _g++;
					if(obj.udims[i].length == 0) {
						continue;
					}
					obj.name = name + "." + (1000 + (i / obj.udimsU | 0) * 10 + i % obj.udimsU + 1);
					obj.inda = obj.udims[i];
					if(i == 0) {
						if(replaceExisting) {
							arm_io_ImportMesh.makeMesh(obj,path);
						} else {
							arm_io_ImportMesh.addMesh(obj);
						}
					} else {
						arm_io_ImportMesh.addMesh(obj);
					}
				}
			} else {
				let parts = [];
				let obj = new arm_format_ObjParser(b);
				parts.push(obj);
				while(obj.hasNext) {
					obj = new arm_format_ObjParser(b,obj.pos);
					parts.push(obj);
				}
				if(arm_Context.splitBy == 2) {
					let posa0;
					let posa1;
					let nora0;
					let nora1;
					let texa0;
					let texa1;
					let inda0;
					let inda1;
					let _g = 0;
					let _g1 = parts.length;
					while(_g < _g1) {
						let i = _g++;
						let j = i + 1;
						while(j < parts.length) if(parts[i].name == parts[j].name) {
							posa0 = parts[i].posa;
							posa1 = parts[j].posa;
							nora0 = parts[i].nora;
							nora1 = parts[j].nora;
							texa0 = parts[i].texa != null ? parts[i].texa : null;
							texa1 = parts[j].texa != null ? parts[j].texa : null;
							inda0 = parts[i].inda;
							inda1 = parts[j].inda;
							let voff = posa0.length / 4 | 0;
							let posa32 = new Float32Array((posa0.length / 4 | 0) * 3 + (posa1.length / 4 | 0) * 3);
							let _g = 0;
							let _g1 = posa0.length / 4 | 0;
							while(_g < _g1) {
								let k = _g++;
								posa32[k * 3] = posa0[k * 4] / 32767 * parts[i].scalePos;
								posa32[k * 3 + 1] = posa0[k * 4 + 1] / 32767 * parts[i].scalePos;
								posa32[k * 3 + 2] = posa0[k * 4 + 2] / 32767 * parts[i].scalePos;
							}
							let _g2 = 0;
							let _g3 = posa1.length / 4 | 0;
							while(_g2 < _g3) {
								let k = _g2++;
								posa32[voff * 3 + k * 3] = posa1[k * 4] / 32767 * parts[j].scalePos;
								posa32[voff * 3 + k * 3 + 1] = posa1[k * 4 + 1] / 32767 * parts[j].scalePos;
								posa32[voff * 3 + k * 3 + 2] = posa1[k * 4 + 2] / 32767 * parts[j].scalePos;
							}
							let scalePos = 0.0;
							let _g4 = 0;
							let _g5 = posa32.length;
							while(_g4 < _g5) {
								let f = Math.abs(posa32[_g4++]);
								if(scalePos < f) {
									scalePos = f;
								}
							}
							let inv = 32767 * (1 / scalePos);
							let posa = new Int16Array(posa0.length + posa1.length);
							let _g6 = 0;
							let _g7 = posa.length / 4 | 0;
							while(_g6 < _g7) {
								let k = _g6++;
								posa[k * 4] = posa32[k * 3] * inv | 0;
								posa[k * 4 + 1] = posa32[k * 3 + 1] * inv | 0;
								posa[k * 4 + 2] = posa32[k * 3 + 2] * inv | 0;
							}
							let _g8 = 0;
							let _g9 = posa0.length / 4 | 0;
							while(_g8 < _g9) {
								let k = _g8++;
								posa[k * 4 + 3] = posa0[k * 4 + 3];
							}
							let _g10 = 0;
							let _g11 = posa1.length / 4 | 0;
							while(_g10 < _g11) {
								let k = _g10++;
								posa[posa0.length + k * 4 + 3] = posa1[k * 4 + 3];
							}
							let nora = new Int16Array(nora0.length + nora1.length);
							let texa = texa0 != null && texa1 != null ? new Int16Array(texa0.length + texa1.length) : null;
							let inda = new Uint32Array(inda0.length + inda1.length);
							nora.set(nora0);
							nora.set(nora1, nora0.length);
							if(texa != null) {
								texa.set(texa0);
								texa.set(texa1, texa0.length);
							}
							inda.set(inda0);
							let _g12 = 0;
							let _g13 = inda1.length;
							while(_g12 < _g13) {
								let k = _g12++;
								inda[k + inda0.length] = inda1[k] + voff;
							}
							parts[i].posa = posa;
							parts[i].nora = nora;
							parts[i].texa = texa;
							parts[i].inda = inda;
							parts[i].scalePos = scalePos;
							parts.splice(j,1);
						} else {
							++j;
						}
					}
				}
				if(replaceExisting) {
					arm_io_ImportMesh.makeMesh(parts[0],path);
				} else {
					arm_io_ImportMesh.addMesh(parts[0]);
				}
				let _g = 1;
				let _g1 = parts.length;
				while(_g < _g1) arm_io_ImportMesh.addMesh(parts[_g++]);
			}
			iron_data_Data.deleteBlob(path);
		});
	}
}
$hxClasses["arm.io.ImportObj"] = arm_io_ImportObj;
arm_io_ImportObj.__name__ = "arm.io.ImportObj";
class arm_io_ImportPlugin {
	static run(path) {
		if(!arm_sys_Path.isPlugin(path)) {
			arm_Console.error(arm_Strings.error1());
			return;
		}
		let filename = HxOverrides.substr(path,path.lastIndexOf(arm_sys_Path.sep) + 1,null);
		arm_sys_File.copy(path,arm_sys_Path.data() + arm_sys_Path.sep + "plugins" + arm_sys_Path.sep + filename);
		arm_ui_BoxPreferences.filesPlugin = null;
		arm_Console.info(arm_Translator.tr("Plugin imported:") + " " + filename);
	}
}
$hxClasses["arm.io.ImportPlugin"] = arm_io_ImportPlugin;
arm_io_ImportPlugin.__name__ = "arm.io.ImportPlugin";
class arm_io_ImportTexture {
	static run(path,hdrAsEnvmap) {
		if(hdrAsEnvmap == null) {
			hdrAsEnvmap = true;
		}
		if(!arm_sys_Path.isTexture(path)) {
			if(!arm_Context.enableImportPlugin(path)) {
				arm_Console.error(arm_Strings.error1());
				return;
			}
		}
		let _g = 0;
		let _g1 = arm_Project.assets;
		while(_g < _g1.length) if(_g1[_g++].file == path) {
			if(hdrAsEnvmap && path.toLowerCase().endsWith(".hdr")) {
				iron_data_Data.getImage(path,function(image) {
					arm_App.notifyOnNextFrame(function() {
						arm_io_ImportEnvmap.run(path,image);
					});
				});
			}
			arm_Console.info(arm_Strings.info0());
			return;
		}
		let importer = arm_sys_Path.textureImporters.h[HxOverrides.substr(path,path.lastIndexOf(".") + 1,null)];
		if(importer == null || iron_data_Data.cachedImages.h[path] != null) {
			importer = arm_io_ImportTexture.defaultImporter;
		}
		importer(path,function(image) {
			iron_data_Data.cachedImages.h[path] = image;
			let ar = path.split(arm_sys_Path.sep);
			let name = ar[ar.length - 1];
			let asset = { name : name, file : path, id : arm_Project.assetId++};
			arm_Project.assets.push(asset);
			if(arm_Context.texture == null) {
				arm_Context.texture = asset;
			}
			arm_Project.assetNames.push(name);
			arm_Project.assetMap.h[asset.id] = image;
			arm_ui_UIStatus.inst.statusHandle.redraws = 2;
			arm_Console.info(arm_Translator.tr("Texture imported:") + " " + name);
			if(hdrAsEnvmap && path.toLowerCase().endsWith(".hdr")) {
				arm_App.notifyOnNextFrame(function() {
					arm_io_ImportEnvmap.run(path,image);
				});
			}
		});
	}
	static defaultImporter(path,done) {
		iron_data_Data.getImage(path,done);
	}
}
$hxClasses["arm.io.ImportTexture"] = arm_io_ImportTexture;
arm_io_ImportTexture.__name__ = "arm.io.ImportTexture";
class arm_io_ImportTheme {
	static run(path) {
		if(!arm_sys_Path.isJson(path)) {
			arm_Console.error(arm_Strings.error1());
			return;
		}
		let filename = HxOverrides.substr(path,path.lastIndexOf(arm_sys_Path.sep) + 1,null);
		arm_sys_File.copy(path,arm_sys_Path.data() + arm_sys_Path.sep + "themes" + arm_sys_Path.sep + filename);
		arm_ui_BoxPreferences.fetchThemes();
		arm_Config.raw.theme = filename;
		arm_ui_BoxPreferences.themeHandle.position = arm_ui_BoxPreferences.getThemeIndex();
		arm_Config.loadTheme(arm_Config.raw.theme);
		arm_Console.info(arm_Translator.tr("Theme imported:") + " " + filename);
	}
}
$hxClasses["arm.io.ImportTheme"] = arm_io_ImportTheme;
arm_io_ImportTheme.__name__ = "arm.io.ImportTheme";
class arm_node_LogicNode {
	constructor(tree) {
		if(arm_node_LogicNode._hx_skip_constructor) {
			return;
		}
		this._hx_constructor(tree);
	}
	_hx_constructor(tree) {
		this.outputs = [];
		this.inputs = [];
		this.tree = tree;
	}
	addInput(node,from) {
		this.inputs.push(new arm_node_LogicNodeInput(node,from));
	}
	addOutputs(nodes) {
		this.outputs.push(nodes);
	}
	get(from) {
		return this;
	}
	set(value) {
	}
}
$hxClasses["arm.node.LogicNode"] = arm_node_LogicNode;
arm_node_LogicNode.__name__ = "arm.node.LogicNode";
Object.assign(arm_node_LogicNode.prototype, {
	__class__: arm_node_LogicNode
});
class arm_node_LogicNodeInput {
	constructor(node,from) {
		this.node = node;
		this.from = from;
	}
	get() {
		return this.node.get(this.from);
	}
	set(value) {
		this.node.set(value);
	}
}
$hxClasses["arm.node.LogicNodeInput"] = arm_node_LogicNodeInput;
arm_node_LogicNodeInput.__name__ = "arm.node.LogicNodeInput";
Object.assign(arm_node_LogicNodeInput.prototype, {
	__class__: arm_node_LogicNodeInput
});
class iron_Trait {
	constructor() {
		if(iron_Trait._hx_skip_constructor) {
			return;
		}
		this._hx_constructor();
	}
	_hx_constructor() {
		this._render2D = null;
		this._render = null;
		this._lateUpdate = null;
		this._update = null;
		this._remove = null;
		this._init = null;
		this._add = null;
	}
	remove() {
		this.object.removeTrait(this);
	}
	notifyOnAdd(f) {
		if(this._add == null) {
			this._add = [];
		}
		this._add.push(f);
	}
	notifyOnRemove(f) {
		if(this._remove == null) {
			this._remove = [];
		}
		this._remove.push(f);
	}
	notifyOnUpdate(f) {
		if(this._update == null) {
			this._update = [];
		}
		this._update.push(f);
		iron_App.notifyOnUpdate(f);
	}
}
$hxClasses["iron.Trait"] = iron_Trait;
iron_Trait.__name__ = "iron.Trait";
Object.assign(iron_Trait.prototype, {
	__class__: iron_Trait
});
class arm_node_LogicTree extends iron_Trait {
	constructor() {
		super();
	}
}
$hxClasses["arm.node.LogicTree"] = arm_node_LogicTree;
arm_node_LogicTree.__name__ = "arm.node.LogicTree";
arm_node_LogicTree.__super__ = iron_Trait;
Object.assign(arm_node_LogicTree.prototype, {
	__class__: arm_node_LogicTree
});
class arm_node_MakeBake {
	static run(con,vert,frag) {
		if(arm_Context.bakeType == 0) {
			frag.wposition = true;
			frag.n = true;
			frag.vVec = true;
			frag.add_function(arm_shader_ShaderFunctions.str_cotangentFrame);
			frag.write("mat3 TBN = cotangentFrame(n, vVec, texCoord);");
			frag.write("n = nortan * 2.0 - 1.0;");
			frag.write("n.y = -n.y;");
			frag.write("n = normalize(mul(n, TBN));");
			let ext = arm_Context.vxaoExt;
			frag.write("const vec3 voxelgiHalfExtents = vec3(" + ext + ", " + ext + ", " + ext + ");");
			frag.write("vec3 voxpos = wposition / voxelgiHalfExtents;");
			frag.add_uniform("sampler3D voxels");
			frag.add_function(arm_shader_ShaderFunctions.str_traceAO);
			frag.n = true;
			frag.write("float ao = traceAO(voxpos, n, " + arm_Context.bakeAoRadius + ", " + arm_Context.bakeAoOffset + ") * " + arm_Context.bakeAoStrength + ";");
			if(arm_Context.bakeAxis != 0) {
				frag.write("ao *= dot(n, " + arm_node_MakeBake.axisString(arm_Context.bakeAxis) + ");");
			}
			frag.write("ao = 1.0 - ao;");
			frag.write("fragColor[0] = vec4(ao, ao, ao, 1.0);");
		} else if(arm_Context.bakeType == 1) {
			let pass = arm_shader_MaterialParser.bake_passthrough;
			let strength = pass ? arm_shader_MaterialParser.bake_passthrough_strength : arm_Context.bakeCurvStrength + "";
			let radius = pass ? arm_shader_MaterialParser.bake_passthrough_radius : arm_Context.bakeCurvRadius + "";
			let offset = pass ? arm_shader_MaterialParser.bake_passthrough_offset : arm_Context.bakeCurvOffset + "";
			frag.n = true;
			frag.write("vec3 dx = dFdx(n);");
			frag.write("vec3 dy = dFdy(n);");
			frag.write("float curvature = max(dot(dx, dx), dot(dy, dy));");
			frag.write("curvature = clamp(pow(curvature, (1.0 / " + radius + ") * 0.25) * " + strength + " * 2.0 + " + offset + " / 10.0, 0.0, 1.0);");
			if(arm_Context.bakeAxis != 0) {
				frag.write("curvature *= dot(n, " + arm_node_MakeBake.axisString(arm_Context.bakeAxis) + ");");
			}
			frag.write("fragColor[0] = vec4(curvature, curvature, curvature, 1.0);");
		} else if(arm_Context.bakeType == 2) {
			frag.n = true;
			frag.add_uniform("sampler2D texpaint_undo","_texpaint_undo");
			frag.write("vec3 n0 = textureLod(texpaint_undo, texCoord, 0.0).rgb * vec3(2.0, 2.0, 2.0) - vec3(1.0, 1.0, 1.0);");
			frag.add_function(arm_shader_ShaderFunctions.str_cotangentFrame);
			frag.write("mat3 invTBN = transpose(cotangentFrame(n, n, texCoord));");
			frag.write("vec3 res = normalize(mul(n0, invTBN)) * vec3(0.5, 0.5, 0.5) + vec3(0.5, 0.5, 0.5);");
			frag.write("fragColor[0] = vec4(res, 1.0);");
		} else if(arm_Context.bakeType == 3) {
			frag.n = true;
			frag.write("fragColor[0] = vec4(n * vec3(0.5, 0.5, 0.5) + vec3(0.5, 0.5, 0.5), 1.0);");
			if(arm_Context.bakeUpAxis == 1) {
				frag.write("fragColor[0].rgb = vec3(fragColor[0].r, fragColor[0].b, 1.0 - fragColor[0].g);");
			}
		} else if(arm_Context.bakeType == 4) {
			frag.wposition = true;
			frag.add_uniform("sampler2D texpaint_undo","_texpaint_undo");
			frag.write("vec3 wpos0 = textureLod(texpaint_undo, texCoord, 0.0).rgb * vec3(2.0, 2.0, 2.0) - vec3(1.0, 1.0, 1.0);");
			frag.write("float res = distance(wpos0, wposition) * 10.0;");
			frag.write("fragColor[0] = vec4(res, res, res, 1.0);");
		} else if(arm_Context.bakeType == 5) {
			frag.add_uniform("sampler2D texpaint_undo","_texpaint_undo");
			frag.write("vec2 texDx = dFdx(texCoord);");
			frag.write("vec2 texDy = dFdy(texCoord);");
			frag.write("float h0 = textureLod(texpaint_undo, texCoord, 0.0).r * 100;");
			frag.write("float h1 = textureLod(texpaint_undo, texCoord + texDx, 0.0).r * 100;");
			frag.write("float h2 = textureLod(texpaint_undo, texCoord + texDy, 0.0).r * 100;");
			frag.write("fragColor[0] = vec4((h1 - h0) * 0.5 + 0.5, (h2 - h0) * 0.5 + 0.5, 0.0, 1.0);");
		} else if(arm_Context.bakeType == 6) {
			frag.wposition = true;
			frag.write("fragColor[0] = vec4(wposition * vec3(0.5, 0.5, 0.5) + vec3(0.5, 0.5, 0.5), 1.0);");
			if(arm_Context.bakeUpAxis == 1) {
				frag.write("fragColor[0].rgb = vec3(fragColor[0].r, fragColor[0].b, 1.0 - fragColor[0].g);");
			}
		} else if(arm_Context.bakeType == 7) {
			frag.write("fragColor[0] = vec4(texCoord.xy, 0.0, 1.0);");
		} else if(arm_Context.bakeType == 8) {
			frag.add_uniform("sampler2D texpaint_nor_undo","_texpaint_nor_undo");
			frag.write("float sample_matid = textureLod(texpaint_nor_undo, texCoord, 0.0).a + 1.0 / 255.0;");
			frag.write("float matid_r = fract(sin(dot(vec2(sample_matid, sample_matid * 20.0), vec2(12.9898, 78.233))) * 43758.5453);");
			frag.write("float matid_g = fract(sin(dot(vec2(sample_matid * 20.0, sample_matid), vec2(12.9898, 78.233))) * 43758.5453);");
			frag.write("float matid_b = fract(sin(dot(vec2(sample_matid, sample_matid * 40.0), vec2(12.9898, 78.233))) * 43758.5453);");
			frag.write("fragColor[0] = vec4(matid_r, matid_g, matid_b, 1.0);");
		} else if(arm_Context.bakeType == 9) {
			frag.add_uniform("float objectId","_objectId");
			frag.write("float obid = objectId + 1.0 / 255.0;");
			frag.write("float id_r = fract(sin(dot(vec2(obid, obid * 20.0), vec2(12.9898, 78.233))) * 43758.5453);");
			frag.write("float id_g = fract(sin(dot(vec2(obid * 20.0, obid), vec2(12.9898, 78.233))) * 43758.5453);");
			frag.write("float id_b = fract(sin(dot(vec2(obid, obid * 40.0), vec2(12.9898, 78.233))) * 43758.5453);");
			frag.write("fragColor[0] = vec4(id_r, id_g, id_b, 1.0);");
		} else if(arm_Context.bakeType == 10) {
			if(con.allow_vcols) {
				con.add_elem("col","short4norm");
				frag.write("fragColor[0] = vec4(vcolor.r, vcolor.g, vcolor.b, 1.0);");
			} else {
				frag.write("fragColor[0] = vec4(1.0, 1.0, 1.0, 1.0);");
			}
		}
	}
	static setColorWrites(con_paint) {
		con_paint.data.color_writes_red[1] = false;
		con_paint.data.color_writes_green[1] = false;
		con_paint.data.color_writes_blue[1] = false;
		con_paint.data.color_writes_alpha[1] = false;
		con_paint.data.color_writes_red[2] = false;
		con_paint.data.color_writes_green[2] = false;
		con_paint.data.color_writes_blue[2] = false;
		con_paint.data.color_writes_alpha[2] = false;
	}
	static axisString(i) {
		if(i == 1) {
			return "vec3(1,0,0)";
		} else if(i == 2) {
			return "vec3(0,1,0)";
		} else if(i == 3) {
			return "vec3(0,0,1)";
		} else if(i == 4) {
			return "vec3(-1,0,0)";
		} else if(i == 5) {
			return "vec3(0,-1,0)";
		} else {
			return "vec3(0,0,-1)";
		}
	}
}
$hxClasses["arm.node.MakeBake"] = arm_node_MakeBake;
arm_node_MakeBake.__name__ = "arm.node.MakeBake";
class arm_node_MakeBlur {
	static run(vert,frag) {
		frag.write("vec2 gbufferSizeLocal = gbufferSize;");
		frag.write("vec2 texCoordInp = texelFetch(gbuffer2, ivec2(sp.x * gbufferSizeLocal.x, sp.y * gbufferSizeLocal.y), 0).ba;");
		frag.write("vec3 basecol = vec3(0.0, 0.0, 0.0);");
		frag.write("float roughness = 0.0;");
		frag.write("float metallic = 0.0;");
		frag.write("float occlusion = 0.0;");
		frag.write("vec3 nortan = vec3(0.0, 0.0, 0.0);");
		frag.write("float height = 0.0;");
		frag.write("float mat_opacity = 1.0;");
		frag.write("float opacity = 0.0;");
		if(arm_Context.material.paintEmis) {
			frag.write("float emis = 0.0;");
		}
		if(arm_Context.material.paintSubs) {
			frag.write("float subs = 0.0;");
		}
		frag.add_uniform("vec2 texpaintSize","_texpaintSize");
		frag.write("vec2 texpaintSizeLocal = texpaintSize;");
		frag.write("float blur_step = 1.0 / texpaintSizeLocal.x;");
		if(arm_Context.blurDirectional) {
			frag.write("const float blur_weight[7] = {1.0 / 28.0, 2.0 / 28.0, 3.0 / 28.0, 4.0 / 28.0, 5.0 / 28.0, 6.0 / 28.0, 7.0 / 28.0};");
			frag.add_uniform("vec3 brushDirection","_brushDirection");
			frag.write("vec2 blur_direction = brushDirection.yx;");
			frag.write("for (int i = 0; i < 7; ++i) {");
			frag.write("vec2 texCoordInp2 = texelFetch(gbuffer2, ivec2((sp.x + blur_direction.x * blur_step * float(i)) * gbufferSizeLocal.x, (sp.y + blur_direction.y * blur_step * float(i)) * gbufferSizeLocal.y), 0).ba;");
			frag.write("vec4 texpaint_sample = texture(texpaint_undo, texCoordInp2);");
			frag.write("opacity += texpaint_sample.a * blur_weight[i];");
			frag.write("basecol += texpaint_sample.rgb * blur_weight[i];");
			frag.write("vec4 texpaint_pack_sample = texture(texpaint_pack_undo, texCoordInp2) * blur_weight[i];");
			frag.write("roughness += texpaint_pack_sample.g;");
			frag.write("metallic += texpaint_pack_sample.b;");
			frag.write("occlusion += texpaint_pack_sample.r;");
			frag.write("height += texpaint_pack_sample.a;");
			frag.write("nortan += texture(texpaint_nor_undo, texCoordInp2).rgb * blur_weight[i];");
			frag.write("}");
		} else {
			frag.write("const float blur_weight[15] = {0.034619 / 2.0, 0.044859 / 2.0, 0.055857 / 2.0, 0.066833 / 2.0, 0.076841 / 2.0, 0.084894 / 2.0, 0.090126 / 2.0, 0.09194 / 2.0, 0.090126 / 2.0, 0.084894 / 2.0, 0.076841 / 2.0, 0.066833 / 2.0, 0.055857 / 2.0, 0.044859 / 2.0, 0.034619 / 2.0};");
			frag.write("for (int i = -7; i <= 7; ++i) {");
			frag.write("vec4 texpaint_sample = texture(texpaint_undo, texCoordInp + vec2(blur_step * float(i), 0.0));");
			frag.write("opacity += texpaint_sample.a * blur_weight[i + 7];");
			frag.write("basecol += texpaint_sample.rgb * blur_weight[i + 7];");
			frag.write("vec4 texpaint_pack_sample = texture(texpaint_pack_undo, texCoordInp + vec2(blur_step * float(i), 0.0)) * blur_weight[i + 7];");
			frag.write("roughness += texpaint_pack_sample.g;");
			frag.write("metallic += texpaint_pack_sample.b;");
			frag.write("occlusion += texpaint_pack_sample.r;");
			frag.write("height += texpaint_pack_sample.a;");
			frag.write("nortan += texture(texpaint_nor_undo, texCoordInp + vec2(blur_step * float(i), 0.0)).rgb * blur_weight[i + 7];");
			frag.write("}");
			frag.write("for (int j = -7; j <= 7; ++j) {");
			frag.write("vec4 texpaint_sample = texture(texpaint_undo, texCoordInp + vec2(0.0, blur_step * float(j)));");
			frag.write("opacity += texpaint_sample.a * blur_weight[j + 7];");
			frag.write("basecol += texpaint_sample.rgb * blur_weight[j + 7];");
			frag.write("vec4 texpaint_pack_sample = texture(texpaint_pack_undo, texCoordInp + vec2(0.0, blur_step * float(j))) * blur_weight[j + 7];");
			frag.write("roughness += texpaint_pack_sample.g;");
			frag.write("metallic += texpaint_pack_sample.b;");
			frag.write("occlusion += texpaint_pack_sample.r;");
			frag.write("height += texpaint_pack_sample.a;");
			frag.write("nortan += texture(texpaint_nor_undo, texCoordInp + vec2(0.0, blur_step * float(j))).rgb * blur_weight[j + 7];");
			frag.write("}");
		}
		frag.write("opacity *= brushOpacity;");
	}
}
$hxClasses["arm.node.MakeBlur"] = arm_node_MakeBlur;
arm_node_MakeBlur.__name__ = "arm.node.MakeBlur";
class arm_node_MakeBrush {
	static run(vert,frag) {
		frag.write("float dist = 0.0;");
		if(arm_Context.tool == 7) {
			return;
		}
		let decal = arm_Context.tool == 3 || arm_Context.tool == 4;
		if(decal) {
			frag.write("if (decalMaskLocal.z > 0.0) {");
		}
		if(arm_Config.raw.brush_3d) {
			frag.write("vec4 inpLocal = inp;");
			frag.write("vec4 inplastLocal = inplast;");
			frag.write("float depth = textureLod(gbufferD, inpLocal.xy, 0.0).r;");
			frag.add_uniform("mat4 invVP","_inverseViewProjectionMatrix");
			frag.write("vec4 winp = vec4(vec2(inpLocal.x, 1.0 - inpLocal.y) * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0);");
			frag.write("winp = mul(winp, invVP);");
			frag.write("winp.xyz /= winp.w;");
			frag.wposition = true;
			if(arm_Config.raw.brush_angle_reject || arm_Context.xray) {
				frag.add_function(arm_shader_ShaderFunctions.str_octahedronWrap);
				frag.add_uniform("sampler2D gbuffer0");
				frag.write("vec2 g0 = textureLod(gbuffer0, inpLocal.xy, 0.0).rg;");
				frag.write("vec3 wn;");
				frag.write("wn.z = 1.0 - abs(g0.x) - abs(g0.y);");
				frag.write("wn.xy = wn.z >= 0.0 ? g0.xy : octahedronWrap(g0.xy);");
				frag.write("wn = normalize(wn);");
				frag.write("float planeDist = dot(wn, winp.xyz - wposition);");
				if(arm_Config.raw.brush_angle_reject && !arm_Context.xray) {
					frag.write("if (planeDist < -0.01) discard;");
					frag.n = true;
					frag.write("if (dot(wn, n) < " + arm_Context.brushAngleRejectDot + ") discard;");
				}
			}
			frag.write("float depthlast = textureLod(gbufferD, inplastLocal.xy, 0.0).r;");
			frag.write("vec4 winplast = vec4(vec2(inplastLocal.x, 1.0 - inplastLocal.y) * 2.0 - 1.0, depthlast * 2.0 - 1.0, 1.0);");
			frag.write("winplast = mul(winplast, invVP);");
			frag.write("winplast.xyz /= winplast.w;");
			frag.write("vec3 pa = wposition - winp.xyz;");
			if(arm_Context.xray) {
				frag.write("pa += wn * vec3(planeDist, planeDist, planeDist);");
			}
			frag.write("vec3 ba = winplast.xyz - winp.xyz;");
			if(arm_Context.brushLazyRadius > 0 && arm_Context.brushLazyStep > 0) {
				frag.write("dist = distance(wposition, winp.xyz);");
			} else {
				frag.write("float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);");
				frag.write("dist = length(pa - ba * h);");
			}
		} else {
			frag.write("vec2 binp = inp.xy * 2.0 - 1.0;");
			frag.write("binp.x *= aspectRatio;");
			frag.write("binp = binp * 0.5 + 0.5;");
			frag.write("vec2 binplast = inplast.xy * 2.0 - 1.0;");
			frag.write("binplast.x *= aspectRatio;");
			frag.write("binplast = binplast * 0.5 + 0.5;");
			frag.write("vec2 pa = bsp.xy - binp.xy;");
			frag.write("vec2 ba = binplast.xy - binp.xy;");
			frag.write("float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);");
			frag.write("dist = length(pa - ba * h);");
		}
		frag.write("if (dist > brushRadius) discard;");
		if(decal) {
			frag.write("}");
		}
	}
}
$hxClasses["arm.node.MakeBrush"] = arm_node_MakeBrush;
arm_node_MakeBrush.__name__ = "arm.node.MakeBrush";
class arm_node_MakeClone {
	static run(vert,frag) {
		frag.add_uniform("vec2 cloneDelta","_cloneDelta");
		frag.write("vec2 cloneDeltaLocal = cloneDelta;");
		frag.write("vec2 gbufferSizeLocal = gbufferSize;");
		frag.write("vec2 texCoordInp = texelFetch(gbuffer2, ivec2((sp.xy + cloneDeltaLocal) * gbufferSizeLocal), 0).ba;");
		frag.write("vec3 texpaint_pack_sample = textureLod(texpaint_pack_undo, texCoordInp, 0.0).rgb;");
		frag.write("vec3 basecol = " + "textureLod(texpaint_undo, texCoordInp, 0.0).rgb" + ";");
		frag.write("float roughness = " + "texpaint_pack_sample.g" + ";");
		frag.write("float metallic = " + "texpaint_pack_sample.b" + ";");
		frag.write("float occlusion = " + "texpaint_pack_sample.r" + ";");
		frag.write("vec3 nortan = " + "textureLod(texpaint_nor_undo, texCoordInp, 0.0).rgb" + ";");
		frag.write("float height = " + "0.0" + ";");
		frag.write("float mat_opacity = " + "1.0" + ";");
		frag.write("float opacity = mat_opacity * brushOpacity;");
		if(arm_Context.material.paintEmis) {
			frag.write("float emis = 0.0;");
		}
		if(arm_Context.material.paintSubs) {
			frag.write("float subs = 0.0;");
		}
	}
}
$hxClasses["arm.node.MakeClone"] = arm_node_MakeClone;
arm_node_MakeClone.__name__ = "arm.node.MakeClone";
class arm_node_MakeColorIdPicker {
	static run(vert,frag) {
		vert.write("gl_Position = vec4(-1.0 + float((gl_VertexID & 1) << 2), -1.0 + float((gl_VertexID & 2) << 1), 0.0, 1.0);");
		frag.add_uniform("sampler2D gbuffer2");
		frag.add_uniform("vec2 gbufferSize","_gbufferSize");
		frag.add_uniform("vec4 inp","_inputBrush");
		frag.write("vec4 inpLocal = inp;");
		frag.write("vec2 gbufferSizeLocal = gbufferSize;");
		frag.write("vec2 texCoordInp = texelFetch(gbuffer2, ivec2(inpLocal.x * gbufferSizeLocal.x, inpLocal.y * gbufferSizeLocal.y), 0).ba;");
		if(arm_Context.tool == 8) {
			frag.add_out("vec4 fragColor");
			frag.add_uniform("sampler2D texcolorid","_texcolorid");
			frag.write("vec3 idcol = textureLod(texcolorid, texCoordInp, 0.0).rgb;");
			frag.write("fragColor = vec4(idcol, 1.0);");
		} else if(arm_Context.tool == 9) {
			if(arm_Context.pickPosNorTex) {
				frag.add_out("vec4 fragColor[2]");
				frag.add_uniform("sampler2D gbufferD");
				frag.add_uniform("mat4 invVP","_inverseViewProjectionMatrix");
				frag.add_function(arm_shader_ShaderFunctions.str_get_pos_from_depth);
				frag.add_function(arm_shader_ShaderFunctions.str_get_nor_from_depth);
				frag.write("fragColor[0] = vec4(get_pos_from_depth(vec2(inpLocal.x, 1.0 - inpLocal.y), invVP, texturePass(gbufferD)), texCoordInp.x);");
				frag.write("fragColor[1] = vec4(get_nor_from_depth(fragColor[0].rgb, vec2(inpLocal.x, 1.0 - inpLocal.y), invVP, vec2(1.0, 1.0) / gbufferSize, texturePass(gbufferD)), texCoordInp.y);");
			} else {
				frag.add_out("vec4 fragColor[4]");
				frag.add_uniform("sampler2D texpaint");
				frag.add_uniform("sampler2D texpaint_nor");
				frag.add_uniform("sampler2D texpaint_pack");
				frag.write("fragColor[0] = textureLod(texpaint, texCoordInp, 0.0);");
				frag.write("fragColor[1] = textureLod(texpaint_nor, texCoordInp, 0.0);");
				frag.write("fragColor[2] = textureLod(texpaint_pack, texCoordInp, 0.0);");
				frag.write("fragColor[3].rg = texCoordInp.xy;");
			}
		}
	}
}
$hxClasses["arm.node.MakeColorIdPicker"] = arm_node_MakeColorIdPicker;
arm_node_MakeColorIdPicker.__name__ = "arm.node.MakeColorIdPicker";
class arm_node_MakeDiscard {
	static colorId(vert,frag) {
		frag.add_uniform("sampler2D texpaint_colorid");
		frag.add_uniform("sampler2D texcolorid","_texcolorid");
		frag.write("vec3 colorid_c1 = texelFetch(texpaint_colorid, ivec2(0, 0), 0).rgb;");
		frag.write("vec3 colorid_c2 = textureLod(texcolorid, texCoordPick, 0).rgb;");
		frag.write("if (any(colorid_c1 != colorid_c2)) discard;");
	}
	static face(vert,frag) {
		frag.add_uniform("sampler2D gbuffer2");
		frag.add_uniform("sampler2D textrianglemap","_textrianglemap");
		frag.add_uniform("vec2 textrianglemapSize","_texpaintSize");
		frag.add_uniform("vec2 gbufferSize","_gbufferSize");
		frag.write("vec2 texCoordInp = texelFetch(gbuffer2, ivec2(inp.x * gbufferSize.x, inp.y * gbufferSize.y), 0).ba;");
		frag.write("vec4 face_c1 = texelFetch(textrianglemap, ivec2(texCoordInp * textrianglemapSize), 0);");
		frag.write("vec4 face_c2 = textureLod(textrianglemap, texCoordPick, 0);");
		frag.write("if (any(face_c1 != face_c2)) discard;");
	}
	static uvIsland(vert,frag) {
		frag.add_uniform("sampler2D texuvislandmap","_texuvislandmap");
		frag.write("if (textureLod(texuvislandmap, texCoordPick, 0).r == 0.0) discard;");
	}
	static materialId(vert,frag) {
		frag.wvpposition = true;
		frag.write("vec2 picker_sample_tc = vec2(wvpposition.x / wvpposition.w, wvpposition.y / wvpposition.w) * 0.5 + 0.5;");
		frag.write("picker_sample_tc.y = 1.0 - picker_sample_tc.y;");
		frag.add_uniform("sampler2D texpaint_nor_undo","_texpaint_nor_undo");
		frag.write("if (" + arm_Context.materialIdPicked / 255 + " != textureLod(texpaint_nor_undo, picker_sample_tc, 0.0).a) discard;");
	}
}
$hxClasses["arm.node.MakeDiscard"] = arm_node_MakeDiscard;
arm_node_MakeDiscard.__name__ = "arm.node.MakeDiscard";
class arm_node_MakeMesh {
	static run(data,layerPass) {
		if(layerPass == null) {
			layerPass = 0;
		}
		let con_mesh = data.add_context({ name : layerPass == 0 ? "mesh" : "mesh" + layerPass, depth_write : layerPass == 0, compare_mode : layerPass == 0 ? "less" : "equal", cull_mode : arm_Context.cullBackfaces || layerPass > 0 ? "clockwise" : "none", vertex_elements : [{ name : "pos", data : "short4norm"},{ name : "nor", data : "short2norm"},{ name : "tex", data : "short2norm"}], color_attachments : ["RGBA64","RGBA64","RGBA64"], depth_attachment : "DEPTH32"});
		let vert = con_mesh.make_vert();
		let frag = con_mesh.make_frag();
		frag.ins = vert.outs;
		vert.add_out("vec2 texCoord");
		frag.wvpposition = true;
		vert.add_out("vec4 prevwvpposition");
		vert.add_uniform("mat4 VP","_viewProjectionMatrix");
		vert.add_uniform("mat4 prevWVP","_prevWorldViewProjectionMatrix");
		vert.wposition = true;
		let textureCount = 0;
		let displaceStrength = arm_Config.raw.displace_strength * 0.02 * arm_Context.mainObject().transform.scale.x;
		if(arm_node_MakeMaterial.heightUsed && displaceStrength > 0.0) {
			vert.n = true;
			vert.write("float height = 0.0;");
			let numLayers = 0;
			let _g = 0;
			let _g1 = arm_Project.layers;
			while(_g < _g1.length) {
				let l = _g1[_g];
				++_g;
				if(!l.isVisible() || !l.paintHeight || !l.isLayer()) {
					continue;
				}
				if(numLayers > 16) {
					break;
				}
				++numLayers;
				++textureCount;
				vert.add_uniform("sampler2D texpaint_pack_vert" + l.id,"_texpaint_pack_vert" + l.id);
				vert.write("height += textureLod(texpaint_pack_vert" + l.id + ", tex, 0.0).a;");
				let masks = l.getMasks();
				if(masks != null) {
					let _g = 0;
					while(_g < masks.length) {
						let m = masks[_g];
						++_g;
						if(!m.isVisible()) {
							continue;
						}
						++textureCount;
						vert.add_uniform("sampler2D texpaint_vert" + m.id,"_texpaint_vert" + m.id);
						vert.write("height *= textureLod(texpaint_vert" + m.id + ", tex, 0.0).r;");
					}
				}
			}
			vert.write("wposition += wnormal * vec3(height, height, height) * vec3(" + displaceStrength + ", " + displaceStrength + ", " + displaceStrength + ");");
		}
		vert.write("gl_Position = mul(vec4(wposition.xyz, 1.0), VP);");
		vert.write("texCoord = tex;");
		if(arm_node_MakeMaterial.heightUsed && displaceStrength > 0) {
			vert.add_uniform("mat4 invW","_inverseWorldMatrix");
			vert.write("prevwvpposition = mul(mul(vec4(wposition, 1.0), invW), prevWVP);");
		} else {
			vert.write("prevwvpposition = mul(vec4(pos.xyz, 1.0), prevWVP);");
		}
		frag.add_out("vec4 fragColor[3]");
		frag.n = true;
		frag.add_function(arm_shader_ShaderFunctions.str_packFloatInt16);
		if(arm_Context.tool == 8) {
			frag.add_uniform("sampler2D texcolorid","_texcolorid");
			frag.write("fragColor[0] = vec4(n.xy, 1.0, packFloatInt16(0.0, uint(0)));");
			frag.write("vec3 idcol = pow(textureLod(texcolorid, texCoord, 0.0).rgb, vec3(2.2, 2.2, 2.2));");
			frag.write("fragColor[1] = vec4(idcol.rgb, 1.0);");
		} else {
			frag.add_function(arm_shader_ShaderFunctions.str_octahedronWrap);
			frag.add_function(arm_shader_ShaderFunctions.str_cotangentFrame);
			if(layerPass > 0) {
				frag.add_uniform("sampler2D gbuffer0");
				frag.add_uniform("sampler2D gbuffer1");
				frag.add_uniform("sampler2D gbuffer2");
				frag.write("vec2 fragcoord = (wvpposition.xy / wvpposition.w) * 0.5 + 0.5;");
				frag.write("fragcoord.y = 1.0 - fragcoord.y;");
				frag.write("vec4 gbuffer0_sample = textureLod(gbuffer0, fragcoord, 0.0);");
				frag.write("vec4 gbuffer1_sample = textureLod(gbuffer1, fragcoord, 0.0);");
				frag.write("vec4 gbuffer2_sample = textureLod(gbuffer2, fragcoord, 0.0);");
				frag.write("vec3 basecol = gbuffer0_sample.rgb;");
				frag.write("float roughness = gbuffer2_sample.g;");
				frag.write("float metallic = gbuffer2_sample.b;");
				frag.write("float occlusion = gbuffer2_sample.r;");
				frag.write("float opacity = 1.0;//gbuffer0_sample.a;");
				frag.write("float matid = gbuffer1_sample.a;");
				frag.write("vec3 ntex = gbuffer1_sample.rgb;");
				frag.write("float height = gbuffer2_sample.a;");
			} else {
				frag.write("vec3 basecol = vec3(0.0, 0.0, 0.0);");
				frag.write("float roughness = 0.0;");
				frag.write("float metallic = 0.0;");
				frag.write("float occlusion = 1.0;");
				frag.write("float opacity = 1.0;");
				frag.write("float matid = 0.0;");
				frag.write("vec3 ntex = vec3(0.5, 0.5, 1.0);");
				frag.write("float height = 0.0;");
			}
			frag.write("vec4 texpaint_sample = vec4(0.0, 0.0, 0.0, 1.0);");
			frag.write("vec4 texpaint_nor_sample;");
			frag.write("vec4 texpaint_pack_sample;");
			frag.write("float texpaint_opac;");
			if(arm_node_MakeMaterial.heightUsed) {
				frag.write("float height0 = 0.0;");
				frag.write("float height1 = 0.0;");
				frag.write("float height2 = 0.0;");
				frag.write("float height3 = 0.0;");
			}
			if(arm_Context.drawWireframe) {
				++textureCount;
				frag.add_uniform("sampler2D texuvmap","_texuvmap");
			}
			if(arm_Context.viewportMode == 12 && arm_Context.layer.getMasks() != null) {
				let _g = 0;
				let _g1 = arm_Context.layer.getMasks();
				while(_g < _g1.length) {
					let m = _g1[_g];
					++_g;
					if(!m.isVisible()) {
						continue;
					}
					++textureCount;
					frag.add_uniform("sampler2D texpaint_view_mask" + m.id,"_texpaint" + arm_Project.layers.indexOf(m));
				}
			}
			if(arm_Context.viewportMode == 0 && arm_Context.renderMode == 1) {
				textureCount += 4;
				frag.add_uniform("sampler2D senvmapBrdf","$brdf.k");
				frag.add_uniform("sampler2D senvmapRadiance","_envmapRadiance");
				frag.add_uniform("sampler2D sltcMat","_ltcMat");
				frag.add_uniform("sampler2D sltcMag","_ltcMag");
			}
			arm_node_MakeMesh.layerPassCount = 1;
			let layers = [];
			let startCount = textureCount;
			let isMaterialSpace = arm_ui_UIHeader.inst.worktab.position == 1;
			let _g = 0;
			let _g1 = arm_Project.layers;
			while(_g < _g1.length) {
				let l = _g1[_g];
				++_g;
				if(isMaterialSpace && l != arm_Context.layer) {
					continue;
				}
				if(!l.isLayer() || !l.isVisible()) {
					continue;
				}
				let count = 3;
				let masks = l.getMasks();
				if(masks != null) {
					count = 3 + masks.length;
				}
				textureCount += count;
				if(textureCount >= 62) {
					textureCount = startCount + count + 3;
					arm_node_MakeMesh.layerPassCount++;
				}
				if(layerPass == arm_node_MakeMesh.layerPassCount - 1) {
					layers.push(l);
				}
			}
			let lastPass = layerPass == arm_node_MakeMesh.layerPassCount - 1;
			let _g2 = 0;
			while(_g2 < layers.length) {
				let l = layers[_g2];
				++_g2;
				if(l.getObjectMask() > 0) {
					frag.add_uniform("int uid","_uid");
					if(l.getObjectMask() > arm_Project.paintObjects.length) {
						let visibles = arm_Project.getAtlasObjects(l.getObjectMask());
						frag.write("if (");
						let _g = 0;
						let _g1 = visibles.length;
						while(_g < _g1) {
							let i = _g++;
							if(i > 0) {
								frag.write(" || ");
							}
							frag.write("" + visibles[i].uid + " == uid");
						}
						frag.write(") {");
					} else {
						frag.write("if (" + arm_Project.paintObjects[l.getObjectMask() - 1].uid + " == uid) {");
					}
				}
				frag.add_shared_sampler("sampler2D texpaint" + l.id);
				frag.write("texpaint_sample = textureLodShared(texpaint" + l.id + ", texCoord, 0.0);");
				frag.write("texpaint_opac = texpaint_sample.a;");
				let masks = l.getMasks();
				if(masks != null) {
					let hasVisible = false;
					let _g = 0;
					while(_g < masks.length) if(masks[_g++].isVisible()) {
						hasVisible = true;
						break;
					}
					if(hasVisible) {
						let texpaint_mask = "texpaint_mask" + l.id;
						frag.write("float " + texpaint_mask + " = 0.0;");
						let _g = 0;
						while(_g < masks.length) {
							let m = masks[_g];
							++_g;
							if(!m.isVisible()) {
								continue;
							}
							frag.add_shared_sampler("sampler2D texpaint" + m.id);
							frag.write("{");
							frag.write("float texpaint_mask_sample" + m.id + " = textureLodShared(texpaint" + m.id + ", texCoord, 0.0).r;");
							frag.write("" + texpaint_mask + " = " + arm_node_MakeMaterial.blendModeMask(frag,m.blending,"" + texpaint_mask,"texpaint_mask_sample" + m.id,"float(" + m.getOpacity() + ")") + ";");
							frag.write("}");
						}
						frag.write("texpaint_opac *= clamp(" + texpaint_mask + ", 0.0, 1.0);");
					}
				}
				if(l.getOpacity() < 1) {
					frag.write("texpaint_opac *= " + l.getOpacity() + ";");
				}
				if(l.paintBase) {
					if(l == arm_Project.layers[0]) {
						frag.write("basecol = texpaint_sample.rgb * texpaint_opac;");
					} else {
						frag.write("basecol = " + arm_node_MakeMaterial.blendMode(frag,l.blending,"basecol","texpaint_sample.rgb","texpaint_opac") + ";");
					}
				}
				if(l.paintNor || arm_node_MakeMaterial.emisUsed) {
					frag.add_shared_sampler("sampler2D texpaint_nor" + l.id);
					frag.write("texpaint_nor_sample = textureLodShared(texpaint_nor" + l.id + ", texCoord, 0.0);");
					if(arm_node_MakeMaterial.emisUsed) {
						frag.write("if (texpaint_opac > 0.0) matid = texpaint_nor_sample.a;");
					}
					if(l.paintNor) {
						if(l.paintNorBlend) {
							frag.write("{");
							frag.write("vec3 n1 = ntex * vec3(2.0, 2.0, 2.0) - vec3(1.0, 1.0, 1.0);");
							frag.write("vec3 n2 = mix(vec3(0.5, 0.5, 1.0), texpaint_nor_sample.rgb, texpaint_opac) * vec3(2.0, 2.0, 2.0) - vec3(1.0, 1.0, 1.0);");
							frag.write("ntex = normalize(vec3(n1.xy + n2.xy, n1.z * n2.z)) * vec3(0.5, 0.5, 0.5) + vec3(0.5, 0.5, 0.5);");
							frag.write("}");
						} else {
							frag.write("ntex = mix(ntex, texpaint_nor_sample.rgb, texpaint_opac);");
						}
					}
				}
				if(l.paintOcc || l.paintRough || l.paintMet || l.paintHeight && arm_node_MakeMaterial.heightUsed) {
					frag.add_shared_sampler("sampler2D texpaint_pack" + l.id);
					frag.write("texpaint_pack_sample = textureLodShared(texpaint_pack" + l.id + ", texCoord, 0.0);");
					if(l.paintOcc) {
						frag.write("occlusion = mix(occlusion, texpaint_pack_sample.r, texpaint_opac);");
					}
					if(l.paintRough) {
						frag.write("roughness = mix(roughness, texpaint_pack_sample.g, texpaint_opac);");
					}
					if(l.paintMet) {
						frag.write("metallic = mix(metallic, texpaint_pack_sample.b, texpaint_opac);");
					}
					if(l.paintHeight && arm_node_MakeMaterial.heightUsed) {
						let assign = l.paintHeightBlend ? "+=" : "=";
						frag.write("height " + assign + " texpaint_pack_sample.a * texpaint_opac;");
						frag.write("{");
						frag.add_uniform("vec2 texpaintSize","_texpaintSize");
						frag.write("float tex_step = 1.0 / texpaintSize.x;");
						frag.write("height0 " + assign + " textureLodShared(texpaint_pack" + l.id + ", vec2(texCoord.x - tex_step, texCoord.y), 0.0).a * texpaint_opac;");
						frag.write("height1 " + assign + " textureLodShared(texpaint_pack" + l.id + ", vec2(texCoord.x + tex_step, texCoord.y), 0.0).a * texpaint_opac;");
						frag.write("height2 " + assign + " textureLodShared(texpaint_pack" + l.id + ", vec2(texCoord.x, texCoord.y - tex_step), 0.0).a * texpaint_opac;");
						frag.write("height3 " + assign + " textureLodShared(texpaint_pack" + l.id + ", vec2(texCoord.x, texCoord.y + tex_step), 0.0).a * texpaint_opac;");
						frag.write("}");
					}
				}
				if(l.getObjectMask() > 0) {
					frag.write("}");
				}
			}
			if(lastPass && arm_Context.drawTexels) {
				frag.add_uniform("vec2 texpaintSize","_texpaintSize");
				frag.write("vec2 texel0 = texCoord * texpaintSize * 0.01;");
				frag.write("vec2 texel1 = texCoord * texpaintSize * 0.1;");
				frag.write("vec2 texel2 = texCoord * texpaintSize;");
				frag.write("basecol *= max(float(mod(int(texel0.x), 2.0) == mod(int(texel0.y), 2.0)), 0.9);");
				frag.write("basecol *= max(float(mod(int(texel1.x), 2.0) == mod(int(texel1.y), 2.0)), 0.9);");
				frag.write("basecol *= max(float(mod(int(texel2.x), 2.0) == mod(int(texel2.y), 2.0)), 0.9);");
			}
			if(lastPass && arm_Context.drawWireframe) {
				frag.write("basecol *= 1.0 - textureLod(texuvmap, texCoord, 0.0).r;");
			}
			if(arm_node_MakeMaterial.heightUsed) {
				frag.write("if (height > 0.0) {");
				frag.write("float height_dx = height0 - height1;");
				frag.write("float height_dy = height2 - height3;");
				frag.write("vec3 n1 = ntex * vec3(2.0, 2.0, 2.0) - vec3(1.0, 1.0, 1.0);");
				frag.write("vec3 n2 = normalize(vec3(height_dx * 16.0, height_dy * 16.0, 1.0));");
				frag.write("ntex = normalize(vec3(n1.xy + n2.xy, n1.z * n2.z)) * vec3(0.5, 0.5, 0.5) + vec3(0.5, 0.5, 0.5);");
				frag.write("}");
			}
			if(!lastPass) {
				frag.write("fragColor[0] = vec4(basecol, opacity);");
				frag.write("fragColor[1] = vec4(ntex, matid);");
				frag.write("fragColor[2] = vec4(occlusion, roughness, metallic, height);");
				arm_shader_MaterialParser.finalize(con_mesh);
				con_mesh.data.shader_from_source = true;
				con_mesh.data.vertex_shader = vert.get();
				con_mesh.data.fragment_shader = frag.get();
				return con_mesh;
			}
			frag.vVec = true;
			frag.write("mat3 TBN = cotangentFrame(n, vVec, texCoord);");
			frag.write("n = ntex * 2.0 - 1.0;");
			frag.write("n.y = -n.y;");
			frag.write("n = normalize(mul(n, TBN));");
			if(arm_Context.viewportMode == 0 || arm_Context.viewportMode == 13) {
				frag.write("basecol = pow(basecol, vec3(2.2, 2.2, 2.2));");
				if(arm_Context.viewportShader != null) {
					frag.write("fragColor[1] = vec4(" + arm_Context.viewportShader(frag) + ", 1.0);");
				} else if(arm_Context.renderMode == 1) {
					frag.wposition = true;
					frag.write("vec3 albedo = mix(basecol, vec3(0.0, 0.0, 0.0), metallic);");
					frag.write("vec3 f0 = mix(vec3(0.04, 0.04, 0.04), basecol, metallic);");
					frag.vVec = true;
					frag.write("float dotNV = max(dot(n, vVec), 0.0);");
					frag.write("vec2 envBRDF = texture(senvmapBrdf, vec2(roughness, 1.0 - dotNV)).xy;");
					frag.add_uniform("int envmapNumMipmaps","_envmapNumMipmaps");
					frag.add_uniform("vec4 envmapData","_envmapData");
					frag.write("vec3 wreflect = reflect(-vVec, n);");
					frag.write("float envlod = roughness * float(envmapNumMipmaps);");
					frag.add_function(arm_shader_ShaderFunctions.str_envMapEquirect);
					frag.write("vec4 envmapDataLocal = envmapData;");
					frag.write("vec3 prefilteredColor = textureLod(senvmapRadiance, envMapEquirect(wreflect, envmapDataLocal.x), envlod).rgb;");
					frag.add_uniform("vec3 lightArea0","_lightArea0");
					frag.add_uniform("vec3 lightArea1","_lightArea1");
					frag.add_uniform("vec3 lightArea2","_lightArea2");
					frag.add_uniform("vec3 lightArea3","_lightArea3");
					frag.add_function(arm_shader_ShaderFunctions.str_ltcEvaluate);
					frag.add_uniform("vec3 lightPos","_pointPosition");
					frag.add_uniform("vec3 lightColor","_pointColor");
					frag.write("float ldist = distance(wposition, lightPos);");
					frag.write("const float LUT_SIZE = 64.0;");
					frag.write("const float LUT_SCALE = (LUT_SIZE - 1.0) / LUT_SIZE;");
					frag.write("const float LUT_BIAS = 0.5 / LUT_SIZE;");
					frag.write("float theta = acos(dotNV);");
					frag.write("vec2 tuv = vec2(roughness, theta / (0.5 * 3.14159265));");
					frag.write("tuv = tuv * LUT_SCALE + LUT_BIAS;");
					frag.write("vec4 t = textureLod(sltcMat, tuv, 0.0);");
					frag.write("mat3 minv = mat3(vec3(1.0, 0.0, t.y), vec3(0.0, t.z, 0.0), vec3(t.w, 0.0, t.x));");
					frag.write("float ltcspec = ltcEvaluate(n, vVec, dotNV, wposition, minv, lightArea0, lightArea1, lightArea2, lightArea3);");
					frag.write("ltcspec *= textureLod(sltcMag, tuv, 0.0).a;");
					frag.write("mat3 mident = mat3(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);");
					frag.write("float ltcdiff = ltcEvaluate(n, vVec, dotNV, wposition, mident, lightArea0, lightArea1, lightArea2, lightArea3);");
					frag.write("vec3 direct = albedo * ltcdiff + ltcspec * 0.05;");
					frag.write("direct *= lightColor * (1.0 / (ldist * ldist));");
					frag.add_uniform("vec4 shirr[7]","_envmapIrradiance");
					frag.add_function(arm_shader_ShaderFunctions.str_shIrradiance);
					frag.write("vec3 indirect = albedo * (shIrradiance(vec3(n.x * envmapDataLocal.z - n.y * envmapDataLocal.y, n.x * envmapDataLocal.y + n.y * envmapDataLocal.z, n.z), shirr) / 3.14159265);");
					frag.write("indirect += prefilteredColor * (f0 * envBRDF.x + envBRDF.y) * 1.5;");
					frag.write("indirect *= envmapDataLocal.w * occlusion;");
					frag.write("fragColor[1] = vec4(direct + indirect, 1.0);");
				} else {
					if(arm_node_MakeMaterial.emisUsed) {
						frag.write("if (int(matid * 255.0) % 3 == 1) basecol *= 10.0;");
					}
					frag.write("fragColor[1] = vec4(basecol, occlusion);");
				}
			} else if(arm_Context.viewportMode == 1 && arm_Context.layer.paintBase) {
				frag.write("fragColor[1] = vec4(basecol, 1.0);");
			} else if(arm_Context.viewportMode == 2 && arm_Context.layer.paintNor) {
				frag.write("fragColor[1] = vec4(ntex.rgb, 1.0);");
			} else if(arm_Context.viewportMode == 3 && arm_Context.layer.paintOcc) {
				frag.write("fragColor[1] = vec4(vec3(occlusion, occlusion, occlusion), 1.0);");
			} else if(arm_Context.viewportMode == 4 && arm_Context.layer.paintRough) {
				frag.write("fragColor[1] = vec4(vec3(roughness, roughness, roughness), 1.0);");
			} else if(arm_Context.viewportMode == 5 && arm_Context.layer.paintMet) {
				frag.write("fragColor[1] = vec4(vec3(metallic, metallic, metallic), 1.0);");
			} else if(arm_Context.viewportMode == 6 && arm_Context.layer.paintOpac) {
				frag.write("fragColor[1] = vec4(vec3(texpaint_sample.a, texpaint_sample.a, texpaint_sample.a), 1.0);");
			} else if(arm_Context.viewportMode == 7 && arm_Context.layer.paintHeight) {
				frag.write("fragColor[1] = vec4(vec3(height, height, height), 1.0);");
			} else if(arm_Context.viewportMode == 8) {
				frag.write("fragColor[1] = vec4(texCoord, 0.0, 1.0);");
			} else if(arm_Context.viewportMode == 9) {
				frag.nAttr = true;
				frag.write("fragColor[1] = vec4(nAttr, 1.0);");
			} else if(arm_Context.viewportMode == 10) {
				frag.add_shared_sampler("sampler2D texpaint_nor" + arm_Context.layer.id);
				frag.add_uniform("vec2 texpaintSize","_texpaintSize");
				frag.write("float sample_matid = texelFetch(texpaint_nor" + arm_Context.layer.id + ", ivec2(texCoord * texpaintSize), 0).a + 1.0 / 255.0;");
				frag.write("float matid_r = fract(sin(dot(vec2(sample_matid, sample_matid * 20.0), vec2(12.9898, 78.233))) * 43758.5453);");
				frag.write("float matid_g = fract(sin(dot(vec2(sample_matid * 20.0, sample_matid), vec2(12.9898, 78.233))) * 43758.5453);");
				frag.write("float matid_b = fract(sin(dot(vec2(sample_matid, sample_matid * 40.0), vec2(12.9898, 78.233))) * 43758.5453);");
				frag.write("fragColor[1] = vec4(matid_r, matid_g, matid_b, 1.0);");
			} else if(arm_Context.viewportMode == 11) {
				frag.add_uniform("float objectId","_objectId");
				frag.write("float obid = objectId + 1.0 / 255.0;");
				frag.write("float id_r = fract(sin(dot(vec2(obid, obid * 20.0), vec2(12.9898, 78.233))) * 43758.5453);");
				frag.write("float id_g = fract(sin(dot(vec2(obid * 20.0, obid), vec2(12.9898, 78.233))) * 43758.5453);");
				frag.write("float id_b = fract(sin(dot(vec2(obid, obid * 40.0), vec2(12.9898, 78.233))) * 43758.5453);");
				frag.write("fragColor[1] = vec4(id_r, id_g, id_b, 1.0);");
			} else if(arm_Context.viewportMode == 12 && (arm_Context.layer.getMasks() != null || arm_Context.layer.isMask())) {
				if(arm_Context.layer.isMask()) {
					frag.write("float mask_view = textureLodShared(texpaint" + arm_Context.layer.id + ", texCoord, 0.0).r;");
				} else {
					frag.write("float mask_view = 0.0;");
					let _g = 0;
					let _g1 = arm_Context.layer.getMasks();
					while(_g < _g1.length) {
						let m = _g1[_g];
						++_g;
						if(!m.isVisible()) {
							continue;
						}
						frag.write("float mask_sample" + m.id + " = textureLodShared(texpaint_view_mask" + m.id + ", texCoord, 0.0).r;");
						frag.write("mask_view = " + arm_node_MakeMaterial.blendModeMask(frag,m.blending,"mask_view","mask_sample" + m.id,"float(" + m.getOpacity() + ")") + ";");
					}
				}
				frag.write("fragColor[1] = vec4(mask_view, mask_view, mask_view, 1.0);");
			} else {
				frag.write("fragColor[1] = vec4(1.0, 0.0, 1.0, 1.0);");
			}
			frag.write("n /= (abs(n.x) + abs(n.y) + abs(n.z));");
			frag.write("n.xy = n.z >= 0.0 ? n.xy : octahedronWrap(n.xy);");
			frag.write("fragColor[0] = vec4(n.xy, roughness, packFloatInt16(metallic, uint(int(matid * 255.0) % 3)));");
		}
		frag.write("vec2 posa = (wvpposition.xy / wvpposition.w) * 0.5 + 0.5;");
		frag.write("vec2 posb = (prevwvpposition.xy / prevwvpposition.w) * 0.5 + 0.5;");
		frag.write("fragColor[2] = vec4(posa - posb, texCoord.xy);");
		arm_shader_MaterialParser.finalize(con_mesh);
		con_mesh.data.shader_from_source = true;
		con_mesh.data.vertex_shader = vert.get();
		con_mesh.data.fragment_shader = frag.get();
		return con_mesh;
	}
}
$hxClasses["arm.node.MakeMesh"] = arm_node_MakeMesh;
arm_node_MakeMesh.__name__ = "arm.node.MakeMesh";
class arm_node_MakeMeshPreview {
	static run(data,matcon) {
		let con_mesh = data.add_context({ name : "mesh", depth_write : true, compare_mode : "less", cull_mode : "clockwise", vertex_elements : [{ name : "pos", data : "short4norm"},{ name : "nor", data : "short2norm"},{ name : "tex", data : "short2norm"}], color_attachments : ["RGBA64","RGBA64","RGBA64"], depth_attachment : "DEPTH32"});
		let vert = con_mesh.make_vert();
		let frag = con_mesh.make_frag();
		frag.ins = vert.outs;
		vert.add_uniform("mat4 WVP","_worldViewProjectionMatrix");
		vert.write_attrib("gl_Position = mul(vec4(" + "pos" + ".xyz, 1.0), WVP);");
		let brushScale = arm_Context.brushScale * arm_Context.brushNodesScale + "";
		vert.add_out("vec2 texCoord");
		vert.write_attrib("texCoord = tex * float(" + brushScale + ");");
		let decal = arm_Context.decalPreview;
		arm_shader_MaterialParser.sample_keep_aspect = decal;
		arm_shader_MaterialParser.sample_uv_scale = brushScale;
		arm_shader_MaterialParser.parse_height = arm_node_MakeMaterial.heightUsed;
		arm_shader_MaterialParser.parse_height_as_channel = true;
		let sout = arm_shader_MaterialParser.parse(arm_ui_UINodes.inst.getCanvasMaterial(),con_mesh,vert,frag,matcon);
		arm_shader_MaterialParser.parse_height = false;
		arm_shader_MaterialParser.parse_height_as_channel = false;
		arm_shader_MaterialParser.sample_keep_aspect = false;
		let rough = sout.out_roughness;
		let met = sout.out_metallic;
		let occ = sout.out_occlusion;
		let opac = sout.out_opacity;
		let height = sout.out_height;
		let nortan = arm_shader_MaterialParser.out_normaltan;
		frag.write("vec3 basecol = pow(" + sout.out_basecol + ", vec3(2.2, 2.2, 2.2));");
		frag.write("float roughness = " + rough + ";");
		frag.write("float metallic = " + met + ";");
		frag.write("float occlusion = " + occ + ";");
		frag.write("float opacity = " + opac + ";");
		frag.write("vec3 nortan = " + nortan + ";");
		frag.write("float height = " + height + ";");
		if(decal) {
			if(arm_Context.tool == 4) {
				frag.add_uniform("sampler2D textexttool","_textexttool");
				frag.write("opacity *= textureLod(textexttool, texCoord / float(" + brushScale + "), 0.0).r;");
			}
		}
		if(decal) {
			frag.write("if (opacity < " + arm_node_MakeMeshPreview.opacityDiscardDecal + ") discard;");
		}
		frag.add_out("vec4 fragColor[3]");
		frag.n = true;
		frag.add_function(arm_shader_ShaderFunctions.str_packFloatInt16);
		frag.add_function(arm_shader_ShaderFunctions.str_cotangentFrame);
		frag.add_function(arm_shader_ShaderFunctions.str_octahedronWrap);
		if(arm_node_MakeMaterial.heightUsed) {
			frag.write("if (height > 0.0) {");
			frag.write("float height_dx = dFdx(height * 2.0);");
			frag.write("float height_dy = dFdy(height * 2.0);");
			frag.write("vec3 n1 = nortan * vec3(2.0, 2.0, 2.0) - vec3(1.0, 1.0, 1.0);");
			frag.write("vec3 n2 = normalize(vec3(height_dx * 16.0, height_dy * 16.0, 1.0));");
			frag.write("nortan = normalize(vec3(n1.xy + n2.xy, n1.z * n2.z)) * vec3(0.5, 0.5, 0.5) + vec3(0.5, 0.5, 0.5);");
			frag.write("}");
		}
		if(!decal) {
			frag.vVec = true;
			frag.write("mat3 TBN = cotangentFrame(n, vVec, texCoord);");
			frag.write("n = nortan * 2.0 - 1.0;");
			frag.write("n.y = -n.y;");
			frag.write("n = normalize(mul(n, TBN));");
		}
		frag.write("n /= (abs(n.x) + abs(n.y) + abs(n.z));");
		frag.write("n.xy = n.z >= 0.0 ? n.xy : octahedronWrap(n.xy);");
		if(decal) {
			frag.write("fragColor[0] = vec4(n.x, n.y, roughness, packFloatInt16(metallic, uint(0)));");
			frag.write("fragColor[1] = vec4(basecol, occlusion);");
		} else {
			frag.write("fragColor[0] = vec4(n.x, n.y, mix(1.0, roughness, opacity), packFloatInt16(mix(1.0, metallic, opacity), uint(0)));");
			frag.write("fragColor[1] = vec4(mix(vec3(0.0, 0.0, 0.0), basecol, opacity), occlusion);");
		}
		frag.write("fragColor[2] = vec4(0.0, 0.0, 0.0, 0.0);");
		arm_shader_MaterialParser.finalize(con_mesh);
		con_mesh.data.shader_from_source = true;
		con_mesh.data.vertex_shader = vert.get();
		con_mesh.data.fragment_shader = frag.get();
		return con_mesh;
	}
}
$hxClasses["arm.node.MakeMeshPreview"] = arm_node_MakeMeshPreview;
arm_node_MakeMeshPreview.__name__ = "arm.node.MakeMeshPreview";
class arm_node_MakeNodePreview {
	static run(data,matcon,node,group,parents) {
		let con_mesh = data.add_context({ name : "mesh", depth_write : true, compare_mode : "less", cull_mode : "clockwise", vertex_elements : [{ name : "pos", data : "short4norm"},{ name : "nor", data : "short2norm"},{ name : "tex", data : "short2norm"},{ name : "col", data : "short4norm"}], color_attachments : ["RGBA32"]});
		con_mesh.allow_vcols = true;
		let vert = con_mesh.make_vert();
		let frag = con_mesh.make_frag();
		frag.ins = vert.outs;
		vert.write_attrib("gl_Position = vec4(pos.xy * 3.0, 0.0, 1.0);");
		vert.write_attrib("const vec2 madd = vec2(0.5, 0.5);");
		vert.add_out("vec2 texCoord");
		vert.write_attrib("texCoord = gl_Position.xy * madd + madd;");
		vert.write_attrib("texCoord.y = 1.0 - texCoord.y;");
		arm_shader_MaterialParser.init();
		arm_shader_MaterialParser.canvases = [arm_Context.material.canvas];
		arm_shader_MaterialParser.nodes = arm_Context.material.canvas.nodes;
		arm_shader_MaterialParser.links = arm_Context.material.canvas.links;
		if(group != null) {
			arm_shader_MaterialParser.push_group(group);
			arm_shader_MaterialParser.parents = parents;
		}
		let links = arm_shader_MaterialParser.links;
		let link = { id : arm_Context.material.nodes.getLinkId(links), from_id : node.id, from_socket : arm_Context.nodePreviewSocket, to_id : -1, to_socket : -1};
		links.push(link);
		arm_shader_MaterialParser.con = con_mesh;
		arm_shader_MaterialParser.vert = vert;
		arm_shader_MaterialParser.frag = frag;
		arm_shader_MaterialParser.curshader = frag;
		arm_shader_MaterialParser.matcon = matcon;
		arm_shader_MaterialParser.transform_color_space = false;
		let res = arm_shader_MaterialParser.write_result(link);
		arm_shader_MaterialParser.transform_color_space = true;
		let st = node.outputs[link.from_socket].type;
		if(st != "RGB" && st != "RGBA" && st != "VECTOR") {
			res = "(" + res + ").xxx";
		}
		HxOverrides.remove(links,link);
		frag.add_out("vec4 fragColor");
		frag.write("vec3 basecol = " + res + ";");
		frag.write("fragColor = vec4(basecol.rgb, 1.0);");
		arm_shader_MaterialParser.finalize(con_mesh);
		con_mesh.data.shader_from_source = true;
		con_mesh.data.vertex_shader = vert.get();
		con_mesh.data.fragment_shader = frag.get();
		return con_mesh;
	}
}
$hxClasses["arm.node.MakeNodePreview"] = arm_node_MakeNodePreview;
arm_node_MakeNodePreview.__name__ = "arm.node.MakeNodePreview";
class arm_node_MakePaint {
	static run(data,matcon) {
		while(true) {
			let con_paint = data.add_context({ name : "paint", depth_write : false, compare_mode : "always", cull_mode : "none", vertex_elements : [{ name : "pos", data : "short4norm"},{ name : "nor", data : "short2norm"},{ name : "tex", data : "short2norm"}], color_attachments : arm_Context.tool == 8 ? ["RGBA32"] : arm_Context.tool == 9 && arm_Context.pickPosNorTex ? ["RGBA128","RGBA128"] : arm_Context.tool == 9 ? ["RGBA32","RGBA32","RGBA32","RGBA32"] : ["RGBA32","RGBA32","RGBA32","R8"]});
			con_paint.data.color_writes_red = [true,true,true,true];
			con_paint.data.color_writes_green = [true,true,true,true];
			con_paint.data.color_writes_blue = [true,true,true,true];
			con_paint.data.color_writes_alpha = [true,true,true,true];
			con_paint.allow_vcols = arm_Context.paintObject.data.geom.cols != null;
			let vert = con_paint.make_vert();
			let frag = con_paint.make_frag();
			frag.ins = vert.outs;
			if(arm_Context.tool == 11) {
				arm_node_MakeBake.setColorWrites(con_paint);
			}
			if(arm_Context.tool == 8 || arm_Context.tool == 9) {
				arm_node_MakeColorIdPicker.run(vert,frag);
				con_paint.data.shader_from_source = true;
				con_paint.data.vertex_shader = vert.get();
				con_paint.data.fragment_shader = frag.get();
				return con_paint;
			}
			let faceFill = arm_Context.tool == 2 && arm_Context.fillTypeHandle.position == 1;
			let uvIslandFill = arm_Context.tool == 2 && arm_Context.fillTypeHandle.position == 3;
			let decal = arm_Context.tool == 3 || arm_Context.tool == 4;
			vert.write("vec2 tpos = vec2(tex.x * 2.0 - 1.0, (1.0 - tex.y) * 2.0 - 1.0);");
			vert.write("gl_Position = vec4(tpos, 0.0, 1.0);");
			if(arm_Context.layer.fill_layer != null && arm_Context.layer.uvType == 2) {
				vert.add_uniform("mat4 WVP","_decalLayerMatrix");
			} else {
				vert.add_uniform("mat4 WVP","_worldViewProjectionMatrix");
			}
			vert.add_out("vec4 ndc");
			vert.write_attrib("ndc = mul(vec4(pos.xyz, 1.0), WVP);");
			frag.write_attrib("vec3 sp = vec3((ndc.xyz / ndc.w) * 0.5 + 0.5);");
			frag.write_attrib("sp.y = 1.0 - sp.y;");
			frag.write_attrib("sp.z -= 0.0001;");
			if((arm_Context.layer.fill_layer != null ? arm_Context.layer.uvType : arm_Context.brushPaint) == 2) {
				frag.ndcpos = true;
			}
			frag.add_uniform("vec4 inp","_inputBrush");
			frag.add_uniform("vec4 inplast","_inputBrushLast");
			frag.add_uniform("float aspectRatio","_aspectRatioWindowF");
			frag.write("vec2 bsp = sp.xy * 2.0 - 1.0;");
			frag.write("bsp.x *= aspectRatio;");
			frag.write("bsp = bsp * 0.5 + 0.5;");
			frag.add_uniform("sampler2D gbufferD");
			frag.add_out("vec4 fragColor[4]");
			frag.add_uniform("float brushRadius","_brushRadius");
			frag.add_uniform("float brushOpacity","_brushOpacity");
			frag.add_uniform("float brushHardness","_brushHardness");
			if(arm_Context.tool == 0 || arm_Context.tool == 1 || arm_Context.tool == 5 || arm_Context.tool == 6 || arm_Context.tool == 7 || decal) {
				let depthReject = !arm_Context.xray;
				if(arm_Config.raw.brush_3d && !arm_Config.raw.brush_depth_reject) {
					depthReject = false;
				}
				if(arm_Config.raw.brush_3d && !decal && arm_Context.tool != 7) {
					if(arm_node_MakeMaterial.heightUsed || arm_Context.symX || arm_Context.symY || arm_Context.symZ) {
						depthReject = false;
					}
				}
				if(depthReject) {
					frag.write("if (sp.z > textureLod(gbufferD, sp.xy, 0.0).r + 0.0005) discard;");
				}
				arm_node_MakeBrush.run(vert,frag);
			} else {
				frag.write("float dist = 0.0;");
				if(arm_Context.tool == 2 && arm_Context.fillTypeHandle.position == 2) {
					frag.add_function(arm_shader_ShaderFunctions.str_octahedronWrap);
					frag.add_uniform("sampler2D gbuffer0");
					frag.write("vec2 g0 = textureLod(gbuffer0, inp.xy, 0.0).rg;");
					frag.write("vec3 wn;");
					frag.write("wn.z = 1.0 - abs(g0.x) - abs(g0.y);");
					frag.write("wn.xy = wn.z >= 0.0 ? g0.xy : octahedronWrap(g0.xy);");
					frag.write("wn = normalize(wn);");
					frag.n = true;
					frag.write("if (dot(wn, n) < " + arm_Context.brushAngleRejectDot + ") discard;");
				}
				if(arm_Context.tool == 2 && arm_Context.brushStencilImage != null) {
					frag.write("if (sp.z > textureLod(gbufferD, sp.xy, 0.0).r + 0.0005) discard;");
				}
			}
			if(arm_Context.colorIdPicked || faceFill || uvIslandFill) {
				vert.add_out("vec2 texCoordPick");
				vert.write("texCoordPick = tex;");
				if(arm_Context.colorIdPicked) {
					arm_node_MakeDiscard.colorId(vert,frag);
				}
				if(faceFill) {
					arm_node_MakeDiscard.face(vert,frag);
				} else if(uvIslandFill) {
					arm_node_MakeDiscard.uvIsland(vert,frag);
				}
			}
			if(arm_Context.pickerMaskHandle.position == 1) {
				arm_node_MakeDiscard.materialId(vert,frag);
			}
			arm_node_MakeTexcoord.run(vert,frag);
			if(arm_Context.tool == 5 || arm_Context.tool == 6) {
				frag.add_uniform("sampler2D gbuffer2");
				frag.add_uniform("vec2 gbufferSize","_gbufferSize");
				frag.add_uniform("sampler2D texpaint_undo","_texpaint_undo");
				frag.add_uniform("sampler2D texpaint_nor_undo","_texpaint_nor_undo");
				frag.add_uniform("sampler2D texpaint_pack_undo","_texpaint_pack_undo");
				if(arm_Context.tool == 5) {
					arm_node_MakeClone.run(vert,frag);
				} else {
					arm_node_MakeBlur.run(vert,frag);
				}
			} else {
				arm_shader_MaterialParser.parse_emission = arm_Context.material.paintEmis;
				arm_shader_MaterialParser.parse_subsurface = arm_Context.material.paintSubs;
				arm_shader_MaterialParser.parse_height = arm_Context.material.paintHeight;
				arm_shader_MaterialParser.parse_height_as_channel = true;
				arm_shader_MaterialParser.triplanar = (arm_Context.layer.fill_layer != null ? arm_Context.layer.uvType : arm_Context.brushPaint) == 1 && !decal;
				arm_shader_MaterialParser.sample_keep_aspect = decal;
				arm_shader_MaterialParser.sample_uv_scale = "brushScale";
				let sout = arm_shader_MaterialParser.parse(arm_ui_UINodes.inst.getCanvasMaterial(),con_paint,vert,frag,matcon);
				arm_shader_MaterialParser.parse_emission = false;
				arm_shader_MaterialParser.parse_subsurface = false;
				arm_shader_MaterialParser.parse_height_as_channel = false;
				arm_shader_MaterialParser.parse_height = false;
				let rough = sout.out_roughness;
				let met = sout.out_metallic;
				let occ = sout.out_occlusion;
				let nortan = arm_shader_MaterialParser.out_normaltan;
				let height = sout.out_height;
				let opac = sout.out_opacity;
				let emis = sout.out_emission;
				let subs = sout.out_subsurface;
				frag.write("vec3 basecol = " + sout.out_basecol + ";");
				frag.write("float roughness = " + rough + ";");
				frag.write("float metallic = " + met + ";");
				frag.write("float occlusion = " + occ + ";");
				frag.write("vec3 nortan = " + nortan + ";");
				frag.write("float height = " + height + ";");
				frag.write("float mat_opacity = " + opac + ";");
				frag.write("float opacity = mat_opacity;");
				if(arm_Context.layer.fill_layer == null) {
					frag.write("opacity *= brushOpacity;");
				}
				if(arm_Context.material.paintEmis) {
					frag.write("float emis = " + emis + ";");
				}
				if(arm_Context.material.paintSubs) {
					frag.write("float subs = " + subs + ";");
				}
				if(parseFloat(height) != 0.0 && !arm_node_MakeMaterial.heightUsed) {
					arm_node_MakeMaterial.heightUsed = true;
					continue;
				}
				if(parseFloat(emis) != 0.0) {
					arm_node_MakeMaterial.emisUsed = true;
				}
				if(parseFloat(subs) != 0.0) {
					arm_node_MakeMaterial.subsUsed = true;
				}
			}
			if(arm_Context.brushMaskImage != null && arm_Context.tool == 3) {
				frag.add_uniform("sampler2D texbrushmask","_texbrushmask");
				frag.write("vec4 mask_sample = textureLod(texbrushmask, uvsp, 0.0);");
				if(arm_Context.brushMaskImageIsAlpha) {
					frag.write("opacity *= mask_sample.a;");
				} else {
					frag.write("opacity *= mask_sample.r * mask_sample.a;");
				}
			} else if(arm_Context.tool == 4) {
				frag.add_uniform("sampler2D textexttool","_textexttool");
				frag.write("opacity *= textureLod(textexttool, uvsp, 0.0).r;");
			}
			if(arm_Context.brushStencilImage != null && (arm_Context.tool == 0 || arm_Context.tool == 1 || arm_Context.tool == 2 || arm_Context.tool == 5 || arm_Context.tool == 6 || arm_Context.tool == 7 || decal)) {
				frag.add_uniform("sampler2D texbrushstencil","_texbrushstencil");
				frag.add_uniform("vec4 stencilTransform","_stencilTransform");
				frag.write("vec2 stencil_uv = vec2((sp.xy - stencilTransform.xy) / stencilTransform.z * vec2(aspectRatio, 1.0));");
				frag.write("vec2 stencil_size = textureSize(texbrushstencil, 0);");
				frag.write("float stencil_ratio = stencil_size.y / stencil_size.x;");
				frag.write("stencil_uv -= vec2(0.5 / stencil_ratio, 0.5);");
				frag.write("stencil_uv = vec2(stencil_uv.x * cos(stencilTransform.w) - stencil_uv.y * sin(stencilTransform.w),\r\n\t\t\t\t\t\t\t\t\t\t  stencil_uv.x * sin(stencilTransform.w) + stencil_uv.y * cos(stencilTransform.w));");
				frag.write("stencil_uv += vec2(0.5 / stencil_ratio, 0.5);");
				frag.write("stencil_uv.x *= stencil_ratio;");
				frag.write("if (stencil_uv.x < 0 || stencil_uv.x > 1 || stencil_uv.y < 0 || stencil_uv.y > 1) discard;");
				frag.write("vec4 texbrushstencil_sample = textureLod(texbrushstencil, stencil_uv, 0.0);");
				if(arm_Context.brushStencilImageIsAlpha) {
					frag.write("opacity *= texbrushstencil_sample.a;");
				} else {
					frag.write("opacity *= texbrushstencil_sample.r * texbrushstencil_sample.a;");
				}
			}
			if(arm_Context.brushMaskImage != null && (arm_Context.tool == 0 || arm_Context.tool == 1)) {
				frag.add_uniform("sampler2D texbrushmask","_texbrushmask");
				frag.write("vec2 binp_mask = inp.xy * 2.0 - 1.0;");
				frag.write("binp_mask.x *= aspectRatio;");
				frag.write("binp_mask = binp_mask * 0.5 + 0.5;");
				frag.write("vec2 pa_mask = bsp.xy - binp_mask.xy;");
				if(arm_Context.brushDirectional) {
					frag.add_uniform("vec3 brushDirection","_brushDirection");
					frag.write("if (brushDirection.z == 0.0) discard;");
					frag.write("pa_mask = vec2(pa_mask.x * brushDirection.x - pa_mask.y * brushDirection.y, pa_mask.x * brushDirection.y + pa_mask.y * brushDirection.x);");
				}
				if(arm_Context.brushAngle + arm_Context.brushNodesAngle != 0.0) {
					frag.add_uniform("vec2 brushAngle","_brushAngle");
					frag.write("pa_mask.xy = vec2(pa_mask.x * brushAngle.x - pa_mask.y * brushAngle.y, pa_mask.x * brushAngle.y + pa_mask.y * brushAngle.x);");
				}
				frag.write("pa_mask /= brushRadius;");
				if(arm_Config.raw.brush_3d) {
					frag.add_uniform("vec3 eye","_cameraPosition");
					frag.write("pa_mask *= distance(eye, winp.xyz) / 1.5;");
				}
				frag.write("pa_mask = pa_mask.xy * 0.5 + 0.5;");
				frag.write("vec4 mask_sample = textureLod(texbrushmask, pa_mask, 0.0);");
				if(arm_Context.brushMaskImageIsAlpha) {
					frag.write("opacity *= mask_sample.a;");
				} else {
					frag.write("opacity *= mask_sample.r * mask_sample.a;");
				}
			}
			frag.write("if (opacity == 0.0) discard;");
			if(arm_Context.tool == 7) {
				arm_node_MakeParticle.mask(vert,frag);
			} else {
				frag.write("float str = clamp((brushRadius - dist) * brushHardness * 400.0, 0.0, 1.0) * opacity;");
			}
			frag.wvpposition = true;
			frag.write("vec2 sample_tc = vec2(wvpposition.xy / wvpposition.w) * 0.5 + 0.5;");
			frag.write("sample_tc.y = 1.0 - sample_tc.y;");
			frag.add_uniform("sampler2D paintmask");
			frag.write("float sample_mask = textureLod(paintmask, sample_tc, 0.0).r;");
			frag.write("str = max(str, sample_mask);");
			frag.add_uniform("sampler2D texpaint_undo","_texpaint_undo");
			frag.write("vec4 sample_undo = textureLod(texpaint_undo, sample_tc, 0.0);");
			let matid = arm_Context.material.id / 255;
			if(arm_Context.pickerMaskHandle.position == 1) {
				matid = arm_Context.materialIdPicked / 255;
			}
			frag.write("float matid = " + ("" + matid * 3.0) + ";");
			if(arm_Context.material.paintEmis) {
				frag.write("if (emis > 0.0) {");
				frag.write("\tmatid += 1.0 / 255.0;");
				frag.write("\tif (str == 0.0) discard;");
				frag.write("}");
			} else if(arm_Context.material.paintSubs) {
				frag.write("if (subs > 0.0) {");
				frag.write("    matid += 2.0 / 255.0;");
				frag.write("\tif (str == 0.0) discard;");
				frag.write("}");
			}
			let isMask = arm_Context.layer.isMask();
			if(arm_Context.layer != arm_Project.layers[0] && !isMask) {
				if(arm_Context.tool == 1) {
					frag.write("fragColor[0] = vec4(mix(sample_undo.rgb, vec3(0.0, 0.0, 0.0), str), sample_undo.a - str);");
					frag.write("nortan = vec3(0.5, 0.5, 1.0);");
					frag.write("occlusion = 1.0;");
					frag.write("roughness = 0.0;");
					frag.write("metallic = 0.0;");
					frag.write("matid = 0.0;");
				} else if(arm_Context.tool == 7 || decal || arm_Context.brushMaskImage != null) {
					frag.write("fragColor[0] = vec4(" + arm_node_MakeMaterial.blendMode(frag,arm_Context.brushBlending,"sample_undo.rgb","basecol","str") + ", max(str, sample_undo.a));");
				} else if(arm_Context.layer.fill_layer != null) {
					frag.write("fragColor[0] = vec4(" + arm_node_MakeMaterial.blendMode(frag,arm_Context.brushBlending,"sample_undo.rgb","basecol","opacity") + ", mat_opacity);");
				} else {
					frag.write("fragColor[0] = vec4(" + arm_node_MakeMaterial.blendMode(frag,arm_Context.brushBlending,"sample_undo.rgb","basecol","opacity") + ", max(str, sample_undo.a));");
				}
				frag.write("fragColor[1] = vec4(nortan, matid);");
				let height = "0.0";
				if(arm_Context.material.paintHeight && arm_node_MakeMaterial.heightUsed) {
					height = "height";
				}
				if(decal) {
					frag.add_uniform("sampler2D texpaint_pack_undo","_texpaint_pack_undo");
					frag.write("vec4 sample_pack_undo = textureLod(texpaint_pack_undo, sample_tc, 0.0);");
					frag.write("fragColor[2] = mix(sample_pack_undo, vec4(occlusion, roughness, metallic, " + height + "), str);");
				} else {
					frag.write("fragColor[2] = vec4(occlusion, roughness, metallic, " + height + ");");
				}
			} else if(arm_Context.tool == 1) {
				frag.write("fragColor[0] = vec4(mix(sample_undo.rgb, vec3(0.0, 0.0, 0.0), str), sample_undo.a - str);");
				frag.write("fragColor[1] = vec4(0.5, 0.5, 1.0, 0.0);");
				frag.write("fragColor[2] = vec4(1.0, 0.0, 0.0, 0.0);");
			} else {
				frag.add_uniform("sampler2D texpaint_nor_undo","_texpaint_nor_undo");
				frag.add_uniform("sampler2D texpaint_pack_undo","_texpaint_pack_undo");
				frag.write("vec4 sample_nor_undo = textureLod(texpaint_nor_undo, sample_tc, 0.0);");
				frag.write("vec4 sample_pack_undo = textureLod(texpaint_pack_undo, sample_tc, 0.0);");
				frag.write("fragColor[0] = vec4(" + arm_node_MakeMaterial.blendMode(frag,arm_Context.brushBlending,"sample_undo.rgb","basecol","str") + ", max(str, sample_undo.a));");
				frag.write("fragColor[1] = vec4(mix(sample_nor_undo.rgb, nortan, str), matid);");
				if(arm_Context.material.paintHeight && arm_node_MakeMaterial.heightUsed) {
					frag.write("fragColor[2] = mix(sample_pack_undo, vec4(occlusion, roughness, metallic, height), str);");
				} else {
					frag.write("fragColor[2] = vec4(mix(sample_pack_undo.rgb, vec3(occlusion, roughness, metallic), str), 0.0);");
				}
			}
			frag.write("fragColor[3] = vec4(str, 0.0, 0.0, 1.0);");
			if(!arm_Context.material.paintBase) {
				con_paint.data.color_writes_red[0] = false;
				con_paint.data.color_writes_green[0] = false;
				con_paint.data.color_writes_blue[0] = false;
			}
			if(!arm_Context.material.paintOpac) {
				con_paint.data.color_writes_alpha[0] = false;
			}
			if(!arm_Context.material.paintNor) {
				con_paint.data.color_writes_red[1] = false;
				con_paint.data.color_writes_green[1] = false;
				con_paint.data.color_writes_blue[1] = false;
			}
			if(!arm_Context.material.paintOcc) {
				con_paint.data.color_writes_red[2] = false;
			}
			if(!arm_Context.material.paintRough) {
				con_paint.data.color_writes_green[2] = false;
			}
			if(!arm_Context.material.paintMet) {
				con_paint.data.color_writes_blue[2] = false;
			}
			if(!arm_Context.material.paintHeight) {
				con_paint.data.color_writes_alpha[2] = false;
			}
			if(isMask) {
				con_paint.data.color_writes_green[0] = false;
				con_paint.data.color_writes_blue[0] = false;
				con_paint.data.color_writes_alpha[0] = false;
				con_paint.data.color_writes_red[1] = false;
				con_paint.data.color_writes_green[1] = false;
				con_paint.data.color_writes_blue[1] = false;
				con_paint.data.color_writes_alpha[1] = false;
				con_paint.data.color_writes_red[2] = false;
				con_paint.data.color_writes_green[2] = false;
				con_paint.data.color_writes_blue[2] = false;
				con_paint.data.color_writes_alpha[2] = false;
			}
			if(arm_Context.tool == 11) {
				arm_node_MakeBake.run(con_paint,vert,frag);
			}
			arm_shader_MaterialParser.finalize(con_paint);
			arm_shader_MaterialParser.triplanar = false;
			arm_shader_MaterialParser.sample_keep_aspect = false;
			con_paint.data.shader_from_source = true;
			con_paint.data.vertex_shader = vert.get();
			con_paint.data.fragment_shader = frag.get();
			return con_paint;
		}
	}
}
$hxClasses["arm.node.MakePaint"] = arm_node_MakePaint;
arm_node_MakePaint.__name__ = "arm.node.MakePaint";
class arm_node_MakeParticle {
	static run(data) {
		let con_part = data.add_context({ name : "mesh", depth_write : false, compare_mode : "always", cull_mode : "clockwise", vertex_elements : [{ name : "pos", data : "short4norm"}], color_attachments : ["R8"]});
		let vert = con_part.make_vert();
		let frag = con_part.make_frag();
		frag.ins = vert.outs;
		vert.write_attrib("vec4 spos = vec4(pos.xyz, 1.0);");
		vert.add_uniform("float brushRadius","_brushRadius");
		vert.write_attrib("vec3 emitFrom = vec3(fhash(gl_InstanceID), fhash(gl_InstanceID * 2), fhash(gl_InstanceID * 3));");
		vert.write_attrib("emitFrom = emitFrom * brushRadius - brushRadius / 2.0;");
		vert.write_attrib("spos.xyz += emitFrom * vec3(256.0, 256.0, 256.0);");
		vert.add_uniform("mat4 pd","_particleData");
		vert.add_function("float fhash(int n) { return fract(sin(float(n)) * 43758.5453); }\n");
		vert.add_out("float p_age");
		vert.write("p_age = pd[3][3] - float(gl_InstanceID) * pd[0][1];");
		vert.write("p_age -= p_age * fhash(gl_InstanceID) * pd[2][3];");
		vert.write("if (pd[0][0] > 0.0 && p_age < 0.0) p_age += float(int(-p_age / pd[0][0]) + 1) * pd[0][0];");
		vert.add_out("float p_lifetime");
		vert.write("p_lifetime = pd[0][2];");
		vert.write("if (p_age < 0.0 || p_age > p_lifetime) {");
		vert.write("spos /= 0.0;");
		vert.write("}");
		vert.add_out("vec3 p_velocity");
		vert.write("p_velocity = vec3(pd[1][0], pd[1][1], pd[1][2]);");
		vert.write("p_velocity.x += fhash(gl_InstanceID)                     * pd[1][3] - pd[1][3] / 2.0;");
		vert.write("p_velocity.y += fhash(gl_InstanceID +     int(pd[0][3])) * pd[1][3] - pd[1][3] / 2.0;");
		vert.write("p_velocity.z += fhash(gl_InstanceID + 2 * int(pd[0][3])) * pd[1][3] - pd[1][3] / 2.0;");
		vert.write("p_velocity.x += (pd[2][0] * p_age) / 5.0;");
		vert.write("p_velocity.y += (pd[2][1] * p_age) / 5.0;");
		vert.write("p_velocity.z += (pd[2][2] * p_age) / 5.0;");
		vert.add_out("vec3 p_location");
		vert.write("p_location = p_velocity * p_age;");
		vert.write("spos.xyz += p_location;");
		vert.write("spos.xyz *= vec3(0.01, 0.01, 0.01);");
		vert.add_uniform("mat4 WVP","_worldViewProjectionMatrix");
		vert.write("gl_Position = mul(spos, WVP);");
		vert.add_uniform("vec4 inp","_inputBrush");
		vert.write("vec2 binp = vec2(inp.x, 1.0 - inp.y);");
		vert.write("binp = binp * 2.0 - 1.0;");
		vert.write("binp *= gl_Position.w;");
		vert.write("gl_Position.xy += binp;");
		vert.add_out("float p_fade");
		vert.write("p_fade = sin(min((p_age / 8.0) * 3.141592, 3.141592));");
		frag.add_out("float fragColor");
		frag.write("fragColor = p_fade;");
		con_part.data.shader_from_source = true;
		con_part.data.vertex_shader = vert.get();
		con_part.data.fragment_shader = frag.get();
		return con_part;
	}
	static mask(vert,frag) {
		if(arm_Context.particlePhysics) {
			vert.add_out("vec4 wpos");
			vert.add_uniform("mat4 W","_worldMatrix");
			vert.write_attrib("wpos = mul(vec4(pos.xyz, 1.0), W);");
			frag.add_uniform("vec3 particleHit","_particleHit");
			frag.write("float str = clamp(1.0 - distance(particleHit, wpos.xyz) * 2.0, 0.0, 1.0);");
			frag.write("if (particleHit.x == 0.0 && particleHit.y == 0.0 && particleHit.z == 0.0) str = 0.0;");
			return;
		}
		frag.add_uniform("sampler2D texparticle","_texparticle");
		frag.write("float str = textureLod(texparticle, sp.xy, 0.0).r;");
	}
}
$hxClasses["arm.node.MakeParticle"] = arm_node_MakeParticle;
arm_node_MakeParticle.__name__ = "arm.node.MakeParticle";
class arm_node_MakeTexcoord {
	static run(vert,frag) {
		let fillLayer = arm_Context.layer.fill_layer != null;
		let uvType = fillLayer ? arm_Context.layer.uvType : arm_Context.brushPaint;
		let decal = arm_Context.tool == 3 || arm_Context.tool == 4;
		let uvAngle = fillLayer ? arm_Context.layer.angle : arm_Context.brushAngle + arm_Context.brushNodesAngle;
		if(uvType == 2 || decal) {
			frag.add_uniform("float brushScale","_brushScale");
			frag.write_attrib("vec2 uvsp = sp.xy;");
			if(fillLayer) {
				frag.write_attrib("if (uvsp.x < 0.0 || uvsp.y < 0.0 || uvsp.x > 1.0 || uvsp.y > 1.0) discard;");
				if(uvAngle != 0.0) {
					frag.add_uniform("vec2 brushAngle","_brushAngle");
					frag.write_attrib("uvsp = vec2(uvsp.x * brushAngle.x - uvsp.y * brushAngle.y, uvsp.x * brushAngle.y + uvsp.y * brushAngle.x);");
				}
				frag.n = true;
				frag.add_uniform("vec3 decalLayerNor","_decalLayerNor");
				frag.write("if (abs(dot(n, decalLayerNor) - 1.0) > " + arm_Context.brushAngleRejectDot + ") discard;");
				frag.wposition = true;
				frag.add_uniform("vec3 decalLayerLoc","_decalLayerLoc");
				frag.add_uniform("float decalLayerDim","_decalLayerDim");
				frag.write_attrib("if (abs(dot(decalLayerNor, decalLayerLoc - wposition)) > decalLayerDim) discard;");
			} else if(decal) {
				frag.add_uniform("vec4 decalMask","_decalMask");
				frag.write_attrib("vec4 decalMaskLocal = decalMask;");
				frag.write_attrib("uvsp -= decalMaskLocal.xy;");
				frag.write_attrib("uvsp.x *= aspectRatio;");
				frag.write_attrib("uvsp *= 0.21 / (decalMaskLocal.w * 0.9);");
				if(arm_Context.brushDirectional) {
					frag.add_uniform("vec3 brushDirection","_brushDirection");
					frag.write_attrib("if (brushDirection.z == 0.0) discard;");
					frag.write_attrib("uvsp = vec2(uvsp.x * brushDirection.x - uvsp.y * brushDirection.y, uvsp.x * brushDirection.y + uvsp.y * brushDirection.x);");
				}
				if(uvAngle != 0.0) {
					frag.add_uniform("vec2 brushAngle","_brushAngle");
					frag.write_attrib("uvsp = vec2(uvsp.x * brushAngle.x - uvsp.y * brushAngle.y, uvsp.x * brushAngle.y + uvsp.y * brushAngle.x);");
				}
				frag.add_uniform("float brushScaleX","_brushScaleX");
				frag.write_attrib("uvsp.x *= brushScaleX;");
				frag.write_attrib("uvsp += vec2(0.5, 0.5);");
				frag.write_attrib("if (uvsp.x < 0.0 || uvsp.y < 0.0 || uvsp.x > 1.0 || uvsp.y > 1.0) discard;");
			} else {
				frag.write_attrib("uvsp.x *= aspectRatio;");
				if(uvAngle != 0.0) {
					frag.add_uniform("vec2 brushAngle","_brushAngle");
					frag.write_attrib("uvsp = vec2(uvsp.x * brushAngle.x - uvsp.y * brushAngle.y, uvsp.x * brushAngle.y + uvsp.y * brushAngle.x);");
				}
			}
			frag.write_attrib("vec2 texCoord = uvsp * brushScale;");
		} else if(uvType == 0) {
			vert.add_uniform("float brushScale","_brushScale");
			vert.add_out("vec2 texCoord");
			vert.write("texCoord = tex * brushScale;");
			if(uvAngle > 0.0) {
				vert.add_uniform("vec2 brushAngle","_brushAngle");
				vert.write("texCoord = vec2(texCoord.x * brushAngle.x - texCoord.y * brushAngle.y, texCoord.x * brushAngle.y + texCoord.y * brushAngle.x);");
			}
		} else {
			frag.wposition = true;
			frag.n = true;
			frag.add_uniform("float brushScale","_brushScale");
			frag.write_attrib("vec3 triWeight = wnormal * wnormal;");
			frag.write_attrib("float triMax = max(triWeight.x, max(triWeight.y, triWeight.z));");
			frag.write_attrib("triWeight = max(triWeight - triMax * 0.75, 0.0);");
			frag.write_attrib("vec3 texCoordBlend = triWeight * (1.0 / (triWeight.x + triWeight.y + triWeight.z));");
			frag.write_attrib("vec2 texCoord = wposition.yz * brushScale * 0.5;");
			frag.write_attrib("vec2 texCoord1 = wposition.xz * brushScale * 0.5;");
			frag.write_attrib("vec2 texCoord2 = wposition.xy * brushScale * 0.5;");
			if(uvAngle != 0.0) {
				frag.add_uniform("vec2 brushAngle","_brushAngle");
				frag.write_attrib("texCoord = vec2(texCoord.x * brushAngle.x - texCoord.y * brushAngle.y, texCoord.x * brushAngle.y + texCoord.y * brushAngle.x);");
				frag.write_attrib("texCoord1 = vec2(texCoord1.x * brushAngle.x - texCoord1.y * brushAngle.y, texCoord1.x * brushAngle.y + texCoord1.y * brushAngle.x);");
				frag.write_attrib("texCoord2 = vec2(texCoord2.x * brushAngle.x - texCoord2.y * brushAngle.y, texCoord2.x * brushAngle.y + texCoord2.y * brushAngle.x);");
			}
		}
	}
}
$hxClasses["arm.node.MakeTexcoord"] = arm_node_MakeTexcoord;
arm_node_MakeTexcoord.__name__ = "arm.node.MakeTexcoord";
class arm_node_MakeVoxel {
	static run(data) {
		let structure = new kha_graphics4_VertexStructure();
		structure.add("pos",27);
		structure.add("nor",23);
		structure.add("tex",23);
		let pipeState = data.pipeState;
		pipeState.inputLayout = [structure];
		data.raw.vertex_elements = [{ name : "pos", data : "short4norm"},{ name : "nor", data : "short2norm"},{ name : "tex", data : "short2norm"}];
		let ds = arm_Config.raw.displace_strength * 0.02 * arm_Context.mainObject().transform.scale.x;
		let ext = arm_Context.vxaoExt;
		pipeState.vertexShader = kha_graphics4_VertexShader.fromSource("#define vec3 float3\r\n\t\tuniform float4x4 W;\r\n\t\tuniform float3x3 N;\r\n\t\tTexture2D<float4> texpaint_pack;\r\n\t\tSamplerState _texpaint_pack_sampler;\r\n\t\tstruct SPIRV_Cross_Input { float4 pos : TEXCOORD1; float2 nor : TEXCOORD0; float2 tex : TEXCOORD2; };\r\n\t\tstruct SPIRV_Cross_Output { float4 svpos : SV_POSITION; };\r\n\t\tSPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) {\r\n\t\t\tSPIRV_Cross_Output stage_output;\r\n\t\t\t" + ("const vec3 voxelgiHalfExtents = vec3(" + ext + ", " + ext + ", " + ext + ");") + "\r\n\t\t\tstage_output.svpos.xyz = mul(float4(stage_input.pos.xyz, 1.0), W).xyz / voxelgiHalfExtents.xxx;\r\n\t\t\tfloat3 wnormal = normalize(mul(float3(stage_input.nor.xy, stage_input.pos.w), N));\r\n\t\t\tfloat height = texpaint_pack.SampleLevel(_texpaint_pack_sampler, stage_input.tex, 0.0).a;\r\n\t\t\tstage_output.svpos.xyz += wnormal * height.xxx * float3(" + ds + "," + ds + "," + ds + ");\r\n\t\t\tstage_output.svpos.w = 1.0;\r\n\t\t\treturn stage_output;\r\n\t\t}");
		pipeState.compile();
		data.raw.constants = [{ name : "W", type : "mat4", link : "_worldMatrix"},{ name : "N", type : "mat3", link : "_normalMatrix"}];
		data.constants = [pipeState.getConstantLocation("W"),pipeState.getConstantLocation("N")];
		data.raw.texture_units = [{ name : "texpaint_pack"},{ name : "voxels", is_image : true}];
		data.textureUnits = [pipeState.getTextureUnit("texpaint_pack"),pipeState.getTextureUnit("voxels")];
	}
}
$hxClasses["arm.node.MakeVoxel"] = arm_node_MakeVoxel;
arm_node_MakeVoxel.__name__ = "arm.node.MakeVoxel";
class arm_node_brush_BooleanNode extends arm_node_LogicNode {
	constructor(tree,value) {
		if(value == null) {
			value = false;
		}
		super(tree);
		this.value = value;
	}
	get(from) {
		if(this.inputs.length > 0) {
			return this.inputs[0].get();
		}
		return this.value;
	}
	set(value) {
		if(this.inputs.length > 0) {
			this.inputs[0].set(value);
		} else {
			this.value = value;
		}
	}
}
$hxClasses["arm.node.brush.BooleanNode"] = arm_node_brush_BooleanNode;
arm_node_brush_BooleanNode.__name__ = "arm.node.brush.BooleanNode";
arm_node_brush_BooleanNode.__super__ = arm_node_LogicNode;
Object.assign(arm_node_brush_BooleanNode.prototype, {
	__class__: arm_node_brush_BooleanNode
});
class arm_node_brush_BrushOutputNode extends arm_node_LogicNode {
	constructor(tree) {
		arm_node_LogicNode._hx_skip_constructor = true;
		super();
		arm_node_LogicNode._hx_skip_constructor = false;
		this._hx_constructor(tree);
	}
	_hx_constructor(tree) {
		this.Directional = false;
		super._hx_constructor(tree);
		arm_Context.runBrush = $bind(this,this.run);
		arm_Context.parseBrushInputs = $bind(this,this.parseInputs);
	}
	parseInputs() {
		let lastMask = arm_Context.brushMaskImage;
		let lastStencil = arm_Context.brushStencilImage;
		let input0;
		let input1;
		let input2;
		let input3;
		let input4;
		let input5;
		let input6;
		try {
			input0 = this.inputs[0].get();
			input1 = this.inputs[1].get();
			input2 = this.inputs[2].get();
			input3 = this.inputs[3].get();
			input4 = this.inputs[4].get();
			input5 = this.inputs[5].get();
			input6 = this.inputs[6].get();
		} catch( _g ) {
			return;
		}
		arm_Context.paintVec = input0;
		arm_Context.brushNodesRadius = input1;
		arm_Context.brushNodesScale = input2;
		arm_Context.brushNodesAngle = input3;
		let opac = input4;
		if(opac == null) {
			opac = 1.0;
		}
		if(typeof(opac) == "string") {
			arm_Context.brushMaskImageIsAlpha = opac.endsWith(".a");
			opac = opac.substr(0,opac.lastIndexOf("."));
			arm_Context.brushNodesOpacity = 1.0;
			arm_Context.brushMaskImage = arm_Project.getImage(arm_Project.assets[arm_Project.assetNames.indexOf(opac)]);
		} else {
			arm_Context.brushNodesOpacity = opac;
			arm_Context.brushMaskImage = null;
		}
		arm_Context.brushNodesHardness = input5;
		let stencil = input6;
		if(stencil == null) {
			stencil = 1.0;
		}
		if(typeof(stencil) == "string") {
			arm_Context.brushStencilImageIsAlpha = stencil.endsWith(".a");
			stencil = stencil.substr(0,stencil.lastIndexOf("."));
			arm_Context.brushStencilImage = arm_Project.getImage(arm_Project.assets[arm_Project.assetNames.indexOf(stencil)]);
		} else {
			arm_Context.brushStencilImage = null;
		}
		if(lastMask != arm_Context.brushMaskImage || lastStencil != arm_Context.brushStencilImage) {
			arm_node_MakeMaterial.parsePaintMaterial();
		}
		arm_Context.brushDirectional = this.Directional;
	}
	run(from) {
		let left = 0.0;
		let right = 1.0;
		if(arm_Context.paint2d) {
			left = 1.0;
			right = (arm_Context.splitView ? 2.0 : 1.0) + arm_ui_UIView2D.inst.ww / arm_App.w();
		}
		if(arm_Context.lastPaintX < 0 || arm_Context.lastPaintY < 0) {
			arm_Context.lastPaintVecX = arm_Context.paintVec.x;
			arm_Context.lastPaintVecY = arm_Context.paintVec.y;
		}
		let fillLayer = arm_Context.layer.fill_layer != null && arm_Context.tool != 9 && arm_Context.tool != 8;
		let groupLayer = arm_Context.layer.isGroup();
		if(arm_Context.paintVec.x > left && arm_Context.paintVec.x < right && arm_Context.paintVec.y > 0 && arm_Context.paintVec.y < 1 && !fillLayer && !groupLayer && (arm_Context.layer.isVisible() || arm_Context.paint2d) && !arm_ui_UISidebar.inst.ui.isHovered && !arm_App.isDragging && !arm_App.isResizing && !arm_App.isScrolling() && !arm_App.isComboSelected()) {
			let down = iron_system_Input.getMouse().down() || iron_system_Input.getPen().down();
			if(down && arm_Context.tool == 8 && arm_Project.assets.length > 0) {
				arm_Context.colorIdPicked = true;
			}
			if(down && (arm_Context.paintVec.x == arm_Context.lastPaintX && arm_Context.paintVec.y == arm_Context.lastPaintY || arm_Context.tool == 0 && arm_Context.brushLazyRadius > 0)) {
				arm_Context.painted++;
			} else {
				arm_Context.painted = 0;
			}
			arm_Context.lastPaintX = arm_Context.paintVec.x;
			arm_Context.lastPaintY = arm_Context.paintVec.y;
			if(arm_Context.tool == 7) {
				arm_Context.painted = 0;
			}
			if(arm_Context.painted == 0) {
				this.parseInputs();
			}
			if(arm_Context.painted <= 1) {
				arm_Context.pdirty = 1;
				arm_Context.rdirty = 2;
			}
		}
	}
}
$hxClasses["arm.node.brush.BrushOutputNode"] = arm_node_brush_BrushOutputNode;
arm_node_brush_BrushOutputNode.__name__ = "arm.node.brush.BrushOutputNode";
arm_node_brush_BrushOutputNode.__super__ = arm_node_LogicNode;
Object.assign(arm_node_brush_BrushOutputNode.prototype, {
	__class__: arm_node_brush_BrushOutputNode
});
class arm_node_brush_ColorNode extends arm_node_LogicNode {
	constructor(tree,r,g,b,a) {
		arm_node_LogicNode._hx_skip_constructor = true;
		super();
		arm_node_LogicNode._hx_skip_constructor = false;
		this._hx_constructor(tree,r,g,b,a);
	}
	_hx_constructor(tree,r,g,b,a) {
		if(a == null) {
			a = 1.0;
		}
		if(b == null) {
			b = 0.8;
		}
		if(g == null) {
			g = 0.8;
		}
		if(r == null) {
			r = 0.8;
		}
		this.value = new iron_math_Vec4();
		super._hx_constructor(tree);
		let _this = this.value;
		let w = a;
		if(a == null) {
			w = 1.0;
		}
		_this.x = r;
		_this.y = g;
		_this.z = b;
		_this.w = w;
	}
	get(from) {
		if(this.inputs.length > 0) {
			return this.inputs[0].get();
		}
		return this.value;
	}
	set(value) {
		if(this.inputs.length > 0) {
			this.inputs[0].set(value);
		} else {
			this.value = value;
		}
	}
}
$hxClasses["arm.node.brush.ColorNode"] = arm_node_brush_ColorNode;
arm_node_brush_ColorNode.__name__ = "arm.node.brush.ColorNode";
arm_node_brush_ColorNode.__super__ = arm_node_LogicNode;
Object.assign(arm_node_brush_ColorNode.prototype, {
	__class__: arm_node_brush_ColorNode
});
class arm_node_brush_FloatNode extends arm_node_LogicNode {
	constructor(tree,value) {
		if(value == null) {
			value = 0.0;
		}
		super(tree);
		this.value = value;
	}
	get(from) {
		if(this.inputs.length > 0) {
			return this.inputs[0].get();
		}
		return this.value;
	}
	set(value) {
		if(this.inputs.length > 0) {
			this.inputs[0].set(value);
		} else {
			this.value = value;
		}
	}
}
$hxClasses["arm.node.brush.FloatNode"] = arm_node_brush_FloatNode;
arm_node_brush_FloatNode.__name__ = "arm.node.brush.FloatNode";
arm_node_brush_FloatNode.__super__ = arm_node_LogicNode;
Object.assign(arm_node_brush_FloatNode.prototype, {
	__class__: arm_node_brush_FloatNode
});
class arm_node_brush_InputNode extends arm_node_LogicNode {
	constructor(tree) {
		super(tree);
		if(!arm_node_brush_InputNode.registered) {
			arm_node_brush_InputNode.registered = true;
			tree.notifyOnUpdate($bind(this,this.update));
		}
	}
	update() {
		if(arm_Context.splitView) {
			arm_Context.viewIndex = iron_system_Input.getMouse().x - arm_App.x() > arm_App.w() / 2 ? 1 : 0;
		}
		let decalMask = (arm_Context.tool == 3 || arm_Context.tool == 4) && arm_Operator.shortcut(arm_Config.keymap.decal_mask + "+" + arm_Config.keymap.action_paint,2);
		let lazyPaint = arm_Context.brushLazyRadius > 0 && (arm_Operator.shortcut(arm_Config.keymap.action_paint,2) || arm_Operator.shortcut(arm_Config.keymap.brush_ruler + "+" + arm_Config.keymap.action_paint,2) || decalMask);
		let mouse = iron_system_Input.getMouse();
		let paintX = (mouse.x - arm_App.x()) / arm_App.w();
		let paintY = (mouse.y - arm_App.y()) / arm_App.h();
		if(mouse.started()) {
			arm_node_brush_InputNode.startX = (mouse.x - arm_App.x()) / arm_App.w();
			arm_node_brush_InputNode.startY = (mouse.y - arm_App.y()) / arm_App.h();
		}
		let pen = iron_system_Input.getPen();
		if(pen.down()) {
			paintX = (pen.x - arm_App.x()) / arm_App.w();
			paintY = (pen.y - arm_App.y()) / arm_App.h();
		}
		if(pen.started()) {
			arm_node_brush_InputNode.startX = (pen.x - arm_App.x()) / arm_App.w();
			arm_node_brush_InputNode.startY = (pen.y - arm_App.y()) / arm_App.h();
		}
		if(arm_Operator.shortcut(arm_Config.keymap.brush_ruler + "+" + arm_Config.keymap.action_paint,2)) {
			if(arm_node_brush_InputNode.lockX) {
				paintX = arm_node_brush_InputNode.startX;
			}
			if(arm_node_brush_InputNode.lockY) {
				paintY = arm_node_brush_InputNode.startY;
			}
		}
		if(arm_Context.brushLazyRadius > 0) {
			arm_Context.brushLazyX = paintX;
			arm_Context.brushLazyY = paintY;
		}
		if(!lazyPaint) {
			arm_node_brush_InputNode.coords.x = paintX;
			arm_node_brush_InputNode.coords.y = paintY;
		}
		if(arm_Context.splitView) {
			arm_Context.viewIndex = -1;
		}
		if(arm_node_brush_InputNode.lockBegin) {
			let dx = Math.abs(arm_node_brush_InputNode.lockStartX - (mouse.x - arm_App.x()));
			let dy = Math.abs(arm_node_brush_InputNode.lockStartY - (mouse.y - arm_App.y()));
			if(dx > 1 || dy > 1) {
				arm_node_brush_InputNode.lockBegin = false;
				if(dx > dy) {
					arm_node_brush_InputNode.lockY = true;
				} else {
					arm_node_brush_InputNode.lockX = true;
				}
			}
		}
		let kb = iron_system_Input.getKeyboard();
		if(kb.started(arm_Config.keymap.brush_ruler)) {
			arm_node_brush_InputNode.lockStartX = mouse.x - arm_App.x();
			arm_node_brush_InputNode.lockStartY = mouse.y - arm_App.y();
			arm_node_brush_InputNode.lockBegin = true;
		} else if(kb.released(arm_Config.keymap.brush_ruler)) {
			arm_node_brush_InputNode.lockX = arm_node_brush_InputNode.lockY = arm_node_brush_InputNode.lockBegin = false;
		}
		if(arm_Context.brushLazyRadius > 0) {
			let x = arm_Context.brushLazyX * arm_App.w();
			let y = arm_Context.brushLazyY * arm_App.h();
			if(y == null) {
				y = 0.0;
			}
			if(x == null) {
				x = 0.0;
			}
			let v1_x = x;
			let v1_y = y;
			let x1 = arm_node_brush_InputNode.coords.x * arm_App.w();
			let y1 = arm_node_brush_InputNode.coords.y * arm_App.h();
			if(y1 == null) {
				y1 = 0.0;
			}
			if(x1 == null) {
				x1 = 0.0;
			}
			let v2_x = x1;
			let v2_y = y1;
			let vx = v1_x - v2_x;
			let vy = v1_y - v2_y;
			let r = arm_Context.brushLazyRadius * 85;
			if(Math.sqrt(vx * vx + vy * vy) > r) {
				let v3_x = 0.0;
				let v3_y = 0.0;
				v3_x = v2_x - v1_x;
				v3_y = v2_y - v1_y;
				let n = Math.sqrt(v3_x * v3_x + v3_y * v3_y);
				if(n > 0.0) {
					let invN = 1.0 / n;
					v3_x *= invN;
					v3_y *= invN;
				}
				let f = 1.0 - arm_Context.brushLazyStep;
				v3_x *= f;
				v3_y *= f;
				v3_x *= r;
				v3_y *= r;
				v2_x = v1_x + v3_x;
				v2_y = v1_y + v3_y;
				let tmp = arm_App.w();
				arm_node_brush_InputNode.coords.x = v2_x / tmp;
				let tmp1 = arm_App.h();
				arm_node_brush_InputNode.coords.y = v2_y / tmp1;
				arm_Context.painted = -1;
			}
			arm_Context.lastPaintX = -1;
			arm_Context.lastPaintY = -1;
		}
		arm_Context.parseBrushInputs();
	}
	get(from) {
		arm_Context.brushLazyRadius = this.inputs[0].get();
		arm_Context.brushLazyStep = this.inputs[1].get();
		return arm_node_brush_InputNode.coords;
	}
}
$hxClasses["arm.node.brush.InputNode"] = arm_node_brush_InputNode;
arm_node_brush_InputNode.__name__ = "arm.node.brush.InputNode";
arm_node_brush_InputNode.__super__ = arm_node_LogicNode;
Object.assign(arm_node_brush_InputNode.prototype, {
	__class__: arm_node_brush_InputNode
});
class arm_node_brush_IntegerNode extends arm_node_LogicNode {
	constructor(tree,value) {
		if(value == null) {
			value = 0;
		}
		super(tree);
		this.value = value;
	}
	get(from) {
		if(this.inputs.length > 0) {
			return this.inputs[0].get();
		}
		return this.value;
	}
	set(value) {
		if(this.inputs.length > 0) {
			this.inputs[0].set(value);
		} else {
			this.value = value;
		}
	}
}
$hxClasses["arm.node.brush.IntegerNode"] = arm_node_brush_IntegerNode;
arm_node_brush_IntegerNode.__name__ = "arm.node.brush.IntegerNode";
arm_node_brush_IntegerNode.__super__ = arm_node_LogicNode;
Object.assign(arm_node_brush_IntegerNode.prototype, {
	__class__: arm_node_brush_IntegerNode
});
class arm_node_brush_MathNode extends arm_node_LogicNode {
	constructor(tree) {
		super(tree);
	}
	get(from) {
		let v1 = this.inputs[0].get();
		let v2 = this.inputs[1].get();
		let f = 0.0;
		switch(this.operation) {
		case "Absolute":
			f = Math.abs(v1);
			break;
		case "Add":
			f = v1 + v2;
			break;
		case "Arccosine":
			f = Math.acos(v1);
			break;
		case "Arcsine":
			f = Math.asin(v1);
			break;
		case "Arctan2":
			f = Math.atan2(v2,v1);
			break;
		case "Arctangent":
			f = Math.atan(v1);
			break;
		case "Ceil":
			f = Math.ceil(v1);
			break;
		case "Cosine":
			f = Math.cos(v1);
			break;
		case "Divide":
			f = v1 / (v2 == 0.0 ? 0.000001 : v2);
			break;
		case "Exponent":
			f = Math.exp(v1);
			break;
		case "Floor":
			f = Math.floor(v1);
			break;
		case "Fraction":
			f = v1 - Math.floor(v1);
			break;
		case "Greater Than":
			f = v1 > v2 ? 1.0 : 0.0;
			break;
		case "Hyperbolic Cosine":
			f = (Math.exp(v1) + Math.exp(-v1)) / 2.0;
			break;
		case "Hyperbolic Sine":
			f = (Math.exp(v1) - Math.exp(-v1)) / 2.0;
			break;
		case "Hyperbolic Tangent":
			f = 1.0 - 2.0 / (Math.exp(2 * v1) + 1);
			break;
		case "Inverse Square Root":
			f = 1.0 / Math.sqrt(v1);
			break;
		case "Less Than":
			f = v1 < v2 ? 1.0 : 0.0;
			break;
		case "Logarithm":
			f = Math.log(v1);
			break;
		case "Max":
			f = Math.max(v1,v2);
			break;
		case "Min":
			f = Math.min(v1,v2);
			break;
		case "Modulo":
			f = v1 % v2;
			break;
		case "Multiply":
			f = v1 * v2;
			break;
		case "Ping-Pong":
			f = v2 != 0.0 ? v2 - Math.abs(Math.abs(v1) % (2 * v2) - v2) : 0.0;
			break;
		case "Power":
			f = Math.pow(v1,v2);
			break;
		case "Round":
			f = Math.round(v1);
			break;
		case "Sign":
			f = v1 > 0 ? 1.0 : v1 < 0 ? -1.0 : 0;
			break;
		case "Sine":
			f = Math.sin(v1);
			break;
		case "Snap":
			f = Math.floor(v1 / v2) * v2;
			break;
		case "Square Root":
			f = Math.sqrt(v1);
			break;
		case "Subtract":
			f = v1 - v2;
			break;
		case "Tangent":
			f = Math.tan(v1);
			break;
		case "To Degrees":
			f = v1 / Math.PI * 180.0;
			break;
		case "To Radians":
			f = v1 / 180.0 * Math.PI;
			break;
		case "Truncate":
			f = Math.floor(v1);
			break;
		}
		if(this.use_clamp) {
			if(f < 0.0) {
				f = 0.0;
			} else if(f > 1.0) {
				f = 1.0;
			}
		}
		return f;
	}
}
$hxClasses["arm.node.brush.MathNode"] = arm_node_brush_MathNode;
arm_node_brush_MathNode.__name__ = "arm.node.brush.MathNode";
arm_node_brush_MathNode.__super__ = arm_node_LogicNode;
Object.assign(arm_node_brush_MathNode.prototype, {
	__class__: arm_node_brush_MathNode
});
class arm_node_brush_NullNode extends arm_node_LogicNode {
	constructor(tree) {
		super(tree);
	}
	get(from) {
		return null;
	}
}
$hxClasses["arm.node.brush.NullNode"] = arm_node_brush_NullNode;
arm_node_brush_NullNode.__name__ = "arm.node.brush.NullNode";
arm_node_brush_NullNode.__super__ = arm_node_LogicNode;
Object.assign(arm_node_brush_NullNode.prototype, {
	__class__: arm_node_brush_NullNode
});
class arm_node_brush_RandomNode extends arm_node_LogicNode {
	constructor(tree) {
		super(tree);
	}
	get(from) {
		let min = this.inputs[0].get();
		let max = this.inputs[1].get();
		return min + Math.random() * (max - min);
	}
}
$hxClasses["arm.node.brush.RandomNode"] = arm_node_brush_RandomNode;
arm_node_brush_RandomNode.__name__ = "arm.node.brush.RandomNode";
arm_node_brush_RandomNode.__super__ = arm_node_LogicNode;
Object.assign(arm_node_brush_RandomNode.prototype, {
	__class__: arm_node_brush_RandomNode
});
class arm_node_brush_SeparateVectorNode extends arm_node_LogicNode {
	constructor(tree) {
		super(tree);
	}
	get(from) {
		let vector = this.inputs[0].get();
		if(from == 0) {
			return vector.x;
		} else if(from == 1) {
			return vector.y;
		} else {
			return vector.z;
		}
	}
}
$hxClasses["arm.node.brush.SeparateVectorNode"] = arm_node_brush_SeparateVectorNode;
arm_node_brush_SeparateVectorNode.__name__ = "arm.node.brush.SeparateVectorNode";
arm_node_brush_SeparateVectorNode.__super__ = arm_node_LogicNode;
Object.assign(arm_node_brush_SeparateVectorNode.prototype, {
	__class__: arm_node_brush_SeparateVectorNode
});
class arm_node_brush_StringNode extends arm_node_LogicNode {
	constructor(tree,value) {
		if(value == null) {
			value = "";
		}
		super(tree);
		this.value = value;
	}
	get(from) {
		if(this.inputs.length > 0) {
			return this.inputs[0].get();
		}
		return this.value;
	}
	set(value) {
		if(this.inputs.length > 0) {
			this.inputs[0].set(value);
		} else {
			this.value = value;
		}
	}
}
$hxClasses["arm.node.brush.StringNode"] = arm_node_brush_StringNode;
arm_node_brush_StringNode.__name__ = "arm.node.brush.StringNode";
arm_node_brush_StringNode.__super__ = arm_node_LogicNode;
Object.assign(arm_node_brush_StringNode.prototype, {
	__class__: arm_node_brush_StringNode
});
class arm_node_brush_TEX_$IMAGE extends arm_node_LogicNode {
	constructor(tree) {
		super(tree);
	}
	get(from) {
		if(from == 0) {
			return this.file + ".rgb";
		}
		return this.file + ".a";
	}
}
$hxClasses["arm.node.brush.TEX_IMAGE"] = arm_node_brush_TEX_$IMAGE;
arm_node_brush_TEX_$IMAGE.__name__ = "arm.node.brush.TEX_IMAGE";
arm_node_brush_TEX_$IMAGE.__super__ = arm_node_LogicNode;
Object.assign(arm_node_brush_TEX_$IMAGE.prototype, {
	__class__: arm_node_brush_TEX_$IMAGE
});
class arm_node_brush_TimeNode extends arm_node_LogicNode {
	constructor(tree) {
		super(tree);
	}
	get(from) {
		if(from == 0) {
			return kha_Scheduler.time();
		} else if(from == 1) {
			return iron_system_Time.get_delta();
		} else {
			return arm_Context.brushTime;
		}
	}
}
$hxClasses["arm.node.brush.TimeNode"] = arm_node_brush_TimeNode;
arm_node_brush_TimeNode.__name__ = "arm.node.brush.TimeNode";
arm_node_brush_TimeNode.__super__ = arm_node_LogicNode;
Object.assign(arm_node_brush_TimeNode.prototype, {
	__class__: arm_node_brush_TimeNode
});
class arm_node_brush_VectorMathNode extends arm_node_LogicNode {
	constructor(tree) {
		arm_node_LogicNode._hx_skip_constructor = true;
		super();
		arm_node_LogicNode._hx_skip_constructor = false;
		this._hx_constructor(tree);
	}
	_hx_constructor(tree) {
		this.v = new iron_math_Vec4();
		super._hx_constructor(tree);
	}
	get(from) {
		let v1 = this.inputs[0].get();
		let v2 = this.inputs[1].get();
		let _this = this.v;
		_this.x = v1.x;
		_this.y = v1.y;
		_this.z = v1.z;
		_this.w = v1.w;
		let f = 0.0;
		switch(this.operation) {
		case "Absolute":
			this.v.x = Math.abs(this.v.x);
			this.v.y = Math.abs(this.v.y);
			this.v.z = Math.abs(this.v.z);
			break;
		case "Add":
			let _this1 = this.v;
			_this1.x += v2.x;
			_this1.y += v2.y;
			_this1.z += v2.z;
			break;
		case "Average":
			let _this2 = this.v;
			_this2.x += v2.x;
			_this2.y += v2.y;
			_this2.z += v2.z;
			this.v.x *= 0.5;
			this.v.y *= 0.5;
			this.v.z *= 0.5;
			break;
		case "Ceil":
			this.v.x = Math.ceil(v1.x);
			this.v.y = Math.ceil(v1.y);
			this.v.z = Math.ceil(v1.z);
			break;
		case "Cosine":
			this.v.x = Math.cos(v1.x);
			this.v.y = Math.cos(v1.y);
			this.v.z = Math.cos(v1.z);
			break;
		case "Cross Product":
			let _this3 = this.v;
			let ax = _this3.x;
			let ay = _this3.y;
			let az = _this3.z;
			let vx = v2.x;
			let vy = v2.y;
			let vz = v2.z;
			_this3.x = ay * vz - az * vy;
			_this3.y = az * vx - ax * vz;
			_this3.z = ax * vy - ay * vx;
			break;
		case "Distance":
			let _this4 = this.v;
			f = Math.sqrt((v2.x - _this4.x) * (v2.x - _this4.x) + (v2.y - _this4.y) * (v2.y - _this4.y) + (v2.z - _this4.z) * (v2.z - _this4.z));
			let _this5 = this.v;
			_this5.x = f;
			_this5.y = f;
			_this5.z = f;
			_this5.w = 1.0;
			break;
		case "Divide":
			this.v.x /= v2.x == 0.0 ? 0.000001 : v2.x;
			this.v.y /= v2.y == 0.0 ? 0.000001 : v2.y;
			this.v.z /= v2.z == 0.0 ? 0.000001 : v2.z;
			break;
		case "Dot Product":
			let _this6 = this.v;
			f = _this6.x * v2.x + _this6.y * v2.y + _this6.z * v2.z;
			let _this7 = this.v;
			_this7.x = f;
			_this7.y = f;
			_this7.z = f;
			_this7.w = 1.0;
			break;
		case "Floor":
			this.v.x = Math.floor(v1.x);
			this.v.y = Math.floor(v1.y);
			this.v.z = Math.floor(v1.z);
			break;
		case "Fraction":
			this.v.x = v1.x - Math.floor(v1.x);
			this.v.y = v1.y - Math.floor(v1.y);
			this.v.z = v1.z - Math.floor(v1.z);
			break;
		case "Length":
			let _this8 = this.v;
			f = Math.sqrt(_this8.x * _this8.x + _this8.y * _this8.y + _this8.z * _this8.z);
			let _this9 = this.v;
			_this9.x = f;
			_this9.y = f;
			_this9.z = f;
			_this9.w = 1.0;
			break;
		case "Maximum":
			this.v.x = Math.max(v1.x,v2.x);
			this.v.y = Math.max(v1.y,v2.y);
			this.v.z = Math.max(v1.z,v2.z);
			break;
		case "Minimum":
			this.v.x = Math.min(v1.x,v2.x);
			this.v.y = Math.min(v1.y,v2.y);
			this.v.z = Math.min(v1.z,v2.z);
			break;
		case "Modulo":
			this.v.x = v1.x % v2.x;
			this.v.y = v1.y % v2.y;
			this.v.z = v1.z % v2.z;
			break;
		case "Multiply":
			this.v.x *= v2.x;
			this.v.y *= v2.y;
			this.v.z *= v2.z;
			break;
		case "Normalize":
			let _this10 = this.v;
			let n = Math.sqrt(_this10.x * _this10.x + _this10.y * _this10.y + _this10.z * _this10.z);
			if(n > 0.0) {
				let invN = 1.0 / n;
				_this10.x *= invN;
				_this10.y *= invN;
				_this10.z *= invN;
			}
			break;
		case "Project":
			let _this11 = this.v;
			_this11.x = v2.x;
			_this11.y = v2.y;
			_this11.z = v2.z;
			_this11.w = v2.w;
			let _this12 = this.v;
			let f1 = (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z) / (v2.x * v2.x + v2.y * v2.y + v2.z * v2.z);
			_this12.x *= f1;
			_this12.y *= f1;
			_this12.z *= f1;
			break;
		case "Reflect":
			let tmp_x = 0.0;
			let tmp_y = 0.0;
			let tmp_z = 0.0;
			tmp_x = v2.x;
			tmp_y = v2.y;
			tmp_z = v2.z;
			let n1 = Math.sqrt(tmp_x * tmp_x + tmp_y * tmp_y + tmp_z * tmp_z);
			if(n1 > 0.0) {
				let invN = 1.0 / n1;
				tmp_x *= invN;
				tmp_y *= invN;
				tmp_z *= invN;
			}
			let _this13 = this.v;
			let d = 2 * (_this13.x * tmp_x + _this13.y * tmp_y + _this13.z * tmp_z);
			_this13.x -= d * tmp_x;
			_this13.y -= d * tmp_y;
			_this13.z -= d * tmp_z;
			break;
		case "Scale":
			this.v.x *= v2.x;
			this.v.y *= v2.x;
			this.v.z *= v2.x;
			break;
		case "Sine":
			this.v.x = Math.sin(v1.x);
			this.v.y = Math.sin(v1.y);
			this.v.z = Math.sin(v1.z);
			break;
		case "Snap":
			this.v.x = Math.floor(v1.x / v2.x) * v2.x;
			this.v.y = Math.floor(v1.y / v2.y) * v2.y;
			this.v.z = Math.floor(v1.z / v2.z) * v2.z;
			break;
		case "Subtract":
			let _this14 = this.v;
			_this14.x -= v2.x;
			_this14.y -= v2.y;
			_this14.z -= v2.z;
			break;
		case "Tangent":
			this.v.x = Math.tan(v1.x);
			this.v.y = Math.tan(v1.y);
			this.v.z = Math.tan(v1.z);
			break;
		}
		if(from == 0) {
			return this.v;
		} else {
			return f;
		}
	}
}
$hxClasses["arm.node.brush.VectorMathNode"] = arm_node_brush_VectorMathNode;
arm_node_brush_VectorMathNode.__name__ = "arm.node.brush.VectorMathNode";
arm_node_brush_VectorMathNode.__super__ = arm_node_LogicNode;
Object.assign(arm_node_brush_VectorMathNode.prototype, {
	__class__: arm_node_brush_VectorMathNode
});
class arm_node_brush_VectorNode extends arm_node_LogicNode {
	constructor(tree,x,y,z) {
		arm_node_LogicNode._hx_skip_constructor = true;
		super();
		arm_node_LogicNode._hx_skip_constructor = false;
		this._hx_constructor(tree,x,y,z);
	}
	_hx_constructor(tree,x,y,z) {
		this.value = new iron_math_Vec4();
		super._hx_constructor(tree);
		if(x != null) {
			this.addInput(new arm_node_brush_FloatNode(tree,x),0);
			this.addInput(new arm_node_brush_FloatNode(tree,y),0);
			this.addInput(new arm_node_brush_FloatNode(tree,z),0);
		}
	}
	get(from) {
		this.value.x = this.inputs[0].get();
		this.value.y = this.inputs[1].get();
		this.value.z = this.inputs[2].get();
		return this.value;
	}
	set(value) {
		this.inputs[0].set(value.x);
		this.inputs[1].set(value.y);
		this.inputs[2].set(value.z);
	}
}
$hxClasses["arm.node.brush.VectorNode"] = arm_node_brush_VectorNode;
arm_node_brush_VectorNode.__name__ = "arm.node.brush.VectorNode";
arm_node_brush_VectorNode.__super__ = arm_node_LogicNode;
Object.assign(arm_node_brush_VectorNode.prototype, {
	__class__: arm_node_brush_VectorNode
});
class iron_math_Quat {
	constructor(x,y,z,w) {
		if(w == null) {
			w = 1.0;
		}
		if(z == null) {
			z = 0.0;
		}
		if(y == null) {
			y = 0.0;
		}
		if(x == null) {
			x = 0.0;
		}
		this.x = x;
		this.y = y;
		this.z = z;
		this.w = w;
	}
}
$hxClasses["iron.math.Quat"] = iron_math_Quat;
iron_math_Quat.__name__ = "iron.math.Quat";
Object.assign(iron_math_Quat.prototype, {
	__class__: iron_math_Quat
});
class arm_plugin_PhysicsBody extends iron_Trait {
	constructor() {
		iron_Trait._hx_skip_constructor = true;
		super();
		iron_Trait._hx_skip_constructor = false;
		this._hx_constructor();
	}
	_hx_constructor() {
		this.heightData = null;
		this.id = 0;
		this.ready = false;
		this.body = null;
		this.destroyed = false;
		this.shape = 0;
		this.mask = 1;
		this.group = 1;
		this.trigger = false;
		this.ccd = false;
		this.angularFactors = [1.0,1.0,1.0];
		this.linearFactors = [1.0,1.0,1.0];
		this.angularDamping = 0.1;
		this.linearDamping = 0.04;
		this.collisionMargin = 0.0;
		this.restitution = 0.0;
		this.friction = 0.5;
		this.mass = 0.0;
		this.props = ["mass"];
		super._hx_constructor();
		if(arm_plugin_PhysicsBody.first) {
			arm_plugin_PhysicsBody.first = false;
			arm_plugin_PhysicsBody.vec1 = new Ammo.btVector3(0,0,0);
			arm_plugin_PhysicsBody.vec2 = new Ammo.btVector3(0,0,0);
			arm_plugin_PhysicsBody.vec3 = new Ammo.btVector3(0,0,0);
			arm_plugin_PhysicsBody.quat1 = new Ammo.btQuaternion(0,0,0,0);
			arm_plugin_PhysicsBody.trans1 = new Ammo.btTransform();
			arm_plugin_PhysicsBody.trans2 = new Ammo.btTransform();
		}
		this.notifyOnAdd($bind(this,this.init));
	}
	set_mass(f) {
		if(this.ready) {
			this.remove();
			let t = new arm_plugin_PhysicsBody();
			t.set_mass(f);
			this.object.addTrait(t);
		} else {
			this.mass = f;
		}
		return f;
	}
	init() {
		if(this.ready) {
			return;
		}
		this.ready = true;
		if(!((this.object) instanceof iron_object_MeshObject)) {
			return;
		}
		let transform = this.object.transform;
		let physics = arm_plugin_PhysicsWorld.active;
		if(this.shape == 0) {
			let f = transform.dim.x / 2;
			arm_plugin_PhysicsBody.vec1.setX(f - f * this.collisionMargin);
			let f1 = transform.dim.y / 2;
			arm_plugin_PhysicsBody.vec1.setY(f1 - f1 * this.collisionMargin);
			let f2 = transform.dim.z / 2;
			arm_plugin_PhysicsBody.vec1.setZ(f2 - f2 * this.collisionMargin);
			this.btshape = new Ammo.btBoxShape(arm_plugin_PhysicsBody.vec1);
		} else if(this.shape == 1) {
			let f = transform.dim.x / 2;
			this.btshape = new Ammo.btSphereShape(f - f * this.collisionMargin);
		} else if(this.shape == 2) {
			let shapeConvex = this.fillConvexHull(transform.scale,this.collisionMargin);
			this.btshape = shapeConvex;
		} else if(this.shape == 4) {
			let f = transform.dim.x / 2;
			let f1 = transform.dim.z;
			let coneZ = new Ammo.btConeShapeZ(f - f * this.collisionMargin,f1 - f1 * this.collisionMargin);
			let cone = coneZ;
			this.btshape = cone;
		} else if(this.shape == 5) {
			let f = transform.dim.x / 2;
			arm_plugin_PhysicsBody.vec1.setX(f - f * this.collisionMargin);
			let f1 = transform.dim.y / 2;
			arm_plugin_PhysicsBody.vec1.setY(f1 - f1 * this.collisionMargin);
			let f2 = transform.dim.z / 2;
			arm_plugin_PhysicsBody.vec1.setZ(f2 - f2 * this.collisionMargin);
			let cylZ = new Ammo.btCylinderShapeZ(arm_plugin_PhysicsBody.vec1);
			let cyl = cylZ;
			this.btshape = cyl;
		} else if(this.shape == 6) {
			let r = transform.dim.x / 2;
			let f = transform.dim.z - r * 2;
			let capsZ = new Ammo.btCapsuleShapeZ(r - r * this.collisionMargin,f - f * this.collisionMargin);
			let caps = capsZ;
			this.btshape = caps;
		} else if(this.shape == 3) {
			let meshInterface = this.fillTriangleMesh(transform.scale);
			if(this.mass > 0) {
				let shapeGImpact = new Ammo.btGImpactMeshShape(meshInterface);
				shapeGImpact.updateBound();
				let shapeConcave = shapeGImpact;
				this.btshape = shapeConcave;
				if(!arm_plugin_PhysicsBody.gimpactRegistered) {
					arm_plugin_PhysicsBody.gimpactRegistered = true;
					new Ammo.GImpactCollisionAlgorithm().registerAlgorithm(physics.dispatcher);
				}
			} else {
				let shapeBvh = new Ammo.btBvhTriangleMeshShape(meshInterface,true,true);
				let shapeTri = shapeBvh;
				let shapeConcave = shapeTri;
				this.btshape = shapeConcave;
			}
		} else if(this.shape == 7) {
			let length = this.heightData.length;
			if(arm_plugin_PhysicsBody.ammoArray == -1) {
				arm_plugin_PhysicsBody.ammoArray = Ammo._malloc(length);
			}
			let _g = 0;
			let _g1 = length;
			while(_g < _g1) {
				let i = _g++;
				Ammo.HEAPU8[arm_plugin_PhysicsBody.ammoArray + i] = this.heightData.b[i];
			}
			let slice = Math.sqrt(length) | 0;
			let axis = 2;
			let dataType = 5;
			this.btshape = new Ammo.btHeightfieldTerrainShape(slice,slice,arm_plugin_PhysicsBody.ammoArray,0.00392156862745098,0,1,axis,dataType,false);
			arm_plugin_PhysicsBody.vec1.setX(transform.dim.x / slice);
			arm_plugin_PhysicsBody.vec1.setY(transform.dim.y / slice);
			arm_plugin_PhysicsBody.vec1.setZ(transform.dim.z);
			this.btshape.setLocalScaling(arm_plugin_PhysicsBody.vec1);
		}
		arm_plugin_PhysicsBody.trans1.setIdentity();
		arm_plugin_PhysicsBody.vec1.setX(transform.world.self._30);
		arm_plugin_PhysicsBody.vec1.setY(transform.world.self._31);
		arm_plugin_PhysicsBody.vec1.setZ(transform.world.self._32);
		arm_plugin_PhysicsBody.trans1.setOrigin(arm_plugin_PhysicsBody.vec1);
		let _this = arm_plugin_PhysicsBody.quat;
		let m = transform.world;
		let _this1 = iron_math_Quat.helpMat;
		_this1.self._00 = m.self._00;
		_this1.self._01 = m.self._01;
		_this1.self._02 = m.self._02;
		_this1.self._03 = m.self._03;
		_this1.self._10 = m.self._10;
		_this1.self._11 = m.self._11;
		_this1.self._12 = m.self._12;
		_this1.self._13 = m.self._13;
		_this1.self._20 = m.self._20;
		_this1.self._21 = m.self._21;
		_this1.self._22 = m.self._22;
		_this1.self._23 = m.self._23;
		_this1.self._30 = m.self._30;
		_this1.self._31 = m.self._31;
		_this1.self._32 = m.self._32;
		_this1.self._33 = m.self._33;
		let _this2 = iron_math_Quat.helpMat;
		let _this3 = iron_math_Mat4.helpVec;
		_this3.x = _this2.self._00;
		_this3.y = _this2.self._01;
		_this3.z = _this2.self._02;
		_this3.w = 1.0;
		let _this4 = _this3;
		let scale = 1.0 / Math.sqrt(_this4.x * _this4.x + _this4.y * _this4.y + _this4.z * _this4.z);
		_this2.self._00 *= scale;
		_this2.self._01 *= scale;
		_this2.self._02 *= scale;
		let _this5 = iron_math_Mat4.helpVec;
		_this5.x = _this2.self._10;
		_this5.y = _this2.self._11;
		_this5.z = _this2.self._12;
		_this5.w = 1.0;
		let _this6 = _this5;
		scale = 1.0 / Math.sqrt(_this6.x * _this6.x + _this6.y * _this6.y + _this6.z * _this6.z);
		_this2.self._10 *= scale;
		_this2.self._11 *= scale;
		_this2.self._12 *= scale;
		let _this7 = iron_math_Mat4.helpVec;
		_this7.x = _this2.self._20;
		_this7.y = _this2.self._21;
		_this7.z = _this2.self._22;
		_this7.w = 1.0;
		let _this8 = _this7;
		scale = 1.0 / Math.sqrt(_this8.x * _this8.x + _this8.y * _this8.y + _this8.z * _this8.z);
		_this2.self._20 *= scale;
		_this2.self._21 *= scale;
		_this2.self._22 *= scale;
		_this2.self._03 = 0.0;
		_this2.self._13 = 0.0;
		_this2.self._23 = 0.0;
		_this2.self._30 = 0.0;
		_this2.self._31 = 0.0;
		_this2.self._32 = 0.0;
		_this2.self._33 = 1.0;
		let m1 = iron_math_Quat.helpMat;
		let m11 = m1.self._00;
		let m12 = m1.self._10;
		let m13 = m1.self._20;
		let m21 = m1.self._01;
		let m22 = m1.self._11;
		let m23 = m1.self._21;
		let m31 = m1.self._02;
		let m32 = m1.self._12;
		let m33 = m1.self._22;
		let tr = m11 + m22 + m33;
		let s = 0.0;
		if(tr > 0) {
			s = 0.5 / Math.sqrt(tr + 1.0);
			_this.w = 0.25 / s;
			_this.x = (m32 - m23) * s;
			_this.y = (m13 - m31) * s;
			_this.z = (m21 - m12) * s;
		} else if(m11 > m22 && m11 > m33) {
			s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
			_this.w = (m32 - m23) / s;
			_this.x = 0.25 * s;
			_this.y = (m12 + m21) / s;
			_this.z = (m13 + m31) / s;
		} else if(m22 > m33) {
			s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
			_this.w = (m13 - m31) / s;
			_this.x = (m12 + m21) / s;
			_this.y = 0.25 * s;
			_this.z = (m23 + m32) / s;
		} else {
			s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
			_this.w = (m21 - m12) / s;
			_this.x = (m13 + m31) / s;
			_this.y = (m23 + m32) / s;
			_this.z = 0.25 * s;
		}
		arm_plugin_PhysicsBody.quat1.setValue(arm_plugin_PhysicsBody.quat.x,arm_plugin_PhysicsBody.quat.y,arm_plugin_PhysicsBody.quat.z,arm_plugin_PhysicsBody.quat.w);
		arm_plugin_PhysicsBody.trans1.setRotation(arm_plugin_PhysicsBody.quat1);
		arm_plugin_PhysicsBody.trans2.setIdentity();
		this.motionState = new Ammo.btDefaultMotionState(arm_plugin_PhysicsBody.trans1,arm_plugin_PhysicsBody.trans2);
		arm_plugin_PhysicsBody.vec1.setX(0);
		arm_plugin_PhysicsBody.vec1.setY(0);
		arm_plugin_PhysicsBody.vec1.setZ(0);
		let inertia = arm_plugin_PhysicsBody.vec1;
		if(this.mass > 0) {
			this.btshape.calculateLocalInertia(this.mass,inertia);
		}
		let bodyCI = new Ammo.btRigidBodyConstructionInfo(this.mass,this.motionState,this.btshape,inertia);
		this.body = new Ammo.btRigidBody(bodyCI);
		this.body.setFriction(this.friction);
		if(this.shape == 1 || this.shape == 5 || this.shape == 4 || this.shape == 6) {
			this.angularDamping += this.friction;
		}
		this.body.setRestitution(this.restitution);
		this.body.setDamping(this.linearDamping,this.angularDamping);
		this.setLinearFactor(this.linearFactors[0],this.linearFactors[1],this.linearFactors[2]);
		this.setAngularFactor(this.angularFactors[0],this.angularFactors[1],this.angularFactors[2]);
		if(this.trigger) {
			this.body.setCollisionFlags(this.body.getCollisionFlags() | 4);
		}
		if(this.mass == 0.0) {
			this.body.setCollisionFlags(this.body.getCollisionFlags() | 1);
		}
		if(this.ccd) {
			this.setCcd(transform.radius);
		}
		this.bodyScaleX = this.currentScaleX = transform.scale.x;
		this.bodyScaleY = this.currentScaleY = transform.scale.y;
		this.bodyScaleZ = this.currentScaleZ = transform.scale.z;
		this.id = arm_plugin_PhysicsBody.nextId++;
		this.body.userIndex = this.id;
		physics.addBody(this);
		this.notifyOnRemove($bind(this,this.removeFromWorld));
		Ammo.destroy(bodyCI);
	}
	physicsUpdate() {
		if(!this.ready) {
			return;
		}
		let trans = this.body.getWorldTransform();
		let p = trans.getOrigin();
		let qw = trans.getRotation();
		let transform = this.object.transform;
		let _this = transform.loc;
		let x = p.x();
		let y = p.y();
		let z = p.z();
		_this.x = x;
		_this.y = y;
		_this.z = z;
		_this.w = 1.0;
		let _this1 = transform.rot;
		let x1 = qw.x();
		let y1 = qw.y();
		let z1 = qw.z();
		let w = qw.w();
		_this1.x = x1;
		_this1.y = y1;
		_this1.z = z1;
		_this1.w = w;
		if(this.object.parent != null) {
			let ptransform = this.object.parent.transform;
			transform.loc.x -= ptransform.world.self._30;
			transform.loc.y -= ptransform.world.self._31;
			transform.loc.z -= ptransform.world.self._32;
		}
		transform.buildMatrix();
	}
	removeFromWorld() {
		arm_plugin_PhysicsWorld.active.removeBody(this);
	}
	activate() {
		this.body.activate(false);
	}
	setLinearFactor(x,y,z) {
		arm_plugin_PhysicsBody.vec1.setValue(x,y,z);
		this.body.setLinearFactor(arm_plugin_PhysicsBody.vec1);
	}
	setAngularFactor(x,y,z) {
		arm_plugin_PhysicsBody.vec1.setValue(x,y,z);
		this.body.setAngularFactor(arm_plugin_PhysicsBody.vec1);
	}
	setScale(v) {
		this.currentScaleX = v.x;
		this.currentScaleY = v.y;
		this.currentScaleZ = v.z;
		arm_plugin_PhysicsBody.vec1.setX(v.x / this.bodyScaleX);
		arm_plugin_PhysicsBody.vec1.setY(v.y / this.bodyScaleY);
		arm_plugin_PhysicsBody.vec1.setZ(v.z / this.bodyScaleZ);
		this.btshape.setLocalScaling(arm_plugin_PhysicsBody.vec1);
		arm_plugin_PhysicsWorld.active.world.updateSingleAabb(this.body);
	}
	syncTransform() {
		let t = this.object.transform;
		t.buildMatrix();
		arm_plugin_PhysicsBody.vec1.setValue(t.world.self._30,t.world.self._31,t.world.self._32);
		arm_plugin_PhysicsBody.trans1.setOrigin(arm_plugin_PhysicsBody.vec1);
		let _this = arm_plugin_PhysicsBody.quat;
		let m = t.world;
		let _this1 = iron_math_Quat.helpMat;
		_this1.self._00 = m.self._00;
		_this1.self._01 = m.self._01;
		_this1.self._02 = m.self._02;
		_this1.self._03 = m.self._03;
		_this1.self._10 = m.self._10;
		_this1.self._11 = m.self._11;
		_this1.self._12 = m.self._12;
		_this1.self._13 = m.self._13;
		_this1.self._20 = m.self._20;
		_this1.self._21 = m.self._21;
		_this1.self._22 = m.self._22;
		_this1.self._23 = m.self._23;
		_this1.self._30 = m.self._30;
		_this1.self._31 = m.self._31;
		_this1.self._32 = m.self._32;
		_this1.self._33 = m.self._33;
		let _this2 = iron_math_Quat.helpMat;
		let _this3 = iron_math_Mat4.helpVec;
		_this3.x = _this2.self._00;
		_this3.y = _this2.self._01;
		_this3.z = _this2.self._02;
		_this3.w = 1.0;
		let scale = 1.0 / Math.sqrt(_this3.x * _this3.x + _this3.y * _this3.y + _this3.z * _this3.z);
		_this2.self._00 *= scale;
		_this2.self._01 *= scale;
		_this2.self._02 *= scale;
		let _this4 = iron_math_Mat4.helpVec;
		_this4.x = _this2.self._10;
		_this4.y = _this2.self._11;
		_this4.z = _this2.self._12;
		_this4.w = 1.0;
		scale = 1.0 / Math.sqrt(_this4.x * _this4.x + _this4.y * _this4.y + _this4.z * _this4.z);
		_this2.self._10 *= scale;
		_this2.self._11 *= scale;
		_this2.self._12 *= scale;
		let _this5 = iron_math_Mat4.helpVec;
		_this5.x = _this2.self._20;
		_this5.y = _this2.self._21;
		_this5.z = _this2.self._22;
		_this5.w = 1.0;
		scale = 1.0 / Math.sqrt(_this5.x * _this5.x + _this5.y * _this5.y + _this5.z * _this5.z);
		_this2.self._20 *= scale;
		_this2.self._21 *= scale;
		_this2.self._22 *= scale;
		_this2.self._03 = 0.0;
		_this2.self._13 = 0.0;
		_this2.self._23 = 0.0;
		_this2.self._30 = 0.0;
		_this2.self._31 = 0.0;
		_this2.self._32 = 0.0;
		_this2.self._33 = 1.0;
		let m1 = iron_math_Quat.helpMat;
		let m11 = m1.self._00;
		let m12 = m1.self._10;
		let m13 = m1.self._20;
		let m21 = m1.self._01;
		let m22 = m1.self._11;
		let m23 = m1.self._21;
		let m31 = m1.self._02;
		let m32 = m1.self._12;
		let m33 = m1.self._22;
		let tr = m11 + m22 + m33;
		let s = 0.0;
		if(tr > 0) {
			s = 0.5 / Math.sqrt(tr + 1.0);
			_this.w = 0.25 / s;
			_this.x = (m32 - m23) * s;
			_this.y = (m13 - m31) * s;
			_this.z = (m21 - m12) * s;
		} else if(m11 > m22 && m11 > m33) {
			s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
			_this.w = (m32 - m23) / s;
			_this.x = 0.25 * s;
			_this.y = (m12 + m21) / s;
			_this.z = (m13 + m31) / s;
		} else if(m22 > m33) {
			s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
			_this.w = (m13 - m31) / s;
			_this.x = (m12 + m21) / s;
			_this.y = 0.25 * s;
			_this.z = (m23 + m32) / s;
		} else {
			s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
			_this.w = (m21 - m12) / s;
			_this.x = (m13 + m31) / s;
			_this.y = (m23 + m32) / s;
			_this.z = 0.25 * s;
		}
		arm_plugin_PhysicsBody.quat1.setValue(arm_plugin_PhysicsBody.quat.x,arm_plugin_PhysicsBody.quat.y,arm_plugin_PhysicsBody.quat.z,arm_plugin_PhysicsBody.quat.w);
		arm_plugin_PhysicsBody.trans1.setRotation(arm_plugin_PhysicsBody.quat1);
		this.body.setWorldTransform(arm_plugin_PhysicsBody.trans1);
		if(this.currentScaleX != t.scale.x || this.currentScaleY != t.scale.y || this.currentScaleZ != t.scale.z) {
			this.setScale(t.scale);
		}
		this.activate();
	}
	setCcd(sphereRadius,motionThreshold) {
		if(motionThreshold == null) {
			motionThreshold = 1e-7;
		}
		this.body.setCcdSweptSphereRadius(sphereRadius);
		this.body.setCcdMotionThreshold(motionThreshold);
	}
	fillConvexHull(scale,margin) {
		let data = (js_Boot.__cast(this.object , iron_object_MeshObject)).data;
		let shape = arm_plugin_PhysicsBody.convexHullCache.h[data.__id__];
		if(shape != null) {
			arm_plugin_PhysicsBody.usersCache.set(data,arm_plugin_PhysicsBody.usersCache.h[data.__id__] + 1);
			return shape;
		}
		shape = new Ammo.btConvexHullShape();
		arm_plugin_PhysicsBody.convexHullCache.set(data,shape);
		arm_plugin_PhysicsBody.usersCache.set(data,1);
		let positions = data.geom.positions.values;
		let sx = scale.x * (1.0 - margin) * 3.0518509475997192e-005;
		let sy = scale.y * (1.0 - margin) * 3.0518509475997192e-005;
		let sz = scale.z * (1.0 - margin) * 3.0518509475997192e-005;
		if(data.raw.scale_pos != null) {
			sx *= data.raw.scale_pos;
			sy *= data.raw.scale_pos;
			sz *= data.raw.scale_pos;
		}
		let _g = 0;
		let _g1 = positions.length / 4 | 0;
		while(_g < _g1) {
			let i = _g++;
			arm_plugin_PhysicsBody.vec1.setX(positions[i * 4] * sx);
			arm_plugin_PhysicsBody.vec1.setY(positions[i * 4 + 1] * sy);
			arm_plugin_PhysicsBody.vec1.setZ(positions[i * 4 + 2] * sz);
			shape.addPoint(arm_plugin_PhysicsBody.vec1,true);
		}
		return shape;
	}
	fillTriangleMesh(scale) {
		let data = (js_Boot.__cast(this.object , iron_object_MeshObject)).data;
		let triangleMesh = arm_plugin_PhysicsBody.triangleMeshCache.h[data.__id__];
		if(triangleMesh != null) {
			arm_plugin_PhysicsBody.usersCache.set(data,arm_plugin_PhysicsBody.usersCache.h[data.__id__] + 1);
			return triangleMesh;
		}
		triangleMesh = new Ammo.btTriangleMesh(true,true);
		arm_plugin_PhysicsBody.triangleMeshCache.set(data,triangleMesh);
		arm_plugin_PhysicsBody.usersCache.set(data,1);
		let positions = data.geom.positions.values;
		let indices = data.geom.indices;
		let sx = scale.x * 3.0518509475997192e-005;
		let sy = scale.y * 3.0518509475997192e-005;
		let sz = scale.z * 3.0518509475997192e-005;
		if(data.raw.scale_pos != null) {
			sx *= data.raw.scale_pos;
			sy *= data.raw.scale_pos;
			sz *= data.raw.scale_pos;
		}
		let _g = 0;
		while(_g < indices.length) {
			let ar = indices[_g];
			++_g;
			let _g1 = 0;
			let _g2 = ar.length / 3 | 0;
			while(_g1 < _g2) {
				let i = _g1++;
				arm_plugin_PhysicsBody.vec1.setX(positions[ar[i * 3] * 4] * sx);
				arm_plugin_PhysicsBody.vec1.setY(positions[ar[i * 3] * 4 + 1] * sy);
				arm_plugin_PhysicsBody.vec1.setZ(positions[ar[i * 3] * 4 + 2] * sz);
				arm_plugin_PhysicsBody.vec2.setX(positions[ar[i * 3 + 1] * 4] * sx);
				arm_plugin_PhysicsBody.vec2.setY(positions[ar[i * 3 + 1] * 4 + 1] * sy);
				arm_plugin_PhysicsBody.vec2.setZ(positions[ar[i * 3 + 1] * 4 + 2] * sz);
				arm_plugin_PhysicsBody.vec3.setX(positions[ar[i * 3 + 2] * 4] * sx);
				arm_plugin_PhysicsBody.vec3.setY(positions[ar[i * 3 + 2] * 4 + 1] * sy);
				arm_plugin_PhysicsBody.vec3.setZ(positions[ar[i * 3 + 2] * 4 + 2] * sz);
				triangleMesh.addTriangle(arm_plugin_PhysicsBody.vec1,arm_plugin_PhysicsBody.vec2,arm_plugin_PhysicsBody.vec3);
			}
		}
		return triangleMesh;
	}
	delete() {
		Ammo.destroy(this.motionState);
		Ammo.destroy(this.body);
		if(this.shape == 2 || this.shape == 3) {
			let data = (js_Boot.__cast(this.object , iron_object_MeshObject)).data;
			let i = arm_plugin_PhysicsBody.usersCache.h[data.__id__] - 1;
			arm_plugin_PhysicsBody.usersCache.set(data,i);
			if(i <= 0) {
				Ammo.destroy(this.btshape);
				if(this.shape == 2) {
					arm_plugin_PhysicsBody.convexHullCache.remove(data);
				} else {
					arm_plugin_PhysicsBody.triangleMeshCache.remove(data);
				}
			}
		} else {
			Ammo.destroy(this.btshape);
		}
	}
}
$hxClasses["arm.plugin.PhysicsBody"] = arm_plugin_PhysicsBody;
arm_plugin_PhysicsBody.__name__ = "arm.plugin.PhysicsBody";
arm_plugin_PhysicsBody.__super__ = iron_Trait;
Object.assign(arm_plugin_PhysicsBody.prototype, {
	__class__: arm_plugin_PhysicsBody
	,__properties__: {set_mass: "set_mass"}
});
class arm_plugin_PhysicsWorld extends iron_Trait {
	constructor() {
		iron_Trait._hx_skip_constructor = true;
		super();
		iron_Trait._hx_skip_constructor = false;
		this._hx_constructor();
	}
	_hx_constructor() {
		this.maxSteps = 1;
		this.timeStep = 0.016666666666666666;
		this.timeScale = 1.0;
		this.bodyMap = new haxe_ds_IntMap();
		this.contacts = [];
		super._hx_constructor();
		arm_plugin_PhysicsWorld.active = this;
		arm_plugin_PhysicsWorld.vec1 = new Ammo.btVector3(0,0,0);
		arm_plugin_PhysicsWorld.vec2 = new Ammo.btVector3(0,0,0);
		this.init();
		this._lateUpdate = [$bind(this,this.lateUpdate)];
		iron_App.traitLateUpdates.splice(0,0,$bind(this,this.lateUpdate));
	}
	init() {
		let broadphase = new Ammo.btDbvtBroadphase();
		let collisionConfiguration = new Ammo.btDefaultCollisionConfiguration();
		this.dispatcher = new Ammo.btCollisionDispatcher(collisionConfiguration);
		let solver = new Ammo.btSequentialImpulseConstraintSolver();
		this.world = new Ammo.btDiscreteDynamicsWorld(this.dispatcher,broadphase,solver,collisionConfiguration);
		this.setGravity(new iron_math_Vec4(0,0,-9.81));
	}
	setGravity(v) {
		arm_plugin_PhysicsWorld.vec1.setValue(v.x,v.y,v.z);
		this.world.setGravity(arm_plugin_PhysicsWorld.vec1);
	}
	addBody(pb) {
		this.world.addRigidBody(pb.body,pb.group,pb.mask);
		this.bodyMap.h[pb.id] = pb;
	}
	removeBody(pb) {
		if(pb.destroyed) {
			return;
		}
		pb.destroyed = true;
		if(this.world != null) {
			this.world.removeRigidBody(pb.body);
		}
		this.bodyMap.remove(pb.id);
		pb.delete();
	}
	lateUpdate() {
		let t = iron_system_Time.get_delta() * this.timeScale;
		if(t == 0.0) {
			return;
		}
		this.world.stepSimulation(this.timeStep,this.maxSteps,t);
		this.updateContacts();
		let body = this.bodyMap.iterator();
		while(body.hasNext()) body.next().physicsUpdate();
	}
	updateContacts() {
		this.contacts = [];
		let disp = this.dispatcher;
		let numManifolds = disp.getNumManifolds();
		let _g = 0;
		let _g1 = numManifolds;
		while(_g < _g1) {
			let i = _g++;
			let contactManifold = disp.getManifoldByIndexInternal(i);
			let body0 = Ammo.btRigidBody.prototype;
			let body01 = contactManifold.getBody0();
			let body02 = body0.upcast(body01);
			let body1 = Ammo.btRigidBody.prototype;
			let body11 = contactManifold.getBody1();
			let body12 = body1.upcast(body11);
			let numContacts = contactManifold.getNumContacts();
			let pt = null;
			let posA = null;
			let posB = null;
			let nor = null;
			let _g1 = 0;
			let _g2 = numContacts;
			while(_g1 < _g2) {
				let j = _g1++;
				pt = contactManifold.getContactPoint(j);
				posA = pt.get_m_positionWorldOnA();
				posB = pt.get_m_positionWorldOnB();
				nor = pt.get_m_normalWorldOnB();
				let cp = { a : body02.userIndex, b : body12.userIndex, posA : new iron_math_Vec4(posA.x(),posA.y(),posA.z()), posB : new iron_math_Vec4(posB.x(),posB.y(),posB.z()), normOnB : new iron_math_Vec4(nor.x(),nor.y(),nor.z()), impulse : pt.getAppliedImpulse(), distance : pt.getDistance()};
				this.contacts.push(cp);
			}
		}
	}
}
$hxClasses["arm.plugin.PhysicsWorld"] = arm_plugin_PhysicsWorld;
arm_plugin_PhysicsWorld.__name__ = "arm.plugin.PhysicsWorld";
arm_plugin_PhysicsWorld.__super__ = iron_Trait;
Object.assign(arm_plugin_PhysicsWorld.prototype, {
	__class__: arm_plugin_PhysicsWorld
});
class arm_render_Gizmo {
	static update() {
		let isObject = arm_Context.tool == 10;
		let isDecal = arm_App.isDecalLayer();
		let gizmo = arm_Context.gizmo;
		let hide = arm_Operator.shortcut(arm_Config.keymap.stencil_hide,2);
		gizmo.visible = (isObject || isDecal) && !hide;
		if(!gizmo.visible) {
			return;
		}
		let mouse = iron_system_Input.getMouse();
		iron_system_Input.getKeyboard();
		if(isObject) {
			let _this = gizmo.transform.loc;
			let v = arm_Context.paintObject.transform.loc;
			_this.x = v.x;
			_this.y = v.y;
			_this.z = v.z;
			_this.w = v.w;
		} else if(isDecal) {
			let _this = gizmo.transform.loc;
			_this.x = arm_Context.layer.decalMat.self._30;
			_this.y = arm_Context.layer.decalMat.self._31;
			_this.z = arm_Context.layer.decalMat.self._32;
			_this.w = 1.0;
		}
		let cam = iron_Scene.active.camera;
		let v1 = cam.transform.loc;
		let v2 = gizmo.transform.loc;
		let vx = v1.x - v2.x;
		let vy = v1.y - v2.y;
		let vz = v1.z - v2.z;
		let dist = Math.sqrt(vx * vx + vy * vy + vz * vz) / 8 * cam.data.raw.fov;
		let _this = gizmo.transform.scale;
		_this.x = dist;
		_this.y = dist;
		_this.z = dist;
		_this.w = 1.0;
		let _this1 = arm_Context.gizmoTranslateX.transform.scale;
		_this1.x = dist;
		_this1.y = dist;
		_this1.z = dist;
		_this1.w = 1.0;
		let _this2 = arm_Context.gizmoTranslateY.transform.scale;
		_this2.x = dist;
		_this2.y = dist;
		_this2.z = dist;
		_this2.w = 1.0;
		let _this3 = arm_Context.gizmoTranslateZ.transform.scale;
		_this3.x = dist;
		_this3.y = dist;
		_this3.z = dist;
		_this3.w = 1.0;
		let _this4 = arm_Context.gizmoScaleX.transform.scale;
		_this4.x = dist;
		_this4.y = dist;
		_this4.z = dist;
		_this4.w = 1.0;
		let _this5 = arm_Context.gizmoScaleY.transform.scale;
		_this5.x = dist;
		_this5.y = dist;
		_this5.z = dist;
		_this5.w = 1.0;
		let _this6 = arm_Context.gizmoScaleZ.transform.scale;
		_this6.x = dist;
		_this6.y = dist;
		_this6.z = dist;
		_this6.w = 1.0;
		let _this7 = arm_Context.gizmoRotateX.transform.scale;
		_this7.x = dist;
		_this7.y = dist;
		_this7.z = dist;
		_this7.w = 1.0;
		let _this8 = arm_Context.gizmoRotateY.transform.scale;
		_this8.x = dist;
		_this8.y = dist;
		_this8.z = dist;
		_this8.w = 1.0;
		let _this9 = arm_Context.gizmoRotateZ.transform.scale;
		_this9.x = dist;
		_this9.y = dist;
		_this9.z = dist;
		_this9.w = 1.0;
		gizmo.transform.buildMatrix();
		if(isObject) {
			if(arm_Context.translateX || arm_Context.translateY || arm_Context.translateZ || arm_Context.scaleX || arm_Context.scaleY || arm_Context.scaleZ || arm_Context.rotateX || arm_Context.rotateY || arm_Context.rotateZ) {
				if(arm_Context.translateX) {
					arm_Context.paintObject.transform.loc.x = arm_Context.gizmoDrag;
				} else if(arm_Context.translateY) {
					arm_Context.paintObject.transform.loc.y = arm_Context.gizmoDrag;
				} else if(arm_Context.translateZ) {
					arm_Context.paintObject.transform.loc.z = arm_Context.gizmoDrag;
				} else if(arm_Context.scaleX) {
					arm_Context.paintObject.transform.scale.x += arm_Context.gizmoDrag - arm_Context.gizmoDragLast;
				} else if(arm_Context.scaleY) {
					arm_Context.paintObject.transform.scale.y += arm_Context.gizmoDrag - arm_Context.gizmoDragLast;
				} else if(arm_Context.scaleZ) {
					arm_Context.paintObject.transform.scale.z += arm_Context.gizmoDrag - arm_Context.gizmoDragLast;
				} else if(arm_Context.rotateX) {
					let _this = arm_render_Gizmo.q0;
					let angle = arm_Context.gizmoDrag - arm_Context.gizmoDragLast;
					let s = Math.sin(angle * 0.5);
					_this.x = s;
					_this.y = 0.0 * s;
					_this.z = 0.0 * s;
					_this.w = Math.cos(angle * 0.5);
					let l = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z + _this.w * _this.w);
					if(l == 0.0) {
						_this.x = 0;
						_this.y = 0;
						_this.z = 0;
						_this.w = 0;
					} else {
						l = 1.0 / l;
						_this.x *= l;
						_this.y *= l;
						_this.z *= l;
						_this.w *= l;
					}
					let _this1 = arm_Context.paintObject.transform.rot;
					let q = arm_render_Gizmo.q0;
					let q1x = _this1.x;
					let q1y = _this1.y;
					let q1z = _this1.z;
					let q1w = _this1.w;
					let q2x = q.x;
					let q2y = q.y;
					let q2z = q.z;
					let q2w = q.w;
					_this1.x = q1x * q2w + q1w * q2x + q1y * q2z - q1z * q2y;
					_this1.y = q1w * q2y - q1x * q2z + q1y * q2w + q1z * q2x;
					_this1.z = q1w * q2z + q1x * q2y - q1y * q2x + q1z * q2w;
					_this1.w = q1w * q2w - q1x * q2x - q1y * q2y - q1z * q2z;
				} else if(arm_Context.rotateY) {
					let _this = arm_render_Gizmo.q0;
					let angle = arm_Context.gizmoDrag - arm_Context.gizmoDragLast;
					let s = Math.sin(angle * 0.5);
					_this.x = 0.0 * s;
					_this.y = s;
					_this.z = 0.0 * s;
					_this.w = Math.cos(angle * 0.5);
					let l = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z + _this.w * _this.w);
					if(l == 0.0) {
						_this.x = 0;
						_this.y = 0;
						_this.z = 0;
						_this.w = 0;
					} else {
						l = 1.0 / l;
						_this.x *= l;
						_this.y *= l;
						_this.z *= l;
						_this.w *= l;
					}
					let _this1 = arm_Context.paintObject.transform.rot;
					let q = arm_render_Gizmo.q0;
					let q1x = _this1.x;
					let q1y = _this1.y;
					let q1z = _this1.z;
					let q1w = _this1.w;
					let q2x = q.x;
					let q2y = q.y;
					let q2z = q.z;
					let q2w = q.w;
					_this1.x = q1x * q2w + q1w * q2x + q1y * q2z - q1z * q2y;
					_this1.y = q1w * q2y - q1x * q2z + q1y * q2w + q1z * q2x;
					_this1.z = q1w * q2z + q1x * q2y - q1y * q2x + q1z * q2w;
					_this1.w = q1w * q2w - q1x * q2x - q1y * q2y - q1z * q2z;
				} else if(arm_Context.rotateZ) {
					let _this = arm_render_Gizmo.q0;
					let angle = arm_Context.gizmoDrag - arm_Context.gizmoDragLast;
					let s = Math.sin(angle * 0.5);
					_this.x = 0.0 * s;
					_this.y = 0.0 * s;
					_this.z = s;
					_this.w = Math.cos(angle * 0.5);
					let l = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z + _this.w * _this.w);
					if(l == 0.0) {
						_this.x = 0;
						_this.y = 0;
						_this.z = 0;
						_this.w = 0;
					} else {
						l = 1.0 / l;
						_this.x *= l;
						_this.y *= l;
						_this.z *= l;
						_this.w *= l;
					}
					let _this1 = arm_Context.paintObject.transform.rot;
					let q = arm_render_Gizmo.q0;
					let q1x = _this1.x;
					let q1y = _this1.y;
					let q1z = _this1.z;
					let q1w = _this1.w;
					let q2x = q.x;
					let q2y = q.y;
					let q2z = q.z;
					let q2w = q.w;
					_this1.x = q1x * q2w + q1w * q2x + q1y * q2z - q1z * q2y;
					_this1.y = q1w * q2y - q1x * q2z + q1y * q2w + q1z * q2x;
					_this1.z = q1w * q2z + q1x * q2y - q1y * q2x + q1z * q2w;
					_this1.w = q1w * q2w - q1x * q2x - q1y * q2y - q1z * q2z;
				}
				arm_Context.gizmoDragLast = arm_Context.gizmoDrag;
				arm_Context.paintObject.transform.buildMatrix();
				let pb = arm_Context.paintObject.getTrait(arm_plugin_PhysicsBody);
				if(pb != null) {
					pb.syncTransform();
				}
			}
		} else if(isDecal) {
			if(arm_Context.translateX || arm_Context.translateY || arm_Context.translateZ || arm_Context.scaleX || arm_Context.scaleY || arm_Context.scaleZ || arm_Context.rotateX || arm_Context.rotateY || arm_Context.rotateZ) {
				if(arm_Context.translateX) {
					arm_Context.layer.decalMat.self._30 = arm_Context.gizmoDrag;
				} else if(arm_Context.translateY) {
					arm_Context.layer.decalMat.self._31 = arm_Context.gizmoDrag;
				} else if(arm_Context.translateZ) {
					arm_Context.layer.decalMat.self._32 = arm_Context.gizmoDrag;
				} else if(arm_Context.scaleX) {
					let _this = arm_Context.layer.decalMat;
					let loc = arm_render_Gizmo.v;
					let quat = arm_render_Gizmo.q;
					let scale = arm_render_Gizmo.v0;
					loc.x = _this.self._30;
					loc.y = _this.self._31;
					loc.z = _this.self._32;
					let _this1 = iron_math_Mat4.helpVec;
					_this1.x = _this.self._00;
					_this1.y = _this.self._01;
					_this1.z = _this.self._02;
					_this1.w = 1.0;
					scale.x = Math.sqrt(_this1.x * _this1.x + _this1.y * _this1.y + _this1.z * _this1.z);
					let _this2 = iron_math_Mat4.helpVec;
					_this2.x = _this.self._10;
					_this2.y = _this.self._11;
					_this2.z = _this.self._12;
					_this2.w = 1.0;
					scale.y = Math.sqrt(_this2.x * _this2.x + _this2.y * _this2.y + _this2.z * _this2.z);
					let _this3 = iron_math_Mat4.helpVec;
					_this3.x = _this.self._20;
					_this3.y = _this.self._21;
					_this3.z = _this.self._22;
					_this3.w = 1.0;
					scale.z = Math.sqrt(_this3.x * _this3.x + _this3.y * _this3.y + _this3.z * _this3.z);
					let _this4 = _this.self;
					let m3 = _this4._12;
					let m4 = _this4._22;
					let m5 = _this4._32;
					let m6 = _this4._13;
					let m7 = _this4._23;
					let m8 = _this4._33;
					let m31 = _this4._12;
					let m41 = _this4._22;
					let m51 = _this4._32;
					let m61 = _this4._13;
					let m71 = _this4._23;
					let m81 = _this4._33;
					let m32 = _this4._11;
					let m42 = _this4._21;
					let m52 = _this4._31;
					let m62 = _this4._13;
					let m72 = _this4._23;
					let m82 = _this4._33;
					let m33 = _this4._11;
					let m43 = _this4._21;
					let m53 = _this4._31;
					let m63 = _this4._12;
					let m73 = _this4._22;
					let m83 = _this4._32;
					if(_this4._00 * (_this4._11 * (m4 * m8 - m5 * m7) - _this4._21 * (m3 * m8 - m5 * m6) + _this4._31 * (m3 * m7 - m4 * m6)) - _this4._01 * (_this4._10 * (m41 * m81 - m51 * m71) - _this4._20 * (m31 * m81 - m51 * m61) + _this4._30 * (m31 * m71 - m41 * m61)) + _this4._02 * (_this4._10 * (m42 * m82 - m52 * m72) - _this4._20 * (m32 * m82 - m52 * m62) + _this4._30 * (m32 * m72 - m42 * m62)) - _this4._03 * (_this4._10 * (m43 * m83 - m53 * m73) - _this4._20 * (m33 * m83 - m53 * m63) + _this4._30 * (m33 * m73 - m43 * m63)) < 0.0) {
						scale.x = -scale.x;
					}
					let invs = 1.0 / scale.x;
					iron_math_Mat4.helpMat.self._00 = _this.self._00 * invs;
					iron_math_Mat4.helpMat.self._01 = _this.self._01 * invs;
					iron_math_Mat4.helpMat.self._02 = _this.self._02 * invs;
					invs = 1.0 / scale.y;
					iron_math_Mat4.helpMat.self._10 = _this.self._10 * invs;
					iron_math_Mat4.helpMat.self._11 = _this.self._11 * invs;
					iron_math_Mat4.helpMat.self._12 = _this.self._12 * invs;
					invs = 1.0 / scale.z;
					iron_math_Mat4.helpMat.self._20 = _this.self._20 * invs;
					iron_math_Mat4.helpMat.self._21 = _this.self._21 * invs;
					iron_math_Mat4.helpMat.self._22 = _this.self._22 * invs;
					let m = iron_math_Mat4.helpMat;
					let m11 = m.self._00;
					let m12 = m.self._10;
					let m13 = m.self._20;
					let m21 = m.self._01;
					let m22 = m.self._11;
					let m23 = m.self._21;
					let m311 = m.self._02;
					let m321 = m.self._12;
					let m331 = m.self._22;
					let tr = m11 + m22 + m331;
					let s = 0.0;
					if(tr > 0) {
						s = 0.5 / Math.sqrt(tr + 1.0);
						quat.w = 0.25 / s;
						quat.x = (m321 - m23) * s;
						quat.y = (m13 - m311) * s;
						quat.z = (m21 - m12) * s;
					} else if(m11 > m22 && m11 > m331) {
						s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m331);
						quat.w = (m321 - m23) / s;
						quat.x = 0.25 * s;
						quat.y = (m12 + m21) / s;
						quat.z = (m13 + m311) / s;
					} else if(m22 > m331) {
						s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m331);
						quat.w = (m13 - m311) / s;
						quat.x = (m12 + m21) / s;
						quat.y = 0.25 * s;
						quat.z = (m23 + m321) / s;
					} else {
						s = 2.0 * Math.sqrt(1.0 + m331 - m11 - m22);
						quat.w = (m21 - m12) / s;
						quat.x = (m13 + m311) / s;
						quat.y = (m23 + m321) / s;
						quat.z = 0.25 * s;
					}
					arm_render_Gizmo.v0.x += arm_Context.gizmoDrag - arm_Context.gizmoDragLast;
					let _this5 = arm_Context.layer.decalMat;
					let loc1 = arm_render_Gizmo.v;
					let quat1 = arm_render_Gizmo.q;
					let sc = arm_render_Gizmo.v0;
					let x = quat1.x;
					let y = quat1.y;
					let z = quat1.z;
					let w = quat1.w;
					let x2 = x + x;
					let y2 = y + y;
					let z2 = z + z;
					let xx = x * x2;
					let xy = x * y2;
					let xz = x * z2;
					let yy = y * y2;
					let yz = y * z2;
					let zz = z * z2;
					let wx = w * x2;
					let wy = w * y2;
					let wz = w * z2;
					_this5.self._00 = 1.0 - (yy + zz);
					_this5.self._10 = xy - wz;
					_this5.self._20 = xz + wy;
					_this5.self._01 = xy + wz;
					_this5.self._11 = 1.0 - (xx + zz);
					_this5.self._21 = yz - wx;
					_this5.self._02 = xz - wy;
					_this5.self._12 = yz + wx;
					_this5.self._22 = 1.0 - (xx + yy);
					_this5.self._03 = 0.0;
					_this5.self._13 = 0.0;
					_this5.self._23 = 0.0;
					_this5.self._30 = 0.0;
					_this5.self._31 = 0.0;
					_this5.self._32 = 0.0;
					_this5.self._33 = 1.0;
					let x1 = sc.x;
					let y1 = sc.y;
					let z1 = sc.z;
					_this5.self._00 *= x1;
					_this5.self._01 *= x1;
					_this5.self._02 *= x1;
					_this5.self._03 *= x1;
					_this5.self._10 *= y1;
					_this5.self._11 *= y1;
					_this5.self._12 *= y1;
					_this5.self._13 *= y1;
					_this5.self._20 *= z1;
					_this5.self._21 *= z1;
					_this5.self._22 *= z1;
					_this5.self._23 *= z1;
					_this5.self._30 = loc1.x;
					_this5.self._31 = loc1.y;
					_this5.self._32 = loc1.z;
				} else if(arm_Context.scaleY) {
					let _this = arm_Context.layer.decalMat;
					let loc = arm_render_Gizmo.v;
					let quat = arm_render_Gizmo.q;
					let scale = arm_render_Gizmo.v0;
					loc.x = _this.self._30;
					loc.y = _this.self._31;
					loc.z = _this.self._32;
					let _this1 = iron_math_Mat4.helpVec;
					_this1.x = _this.self._00;
					_this1.y = _this.self._01;
					_this1.z = _this.self._02;
					_this1.w = 1.0;
					scale.x = Math.sqrt(_this1.x * _this1.x + _this1.y * _this1.y + _this1.z * _this1.z);
					let _this2 = iron_math_Mat4.helpVec;
					_this2.x = _this.self._10;
					_this2.y = _this.self._11;
					_this2.z = _this.self._12;
					_this2.w = 1.0;
					scale.y = Math.sqrt(_this2.x * _this2.x + _this2.y * _this2.y + _this2.z * _this2.z);
					let _this3 = iron_math_Mat4.helpVec;
					_this3.x = _this.self._20;
					_this3.y = _this.self._21;
					_this3.z = _this.self._22;
					_this3.w = 1.0;
					scale.z = Math.sqrt(_this3.x * _this3.x + _this3.y * _this3.y + _this3.z * _this3.z);
					let _this4 = _this.self;
					let m3 = _this4._12;
					let m4 = _this4._22;
					let m5 = _this4._32;
					let m6 = _this4._13;
					let m7 = _this4._23;
					let m8 = _this4._33;
					let m31 = _this4._12;
					let m41 = _this4._22;
					let m51 = _this4._32;
					let m61 = _this4._13;
					let m71 = _this4._23;
					let m81 = _this4._33;
					let m32 = _this4._11;
					let m42 = _this4._21;
					let m52 = _this4._31;
					let m62 = _this4._13;
					let m72 = _this4._23;
					let m82 = _this4._33;
					let m33 = _this4._11;
					let m43 = _this4._21;
					let m53 = _this4._31;
					let m63 = _this4._12;
					let m73 = _this4._22;
					let m83 = _this4._32;
					if(_this4._00 * (_this4._11 * (m4 * m8 - m5 * m7) - _this4._21 * (m3 * m8 - m5 * m6) + _this4._31 * (m3 * m7 - m4 * m6)) - _this4._01 * (_this4._10 * (m41 * m81 - m51 * m71) - _this4._20 * (m31 * m81 - m51 * m61) + _this4._30 * (m31 * m71 - m41 * m61)) + _this4._02 * (_this4._10 * (m42 * m82 - m52 * m72) - _this4._20 * (m32 * m82 - m52 * m62) + _this4._30 * (m32 * m72 - m42 * m62)) - _this4._03 * (_this4._10 * (m43 * m83 - m53 * m73) - _this4._20 * (m33 * m83 - m53 * m63) + _this4._30 * (m33 * m73 - m43 * m63)) < 0.0) {
						scale.x = -scale.x;
					}
					let invs = 1.0 / scale.x;
					iron_math_Mat4.helpMat.self._00 = _this.self._00 * invs;
					iron_math_Mat4.helpMat.self._01 = _this.self._01 * invs;
					iron_math_Mat4.helpMat.self._02 = _this.self._02 * invs;
					invs = 1.0 / scale.y;
					iron_math_Mat4.helpMat.self._10 = _this.self._10 * invs;
					iron_math_Mat4.helpMat.self._11 = _this.self._11 * invs;
					iron_math_Mat4.helpMat.self._12 = _this.self._12 * invs;
					invs = 1.0 / scale.z;
					iron_math_Mat4.helpMat.self._20 = _this.self._20 * invs;
					iron_math_Mat4.helpMat.self._21 = _this.self._21 * invs;
					iron_math_Mat4.helpMat.self._22 = _this.self._22 * invs;
					let m = iron_math_Mat4.helpMat;
					let m11 = m.self._00;
					let m12 = m.self._10;
					let m13 = m.self._20;
					let m21 = m.self._01;
					let m22 = m.self._11;
					let m23 = m.self._21;
					let m311 = m.self._02;
					let m321 = m.self._12;
					let m331 = m.self._22;
					let tr = m11 + m22 + m331;
					let s = 0.0;
					if(tr > 0) {
						s = 0.5 / Math.sqrt(tr + 1.0);
						quat.w = 0.25 / s;
						quat.x = (m321 - m23) * s;
						quat.y = (m13 - m311) * s;
						quat.z = (m21 - m12) * s;
					} else if(m11 > m22 && m11 > m331) {
						s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m331);
						quat.w = (m321 - m23) / s;
						quat.x = 0.25 * s;
						quat.y = (m12 + m21) / s;
						quat.z = (m13 + m311) / s;
					} else if(m22 > m331) {
						s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m331);
						quat.w = (m13 - m311) / s;
						quat.x = (m12 + m21) / s;
						quat.y = 0.25 * s;
						quat.z = (m23 + m321) / s;
					} else {
						s = 2.0 * Math.sqrt(1.0 + m331 - m11 - m22);
						quat.w = (m21 - m12) / s;
						quat.x = (m13 + m311) / s;
						quat.y = (m23 + m321) / s;
						quat.z = 0.25 * s;
					}
					arm_render_Gizmo.v0.y += arm_Context.gizmoDrag - arm_Context.gizmoDragLast;
					let _this5 = arm_Context.layer.decalMat;
					let loc1 = arm_render_Gizmo.v;
					let quat1 = arm_render_Gizmo.q;
					let sc = arm_render_Gizmo.v0;
					let x = quat1.x;
					let y = quat1.y;
					let z = quat1.z;
					let w = quat1.w;
					let x2 = x + x;
					let y2 = y + y;
					let z2 = z + z;
					let xx = x * x2;
					let xy = x * y2;
					let xz = x * z2;
					let yy = y * y2;
					let yz = y * z2;
					let zz = z * z2;
					let wx = w * x2;
					let wy = w * y2;
					let wz = w * z2;
					_this5.self._00 = 1.0 - (yy + zz);
					_this5.self._10 = xy - wz;
					_this5.self._20 = xz + wy;
					_this5.self._01 = xy + wz;
					_this5.self._11 = 1.0 - (xx + zz);
					_this5.self._21 = yz - wx;
					_this5.self._02 = xz - wy;
					_this5.self._12 = yz + wx;
					_this5.self._22 = 1.0 - (xx + yy);
					_this5.self._03 = 0.0;
					_this5.self._13 = 0.0;
					_this5.self._23 = 0.0;
					_this5.self._30 = 0.0;
					_this5.self._31 = 0.0;
					_this5.self._32 = 0.0;
					_this5.self._33 = 1.0;
					let x1 = sc.x;
					let y1 = sc.y;
					let z1 = sc.z;
					_this5.self._00 *= x1;
					_this5.self._01 *= x1;
					_this5.self._02 *= x1;
					_this5.self._03 *= x1;
					_this5.self._10 *= y1;
					_this5.self._11 *= y1;
					_this5.self._12 *= y1;
					_this5.self._13 *= y1;
					_this5.self._20 *= z1;
					_this5.self._21 *= z1;
					_this5.self._22 *= z1;
					_this5.self._23 *= z1;
					_this5.self._30 = loc1.x;
					_this5.self._31 = loc1.y;
					_this5.self._32 = loc1.z;
				} else if(arm_Context.scaleZ) {
					let _this = arm_Context.layer.decalMat;
					let loc = arm_render_Gizmo.v;
					let quat = arm_render_Gizmo.q;
					let scale = arm_render_Gizmo.v0;
					loc.x = _this.self._30;
					loc.y = _this.self._31;
					loc.z = _this.self._32;
					let _this1 = iron_math_Mat4.helpVec;
					_this1.x = _this.self._00;
					_this1.y = _this.self._01;
					_this1.z = _this.self._02;
					_this1.w = 1.0;
					scale.x = Math.sqrt(_this1.x * _this1.x + _this1.y * _this1.y + _this1.z * _this1.z);
					let _this2 = iron_math_Mat4.helpVec;
					_this2.x = _this.self._10;
					_this2.y = _this.self._11;
					_this2.z = _this.self._12;
					_this2.w = 1.0;
					scale.y = Math.sqrt(_this2.x * _this2.x + _this2.y * _this2.y + _this2.z * _this2.z);
					let _this3 = iron_math_Mat4.helpVec;
					_this3.x = _this.self._20;
					_this3.y = _this.self._21;
					_this3.z = _this.self._22;
					_this3.w = 1.0;
					scale.z = Math.sqrt(_this3.x * _this3.x + _this3.y * _this3.y + _this3.z * _this3.z);
					let _this4 = _this.self;
					let m3 = _this4._12;
					let m4 = _this4._22;
					let m5 = _this4._32;
					let m6 = _this4._13;
					let m7 = _this4._23;
					let m8 = _this4._33;
					let m31 = _this4._12;
					let m41 = _this4._22;
					let m51 = _this4._32;
					let m61 = _this4._13;
					let m71 = _this4._23;
					let m81 = _this4._33;
					let m32 = _this4._11;
					let m42 = _this4._21;
					let m52 = _this4._31;
					let m62 = _this4._13;
					let m72 = _this4._23;
					let m82 = _this4._33;
					let m33 = _this4._11;
					let m43 = _this4._21;
					let m53 = _this4._31;
					let m63 = _this4._12;
					let m73 = _this4._22;
					let m83 = _this4._32;
					if(_this4._00 * (_this4._11 * (m4 * m8 - m5 * m7) - _this4._21 * (m3 * m8 - m5 * m6) + _this4._31 * (m3 * m7 - m4 * m6)) - _this4._01 * (_this4._10 * (m41 * m81 - m51 * m71) - _this4._20 * (m31 * m81 - m51 * m61) + _this4._30 * (m31 * m71 - m41 * m61)) + _this4._02 * (_this4._10 * (m42 * m82 - m52 * m72) - _this4._20 * (m32 * m82 - m52 * m62) + _this4._30 * (m32 * m72 - m42 * m62)) - _this4._03 * (_this4._10 * (m43 * m83 - m53 * m73) - _this4._20 * (m33 * m83 - m53 * m63) + _this4._30 * (m33 * m73 - m43 * m63)) < 0.0) {
						scale.x = -scale.x;
					}
					let invs = 1.0 / scale.x;
					iron_math_Mat4.helpMat.self._00 = _this.self._00 * invs;
					iron_math_Mat4.helpMat.self._01 = _this.self._01 * invs;
					iron_math_Mat4.helpMat.self._02 = _this.self._02 * invs;
					invs = 1.0 / scale.y;
					iron_math_Mat4.helpMat.self._10 = _this.self._10 * invs;
					iron_math_Mat4.helpMat.self._11 = _this.self._11 * invs;
					iron_math_Mat4.helpMat.self._12 = _this.self._12 * invs;
					invs = 1.0 / scale.z;
					iron_math_Mat4.helpMat.self._20 = _this.self._20 * invs;
					iron_math_Mat4.helpMat.self._21 = _this.self._21 * invs;
					iron_math_Mat4.helpMat.self._22 = _this.self._22 * invs;
					let m = iron_math_Mat4.helpMat;
					let m11 = m.self._00;
					let m12 = m.self._10;
					let m13 = m.self._20;
					let m21 = m.self._01;
					let m22 = m.self._11;
					let m23 = m.self._21;
					let m311 = m.self._02;
					let m321 = m.self._12;
					let m331 = m.self._22;
					let tr = m11 + m22 + m331;
					let s = 0.0;
					if(tr > 0) {
						s = 0.5 / Math.sqrt(tr + 1.0);
						quat.w = 0.25 / s;
						quat.x = (m321 - m23) * s;
						quat.y = (m13 - m311) * s;
						quat.z = (m21 - m12) * s;
					} else if(m11 > m22 && m11 > m331) {
						s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m331);
						quat.w = (m321 - m23) / s;
						quat.x = 0.25 * s;
						quat.y = (m12 + m21) / s;
						quat.z = (m13 + m311) / s;
					} else if(m22 > m331) {
						s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m331);
						quat.w = (m13 - m311) / s;
						quat.x = (m12 + m21) / s;
						quat.y = 0.25 * s;
						quat.z = (m23 + m321) / s;
					} else {
						s = 2.0 * Math.sqrt(1.0 + m331 - m11 - m22);
						quat.w = (m21 - m12) / s;
						quat.x = (m13 + m311) / s;
						quat.y = (m23 + m321) / s;
						quat.z = 0.25 * s;
					}
					arm_render_Gizmo.v0.z += arm_Context.gizmoDrag - arm_Context.gizmoDragLast;
					let _this5 = arm_Context.layer.decalMat;
					let loc1 = arm_render_Gizmo.v;
					let quat1 = arm_render_Gizmo.q;
					let sc = arm_render_Gizmo.v0;
					let x = quat1.x;
					let y = quat1.y;
					let z = quat1.z;
					let w = quat1.w;
					let x2 = x + x;
					let y2 = y + y;
					let z2 = z + z;
					let xx = x * x2;
					let xy = x * y2;
					let xz = x * z2;
					let yy = y * y2;
					let yz = y * z2;
					let zz = z * z2;
					let wx = w * x2;
					let wy = w * y2;
					let wz = w * z2;
					_this5.self._00 = 1.0 - (yy + zz);
					_this5.self._10 = xy - wz;
					_this5.self._20 = xz + wy;
					_this5.self._01 = xy + wz;
					_this5.self._11 = 1.0 - (xx + zz);
					_this5.self._21 = yz - wx;
					_this5.self._02 = xz - wy;
					_this5.self._12 = yz + wx;
					_this5.self._22 = 1.0 - (xx + yy);
					_this5.self._03 = 0.0;
					_this5.self._13 = 0.0;
					_this5.self._23 = 0.0;
					_this5.self._30 = 0.0;
					_this5.self._31 = 0.0;
					_this5.self._32 = 0.0;
					_this5.self._33 = 1.0;
					let x1 = sc.x;
					let y1 = sc.y;
					let z1 = sc.z;
					_this5.self._00 *= x1;
					_this5.self._01 *= x1;
					_this5.self._02 *= x1;
					_this5.self._03 *= x1;
					_this5.self._10 *= y1;
					_this5.self._11 *= y1;
					_this5.self._12 *= y1;
					_this5.self._13 *= y1;
					_this5.self._20 *= z1;
					_this5.self._21 *= z1;
					_this5.self._22 *= z1;
					_this5.self._23 *= z1;
					_this5.self._30 = loc1.x;
					_this5.self._31 = loc1.y;
					_this5.self._32 = loc1.z;
				} else if(arm_Context.rotateX) {
					let _this = arm_Context.layer.decalMat;
					let loc = arm_render_Gizmo.v;
					let quat = arm_render_Gizmo.q;
					let scale = arm_render_Gizmo.v0;
					loc.x = _this.self._30;
					loc.y = _this.self._31;
					loc.z = _this.self._32;
					let _this1 = iron_math_Mat4.helpVec;
					_this1.x = _this.self._00;
					_this1.y = _this.self._01;
					_this1.z = _this.self._02;
					_this1.w = 1.0;
					scale.x = Math.sqrt(_this1.x * _this1.x + _this1.y * _this1.y + _this1.z * _this1.z);
					let _this2 = iron_math_Mat4.helpVec;
					_this2.x = _this.self._10;
					_this2.y = _this.self._11;
					_this2.z = _this.self._12;
					_this2.w = 1.0;
					scale.y = Math.sqrt(_this2.x * _this2.x + _this2.y * _this2.y + _this2.z * _this2.z);
					let _this3 = iron_math_Mat4.helpVec;
					_this3.x = _this.self._20;
					_this3.y = _this.self._21;
					_this3.z = _this.self._22;
					_this3.w = 1.0;
					scale.z = Math.sqrt(_this3.x * _this3.x + _this3.y * _this3.y + _this3.z * _this3.z);
					let _this4 = _this.self;
					let m3 = _this4._12;
					let m4 = _this4._22;
					let m5 = _this4._32;
					let m6 = _this4._13;
					let m7 = _this4._23;
					let m8 = _this4._33;
					let m31 = _this4._12;
					let m41 = _this4._22;
					let m51 = _this4._32;
					let m61 = _this4._13;
					let m71 = _this4._23;
					let m81 = _this4._33;
					let m32 = _this4._11;
					let m42 = _this4._21;
					let m52 = _this4._31;
					let m62 = _this4._13;
					let m72 = _this4._23;
					let m82 = _this4._33;
					let m33 = _this4._11;
					let m43 = _this4._21;
					let m53 = _this4._31;
					let m63 = _this4._12;
					let m73 = _this4._22;
					let m83 = _this4._32;
					if(_this4._00 * (_this4._11 * (m4 * m8 - m5 * m7) - _this4._21 * (m3 * m8 - m5 * m6) + _this4._31 * (m3 * m7 - m4 * m6)) - _this4._01 * (_this4._10 * (m41 * m81 - m51 * m71) - _this4._20 * (m31 * m81 - m51 * m61) + _this4._30 * (m31 * m71 - m41 * m61)) + _this4._02 * (_this4._10 * (m42 * m82 - m52 * m72) - _this4._20 * (m32 * m82 - m52 * m62) + _this4._30 * (m32 * m72 - m42 * m62)) - _this4._03 * (_this4._10 * (m43 * m83 - m53 * m73) - _this4._20 * (m33 * m83 - m53 * m63) + _this4._30 * (m33 * m73 - m43 * m63)) < 0.0) {
						scale.x = -scale.x;
					}
					let invs = 1.0 / scale.x;
					iron_math_Mat4.helpMat.self._00 = _this.self._00 * invs;
					iron_math_Mat4.helpMat.self._01 = _this.self._01 * invs;
					iron_math_Mat4.helpMat.self._02 = _this.self._02 * invs;
					invs = 1.0 / scale.y;
					iron_math_Mat4.helpMat.self._10 = _this.self._10 * invs;
					iron_math_Mat4.helpMat.self._11 = _this.self._11 * invs;
					iron_math_Mat4.helpMat.self._12 = _this.self._12 * invs;
					invs = 1.0 / scale.z;
					iron_math_Mat4.helpMat.self._20 = _this.self._20 * invs;
					iron_math_Mat4.helpMat.self._21 = _this.self._21 * invs;
					iron_math_Mat4.helpMat.self._22 = _this.self._22 * invs;
					let m = iron_math_Mat4.helpMat;
					let m11 = m.self._00;
					let m12 = m.self._10;
					let m13 = m.self._20;
					let m21 = m.self._01;
					let m22 = m.self._11;
					let m23 = m.self._21;
					let m311 = m.self._02;
					let m321 = m.self._12;
					let m331 = m.self._22;
					let tr = m11 + m22 + m331;
					let s = 0.0;
					if(tr > 0) {
						s = 0.5 / Math.sqrt(tr + 1.0);
						quat.w = 0.25 / s;
						quat.x = (m321 - m23) * s;
						quat.y = (m13 - m311) * s;
						quat.z = (m21 - m12) * s;
					} else if(m11 > m22 && m11 > m331) {
						s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m331);
						quat.w = (m321 - m23) / s;
						quat.x = 0.25 * s;
						quat.y = (m12 + m21) / s;
						quat.z = (m13 + m311) / s;
					} else if(m22 > m331) {
						s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m331);
						quat.w = (m13 - m311) / s;
						quat.x = (m12 + m21) / s;
						quat.y = 0.25 * s;
						quat.z = (m23 + m321) / s;
					} else {
						s = 2.0 * Math.sqrt(1.0 + m331 - m11 - m22);
						quat.w = (m21 - m12) / s;
						quat.x = (m13 + m311) / s;
						quat.y = (m23 + m321) / s;
						quat.z = 0.25 * s;
					}
					let _this5 = arm_render_Gizmo.q0;
					let angle = -arm_Context.gizmoDrag + arm_Context.gizmoDragLast;
					let s1 = Math.sin(angle * 0.5);
					_this5.x = s1;
					_this5.y = 0.0 * s1;
					_this5.z = 0.0 * s1;
					_this5.w = Math.cos(angle * 0.5);
					let l = Math.sqrt(_this5.x * _this5.x + _this5.y * _this5.y + _this5.z * _this5.z + _this5.w * _this5.w);
					if(l == 0.0) {
						_this5.x = 0;
						_this5.y = 0;
						_this5.z = 0;
						_this5.w = 0;
					} else {
						l = 1.0 / l;
						_this5.x *= l;
						_this5.y *= l;
						_this5.z *= l;
						_this5.w *= l;
					}
					let _this6 = arm_render_Gizmo.q;
					let q1 = arm_render_Gizmo.q0;
					let q2 = arm_render_Gizmo.q;
					let q1x = q1.x;
					let q1y = q1.y;
					let q1z = q1.z;
					let q1w = q1.w;
					let q2x = q2.x;
					let q2y = q2.y;
					let q2z = q2.z;
					let q2w = q2.w;
					_this6.x = q1x * q2w + q1w * q2x + q1y * q2z - q1z * q2y;
					_this6.y = q1w * q2y - q1x * q2z + q1y * q2w + q1z * q2x;
					_this6.z = q1w * q2z + q1x * q2y - q1y * q2x + q1z * q2w;
					_this6.w = q1w * q2w - q1x * q2x - q1y * q2y - q1z * q2z;
					let _this7 = arm_Context.layer.decalMat;
					let loc1 = arm_render_Gizmo.v;
					let quat1 = arm_render_Gizmo.q;
					let sc = arm_render_Gizmo.v0;
					let x = quat1.x;
					let y = quat1.y;
					let z = quat1.z;
					let w = quat1.w;
					let x2 = x + x;
					let y2 = y + y;
					let z2 = z + z;
					let xx = x * x2;
					let xy = x * y2;
					let xz = x * z2;
					let yy = y * y2;
					let yz = y * z2;
					let zz = z * z2;
					let wx = w * x2;
					let wy = w * y2;
					let wz = w * z2;
					_this7.self._00 = 1.0 - (yy + zz);
					_this7.self._10 = xy - wz;
					_this7.self._20 = xz + wy;
					_this7.self._01 = xy + wz;
					_this7.self._11 = 1.0 - (xx + zz);
					_this7.self._21 = yz - wx;
					_this7.self._02 = xz - wy;
					_this7.self._12 = yz + wx;
					_this7.self._22 = 1.0 - (xx + yy);
					_this7.self._03 = 0.0;
					_this7.self._13 = 0.0;
					_this7.self._23 = 0.0;
					_this7.self._30 = 0.0;
					_this7.self._31 = 0.0;
					_this7.self._32 = 0.0;
					_this7.self._33 = 1.0;
					let x1 = sc.x;
					let y1 = sc.y;
					let z1 = sc.z;
					_this7.self._00 *= x1;
					_this7.self._01 *= x1;
					_this7.self._02 *= x1;
					_this7.self._03 *= x1;
					_this7.self._10 *= y1;
					_this7.self._11 *= y1;
					_this7.self._12 *= y1;
					_this7.self._13 *= y1;
					_this7.self._20 *= z1;
					_this7.self._21 *= z1;
					_this7.self._22 *= z1;
					_this7.self._23 *= z1;
					_this7.self._30 = loc1.x;
					_this7.self._31 = loc1.y;
					_this7.self._32 = loc1.z;
				} else if(arm_Context.rotateY) {
					let _this = arm_Context.layer.decalMat;
					let loc = arm_render_Gizmo.v;
					let quat = arm_render_Gizmo.q;
					let scale = arm_render_Gizmo.v0;
					loc.x = _this.self._30;
					loc.y = _this.self._31;
					loc.z = _this.self._32;
					let _this1 = iron_math_Mat4.helpVec;
					_this1.x = _this.self._00;
					_this1.y = _this.self._01;
					_this1.z = _this.self._02;
					_this1.w = 1.0;
					scale.x = Math.sqrt(_this1.x * _this1.x + _this1.y * _this1.y + _this1.z * _this1.z);
					let _this2 = iron_math_Mat4.helpVec;
					_this2.x = _this.self._10;
					_this2.y = _this.self._11;
					_this2.z = _this.self._12;
					_this2.w = 1.0;
					scale.y = Math.sqrt(_this2.x * _this2.x + _this2.y * _this2.y + _this2.z * _this2.z);
					let _this3 = iron_math_Mat4.helpVec;
					_this3.x = _this.self._20;
					_this3.y = _this.self._21;
					_this3.z = _this.self._22;
					_this3.w = 1.0;
					scale.z = Math.sqrt(_this3.x * _this3.x + _this3.y * _this3.y + _this3.z * _this3.z);
					let _this4 = _this.self;
					let m3 = _this4._12;
					let m4 = _this4._22;
					let m5 = _this4._32;
					let m6 = _this4._13;
					let m7 = _this4._23;
					let m8 = _this4._33;
					let m31 = _this4._12;
					let m41 = _this4._22;
					let m51 = _this4._32;
					let m61 = _this4._13;
					let m71 = _this4._23;
					let m81 = _this4._33;
					let m32 = _this4._11;
					let m42 = _this4._21;
					let m52 = _this4._31;
					let m62 = _this4._13;
					let m72 = _this4._23;
					let m82 = _this4._33;
					let m33 = _this4._11;
					let m43 = _this4._21;
					let m53 = _this4._31;
					let m63 = _this4._12;
					let m73 = _this4._22;
					let m83 = _this4._32;
					if(_this4._00 * (_this4._11 * (m4 * m8 - m5 * m7) - _this4._21 * (m3 * m8 - m5 * m6) + _this4._31 * (m3 * m7 - m4 * m6)) - _this4._01 * (_this4._10 * (m41 * m81 - m51 * m71) - _this4._20 * (m31 * m81 - m51 * m61) + _this4._30 * (m31 * m71 - m41 * m61)) + _this4._02 * (_this4._10 * (m42 * m82 - m52 * m72) - _this4._20 * (m32 * m82 - m52 * m62) + _this4._30 * (m32 * m72 - m42 * m62)) - _this4._03 * (_this4._10 * (m43 * m83 - m53 * m73) - _this4._20 * (m33 * m83 - m53 * m63) + _this4._30 * (m33 * m73 - m43 * m63)) < 0.0) {
						scale.x = -scale.x;
					}
					let invs = 1.0 / scale.x;
					iron_math_Mat4.helpMat.self._00 = _this.self._00 * invs;
					iron_math_Mat4.helpMat.self._01 = _this.self._01 * invs;
					iron_math_Mat4.helpMat.self._02 = _this.self._02 * invs;
					invs = 1.0 / scale.y;
					iron_math_Mat4.helpMat.self._10 = _this.self._10 * invs;
					iron_math_Mat4.helpMat.self._11 = _this.self._11 * invs;
					iron_math_Mat4.helpMat.self._12 = _this.self._12 * invs;
					invs = 1.0 / scale.z;
					iron_math_Mat4.helpMat.self._20 = _this.self._20 * invs;
					iron_math_Mat4.helpMat.self._21 = _this.self._21 * invs;
					iron_math_Mat4.helpMat.self._22 = _this.self._22 * invs;
					let m = iron_math_Mat4.helpMat;
					let m11 = m.self._00;
					let m12 = m.self._10;
					let m13 = m.self._20;
					let m21 = m.self._01;
					let m22 = m.self._11;
					let m23 = m.self._21;
					let m311 = m.self._02;
					let m321 = m.self._12;
					let m331 = m.self._22;
					let tr = m11 + m22 + m331;
					let s = 0.0;
					if(tr > 0) {
						s = 0.5 / Math.sqrt(tr + 1.0);
						quat.w = 0.25 / s;
						quat.x = (m321 - m23) * s;
						quat.y = (m13 - m311) * s;
						quat.z = (m21 - m12) * s;
					} else if(m11 > m22 && m11 > m331) {
						s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m331);
						quat.w = (m321 - m23) / s;
						quat.x = 0.25 * s;
						quat.y = (m12 + m21) / s;
						quat.z = (m13 + m311) / s;
					} else if(m22 > m331) {
						s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m331);
						quat.w = (m13 - m311) / s;
						quat.x = (m12 + m21) / s;
						quat.y = 0.25 * s;
						quat.z = (m23 + m321) / s;
					} else {
						s = 2.0 * Math.sqrt(1.0 + m331 - m11 - m22);
						quat.w = (m21 - m12) / s;
						quat.x = (m13 + m311) / s;
						quat.y = (m23 + m321) / s;
						quat.z = 0.25 * s;
					}
					let _this5 = arm_render_Gizmo.q0;
					let angle = -arm_Context.gizmoDrag + arm_Context.gizmoDragLast;
					let s1 = Math.sin(angle * 0.5);
					_this5.x = 0.0 * s1;
					_this5.y = s1;
					_this5.z = 0.0 * s1;
					_this5.w = Math.cos(angle * 0.5);
					let l = Math.sqrt(_this5.x * _this5.x + _this5.y * _this5.y + _this5.z * _this5.z + _this5.w * _this5.w);
					if(l == 0.0) {
						_this5.x = 0;
						_this5.y = 0;
						_this5.z = 0;
						_this5.w = 0;
					} else {
						l = 1.0 / l;
						_this5.x *= l;
						_this5.y *= l;
						_this5.z *= l;
						_this5.w *= l;
					}
					let _this6 = arm_render_Gizmo.q;
					let q1 = arm_render_Gizmo.q0;
					let q2 = arm_render_Gizmo.q;
					let q1x = q1.x;
					let q1y = q1.y;
					let q1z = q1.z;
					let q1w = q1.w;
					let q2x = q2.x;
					let q2y = q2.y;
					let q2z = q2.z;
					let q2w = q2.w;
					_this6.x = q1x * q2w + q1w * q2x + q1y * q2z - q1z * q2y;
					_this6.y = q1w * q2y - q1x * q2z + q1y * q2w + q1z * q2x;
					_this6.z = q1w * q2z + q1x * q2y - q1y * q2x + q1z * q2w;
					_this6.w = q1w * q2w - q1x * q2x - q1y * q2y - q1z * q2z;
					let _this7 = arm_Context.layer.decalMat;
					let loc1 = arm_render_Gizmo.v;
					let quat1 = arm_render_Gizmo.q;
					let sc = arm_render_Gizmo.v0;
					let x = quat1.x;
					let y = quat1.y;
					let z = quat1.z;
					let w = quat1.w;
					let x2 = x + x;
					let y2 = y + y;
					let z2 = z + z;
					let xx = x * x2;
					let xy = x * y2;
					let xz = x * z2;
					let yy = y * y2;
					let yz = y * z2;
					let zz = z * z2;
					let wx = w * x2;
					let wy = w * y2;
					let wz = w * z2;
					_this7.self._00 = 1.0 - (yy + zz);
					_this7.self._10 = xy - wz;
					_this7.self._20 = xz + wy;
					_this7.self._01 = xy + wz;
					_this7.self._11 = 1.0 - (xx + zz);
					_this7.self._21 = yz - wx;
					_this7.self._02 = xz - wy;
					_this7.self._12 = yz + wx;
					_this7.self._22 = 1.0 - (xx + yy);
					_this7.self._03 = 0.0;
					_this7.self._13 = 0.0;
					_this7.self._23 = 0.0;
					_this7.self._30 = 0.0;
					_this7.self._31 = 0.0;
					_this7.self._32 = 0.0;
					_this7.self._33 = 1.0;
					let x1 = sc.x;
					let y1 = sc.y;
					let z1 = sc.z;
					_this7.self._00 *= x1;
					_this7.self._01 *= x1;
					_this7.self._02 *= x1;
					_this7.self._03 *= x1;
					_this7.self._10 *= y1;
					_this7.self._11 *= y1;
					_this7.self._12 *= y1;
					_this7.self._13 *= y1;
					_this7.self._20 *= z1;
					_this7.self._21 *= z1;
					_this7.self._22 *= z1;
					_this7.self._23 *= z1;
					_this7.self._30 = loc1.x;
					_this7.self._31 = loc1.y;
					_this7.self._32 = loc1.z;
				} else if(arm_Context.rotateZ) {
					let _this = arm_Context.layer.decalMat;
					let loc = arm_render_Gizmo.v;
					let quat = arm_render_Gizmo.q;
					let scale = arm_render_Gizmo.v0;
					loc.x = _this.self._30;
					loc.y = _this.self._31;
					loc.z = _this.self._32;
					let _this1 = iron_math_Mat4.helpVec;
					_this1.x = _this.self._00;
					_this1.y = _this.self._01;
					_this1.z = _this.self._02;
					_this1.w = 1.0;
					scale.x = Math.sqrt(_this1.x * _this1.x + _this1.y * _this1.y + _this1.z * _this1.z);
					let _this2 = iron_math_Mat4.helpVec;
					_this2.x = _this.self._10;
					_this2.y = _this.self._11;
					_this2.z = _this.self._12;
					_this2.w = 1.0;
					scale.y = Math.sqrt(_this2.x * _this2.x + _this2.y * _this2.y + _this2.z * _this2.z);
					let _this3 = iron_math_Mat4.helpVec;
					_this3.x = _this.self._20;
					_this3.y = _this.self._21;
					_this3.z = _this.self._22;
					_this3.w = 1.0;
					scale.z = Math.sqrt(_this3.x * _this3.x + _this3.y * _this3.y + _this3.z * _this3.z);
					let _this4 = _this.self;
					let m3 = _this4._12;
					let m4 = _this4._22;
					let m5 = _this4._32;
					let m6 = _this4._13;
					let m7 = _this4._23;
					let m8 = _this4._33;
					let m31 = _this4._12;
					let m41 = _this4._22;
					let m51 = _this4._32;
					let m61 = _this4._13;
					let m71 = _this4._23;
					let m81 = _this4._33;
					let m32 = _this4._11;
					let m42 = _this4._21;
					let m52 = _this4._31;
					let m62 = _this4._13;
					let m72 = _this4._23;
					let m82 = _this4._33;
					let m33 = _this4._11;
					let m43 = _this4._21;
					let m53 = _this4._31;
					let m63 = _this4._12;
					let m73 = _this4._22;
					let m83 = _this4._32;
					if(_this4._00 * (_this4._11 * (m4 * m8 - m5 * m7) - _this4._21 * (m3 * m8 - m5 * m6) + _this4._31 * (m3 * m7 - m4 * m6)) - _this4._01 * (_this4._10 * (m41 * m81 - m51 * m71) - _this4._20 * (m31 * m81 - m51 * m61) + _this4._30 * (m31 * m71 - m41 * m61)) + _this4._02 * (_this4._10 * (m42 * m82 - m52 * m72) - _this4._20 * (m32 * m82 - m52 * m62) + _this4._30 * (m32 * m72 - m42 * m62)) - _this4._03 * (_this4._10 * (m43 * m83 - m53 * m73) - _this4._20 * (m33 * m83 - m53 * m63) + _this4._30 * (m33 * m73 - m43 * m63)) < 0.0) {
						scale.x = -scale.x;
					}
					let invs = 1.0 / scale.x;
					iron_math_Mat4.helpMat.self._00 = _this.self._00 * invs;
					iron_math_Mat4.helpMat.self._01 = _this.self._01 * invs;
					iron_math_Mat4.helpMat.self._02 = _this.self._02 * invs;
					invs = 1.0 / scale.y;
					iron_math_Mat4.helpMat.self._10 = _this.self._10 * invs;
					iron_math_Mat4.helpMat.self._11 = _this.self._11 * invs;
					iron_math_Mat4.helpMat.self._12 = _this.self._12 * invs;
					invs = 1.0 / scale.z;
					iron_math_Mat4.helpMat.self._20 = _this.self._20 * invs;
					iron_math_Mat4.helpMat.self._21 = _this.self._21 * invs;
					iron_math_Mat4.helpMat.self._22 = _this.self._22 * invs;
					let m = iron_math_Mat4.helpMat;
					let m11 = m.self._00;
					let m12 = m.self._10;
					let m13 = m.self._20;
					let m21 = m.self._01;
					let m22 = m.self._11;
					let m23 = m.self._21;
					let m311 = m.self._02;
					let m321 = m.self._12;
					let m331 = m.self._22;
					let tr = m11 + m22 + m331;
					let s = 0.0;
					if(tr > 0) {
						s = 0.5 / Math.sqrt(tr + 1.0);
						quat.w = 0.25 / s;
						quat.x = (m321 - m23) * s;
						quat.y = (m13 - m311) * s;
						quat.z = (m21 - m12) * s;
					} else if(m11 > m22 && m11 > m331) {
						s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m331);
						quat.w = (m321 - m23) / s;
						quat.x = 0.25 * s;
						quat.y = (m12 + m21) / s;
						quat.z = (m13 + m311) / s;
					} else if(m22 > m331) {
						s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m331);
						quat.w = (m13 - m311) / s;
						quat.x = (m12 + m21) / s;
						quat.y = 0.25 * s;
						quat.z = (m23 + m321) / s;
					} else {
						s = 2.0 * Math.sqrt(1.0 + m331 - m11 - m22);
						quat.w = (m21 - m12) / s;
						quat.x = (m13 + m311) / s;
						quat.y = (m23 + m321) / s;
						quat.z = 0.25 * s;
					}
					let _this5 = arm_render_Gizmo.q0;
					let angle = arm_Context.gizmoDrag - arm_Context.gizmoDragLast;
					let s1 = Math.sin(angle * 0.5);
					_this5.x = 0.0 * s1;
					_this5.y = 0.0 * s1;
					_this5.z = s1;
					_this5.w = Math.cos(angle * 0.5);
					let l = Math.sqrt(_this5.x * _this5.x + _this5.y * _this5.y + _this5.z * _this5.z + _this5.w * _this5.w);
					if(l == 0.0) {
						_this5.x = 0;
						_this5.y = 0;
						_this5.z = 0;
						_this5.w = 0;
					} else {
						l = 1.0 / l;
						_this5.x *= l;
						_this5.y *= l;
						_this5.z *= l;
						_this5.w *= l;
					}
					let _this6 = arm_render_Gizmo.q;
					let q1 = arm_render_Gizmo.q0;
					let q2 = arm_render_Gizmo.q;
					let q1x = q1.x;
					let q1y = q1.y;
					let q1z = q1.z;
					let q1w = q1.w;
					let q2x = q2.x;
					let q2y = q2.y;
					let q2z = q2.z;
					let q2w = q2.w;
					_this6.x = q1x * q2w + q1w * q2x + q1y * q2z - q1z * q2y;
					_this6.y = q1w * q2y - q1x * q2z + q1y * q2w + q1z * q2x;
					_this6.z = q1w * q2z + q1x * q2y - q1y * q2x + q1z * q2w;
					_this6.w = q1w * q2w - q1x * q2x - q1y * q2y - q1z * q2z;
					let _this7 = arm_Context.layer.decalMat;
					let loc1 = arm_render_Gizmo.v;
					let quat1 = arm_render_Gizmo.q;
					let sc = arm_render_Gizmo.v0;
					let x = quat1.x;
					let y = quat1.y;
					let z = quat1.z;
					let w = quat1.w;
					let x2 = x + x;
					let y2 = y + y;
					let z2 = z + z;
					let xx = x * x2;
					let xy = x * y2;
					let xz = x * z2;
					let yy = y * y2;
					let yz = y * z2;
					let zz = z * z2;
					let wx = w * x2;
					let wy = w * y2;
					let wz = w * z2;
					_this7.self._00 = 1.0 - (yy + zz);
					_this7.self._10 = xy - wz;
					_this7.self._20 = xz + wy;
					_this7.self._01 = xy + wz;
					_this7.self._11 = 1.0 - (xx + zz);
					_this7.self._21 = yz - wx;
					_this7.self._02 = xz - wy;
					_this7.self._12 = yz + wx;
					_this7.self._22 = 1.0 - (xx + yy);
					_this7.self._03 = 0.0;
					_this7.self._13 = 0.0;
					_this7.self._23 = 0.0;
					_this7.self._30 = 0.0;
					_this7.self._31 = 0.0;
					_this7.self._32 = 0.0;
					_this7.self._33 = 1.0;
					let x1 = sc.x;
					let y1 = sc.y;
					let z1 = sc.z;
					_this7.self._00 *= x1;
					_this7.self._01 *= x1;
					_this7.self._02 *= x1;
					_this7.self._03 *= x1;
					_this7.self._10 *= y1;
					_this7.self._11 *= y1;
					_this7.self._12 *= y1;
					_this7.self._13 *= y1;
					_this7.self._20 *= z1;
					_this7.self._21 *= z1;
					_this7.self._22 *= z1;
					_this7.self._23 *= z1;
					_this7.self._30 = loc1.x;
					_this7.self._31 = loc1.y;
					_this7.self._32 = loc1.z;
				}
				arm_Context.gizmoDragLast = arm_Context.gizmoDrag;
				if(arm_Context.material != arm_Context.layer.fill_layer) {
					arm_Context.setMaterial(arm_Context.layer.fill_layer);
				}
				arm_Layers.updateFillLayer(arm_Context.gizmoStarted);
			}
		}
		arm_Context.gizmoStarted = false;
		if(mouse.started("left") && arm_Context.paintObject.name != "Scene") {
			let hit = iron_math_RayCaster.closestBoxIntersect([arm_Context.gizmoTranslateX.transform,arm_Context.gizmoTranslateY.transform,arm_Context.gizmoTranslateZ.transform,arm_Context.gizmoScaleX.transform,arm_Context.gizmoScaleY.transform,arm_Context.gizmoScaleZ.transform],mouse.x - arm_App.x(),mouse.y - arm_App.y(),iron_Scene.active.camera);
			if(hit != null) {
				if(hit.object == arm_Context.gizmoTranslateX) {
					arm_Context.translateX = true;
				} else if(hit.object == arm_Context.gizmoTranslateY) {
					arm_Context.translateY = true;
				} else if(hit.object == arm_Context.gizmoTranslateZ) {
					arm_Context.translateZ = true;
				} else if(hit.object == arm_Context.gizmoScaleX) {
					arm_Context.scaleX = true;
				} else if(hit.object == arm_Context.gizmoScaleY) {
					arm_Context.scaleY = true;
				} else if(hit.object == arm_Context.gizmoScaleZ) {
					arm_Context.scaleZ = true;
				}
				if(arm_Context.translateX || arm_Context.translateY || arm_Context.translateZ || arm_Context.scaleX || arm_Context.scaleY || arm_Context.scaleZ) {
					arm_Context.gizmoOffset = 0.0;
					arm_Context.gizmoStarted = true;
				}
			} else {
				let hit = iron_math_RayCaster.closestBoxIntersect([arm_Context.gizmoRotateX.transform,arm_Context.gizmoRotateY.transform,arm_Context.gizmoRotateZ.transform],mouse.x - arm_App.x(),mouse.y - arm_App.y(),iron_Scene.active.camera);
				if(hit != null) {
					if(hit.object == arm_Context.gizmoRotateX) {
						arm_Context.rotateX = true;
					} else if(hit.object == arm_Context.gizmoRotateY) {
						arm_Context.rotateY = true;
					} else if(hit.object == arm_Context.gizmoRotateZ) {
						arm_Context.rotateZ = true;
					}
					if(arm_Context.rotateX || arm_Context.rotateY || arm_Context.rotateZ) {
						arm_Context.gizmoOffset = 0.0;
						arm_Context.gizmoStarted = true;
					}
				}
			}
		} else if(mouse.released("left")) {
			arm_Context.translateX = arm_Context.translateY = arm_Context.translateZ = false;
			arm_Context.scaleX = arm_Context.scaleY = arm_Context.scaleZ = false;
			arm_Context.rotateX = arm_Context.rotateY = arm_Context.rotateZ = false;
		}
		if(arm_Context.translateX || arm_Context.translateY || arm_Context.translateZ || arm_Context.scaleX || arm_Context.scaleY || arm_Context.scaleZ || arm_Context.rotateX || arm_Context.rotateY || arm_Context.rotateZ) {
			arm_Context.rdirty = 2;
			if(isObject) {
				let t = arm_Context.paintObject.transform;
				let _this = arm_render_Gizmo.v;
				_this.x = t.world.self._30;
				_this.y = t.world.self._31;
				_this.z = t.world.self._32;
				_this.w = 1.0;
			} else if(isDecal) {
				let _this = arm_render_Gizmo.v;
				_this.x = arm_Context.layer.decalMat.self._30;
				_this.y = arm_Context.layer.decalMat.self._31;
				_this.z = arm_Context.layer.decalMat.self._32;
				_this.w = 1.0;
			}
			if(arm_Context.translateX || arm_Context.scaleX) {
				let hit = iron_math_RayCaster.planeIntersect(new iron_math_Vec4(0.0,1.0,0.0),arm_render_Gizmo.v,mouse.x - arm_App.x(),mouse.y - arm_App.y(),iron_Scene.active.camera);
				if(hit != null) {
					if(arm_Context.gizmoStarted) {
						arm_Context.gizmoOffset = hit.x - arm_render_Gizmo.v.x;
					}
					arm_Context.gizmoDrag = hit.x - arm_Context.gizmoOffset;
				}
			} else if(arm_Context.translateY || arm_Context.scaleY) {
				let hit = iron_math_RayCaster.planeIntersect(new iron_math_Vec4(1.0,0.0,0.0),arm_render_Gizmo.v,mouse.x - arm_App.x(),mouse.y - arm_App.y(),iron_Scene.active.camera);
				if(hit != null) {
					if(arm_Context.gizmoStarted) {
						arm_Context.gizmoOffset = hit.y - arm_render_Gizmo.v.y;
					}
					arm_Context.gizmoDrag = hit.y - arm_Context.gizmoOffset;
				}
			} else if(arm_Context.translateZ || arm_Context.scaleZ) {
				let hit = iron_math_RayCaster.planeIntersect(new iron_math_Vec4(1.0,0.0,0.0),arm_render_Gizmo.v,mouse.x - arm_App.x(),mouse.y - arm_App.y(),iron_Scene.active.camera);
				if(hit != null) {
					if(arm_Context.gizmoStarted) {
						arm_Context.gizmoOffset = hit.z - arm_render_Gizmo.v.z;
					}
					arm_Context.gizmoDrag = hit.z - arm_Context.gizmoOffset;
				}
			} else if(arm_Context.rotateX) {
				let hit = iron_math_RayCaster.planeIntersect(new iron_math_Vec4(1.0,0.0,0.0),arm_render_Gizmo.v,mouse.x - arm_App.x(),mouse.y - arm_App.y(),iron_Scene.active.camera);
				if(hit != null) {
					if(arm_Context.gizmoStarted) {
						let _this = arm_Context.layer.decalMat;
						let loc = arm_render_Gizmo.v;
						let quat = arm_render_Gizmo.q;
						let scale = arm_render_Gizmo.v0;
						loc.x = _this.self._30;
						loc.y = _this.self._31;
						loc.z = _this.self._32;
						let _this1 = iron_math_Mat4.helpVec;
						_this1.x = _this.self._00;
						_this1.y = _this.self._01;
						_this1.z = _this.self._02;
						_this1.w = 1.0;
						scale.x = Math.sqrt(_this1.x * _this1.x + _this1.y * _this1.y + _this1.z * _this1.z);
						let _this2 = iron_math_Mat4.helpVec;
						_this2.x = _this.self._10;
						_this2.y = _this.self._11;
						_this2.z = _this.self._12;
						_this2.w = 1.0;
						scale.y = Math.sqrt(_this2.x * _this2.x + _this2.y * _this2.y + _this2.z * _this2.z);
						let _this3 = iron_math_Mat4.helpVec;
						_this3.x = _this.self._20;
						_this3.y = _this.self._21;
						_this3.z = _this.self._22;
						_this3.w = 1.0;
						scale.z = Math.sqrt(_this3.x * _this3.x + _this3.y * _this3.y + _this3.z * _this3.z);
						let _this4 = _this.self;
						let m3 = _this4._12;
						let m4 = _this4._22;
						let m5 = _this4._32;
						let m6 = _this4._13;
						let m7 = _this4._23;
						let m8 = _this4._33;
						let m31 = _this4._12;
						let m41 = _this4._22;
						let m51 = _this4._32;
						let m61 = _this4._13;
						let m71 = _this4._23;
						let m81 = _this4._33;
						let m32 = _this4._11;
						let m42 = _this4._21;
						let m52 = _this4._31;
						let m62 = _this4._13;
						let m72 = _this4._23;
						let m82 = _this4._33;
						let m33 = _this4._11;
						let m43 = _this4._21;
						let m53 = _this4._31;
						let m63 = _this4._12;
						let m73 = _this4._22;
						let m83 = _this4._32;
						if(_this4._00 * (_this4._11 * (m4 * m8 - m5 * m7) - _this4._21 * (m3 * m8 - m5 * m6) + _this4._31 * (m3 * m7 - m4 * m6)) - _this4._01 * (_this4._10 * (m41 * m81 - m51 * m71) - _this4._20 * (m31 * m81 - m51 * m61) + _this4._30 * (m31 * m71 - m41 * m61)) + _this4._02 * (_this4._10 * (m42 * m82 - m52 * m72) - _this4._20 * (m32 * m82 - m52 * m62) + _this4._30 * (m32 * m72 - m42 * m62)) - _this4._03 * (_this4._10 * (m43 * m83 - m53 * m73) - _this4._20 * (m33 * m83 - m53 * m63) + _this4._30 * (m33 * m73 - m43 * m63)) < 0.0) {
							scale.x = -scale.x;
						}
						let invs = 1.0 / scale.x;
						iron_math_Mat4.helpMat.self._00 = _this.self._00 * invs;
						iron_math_Mat4.helpMat.self._01 = _this.self._01 * invs;
						iron_math_Mat4.helpMat.self._02 = _this.self._02 * invs;
						invs = 1.0 / scale.y;
						iron_math_Mat4.helpMat.self._10 = _this.self._10 * invs;
						iron_math_Mat4.helpMat.self._11 = _this.self._11 * invs;
						iron_math_Mat4.helpMat.self._12 = _this.self._12 * invs;
						invs = 1.0 / scale.z;
						iron_math_Mat4.helpMat.self._20 = _this.self._20 * invs;
						iron_math_Mat4.helpMat.self._21 = _this.self._21 * invs;
						iron_math_Mat4.helpMat.self._22 = _this.self._22 * invs;
						let m = iron_math_Mat4.helpMat;
						let m11 = m.self._00;
						let m12 = m.self._10;
						let m13 = m.self._20;
						let m21 = m.self._01;
						let m22 = m.self._11;
						let m23 = m.self._21;
						let m311 = m.self._02;
						let m321 = m.self._12;
						let m331 = m.self._22;
						let tr = m11 + m22 + m331;
						let s = 0.0;
						if(tr > 0) {
							s = 0.5 / Math.sqrt(tr + 1.0);
							quat.w = 0.25 / s;
							quat.x = (m321 - m23) * s;
							quat.y = (m13 - m311) * s;
							quat.z = (m21 - m12) * s;
						} else if(m11 > m22 && m11 > m331) {
							s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m331);
							quat.w = (m321 - m23) / s;
							quat.x = 0.25 * s;
							quat.y = (m12 + m21) / s;
							quat.z = (m13 + m311) / s;
						} else if(m22 > m331) {
							s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m331);
							quat.w = (m13 - m311) / s;
							quat.x = (m12 + m21) / s;
							quat.y = 0.25 * s;
							quat.z = (m23 + m321) / s;
						} else {
							s = 2.0 * Math.sqrt(1.0 + m331 - m11 - m22);
							quat.w = (m21 - m12) / s;
							quat.x = (m13 + m311) / s;
							quat.y = (m23 + m321) / s;
							quat.z = 0.25 * s;
						}
						arm_Context.gizmoOffset = Math.atan2(hit.y - arm_render_Gizmo.v.y,hit.z - arm_render_Gizmo.v.z);
					}
					arm_Context.gizmoDrag = Math.atan2(hit.y - arm_render_Gizmo.v.y,hit.z - arm_render_Gizmo.v.z) - arm_Context.gizmoOffset;
				}
			} else if(arm_Context.rotateY) {
				let hit = iron_math_RayCaster.planeIntersect(new iron_math_Vec4(0.0,1.0,0.0),arm_render_Gizmo.v,mouse.x - arm_App.x(),mouse.y - arm_App.y(),iron_Scene.active.camera);
				if(hit != null) {
					if(arm_Context.gizmoStarted) {
						let _this = arm_Context.layer.decalMat;
						let loc = arm_render_Gizmo.v;
						let quat = arm_render_Gizmo.q;
						let scale = arm_render_Gizmo.v0;
						loc.x = _this.self._30;
						loc.y = _this.self._31;
						loc.z = _this.self._32;
						let _this1 = iron_math_Mat4.helpVec;
						_this1.x = _this.self._00;
						_this1.y = _this.self._01;
						_this1.z = _this.self._02;
						_this1.w = 1.0;
						scale.x = Math.sqrt(_this1.x * _this1.x + _this1.y * _this1.y + _this1.z * _this1.z);
						let _this2 = iron_math_Mat4.helpVec;
						_this2.x = _this.self._10;
						_this2.y = _this.self._11;
						_this2.z = _this.self._12;
						_this2.w = 1.0;
						scale.y = Math.sqrt(_this2.x * _this2.x + _this2.y * _this2.y + _this2.z * _this2.z);
						let _this3 = iron_math_Mat4.helpVec;
						_this3.x = _this.self._20;
						_this3.y = _this.self._21;
						_this3.z = _this.self._22;
						_this3.w = 1.0;
						scale.z = Math.sqrt(_this3.x * _this3.x + _this3.y * _this3.y + _this3.z * _this3.z);
						let _this4 = _this.self;
						let m3 = _this4._12;
						let m4 = _this4._22;
						let m5 = _this4._32;
						let m6 = _this4._13;
						let m7 = _this4._23;
						let m8 = _this4._33;
						let m31 = _this4._12;
						let m41 = _this4._22;
						let m51 = _this4._32;
						let m61 = _this4._13;
						let m71 = _this4._23;
						let m81 = _this4._33;
						let m32 = _this4._11;
						let m42 = _this4._21;
						let m52 = _this4._31;
						let m62 = _this4._13;
						let m72 = _this4._23;
						let m82 = _this4._33;
						let m33 = _this4._11;
						let m43 = _this4._21;
						let m53 = _this4._31;
						let m63 = _this4._12;
						let m73 = _this4._22;
						let m83 = _this4._32;
						if(_this4._00 * (_this4._11 * (m4 * m8 - m5 * m7) - _this4._21 * (m3 * m8 - m5 * m6) + _this4._31 * (m3 * m7 - m4 * m6)) - _this4._01 * (_this4._10 * (m41 * m81 - m51 * m71) - _this4._20 * (m31 * m81 - m51 * m61) + _this4._30 * (m31 * m71 - m41 * m61)) + _this4._02 * (_this4._10 * (m42 * m82 - m52 * m72) - _this4._20 * (m32 * m82 - m52 * m62) + _this4._30 * (m32 * m72 - m42 * m62)) - _this4._03 * (_this4._10 * (m43 * m83 - m53 * m73) - _this4._20 * (m33 * m83 - m53 * m63) + _this4._30 * (m33 * m73 - m43 * m63)) < 0.0) {
							scale.x = -scale.x;
						}
						let invs = 1.0 / scale.x;
						iron_math_Mat4.helpMat.self._00 = _this.self._00 * invs;
						iron_math_Mat4.helpMat.self._01 = _this.self._01 * invs;
						iron_math_Mat4.helpMat.self._02 = _this.self._02 * invs;
						invs = 1.0 / scale.y;
						iron_math_Mat4.helpMat.self._10 = _this.self._10 * invs;
						iron_math_Mat4.helpMat.self._11 = _this.self._11 * invs;
						iron_math_Mat4.helpMat.self._12 = _this.self._12 * invs;
						invs = 1.0 / scale.z;
						iron_math_Mat4.helpMat.self._20 = _this.self._20 * invs;
						iron_math_Mat4.helpMat.self._21 = _this.self._21 * invs;
						iron_math_Mat4.helpMat.self._22 = _this.self._22 * invs;
						let m = iron_math_Mat4.helpMat;
						let m11 = m.self._00;
						let m12 = m.self._10;
						let m13 = m.self._20;
						let m21 = m.self._01;
						let m22 = m.self._11;
						let m23 = m.self._21;
						let m311 = m.self._02;
						let m321 = m.self._12;
						let m331 = m.self._22;
						let tr = m11 + m22 + m331;
						let s = 0.0;
						if(tr > 0) {
							s = 0.5 / Math.sqrt(tr + 1.0);
							quat.w = 0.25 / s;
							quat.x = (m321 - m23) * s;
							quat.y = (m13 - m311) * s;
							quat.z = (m21 - m12) * s;
						} else if(m11 > m22 && m11 > m331) {
							s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m331);
							quat.w = (m321 - m23) / s;
							quat.x = 0.25 * s;
							quat.y = (m12 + m21) / s;
							quat.z = (m13 + m311) / s;
						} else if(m22 > m331) {
							s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m331);
							quat.w = (m13 - m311) / s;
							quat.x = (m12 + m21) / s;
							quat.y = 0.25 * s;
							quat.z = (m23 + m321) / s;
						} else {
							s = 2.0 * Math.sqrt(1.0 + m331 - m11 - m22);
							quat.w = (m21 - m12) / s;
							quat.x = (m13 + m311) / s;
							quat.y = (m23 + m321) / s;
							quat.z = 0.25 * s;
						}
						arm_Context.gizmoOffset = Math.atan2(hit.z - arm_render_Gizmo.v.z,hit.x - arm_render_Gizmo.v.x);
					}
					arm_Context.gizmoDrag = Math.atan2(hit.z - arm_render_Gizmo.v.z,hit.x - arm_render_Gizmo.v.x) - arm_Context.gizmoOffset;
				}
			} else if(arm_Context.rotateZ) {
				let hit = iron_math_RayCaster.planeIntersect(new iron_math_Vec4(0.0,0.0,1.0),arm_render_Gizmo.v,mouse.x - arm_App.x(),mouse.y - arm_App.y(),iron_Scene.active.camera);
				if(hit != null) {
					if(arm_Context.gizmoStarted) {
						let _this = arm_Context.layer.decalMat;
						let loc = arm_render_Gizmo.v;
						let quat = arm_render_Gizmo.q;
						let scale = arm_render_Gizmo.v0;
						loc.x = _this.self._30;
						loc.y = _this.self._31;
						loc.z = _this.self._32;
						let _this1 = iron_math_Mat4.helpVec;
						_this1.x = _this.self._00;
						_this1.y = _this.self._01;
						_this1.z = _this.self._02;
						_this1.w = 1.0;
						scale.x = Math.sqrt(_this1.x * _this1.x + _this1.y * _this1.y + _this1.z * _this1.z);
						let _this2 = iron_math_Mat4.helpVec;
						_this2.x = _this.self._10;
						_this2.y = _this.self._11;
						_this2.z = _this.self._12;
						_this2.w = 1.0;
						scale.y = Math.sqrt(_this2.x * _this2.x + _this2.y * _this2.y + _this2.z * _this2.z);
						let _this3 = iron_math_Mat4.helpVec;
						_this3.x = _this.self._20;
						_this3.y = _this.self._21;
						_this3.z = _this.self._22;
						_this3.w = 1.0;
						scale.z = Math.sqrt(_this3.x * _this3.x + _this3.y * _this3.y + _this3.z * _this3.z);
						let _this4 = _this.self;
						let m3 = _this4._12;
						let m4 = _this4._22;
						let m5 = _this4._32;
						let m6 = _this4._13;
						let m7 = _this4._23;
						let m8 = _this4._33;
						let m31 = _this4._12;
						let m41 = _this4._22;
						let m51 = _this4._32;
						let m61 = _this4._13;
						let m71 = _this4._23;
						let m81 = _this4._33;
						let m32 = _this4._11;
						let m42 = _this4._21;
						let m52 = _this4._31;
						let m62 = _this4._13;
						let m72 = _this4._23;
						let m82 = _this4._33;
						let m33 = _this4._11;
						let m43 = _this4._21;
						let m53 = _this4._31;
						let m63 = _this4._12;
						let m73 = _this4._22;
						let m83 = _this4._32;
						if(_this4._00 * (_this4._11 * (m4 * m8 - m5 * m7) - _this4._21 * (m3 * m8 - m5 * m6) + _this4._31 * (m3 * m7 - m4 * m6)) - _this4._01 * (_this4._10 * (m41 * m81 - m51 * m71) - _this4._20 * (m31 * m81 - m51 * m61) + _this4._30 * (m31 * m71 - m41 * m61)) + _this4._02 * (_this4._10 * (m42 * m82 - m52 * m72) - _this4._20 * (m32 * m82 - m52 * m62) + _this4._30 * (m32 * m72 - m42 * m62)) - _this4._03 * (_this4._10 * (m43 * m83 - m53 * m73) - _this4._20 * (m33 * m83 - m53 * m63) + _this4._30 * (m33 * m73 - m43 * m63)) < 0.0) {
							scale.x = -scale.x;
						}
						let invs = 1.0 / scale.x;
						iron_math_Mat4.helpMat.self._00 = _this.self._00 * invs;
						iron_math_Mat4.helpMat.self._01 = _this.self._01 * invs;
						iron_math_Mat4.helpMat.self._02 = _this.self._02 * invs;
						invs = 1.0 / scale.y;
						iron_math_Mat4.helpMat.self._10 = _this.self._10 * invs;
						iron_math_Mat4.helpMat.self._11 = _this.self._11 * invs;
						iron_math_Mat4.helpMat.self._12 = _this.self._12 * invs;
						invs = 1.0 / scale.z;
						iron_math_Mat4.helpMat.self._20 = _this.self._20 * invs;
						iron_math_Mat4.helpMat.self._21 = _this.self._21 * invs;
						iron_math_Mat4.helpMat.self._22 = _this.self._22 * invs;
						let m = iron_math_Mat4.helpMat;
						let m11 = m.self._00;
						let m12 = m.self._10;
						let m13 = m.self._20;
						let m21 = m.self._01;
						let m22 = m.self._11;
						let m23 = m.self._21;
						let m311 = m.self._02;
						let m321 = m.self._12;
						let m331 = m.self._22;
						let tr = m11 + m22 + m331;
						let s = 0.0;
						if(tr > 0) {
							s = 0.5 / Math.sqrt(tr + 1.0);
							quat.w = 0.25 / s;
							quat.x = (m321 - m23) * s;
							quat.y = (m13 - m311) * s;
							quat.z = (m21 - m12) * s;
						} else if(m11 > m22 && m11 > m331) {
							s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m331);
							quat.w = (m321 - m23) / s;
							quat.x = 0.25 * s;
							quat.y = (m12 + m21) / s;
							quat.z = (m13 + m311) / s;
						} else if(m22 > m331) {
							s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m331);
							quat.w = (m13 - m311) / s;
							quat.x = (m12 + m21) / s;
							quat.y = 0.25 * s;
							quat.z = (m23 + m321) / s;
						} else {
							s = 2.0 * Math.sqrt(1.0 + m331 - m11 - m22);
							quat.w = (m21 - m12) / s;
							quat.x = (m13 + m311) / s;
							quat.y = (m23 + m321) / s;
							quat.z = 0.25 * s;
						}
						arm_Context.gizmoOffset = Math.atan2(hit.y - arm_render_Gizmo.v.y,hit.x - arm_render_Gizmo.v.x);
					}
					arm_Context.gizmoDrag = Math.atan2(hit.y - arm_render_Gizmo.v.y,hit.x - arm_render_Gizmo.v.x) - arm_Context.gizmoOffset;
				}
			}
			if(arm_Context.gizmoStarted) {
				arm_Context.gizmoDragLast = arm_Context.gizmoDrag;
			}
		}
		iron_system_Input.occupied = (arm_Context.translateX || arm_Context.translateY || arm_Context.translateZ || arm_Context.scaleX || arm_Context.scaleY || arm_Context.scaleZ || arm_Context.rotateX || arm_Context.rotateY || arm_Context.rotateZ) && mouse.x - arm_App.x() < arm_App.w();
	}
}
$hxClasses["arm.render.Gizmo"] = arm_render_Gizmo;
arm_render_Gizmo.__name__ = "arm.render.Gizmo";
class arm_render_Inc {
	static init(_path) {
		arm_render_Inc.path = _path;
		arm_render_Inc.superSample = arm_Config.raw.rp_supersample;
	}
	static applyConfig() {
		let config = arm_Config.raw;
		if(arm_render_Inc.superSample != config.rp_supersample) {
			arm_render_Inc.superSample = config.rp_supersample;
			let h = arm_render_Inc.path.renderTargets.h;
			let rt_keys = Object.keys(h);
			let rt_length = rt_keys.length;
			let rt_current = 0;
			while(rt_current < rt_length) {
				let rt = h[rt_keys[rt_current++]];
				if(rt.raw.width == 0 && rt.raw.scale != null) {
					rt.raw.scale = arm_render_Inc.superSample;
				}
			}
			arm_render_Inc.path.resize();
		}
		if(!arm_render_Inc.voxelsCreated) {
			arm_render_Inc.initGI();
		}
	}
	static initGI(tname) {
		if(tname == null) {
			tname = "voxels";
		}
		if(arm_Config.raw.rp_gi != true || arm_render_Inc.voxelsCreated) {
			return;
		}
		arm_render_Inc.voxelsCreated = true;
		let t = new iron_RenderTargetRaw();
		t.name = tname;
		t.format = "R8";
		t.width = 256;
		t.height = 256;
		t.depth = 256. | 0;
		t.is_image = true;
		t.mipmaps = true;
		arm_render_Inc.path.createRenderTarget(t);
	}
	static drawCompass(currentG) {
		if(arm_Context.showCompass) {
			let cam = iron_Scene.active.camera;
			let compass = iron_Scene.active.getChild(".Compass");
			let visible = compass.visible;
			let parent = compass.parent;
			let loc = compass.transform.loc;
			let rot = compass.transform.rot;
			let crot = cam.transform.rot;
			let ratio = arm_App.w() / arm_App.h();
			let P = cam.P;
			let left = -8 * ratio;
			let right = 8 * ratio;
			let rl = right - left;
			cam.P = new iron_math_Mat4(2 / rl,0,0,-(right + left) / rl,0,0.125,0,0.,0,0,-0.5,0.,0,0,0,1);
			compass.visible = true;
			compass.parent = cam;
			compass.transform.loc = new iron_math_Vec4(7.4 * ratio,7.0,-1);
			compass.transform.rot = new iron_math_Quat(-crot.x,-crot.y,-crot.z,crot.w);
			let _this = compass.transform.scale;
			_this.x = 0.4;
			_this.y = 0.4;
			_this.z = 0.4;
			_this.w = 1.0;
			compass.transform.buildMatrix();
			compass.render(currentG,"overlay",[]);
			cam.P = P;
			compass.visible = visible;
			compass.parent = parent;
			compass.transform.loc = loc;
			compass.transform.rot = rot;
			compass.transform.buildMatrix();
		}
	}
	static beginSplit() {
		if(arm_Context.splitView && !arm_Context.paint2dView) {
			if(arm_Context.viewIndexLast == -1 && arm_Context.viewIndex == -1) {
				arm_Context.viewIndex = 1;
			} else {
				arm_Context.viewIndex = iron_system_Input.getMouse().x - arm_App.x() > arm_App.w() / 2 ? 1 : 0;
			}
			let cam = iron_Scene.active.camera;
			if(arm_Context.viewIndexLast > -1) {
				let _this = arm_Camera.inst.views[arm_Context.viewIndexLast];
				let m = cam.transform.local;
				_this.self._00 = m.self._00;
				_this.self._01 = m.self._01;
				_this.self._02 = m.self._02;
				_this.self._03 = m.self._03;
				_this.self._10 = m.self._10;
				_this.self._11 = m.self._11;
				_this.self._12 = m.self._12;
				_this.self._13 = m.self._13;
				_this.self._20 = m.self._20;
				_this.self._21 = m.self._21;
				_this.self._22 = m.self._22;
				_this.self._23 = m.self._23;
				_this.self._30 = m.self._30;
				_this.self._31 = m.self._31;
				_this.self._32 = m.self._32;
				_this.self._33 = m.self._33;
			}
			if(arm_Context.viewIndexLast != arm_Context.viewIndex || (arm_Context.tool == 3 || arm_Context.tool == 4) || !arm_Config.raw.brush_3d) {
				arm_Context.ddirty = 1;
			}
			cam.transform.setMatrix(arm_Camera.inst.views[arm_Context.viewIndex]);
			cam.buildMatrix();
			cam.buildProjection();
		}
	}
	static end() {
		arm_render_Inc.endSplit();
		if(arm_Context.foregroundEvent && !iron_system_Input.getMouse().down()) {
			arm_Context.foregroundEvent = false;
			arm_Context.pdirty = 0;
		}
	}
	static endSplit() {
		arm_Context.viewIndexLast = arm_Context.viewIndex;
		arm_Context.viewIndex = -1;
	}
	static isCached() {
		let mouse = iron_system_Input.getMouse();
		let mx = arm_render_Inc.lastX;
		let my = arm_render_Inc.lastY;
		arm_render_Inc.lastX = mouse.x - arm_App.x();
		arm_render_Inc.lastY = mouse.y - arm_App.y();
		if(arm_Config.raw.brush_live && arm_Context.pdirty <= 0) {
			if((mx != arm_render_Inc.lastX || my != arm_render_Inc.lastY) && (arm_Context.paintVec.x < 1 && arm_Context.paintVec.x > 0 && arm_Context.paintVec.y < 1 && arm_Context.paintVec.y > 0 || arm_ui_UIView2D.inst.show && arm_ui_UIView2D.inst.type == 0 && mx > arm_ui_UIView2D.inst.wx && mx < arm_ui_UIView2D.inst.wx + arm_ui_UIView2D.inst.ww && my > arm_ui_UIView2D.inst.wy && my < arm_ui_UIView2D.inst.wy + arm_ui_UIView2D.inst.wh) || arm_Context.brushLocked) {
				arm_Context.rdirty = 2;
			}
		}
		if(arm_Context.ddirty <= 0 && arm_Context.rdirty <= 0 && arm_Context.pdirty <= 0) {
			if(mx != arm_render_Inc.lastX || my != arm_render_Inc.lastY || mouse.locked) {
				arm_Context.ddirty = 0;
			}
			if(arm_Context.ddirty > -2) {
				arm_render_Inc.path.setTarget("");
				arm_render_Inc.path.bindTarget("taa","tex");
				if(arm_Config.raw.rp_supersample == 4) {
					arm_render_Inc.path.drawShader("shader_datas/supersample_resolve/supersample_resolve");
				} else {
					arm_render_Inc.path.drawShader("shader_datas/copy_pass/copy_pass");
				}
				if(arm_Config.raw.brush_3d) {
					arm_render_RenderPathPaint.commandsCursor();
				}
				if(arm_Context.ddirty <= 0) {
					arm_Context.ddirty--;
				}
			}
			arm_render_Inc.end();
			if(!arm_render_RenderPathPaint.dilated) {
				arm_render_RenderPathPaint.dilate(arm_Config.raw.dilate == 1,true);
				arm_render_RenderPathPaint.dilated = true;
			}
			return true;
		}
		return false;
	}
}
$hxClasses["arm.render.Inc"] = arm_render_Inc;
arm_render_Inc.__name__ = "arm.render.Inc";
class arm_render_LineDraw {
	static render(g4) {
		let hide = arm_Operator.shortcut(arm_Config.keymap.stencil_hide,2) || iron_system_Input.getKeyboard().down("control");
		if(!arm_App.isDecalLayer() || hide) {
			return;
		}
		arm_render_LineDraw.mat = arm_Context.layer.decalMat;
		let _this = arm_Context.layer.decalMat;
		arm_render_LineDraw.dim = new iron_math_Vec4(Math.sqrt(_this.self._00 * _this.self._00 + _this.self._10 * _this.self._10 + _this.self._20 * _this.self._20),Math.sqrt(_this.self._01 * _this.self._01 + _this.self._11 * _this.self._11 + _this.self._21 * _this.self._21),Math.sqrt(_this.self._02 * _this.self._02 + _this.self._12 * _this.self._12 + _this.self._22 * _this.self._22));
		arm_render_LineDraw.g = g4;
		if(arm_render_LineDraw.pipeline == null) {
			let structure = new kha_graphics4_VertexStructure();
			structure.add("pos",2);
			structure.add("col",2);
			arm_render_LineDraw.pipeline = new kha_graphics4_PipelineState();
			arm_render_LineDraw.pipeline.inputLayout = [structure];
			arm_render_LineDraw.pipeline.fragmentShader = kha_Shaders.getFragment("line.frag");
			arm_render_LineDraw.pipeline.vertexShader = kha_Shaders.getVertex("line.vert");
			arm_render_LineDraw.pipeline.depthWrite = true;
			arm_render_LineDraw.pipeline.depthMode = 4;
			arm_render_LineDraw.pipeline.cullMode = 2;
			arm_render_LineDraw.pipeline.colorAttachmentCount = 3;
			arm_render_LineDraw.pipeline.colorAttachments[0] = 4;
			arm_render_LineDraw.pipeline.colorAttachments[1] = 4;
			arm_render_LineDraw.pipeline.colorAttachments[2] = 4;
			arm_render_LineDraw.pipeline.depthStencilAttachment = 1;
			arm_render_LineDraw.pipeline.compile();
			arm_render_LineDraw.vpID = arm_render_LineDraw.pipeline.getConstantLocation("VP");
			arm_render_LineDraw.vp = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
			arm_render_LineDraw.vertexBuffer = new kha_graphics4_VertexBuffer(1200,structure,1);
			arm_render_LineDraw.indexBuffer = new kha_graphics4_IndexBuffer(1800,1);
		}
		arm_render_LineDraw.begin();
		arm_render_LineDraw.bounds(arm_render_LineDraw.mat,arm_render_LineDraw.dim);
		arm_render_LineDraw.end();
	}
	static bounds(mat,dim) {
		arm_render_LineDraw.wpos = new iron_math_Vec4(mat.self._30,mat.self._31,mat.self._32,mat.self._33);
		let dx = dim.x / 2;
		let dy = dim.y / 2;
		let dz = dim.z / 2;
		let x = mat.self._20;
		let y = mat.self._21;
		let z = mat.self._22;
		if(z == null) {
			z = 0.0;
		}
		if(y == null) {
			y = 0.0;
		}
		if(x == null) {
			x = 0.0;
		}
		let up_x = x;
		let up_y = y;
		let up_z = z;
		let x1 = mat.self._10;
		let y1 = mat.self._11;
		let z1 = mat.self._12;
		if(z1 == null) {
			z1 = 0.0;
		}
		if(y1 == null) {
			y1 = 0.0;
		}
		if(x1 == null) {
			x1 = 0.0;
		}
		let look_x = x1;
		let look_y = y1;
		let look_z = z1;
		let x2 = mat.self._00;
		let y2 = mat.self._01;
		let z2 = mat.self._02;
		if(z2 == null) {
			z2 = 0.0;
		}
		if(y2 == null) {
			y2 = 0.0;
		}
		if(x2 == null) {
			x2 = 0.0;
		}
		let right_x = x2;
		let right_y = y2;
		let right_z = z2;
		let n = Math.sqrt(up_x * up_x + up_y * up_y + up_z * up_z);
		if(n > 0.0) {
			let invN = 1.0 / n;
			up_x *= invN;
			up_y *= invN;
			up_z *= invN;
		}
		let n1 = Math.sqrt(look_x * look_x + look_y * look_y + look_z * look_z);
		if(n1 > 0.0) {
			let invN = 1.0 / n1;
			look_x *= invN;
			look_y *= invN;
			look_z *= invN;
		}
		let n2 = Math.sqrt(right_x * right_x + right_y * right_y + right_z * right_z);
		if(n2 > 0.0) {
			let invN = 1.0 / n2;
			right_x *= invN;
			right_y *= invN;
			right_z *= invN;
		}
		let _this = arm_render_LineDraw.vx;
		_this.x = right_x;
		_this.y = right_y;
		_this.z = right_z;
		_this.w = 1.0;
		let _this1 = arm_render_LineDraw.vx;
		_this1.x *= dx;
		_this1.y *= dx;
		_this1.z *= dx;
		let _this2 = arm_render_LineDraw.vy;
		_this2.x = look_x;
		_this2.y = look_y;
		_this2.z = look_z;
		_this2.w = 1.0;
		let _this3 = arm_render_LineDraw.vy;
		_this3.x *= dy;
		_this3.y *= dy;
		_this3.z *= dy;
		let _this4 = arm_render_LineDraw.vz;
		_this4.x = up_x;
		_this4.y = up_y;
		_this4.z = up_z;
		_this4.w = 1.0;
		let _this5 = arm_render_LineDraw.vz;
		_this5.x *= dz;
		_this5.y *= dz;
		_this5.z *= dz;
		arm_render_LineDraw.lineb(-1,-1,-1,1,-1,-1);
		arm_render_LineDraw.lineb(-1,1,-1,1,1,-1);
		arm_render_LineDraw.lineb(-1,-1,1,1,-1,1);
		arm_render_LineDraw.lineb(-1,1,1,1,1,1);
		arm_render_LineDraw.lineb(-1,-1,-1,-1,1,-1);
		arm_render_LineDraw.lineb(-1,-1,1,-1,1,1);
		arm_render_LineDraw.lineb(1,-1,-1,1,1,-1);
		arm_render_LineDraw.lineb(1,-1,1,1,1,1);
		arm_render_LineDraw.lineb(-1,-1,-1,-1,-1,1);
		arm_render_LineDraw.lineb(-1,1,-1,-1,1,1);
		arm_render_LineDraw.lineb(1,-1,-1,1,-1,1);
		arm_render_LineDraw.lineb(1,1,-1,1,1,1);
	}
	static lineb(a,b,c,d,e,f) {
		let _this = arm_render_LineDraw.v1;
		let v = arm_render_LineDraw.wpos;
		_this.x = v.x;
		_this.y = v.y;
		_this.z = v.z;
		_this.w = v.w;
		let _this1 = arm_render_LineDraw.t;
		let v1 = arm_render_LineDraw.vx;
		_this1.x = v1.x;
		_this1.y = v1.y;
		_this1.z = v1.z;
		_this1.w = v1.w;
		let _this2 = arm_render_LineDraw.t;
		_this2.x *= a;
		_this2.y *= a;
		_this2.z *= a;
		let _this3 = arm_render_LineDraw.v1;
		let v2 = arm_render_LineDraw.t;
		_this3.x += v2.x;
		_this3.y += v2.y;
		_this3.z += v2.z;
		let _this4 = arm_render_LineDraw.t;
		let v3 = arm_render_LineDraw.vy;
		_this4.x = v3.x;
		_this4.y = v3.y;
		_this4.z = v3.z;
		_this4.w = v3.w;
		let _this5 = arm_render_LineDraw.t;
		_this5.x *= b;
		_this5.y *= b;
		_this5.z *= b;
		let _this6 = arm_render_LineDraw.v1;
		let v4 = arm_render_LineDraw.t;
		_this6.x += v4.x;
		_this6.y += v4.y;
		_this6.z += v4.z;
		let _this7 = arm_render_LineDraw.t;
		let v5 = arm_render_LineDraw.vz;
		_this7.x = v5.x;
		_this7.y = v5.y;
		_this7.z = v5.z;
		_this7.w = v5.w;
		let _this8 = arm_render_LineDraw.t;
		_this8.x *= c;
		_this8.y *= c;
		_this8.z *= c;
		let _this9 = arm_render_LineDraw.v1;
		let v6 = arm_render_LineDraw.t;
		_this9.x += v6.x;
		_this9.y += v6.y;
		_this9.z += v6.z;
		let _this10 = arm_render_LineDraw.v2;
		let v7 = arm_render_LineDraw.wpos;
		_this10.x = v7.x;
		_this10.y = v7.y;
		_this10.z = v7.z;
		_this10.w = v7.w;
		let _this11 = arm_render_LineDraw.t;
		let v8 = arm_render_LineDraw.vx;
		_this11.x = v8.x;
		_this11.y = v8.y;
		_this11.z = v8.z;
		_this11.w = v8.w;
		let _this12 = arm_render_LineDraw.t;
		_this12.x *= d;
		_this12.y *= d;
		_this12.z *= d;
		let _this13 = arm_render_LineDraw.v2;
		let v9 = arm_render_LineDraw.t;
		_this13.x += v9.x;
		_this13.y += v9.y;
		_this13.z += v9.z;
		let _this14 = arm_render_LineDraw.t;
		let v10 = arm_render_LineDraw.vy;
		_this14.x = v10.x;
		_this14.y = v10.y;
		_this14.z = v10.z;
		_this14.w = v10.w;
		let _this15 = arm_render_LineDraw.t;
		_this15.x *= e;
		_this15.y *= e;
		_this15.z *= e;
		let _this16 = arm_render_LineDraw.v2;
		let v11 = arm_render_LineDraw.t;
		_this16.x += v11.x;
		_this16.y += v11.y;
		_this16.z += v11.z;
		let _this17 = arm_render_LineDraw.t;
		let v12 = arm_render_LineDraw.vz;
		_this17.x = v12.x;
		_this17.y = v12.y;
		_this17.z = v12.z;
		_this17.w = v12.w;
		let _this18 = arm_render_LineDraw.t;
		_this18.x *= f;
		_this18.y *= f;
		_this18.z *= f;
		let _this19 = arm_render_LineDraw.v2;
		let v13 = arm_render_LineDraw.t;
		_this19.x += v13.x;
		_this19.y += v13.y;
		_this19.z += v13.z;
		arm_render_LineDraw.line(arm_render_LineDraw.v1.x,arm_render_LineDraw.v1.y,arm_render_LineDraw.v1.z,arm_render_LineDraw.v2.x,arm_render_LineDraw.v2.y,arm_render_LineDraw.v2.z);
	}
	static line(x1,y1,z1,x2,y2,z2) {
		if(arm_render_LineDraw.lines >= 300) {
			arm_render_LineDraw.end();
			arm_render_LineDraw.begin();
		}
		let _this = arm_render_LineDraw.midPoint;
		_this.x = x1 + x2;
		_this.y = y1 + y2;
		_this.z = z1 + z2;
		_this.w = 1.0;
		let _this1 = arm_render_LineDraw.midPoint;
		_this1.x *= 0.5;
		_this1.y *= 0.5;
		_this1.z *= 0.5;
		let _this2 = arm_render_LineDraw.midLine;
		_this2.x = x1;
		_this2.y = y1;
		_this2.z = z1;
		_this2.w = 1.0;
		let _this3 = arm_render_LineDraw.midLine;
		let v = arm_render_LineDraw.midPoint;
		_this3.x -= v.x;
		_this3.y -= v.y;
		_this3.z -= v.z;
		let _this4 = iron_Scene.active.camera.transform.world;
		arm_render_LineDraw.cameraLook = new iron_math_Vec4(_this4.self._30,_this4.self._31,_this4.self._32,_this4.self._33);
		let _this5 = arm_render_LineDraw.cameraLook;
		let v1 = arm_render_LineDraw.midPoint;
		_this5.x -= v1.x;
		_this5.y -= v1.y;
		_this5.z -= v1.z;
		let _this6 = arm_render_LineDraw.cameraLook;
		let v2 = arm_render_LineDraw.midLine;
		let ax = _this6.x;
		let ay = _this6.y;
		let az = _this6.z;
		let vx = v2.x;
		let vy = v2.y;
		let vz = v2.z;
		_this6.x = ay * vz - az * vy;
		_this6.y = az * vx - ax * vz;
		_this6.z = ax * vy - ay * vx;
		let n = Math.sqrt(_this6.x * _this6.x + _this6.y * _this6.y + _this6.z * _this6.z);
		if(n > 0.0) {
			let invN = 1.0 / n;
			_this6.x *= invN;
			_this6.y *= invN;
			_this6.z *= invN;
		}
		let f = arm_render_LineDraw.strength;
		_this6.x *= f;
		_this6.y *= f;
		_this6.z *= f;
		let _this7 = arm_render_LineDraw.corner1;
		_this7.x = x1;
		_this7.y = y1;
		_this7.z = z1;
		_this7.w = 1.0;
		_this7.x += _this6.x;
		_this7.y += _this6.y;
		_this7.z += _this6.z;
		let _this8 = arm_render_LineDraw.corner2;
		_this8.x = x1;
		_this8.y = y1;
		_this8.z = z1;
		_this8.w = 1.0;
		_this8.x -= _this6.x;
		_this8.y -= _this6.y;
		_this8.z -= _this6.z;
		let _this9 = arm_render_LineDraw.corner3;
		_this9.x = x2;
		_this9.y = y2;
		_this9.z = z2;
		_this9.w = 1.0;
		_this9.x -= _this6.x;
		_this9.y -= _this6.y;
		_this9.z -= _this6.z;
		let _this10 = arm_render_LineDraw.corner4;
		_this10.x = x2;
		_this10.y = y2;
		_this10.z = z2;
		_this10.w = 1.0;
		_this10.x += _this6.x;
		_this10.y += _this6.y;
		_this10.z += _this6.z;
		let i = arm_render_LineDraw.lines * 24;
		let data_1 = arm_render_LineDraw.corner1.y;
		let data_2 = arm_render_LineDraw.corner1.z;
		let data_3 = ((arm_render_LineDraw.color & 16711680) >>> 16) * 0.00392156862745098;
		let data_4 = ((arm_render_LineDraw.color & 65280) >>> 8) * 0.00392156862745098;
		let data_5 = (arm_render_LineDraw.color & 255) * 0.00392156862745098;
		arm_render_LineDraw.vbData.setFloat32(i * 4,arm_render_LineDraw.corner1.x,true);
		arm_render_LineDraw.vbData.setFloat32((i + 1) * 4,data_1,true);
		arm_render_LineDraw.vbData.setFloat32((i + 2) * 4,data_2,true);
		arm_render_LineDraw.vbData.setFloat32((i + 3) * 4,data_3,true);
		arm_render_LineDraw.vbData.setFloat32((i + 4) * 4,data_4,true);
		arm_render_LineDraw.vbData.setFloat32((i + 5) * 4,data_5,true);
		i += 6;
		let data_11 = arm_render_LineDraw.corner2.y;
		let data_21 = arm_render_LineDraw.corner2.z;
		let data_31 = ((arm_render_LineDraw.color & 16711680) >>> 16) * 0.00392156862745098;
		let data_41 = ((arm_render_LineDraw.color & 65280) >>> 8) * 0.00392156862745098;
		let data_51 = (arm_render_LineDraw.color & 255) * 0.00392156862745098;
		arm_render_LineDraw.vbData.setFloat32(i * 4,arm_render_LineDraw.corner2.x,true);
		arm_render_LineDraw.vbData.setFloat32((i + 1) * 4,data_11,true);
		arm_render_LineDraw.vbData.setFloat32((i + 2) * 4,data_21,true);
		arm_render_LineDraw.vbData.setFloat32((i + 3) * 4,data_31,true);
		arm_render_LineDraw.vbData.setFloat32((i + 4) * 4,data_41,true);
		arm_render_LineDraw.vbData.setFloat32((i + 5) * 4,data_51,true);
		i += 6;
		let data_12 = arm_render_LineDraw.corner3.y;
		let data_22 = arm_render_LineDraw.corner3.z;
		let data_32 = ((arm_render_LineDraw.color & 16711680) >>> 16) * 0.00392156862745098;
		let data_42 = ((arm_render_LineDraw.color & 65280) >>> 8) * 0.00392156862745098;
		let data_52 = (arm_render_LineDraw.color & 255) * 0.00392156862745098;
		arm_render_LineDraw.vbData.setFloat32(i * 4,arm_render_LineDraw.corner3.x,true);
		arm_render_LineDraw.vbData.setFloat32((i + 1) * 4,data_12,true);
		arm_render_LineDraw.vbData.setFloat32((i + 2) * 4,data_22,true);
		arm_render_LineDraw.vbData.setFloat32((i + 3) * 4,data_32,true);
		arm_render_LineDraw.vbData.setFloat32((i + 4) * 4,data_42,true);
		arm_render_LineDraw.vbData.setFloat32((i + 5) * 4,data_52,true);
		i += 6;
		let data_13 = arm_render_LineDraw.corner4.y;
		let data_23 = arm_render_LineDraw.corner4.z;
		let data_33 = ((arm_render_LineDraw.color & 16711680) >>> 16) * 0.00392156862745098;
		let data_43 = ((arm_render_LineDraw.color & 65280) >>> 8) * 0.00392156862745098;
		let data_53 = (arm_render_LineDraw.color & 255) * 0.00392156862745098;
		arm_render_LineDraw.vbData.setFloat32(i * 4,arm_render_LineDraw.corner4.x,true);
		arm_render_LineDraw.vbData.setFloat32((i + 1) * 4,data_13,true);
		arm_render_LineDraw.vbData.setFloat32((i + 2) * 4,data_23,true);
		arm_render_LineDraw.vbData.setFloat32((i + 3) * 4,data_33,true);
		arm_render_LineDraw.vbData.setFloat32((i + 4) * 4,data_43,true);
		arm_render_LineDraw.vbData.setFloat32((i + 5) * 4,data_53,true);
		i = arm_render_LineDraw.lines * 6;
		arm_render_LineDraw.ibData[i] = arm_render_LineDraw.lines * 4;
		arm_render_LineDraw.ibData[i + 1] = arm_render_LineDraw.lines * 4 + 1;
		arm_render_LineDraw.ibData[i + 2] = arm_render_LineDraw.lines * 4 + 2;
		arm_render_LineDraw.ibData[i + 3] = arm_render_LineDraw.lines * 4 + 2;
		arm_render_LineDraw.ibData[i + 4] = arm_render_LineDraw.lines * 4 + 3;
		arm_render_LineDraw.ibData[i + 5] = arm_render_LineDraw.lines * 4;
		arm_render_LineDraw.lines++;
	}
	static begin() {
		arm_render_LineDraw.lines = 0;
		arm_render_LineDraw.vbData = arm_render_LineDraw.vertexBuffer.lock();
		arm_render_LineDraw.ibData = arm_render_LineDraw.indexBuffer.lock();
	}
	static end() {
		arm_render_LineDraw.vertexBuffer.unlock();
		arm_render_LineDraw.indexBuffer.unlock();
		arm_render_LineDraw.g.setVertexBuffer(arm_render_LineDraw.vertexBuffer);
		arm_render_LineDraw.g.setIndexBuffer(arm_render_LineDraw.indexBuffer);
		arm_render_LineDraw.g.setPipeline(arm_render_LineDraw.pipeline);
		let camera = iron_Scene.active.camera;
		let _this = arm_render_LineDraw.vp;
		let m = camera.V;
		_this.self._00 = m.self._00;
		_this.self._01 = m.self._01;
		_this.self._02 = m.self._02;
		_this.self._03 = m.self._03;
		_this.self._10 = m.self._10;
		_this.self._11 = m.self._11;
		_this.self._12 = m.self._12;
		_this.self._13 = m.self._13;
		_this.self._20 = m.self._20;
		_this.self._21 = m.self._21;
		_this.self._22 = m.self._22;
		_this.self._23 = m.self._23;
		_this.self._30 = m.self._30;
		_this.self._31 = m.self._31;
		_this.self._32 = m.self._32;
		_this.self._33 = m.self._33;
		let _this1 = arm_render_LineDraw.vp;
		let m1 = camera.P;
		let a00 = _this1.self._00;
		let a01 = _this1.self._01;
		let a02 = _this1.self._02;
		let a03 = _this1.self._03;
		let a10 = _this1.self._10;
		let a11 = _this1.self._11;
		let a12 = _this1.self._12;
		let a13 = _this1.self._13;
		let a20 = _this1.self._20;
		let a21 = _this1.self._21;
		let a22 = _this1.self._22;
		let a23 = _this1.self._23;
		let a30 = _this1.self._30;
		let a31 = _this1.self._31;
		let a32 = _this1.self._32;
		let a33 = _this1.self._33;
		let b0 = m1.self._00;
		let b1 = m1.self._10;
		let b2 = m1.self._20;
		let b3 = m1.self._30;
		_this1.self._00 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
		_this1.self._10 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
		_this1.self._20 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
		_this1.self._30 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
		b0 = m1.self._01;
		b1 = m1.self._11;
		b2 = m1.self._21;
		b3 = m1.self._31;
		_this1.self._01 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
		_this1.self._11 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
		_this1.self._21 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
		_this1.self._31 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
		b0 = m1.self._02;
		b1 = m1.self._12;
		b2 = m1.self._22;
		b3 = m1.self._32;
		_this1.self._02 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
		_this1.self._12 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
		_this1.self._22 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
		_this1.self._32 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
		b0 = m1.self._03;
		b1 = m1.self._13;
		b2 = m1.self._23;
		b3 = m1.self._33;
		_this1.self._03 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
		_this1.self._13 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
		_this1.self._23 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
		_this1.self._33 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
		let matrix = arm_render_LineDraw.vp.self;
		kha_graphics4_Graphics.mat[0] = matrix._00;
		kha_graphics4_Graphics.mat[1] = matrix._01;
		kha_graphics4_Graphics.mat[2] = matrix._02;
		kha_graphics4_Graphics.mat[3] = matrix._03;
		kha_graphics4_Graphics.mat[4] = matrix._10;
		kha_graphics4_Graphics.mat[5] = matrix._11;
		kha_graphics4_Graphics.mat[6] = matrix._12;
		kha_graphics4_Graphics.mat[7] = matrix._13;
		kha_graphics4_Graphics.mat[8] = matrix._20;
		kha_graphics4_Graphics.mat[9] = matrix._21;
		kha_graphics4_Graphics.mat[10] = matrix._22;
		kha_graphics4_Graphics.mat[11] = matrix._23;
		kha_graphics4_Graphics.mat[12] = matrix._30;
		kha_graphics4_Graphics.mat[13] = matrix._31;
		kha_graphics4_Graphics.mat[14] = matrix._32;
		kha_graphics4_Graphics.mat[15] = matrix._33;
		Krom.setMatrix(arm_render_LineDraw.vpID,kha_graphics4_Graphics.mat.buffer);
		arm_render_LineDraw.g.drawIndexedVertices(0,arm_render_LineDraw.lines * 6);
	}
}
$hxClasses["arm.render.LineDraw"] = arm_render_LineDraw;
arm_render_LineDraw.__name__ = "arm.render.LineDraw";
class arm_render_RenderPathDeferred {
	static init(_path) {
		arm_render_RenderPathDeferred.path = _path;
		arm_render_RenderPathDeferred.path.createDepthBuffer("main","DEPTH24");
		let t = new iron_RenderTargetRaw();
		t.name = "gbuffer0";
		t.width = 0;
		t.height = 0;
		t.format = "RGBA64";
		t.scale = arm_render_Inc.superSample;
		t.depth_buffer = "main";
		arm_render_RenderPathDeferred.path.createRenderTarget(t);
		let t1 = new iron_RenderTargetRaw();
		t1.name = "gbuffer1";
		t1.width = 0;
		t1.height = 0;
		t1.format = "RGBA64";
		t1.scale = arm_render_Inc.superSample;
		arm_render_RenderPathDeferred.path.createRenderTarget(t1);
		let t2 = new iron_RenderTargetRaw();
		t2.name = "gbuffer2";
		t2.width = 0;
		t2.height = 0;
		t2.format = "RGBA64";
		t2.scale = arm_render_Inc.superSample;
		arm_render_RenderPathDeferred.path.createRenderTarget(t2);
		let t3 = new iron_RenderTargetRaw();
		t3.name = "tex";
		t3.width = 0;
		t3.height = 0;
		t3.format = "RGBA64";
		t3.scale = arm_render_Inc.superSample;
		arm_render_RenderPathDeferred.path.createRenderTarget(t3);
		let t4 = new iron_RenderTargetRaw();
		t4.name = "buf";
		t4.width = 0;
		t4.height = 0;
		t4.format = "RGBA32";
		t4.scale = arm_render_Inc.superSample;
		arm_render_RenderPathDeferred.path.createRenderTarget(t4);
		let t5 = new iron_RenderTargetRaw();
		t5.name = "bufa";
		t5.width = 0;
		t5.height = 0;
		t5.format = "RGBA32";
		t5.scale = arm_render_Inc.superSample;
		arm_render_RenderPathDeferred.path.createRenderTarget(t5);
		let t6 = new iron_RenderTargetRaw();
		t6.name = "taa";
		t6.width = 0;
		t6.height = 0;
		t6.format = "RGBA32";
		t6.scale = arm_render_Inc.superSample;
		arm_render_RenderPathDeferred.path.createRenderTarget(t6);
		let t7 = new iron_RenderTargetRaw();
		t7.name = "taa2";
		t7.width = 0;
		t7.height = 0;
		t7.format = "RGBA32";
		t7.scale = arm_render_Inc.superSample;
		arm_render_RenderPathDeferred.path.createRenderTarget(t7);
		let t8 = new iron_RenderTargetRaw();
		t8.name = "empty_white";
		t8.width = 1;
		t8.height = 1;
		t8.format = "R8";
		let rt = new iron_RenderTarget(t8);
		let b = new haxe_io_Bytes(new ArrayBuffer(1));
		b.b[0] = 255;
		rt.image = kha_Image.fromBytes(b,t8.width,t8.height,1);
		arm_render_RenderPathDeferred.path.renderTargets.h[t8.name] = rt;
		let t9 = new iron_RenderTargetRaw();
		t9.name = "empty_black";
		t9.width = 1;
		t9.height = 1;
		t9.format = "RGBA32";
		let rt1 = new iron_RenderTarget(t9);
		let b1 = new haxe_io_Bytes(new ArrayBuffer(4));
		b1.b[0] = 0;
		b1.b[1] = 0;
		b1.b[2] = 0;
		b1.b[3] = 0;
		rt1.image = kha_Image.fromBytes(b1,t9.width,t9.height,0);
		arm_render_RenderPathDeferred.path.renderTargets.h[t9.name] = rt1;
		arm_render_RenderPathDeferred.path.loadShader("shader_datas/world_pass/world_pass");
		arm_render_RenderPathDeferred.path.loadShader("shader_datas/deferred_light/deferred_light");
		arm_render_RenderPathDeferred.path.loadShader("shader_datas/compositor_pass/compositor_pass");
		arm_render_RenderPathDeferred.path.loadShader("shader_datas/copy_pass/copy_pass");
		arm_render_RenderPathDeferred.path.loadShader("shader_datas/copy_pass/copyR8_pass");
		arm_render_RenderPathDeferred.path.loadShader("shader_datas/smaa_edge_detect/smaa_edge_detect");
		arm_render_RenderPathDeferred.path.loadShader("shader_datas/smaa_blend_weight/smaa_blend_weight");
		arm_render_RenderPathDeferred.path.loadShader("shader_datas/smaa_neighborhood_blend/smaa_neighborhood_blend");
		arm_render_RenderPathDeferred.path.loadShader("shader_datas/taa_pass/taa_pass");
		arm_render_RenderPathDeferred.path.loadShader("shader_datas/supersample_resolve/supersample_resolve");
		arm_render_Inc.initGI();
		arm_render_RenderPathDeferred.path.loadShader("shader_datas/deferred_light/deferred_light_voxel");
		arm_render_RenderPathPaint.init(arm_render_RenderPathDeferred.path);
		arm_render_RenderPathPreview.init(arm_render_RenderPathDeferred.path);
	}
	static commands() {
		if(kha_System.windowWidth() == 0 || kha_System.windowHeight() == 0) {
			return;
		}
		arm_render_Inc.beginSplit();
		if(arm_render_Inc.isCached()) {
			return;
		}
		iron_Scene.active.camera.frame = arm_Context.splitView || (arm_Context.tool == 5 || arm_Context.tool == 6) && arm_Context.pdirty > 0 ? 0 : arm_render_RenderPathDeferred.taaFrame;
		iron_Scene.active.camera.projectionJitter();
		iron_Scene.active.camera.buildMatrix();
		arm_render_RenderPathPaint.begin();
		arm_render_RenderPathDeferred.drawSplit();
		arm_render_RenderPathDeferred.drawGbuffer();
		arm_render_RenderPathPaint.draw();
		arm_render_RenderPathDeferred.drawDeferred();
		arm_render_RenderPathPaint.end();
		arm_render_Inc.end();
		arm_render_RenderPathDeferred.taaFrame++;
	}
	static drawDeferred() {
		let cameraType = arm_Context.cameraType;
		let ddirty = arm_Context.ddirty;
		if(arm_Config.raw.rp_ssgi != false && cameraType == 0 && ddirty > 0 && arm_render_RenderPathDeferred.taaFrame > 0) {
			if(arm_render_RenderPathDeferred.path.renderTargets.h["singlea"] == null) {
				let t = new iron_RenderTargetRaw();
				t.name = "singlea";
				t.width = 0;
				t.height = 0;
				t.format = "R8";
				t.scale = arm_render_Inc.superSample;
				arm_render_RenderPathDeferred.path.createRenderTarget(t);
				let t1 = new iron_RenderTargetRaw();
				t1.name = "singleb";
				t1.width = 0;
				t1.height = 0;
				t1.format = "R8";
				t1.scale = arm_render_Inc.superSample;
				arm_render_RenderPathDeferred.path.createRenderTarget(t1);
				arm_render_RenderPathDeferred.path.loadShader("shader_datas/ssgi_pass/ssgi_pass");
				arm_render_RenderPathDeferred.path.loadShader("shader_datas/blur_edge_pass/blur_edge_pass_x");
				arm_render_RenderPathDeferred.path.loadShader("shader_datas/blur_edge_pass/blur_edge_pass_y");
			}
			arm_render_RenderPathDeferred.path.setTarget("singlea");
			arm_render_RenderPathDeferred.path.bindTarget("_main","gbufferD");
			arm_render_RenderPathDeferred.path.bindTarget("gbuffer0","gbuffer0");
			arm_render_RenderPathDeferred.path.drawShader("shader_datas/ssgi_pass/ssgi_pass");
			arm_render_RenderPathDeferred.path.setTarget("singleb");
			arm_render_RenderPathDeferred.path.bindTarget("singlea","tex");
			arm_render_RenderPathDeferred.path.bindTarget("gbuffer0","gbuffer0");
			arm_render_RenderPathDeferred.path.drawShader("shader_datas/blur_edge_pass/blur_edge_pass_x");
			arm_render_RenderPathDeferred.path.setTarget("singlea");
			arm_render_RenderPathDeferred.path.bindTarget("singleb","tex");
			arm_render_RenderPathDeferred.path.bindTarget("gbuffer0","gbuffer0");
			arm_render_RenderPathDeferred.path.drawShader("shader_datas/blur_edge_pass/blur_edge_pass_y");
		}
		if(arm_Config.raw.rp_gi != false) {
			if(arm_render_RenderPathDeferred.path.voxelize() && ddirty > 0 && arm_render_RenderPathDeferred.taaFrame > 0) {
				let voxtex = arm_render_RenderPathDeferred.voxels;
				arm_render_RenderPathDeferred.path.clearImage(voxtex,0);
				arm_render_RenderPathDeferred.path.setTarget("");
				arm_render_RenderPathDeferred.path.setViewport(256,256);
				arm_render_RenderPathDeferred.path.bindTarget(voxtex,"voxels");
				if(arm_node_MakeMaterial.heightUsed) {
					arm_render_RenderPathDeferred.path.bindTarget("texpaint_pack" + arm_Project.layers[0].id,"texpaint_pack");
				}
				arm_render_RenderPathDeferred.path.drawMeshes("voxel");
				arm_render_RenderPathDeferred.path.generateMipmaps(arm_render_RenderPathDeferred.voxels);
			}
		}
		arm_render_RenderPathDeferred.path.setTarget("tex");
		arm_render_RenderPathDeferred.path.bindTarget("_main","gbufferD");
		arm_render_RenderPathDeferred.path.bindTarget("gbuffer0","gbuffer0");
		arm_render_RenderPathDeferred.path.bindTarget("gbuffer1","gbuffer1");
		if(arm_Config.raw.rp_ssgi != false && cameraType == 0 && arm_render_RenderPathDeferred.taaFrame > 0) {
			arm_render_RenderPathDeferred.path.bindTarget("singlea","ssaotex");
		} else {
			arm_render_RenderPathDeferred.path.bindTarget("empty_white","ssaotex");
		}
		let voxelao_pass = false;
		if(arm_Config.raw.rp_gi != false) {
			voxelao_pass = true;
			arm_render_RenderPathDeferred.path.bindTarget(arm_render_RenderPathDeferred.voxels,"voxels");
		}
		if(voxelao_pass) {
			arm_render_RenderPathDeferred.path.drawShader("shader_datas/deferred_light/deferred_light_voxel");
		} else {
			arm_render_RenderPathDeferred.path.drawShader("shader_datas/deferred_light/deferred_light");
		}
		arm_render_RenderPathDeferred.path.setDepthFrom("tex","gbuffer0");
		arm_render_RenderPathDeferred.path.setTarget("tex");
		arm_render_RenderPathDeferred.path.drawSkydome("shader_datas/world_pass/world_pass");
		arm_render_RenderPathDeferred.path.setDepthFrom("tex","gbuffer1");
		if(arm_Config.raw.rp_bloom != false) {
			arm_render_RenderPathDeferred.commandsBloom();
		}
		if(arm_Config.raw.rp_ssr != false) {
			if(arm_render_RenderPathDeferred.path.cachedShaderContexts.h["shader_datas/ssr_pass/ssr_pass"] == null) {
				let t = new iron_RenderTargetRaw();
				t.name = "bufb";
				t.width = 0;
				t.height = 0;
				t.format = "RGBA64";
				arm_render_RenderPathDeferred.path.createRenderTarget(t);
				arm_render_RenderPathDeferred.path.loadShader("shader_datas/ssr_pass/ssr_pass");
				arm_render_RenderPathDeferred.path.loadShader("shader_datas/blur_adaptive_pass/blur_adaptive_pass_x");
				arm_render_RenderPathDeferred.path.loadShader("shader_datas/blur_adaptive_pass/blur_adaptive_pass_y3_blend");
			}
			arm_render_RenderPathDeferred.path.setTarget("bufb");
			arm_render_RenderPathDeferred.path.bindTarget("tex","tex");
			arm_render_RenderPathDeferred.path.bindTarget("_main","gbufferD");
			arm_render_RenderPathDeferred.path.bindTarget("gbuffer0","gbuffer0");
			arm_render_RenderPathDeferred.path.bindTarget("gbuffer1","gbuffer1");
			arm_render_RenderPathDeferred.path.drawShader("shader_datas/ssr_pass/ssr_pass");
			arm_render_RenderPathDeferred.path.setTarget("gbuffer1");
			arm_render_RenderPathDeferred.path.bindTarget("bufb","tex");
			arm_render_RenderPathDeferred.path.bindTarget("gbuffer0","gbuffer0");
			arm_render_RenderPathDeferred.path.drawShader("shader_datas/blur_adaptive_pass/blur_adaptive_pass_x");
			arm_render_RenderPathDeferred.path.setTarget("tex");
			arm_render_RenderPathDeferred.path.bindTarget("gbuffer1","tex");
			arm_render_RenderPathDeferred.path.bindTarget("gbuffer0","gbuffer0");
			arm_render_RenderPathDeferred.path.drawShader("shader_datas/blur_adaptive_pass/blur_adaptive_pass_y3_blend");
		}
		arm_render_RenderPathDeferred.path.setTarget("buf");
		arm_render_RenderPathDeferred.path.bindTarget("tex","tex");
		arm_render_RenderPathDeferred.path.drawShader("shader_datas/compositor_pass/compositor_pass");
		arm_render_RenderPathDeferred.path.setTarget("buf");
		let currentG = arm_render_RenderPathDeferred.path.currentG;
		arm_render_RenderPathDeferred.path.drawMeshes("overlay");
		arm_render_Inc.drawCompass(currentG);
		let current = arm_render_RenderPathDeferred.taaFrame % 2 == 0 ? "bufa" : "taa2";
		let last = arm_render_RenderPathDeferred.taaFrame % 2 == 0 ? "taa2" : "bufa";
		arm_render_RenderPathDeferred.path.setTarget(current);
		arm_render_RenderPathDeferred.path.clearTarget(0);
		arm_render_RenderPathDeferred.path.bindTarget("buf","colorTex");
		arm_render_RenderPathDeferred.path.drawShader("shader_datas/smaa_edge_detect/smaa_edge_detect");
		arm_render_RenderPathDeferred.path.setTarget("taa");
		arm_render_RenderPathDeferred.path.clearTarget(0);
		arm_render_RenderPathDeferred.path.bindTarget(current,"edgesTex");
		arm_render_RenderPathDeferred.path.drawShader("shader_datas/smaa_blend_weight/smaa_blend_weight");
		arm_render_RenderPathDeferred.path.setTarget(current);
		arm_render_RenderPathDeferred.path.bindTarget("buf","colorTex");
		arm_render_RenderPathDeferred.path.bindTarget("taa","blendTex");
		arm_render_RenderPathDeferred.path.bindTarget("gbuffer2","sveloc");
		arm_render_RenderPathDeferred.path.drawShader("shader_datas/smaa_neighborhood_blend/smaa_neighborhood_blend");
		if(arm_Context.splitView) {
			arm_render_RenderPathDeferred.path.setTarget("taa");
			arm_render_RenderPathDeferred.path.bindTarget(current,"tex");
			arm_render_RenderPathDeferred.path.drawShader("shader_datas/copy_pass/copy_pass");
		} else {
			arm_render_RenderPathDeferred.path.setTarget("taa");
			arm_render_RenderPathDeferred.path.bindTarget(current,"tex");
			arm_render_RenderPathDeferred.path.bindTarget(last,"tex2");
			arm_render_RenderPathDeferred.path.bindTarget("gbuffer2","sveloc");
			arm_render_RenderPathDeferred.path.drawShader("shader_datas/taa_pass/taa_pass");
		}
		if(arm_Config.raw.rp_supersample != 4) {
			arm_render_RenderPathDeferred.path.setTarget("");
			arm_render_RenderPathDeferred.path.bindTarget(arm_render_RenderPathDeferred.taaFrame == 0 ? current : "taa","tex");
			arm_render_RenderPathDeferred.path.drawShader("shader_datas/copy_pass/copy_pass");
		}
		if(arm_Config.raw.rp_supersample == 4) {
			arm_render_RenderPathDeferred.path.setTarget("");
			arm_render_RenderPathDeferred.path.bindTarget(arm_render_RenderPathDeferred.taaFrame % 2 == 0 ? "taa2" : "taa","tex");
			arm_render_RenderPathDeferred.path.drawShader("shader_datas/supersample_resolve/supersample_resolve");
		}
	}
	static drawGbuffer() {
		arm_render_RenderPathDeferred.path.setTarget("gbuffer0");
		arm_render_RenderPathDeferred.path.clearTarget(null,1.0);
		if(arm_node_MakeMesh.layerPassCount == 1) {
			arm_render_RenderPathDeferred.path.setTarget("gbuffer2");
			arm_render_RenderPathDeferred.path.clearTarget(-16777216);
		}
		arm_render_RenderPathDeferred.path.setTarget("gbuffer0",["gbuffer1","gbuffer2"]);
		let currentG = arm_render_RenderPathDeferred.path.currentG;
		arm_render_RenderPathPaint.bindLayers();
		arm_render_RenderPathDeferred.path.drawMeshes("mesh");
		arm_render_RenderPathPaint.unbindLayers();
		if(arm_node_MakeMesh.layerPassCount > 1) {
			arm_render_RenderPathDeferred.makeGbufferCopyTextures();
			let _g = 1;
			let _g1 = arm_node_MakeMesh.layerPassCount;
			while(_g < _g1) {
				let i = _g++;
				let ping = i % 2 == 1 ? "_copy" : "";
				let pong = i % 2 == 1 ? "" : "_copy";
				if(i == arm_node_MakeMesh.layerPassCount - 1) {
					arm_render_RenderPathDeferred.path.setTarget("gbuffer2" + ping);
					arm_render_RenderPathDeferred.path.clearTarget(-16777216);
				}
				arm_render_RenderPathDeferred.path.setTarget("gbuffer0" + ping,["gbuffer1" + ping,"gbuffer2" + ping]);
				arm_render_RenderPathDeferred.path.bindTarget("gbuffer0" + pong,"gbuffer0");
				arm_render_RenderPathDeferred.path.bindTarget("gbuffer1" + pong,"gbuffer1");
				arm_render_RenderPathDeferred.path.bindTarget("gbuffer2" + pong,"gbuffer2");
				arm_render_RenderPathPaint.bindLayers();
				arm_render_RenderPathDeferred.path.drawMeshes("mesh" + i);
				arm_render_RenderPathPaint.unbindLayers();
			}
			if(arm_node_MakeMesh.layerPassCount % 2 == 0) {
				arm_render_RenderPathDeferred.copyToGbuffer();
			}
		}
		arm_render_LineDraw.render(currentG);
	}
	static makeGbufferCopyTextures() {
		let copy = arm_render_RenderPathDeferred.path.renderTargets.h["gbuffer0_copy"];
		if(copy == null || copy.image.get_width() != arm_render_RenderPathDeferred.path.renderTargets.h["gbuffer0"].image.get_width() || copy.image.get_height() != arm_render_RenderPathDeferred.path.renderTargets.h["gbuffer0"].image.get_height()) {
			let t = new iron_RenderTargetRaw();
			t.name = "gbuffer0_copy";
			t.width = 0;
			t.height = 0;
			t.format = "RGBA64";
			t.scale = arm_render_Inc.superSample;
			t.depth_buffer = "main";
			arm_render_RenderPathDeferred.path.createRenderTarget(t);
			let t1 = new iron_RenderTargetRaw();
			t1.name = "gbuffer1_copy";
			t1.width = 0;
			t1.height = 0;
			t1.format = "RGBA64";
			t1.scale = arm_render_Inc.superSample;
			arm_render_RenderPathDeferred.path.createRenderTarget(t1);
			let t2 = new iron_RenderTargetRaw();
			t2.name = "gbuffer2_copy";
			t2.width = 0;
			t2.height = 0;
			t2.format = "RGBA64";
			t2.scale = arm_render_Inc.superSample;
			arm_render_RenderPathDeferred.path.createRenderTarget(t2);
		}
	}
	static copyToGbuffer() {
		arm_render_RenderPathDeferred.path.setTarget("gbuffer0",["gbuffer1","gbuffer2"]);
		arm_render_RenderPathDeferred.path.bindTarget("gbuffer0_copy","tex0");
		arm_render_RenderPathDeferred.path.bindTarget("gbuffer1_copy","tex1");
		arm_render_RenderPathDeferred.path.bindTarget("gbuffer2_copy","tex2");
		arm_render_RenderPathDeferred.path.drawShader("shader_datas/copy_mrt3_pass/copy_mrt3_pass");
	}
	static drawSplit() {
		if(arm_Context.splitView && !arm_Context.paint2dView) {
			arm_Context.ddirty = 1;
			let cam = iron_Scene.active.camera;
			arm_Context.viewIndex = arm_Context.viewIndex == 0 ? 1 : 0;
			cam.transform.setMatrix(arm_Camera.inst.views[arm_Context.viewIndex]);
			cam.buildMatrix();
			cam.buildProjection();
			arm_render_RenderPathDeferred.drawGbuffer();
			arm_render_RenderPathDeferred.drawDeferred();
			arm_Context.viewIndex = arm_Context.viewIndex == 0 ? 1 : 0;
			cam.transform.setMatrix(arm_Camera.inst.views[arm_Context.viewIndex]);
			cam.buildMatrix();
			cam.buildProjection();
		}
	}
	static commandsBloom(tex) {
		if(tex == null) {
			tex = "tex";
		}
		if(arm_render_RenderPathDeferred.path.renderTargets.h["bloomtex"] == null) {
			let t = new iron_RenderTargetRaw();
			t.name = "bloomtex";
			t.width = 0;
			t.height = 0;
			t.scale = 0.25;
			t.format = "RGBA64";
			arm_render_RenderPathDeferred.path.createRenderTarget(t);
			let t1 = new iron_RenderTargetRaw();
			t1.name = "bloomtex2";
			t1.width = 0;
			t1.height = 0;
			t1.scale = 0.25;
			t1.format = "RGBA64";
			arm_render_RenderPathDeferred.path.createRenderTarget(t1);
			arm_render_RenderPathDeferred.path.loadShader("shader_datas/bloom_pass/bloom_pass");
			arm_render_RenderPathDeferred.path.loadShader("shader_datas/blur_gaus_pass/blur_gaus_pass_x");
			arm_render_RenderPathDeferred.path.loadShader("shader_datas/blur_gaus_pass/blur_gaus_pass_y");
			arm_render_RenderPathDeferred.path.loadShader("shader_datas/blur_gaus_pass/blur_gaus_pass_y_blend");
		}
		arm_render_RenderPathDeferred.path.setTarget("bloomtex");
		arm_render_RenderPathDeferred.path.bindTarget(tex,"tex");
		arm_render_RenderPathDeferred.path.drawShader("shader_datas/bloom_pass/bloom_pass");
		arm_render_RenderPathDeferred.path.setTarget("bloomtex2");
		arm_render_RenderPathDeferred.path.bindTarget("bloomtex","tex");
		arm_render_RenderPathDeferred.path.drawShader("shader_datas/blur_gaus_pass/blur_gaus_pass_x");
		arm_render_RenderPathDeferred.path.setTarget("bloomtex");
		arm_render_RenderPathDeferred.path.bindTarget("bloomtex2","tex");
		arm_render_RenderPathDeferred.path.drawShader("shader_datas/blur_gaus_pass/blur_gaus_pass_y");
		arm_render_RenderPathDeferred.path.setTarget("bloomtex2");
		arm_render_RenderPathDeferred.path.bindTarget("bloomtex","tex");
		arm_render_RenderPathDeferred.path.drawShader("shader_datas/blur_gaus_pass/blur_gaus_pass_x");
		arm_render_RenderPathDeferred.path.setTarget("bloomtex");
		arm_render_RenderPathDeferred.path.bindTarget("bloomtex2","tex");
		arm_render_RenderPathDeferred.path.drawShader("shader_datas/blur_gaus_pass/blur_gaus_pass_y");
		arm_render_RenderPathDeferred.path.setTarget("bloomtex2");
		arm_render_RenderPathDeferred.path.bindTarget("bloomtex","tex");
		arm_render_RenderPathDeferred.path.drawShader("shader_datas/blur_gaus_pass/blur_gaus_pass_x");
		arm_render_RenderPathDeferred.path.setTarget("bloomtex");
		arm_render_RenderPathDeferred.path.bindTarget("bloomtex2","tex");
		arm_render_RenderPathDeferred.path.drawShader("shader_datas/blur_gaus_pass/blur_gaus_pass_y");
		arm_render_RenderPathDeferred.path.setTarget("bloomtex2");
		arm_render_RenderPathDeferred.path.bindTarget("bloomtex","tex");
		arm_render_RenderPathDeferred.path.drawShader("shader_datas/blur_gaus_pass/blur_gaus_pass_x");
		arm_render_RenderPathDeferred.path.setTarget(tex);
		arm_render_RenderPathDeferred.path.bindTarget("bloomtex2","tex");
		arm_render_RenderPathDeferred.path.drawShader("shader_datas/blur_gaus_pass/blur_gaus_pass_y_blend");
	}
}
$hxClasses["arm.render.RenderPathDeferred"] = arm_render_RenderPathDeferred;
arm_render_RenderPathDeferred.__name__ = "arm.render.RenderPathDeferred";
class arm_render_RenderPathForward {
	static init(_path) {
		arm_render_RenderPathForward.path = _path;
	}
	static commands() {
		if(kha_System.windowWidth() == 0 || kha_System.windowHeight() == 0) {
			return;
		}
		arm_render_Inc.beginSplit();
		if(arm_render_Inc.isCached()) {
			return;
		}
		iron_Scene.active.camera.frame = arm_Context.splitView || (arm_Context.tool == 5 || arm_Context.tool == 6) && arm_Context.pdirty > 0 ? 0 : arm_render_RenderPathDeferred.taaFrame;
		iron_Scene.active.camera.projectionJitter();
		iron_Scene.active.camera.buildMatrix();
		arm_render_RenderPathPaint.begin();
		arm_render_RenderPathForward.drawSplit();
		arm_render_RenderPathForward.drawGbuffer();
		arm_render_RenderPathPaint.draw();
		arm_render_RenderPathForward.drawForward();
		arm_render_RenderPathPaint.end();
		arm_render_Inc.end();
		arm_render_RenderPathDeferred.taaFrame++;
	}
	static drawGbuffer(gbuffer0,gbuffer1,gbuffer2) {
		if(gbuffer2 == null) {
			gbuffer2 = "gbuffer2";
		}
		if(gbuffer1 == null) {
			gbuffer1 = "gbuffer1";
		}
		if(gbuffer0 == null) {
			gbuffer0 = "gbuffer0";
		}
		arm_render_RenderPathForward.path.setTarget(gbuffer0);
		arm_render_RenderPathForward.path.clearTarget(null,1.0);
		arm_render_RenderPathForward.path.setTarget(gbuffer2);
		arm_render_RenderPathForward.path.clearTarget(-16777216);
		arm_render_RenderPathForward.path.setTarget(gbuffer0,[gbuffer1,gbuffer2]);
		let currentG = arm_render_RenderPathForward.path.currentG;
		arm_render_RenderPathPaint.bindLayers();
		arm_render_RenderPathForward.path.drawMeshes("mesh");
		arm_render_RenderPathPaint.unbindLayers();
		if(arm_node_MakeMesh.layerPassCount > 1) {
			arm_render_RenderPathDeferred.makeGbufferCopyTextures();
			let _g = 1;
			let _g1 = arm_node_MakeMesh.layerPassCount;
			while(_g < _g1) {
				let i = _g++;
				let ping = i % 2 == 1 ? "_copy" : "";
				let pong = i % 2 == 1 ? "" : "_copy";
				arm_render_RenderPathForward.path.setTarget("gbuffer0" + ping,["gbuffer1" + ping,"gbuffer2" + ping]);
				arm_render_RenderPathForward.path.bindTarget("gbuffer0" + pong,"gbuffer0");
				arm_render_RenderPathForward.path.bindTarget("gbuffer1" + pong,"gbuffer1");
				arm_render_RenderPathForward.path.bindTarget("gbuffer2" + pong,"gbuffer2");
				arm_render_RenderPathPaint.bindLayers();
				arm_render_RenderPathForward.path.drawMeshes("mesh" + i);
				arm_render_RenderPathPaint.unbindLayers();
			}
			if(arm_node_MakeMesh.layerPassCount % 2 == 0) {
				arm_render_RenderPathDeferred.copyToGbuffer();
			}
		}
		arm_render_LineDraw.render(currentG);
	}
	static drawForward(eye,output,gbuffer0,gbuffer1,gbuffer2,buf,bufa,taa,taa2) {
		if(taa2 == null) {
			taa2 = "taa2";
		}
		if(taa == null) {
			taa = "taa";
		}
		if(bufa == null) {
			bufa = "bufa";
		}
		if(buf == null) {
			buf = "buf";
		}
		if(gbuffer2 == null) {
			gbuffer2 = "gbuffer2";
		}
		if(gbuffer1 == null) {
			gbuffer1 = "gbuffer1";
		}
		if(gbuffer0 == null) {
			gbuffer0 = "gbuffer0";
		}
		if(output == null) {
			output = "";
		}
		if(eye == null) {
			eye = false;
		}
		arm_render_RenderPathForward.path.setDepthFrom(gbuffer1,gbuffer0);
		arm_render_RenderPathForward.path.setTarget(gbuffer1);
		arm_render_RenderPathForward.path.drawSkydome("shader_datas/world_pass/world_pass");
		arm_render_RenderPathForward.path.setDepthFrom(gbuffer1,gbuffer2);
		arm_render_RenderPathForward.path.setTarget(buf);
		arm_render_RenderPathForward.path.bindTarget(gbuffer1,"tex");
		if(arm_Context.viewportMode == 0) {
			arm_render_RenderPathForward.path.drawShader("shader_datas/compositor_pass/compositor_pass");
		} else {
			arm_render_RenderPathForward.path.drawShader("shader_datas/copy_pass/copy_pass");
		}
		if(output == "") {
			arm_render_RenderPathForward.path.setTarget(buf);
			let currentG = arm_render_RenderPathForward.path.currentG;
			arm_render_RenderPathForward.path.drawMeshes("overlay");
			arm_render_Inc.drawCompass(currentG);
		}
		let taaFrame = arm_render_RenderPathDeferred.taaFrame;
		let current = taaFrame % 2 == 0 ? bufa : taa2;
		arm_render_RenderPathForward.path.setTarget(current);
		arm_render_RenderPathForward.path.clearTarget(0);
		arm_render_RenderPathForward.path.bindTarget(buf,"colorTex");
		arm_render_RenderPathForward.path.drawShader("shader_datas/smaa_edge_detect/smaa_edge_detect");
		arm_render_RenderPathForward.path.setTarget(taa);
		arm_render_RenderPathForward.path.clearTarget(0);
		arm_render_RenderPathForward.path.bindTarget(current,"edgesTex");
		arm_render_RenderPathForward.path.drawShader("shader_datas/smaa_blend_weight/smaa_blend_weight");
		arm_render_RenderPathForward.path.setTarget(current);
		arm_render_RenderPathForward.path.bindTarget(buf,"colorTex");
		arm_render_RenderPathForward.path.bindTarget(taa,"blendTex");
		arm_render_RenderPathForward.path.bindTarget(gbuffer2,"sveloc");
		arm_render_RenderPathForward.path.drawShader("shader_datas/smaa_neighborhood_blend/smaa_neighborhood_blend");
		if(arm_Context.splitView || eye) {
			arm_render_RenderPathForward.path.setTarget(taa);
			arm_render_RenderPathForward.path.bindTarget(current,"tex");
			arm_render_RenderPathForward.path.drawShader("shader_datas/copy_pass/copy_pass");
		} else {
			arm_render_RenderPathForward.path.setTarget(taa);
			arm_render_RenderPathForward.path.bindTarget(current,"tex");
			arm_render_RenderPathForward.path.bindTarget(taaFrame % 2 == 0 ? taa2 : bufa,"tex2");
			arm_render_RenderPathForward.path.bindTarget(gbuffer2,"sveloc");
			arm_render_RenderPathForward.path.drawShader("shader_datas/taa_pass/taa_pass");
		}
		if(arm_Config.raw.rp_supersample != 4) {
			arm_render_RenderPathForward.path.setTarget(output);
			arm_render_RenderPathForward.path.bindTarget(taaFrame % 2 == 0 ? current : taa,"tex");
			arm_render_RenderPathForward.path.drawShader("shader_datas/copy_pass/copy_pass");
		}
		if(arm_Config.raw.rp_supersample == 4) {
			arm_render_RenderPathForward.path.setTarget(output);
			arm_render_RenderPathForward.path.bindTarget(taaFrame % 2 == 0 ? taa2 : taa,"tex");
			arm_render_RenderPathForward.path.drawShader("shader_datas/supersample_resolve/supersample_resolve");
		}
	}
	static drawSplit() {
		if(arm_Context.splitView && !arm_Context.paint2dView) {
			arm_Context.ddirty = 1;
			let cam = iron_Scene.active.camera;
			arm_Context.viewIndex = arm_Context.viewIndex == 0 ? 1 : 0;
			cam.transform.setMatrix(arm_Camera.inst.views[arm_Context.viewIndex]);
			cam.buildMatrix();
			cam.buildProjection();
			arm_render_RenderPathForward.drawGbuffer();
			arm_render_RenderPathForward.drawForward();
			arm_Context.viewIndex = arm_Context.viewIndex == 0 ? 1 : 0;
			cam.transform.setMatrix(arm_Camera.inst.views[arm_Context.viewIndex]);
			cam.buildMatrix();
			cam.buildProjection();
		}
	}
}
$hxClasses["arm.render.RenderPathForward"] = arm_render_RenderPathForward;
arm_render_RenderPathForward.__name__ = "arm.render.RenderPathForward";
class arm_render_RenderPathPaint {
	static init(_path) {
		arm_render_RenderPathPaint.path = _path;
		let t = new iron_RenderTargetRaw();
		t.name = "texpaint_blend0";
		t.width = arm_Config.getTextureResX();
		t.height = arm_Config.getTextureResY();
		t.format = "R8";
		arm_render_RenderPathPaint.path.createRenderTarget(t);
		let t1 = new iron_RenderTargetRaw();
		t1.name = "texpaint_blend1";
		t1.width = arm_Config.getTextureResX();
		t1.height = arm_Config.getTextureResY();
		t1.format = "R8";
		arm_render_RenderPathPaint.path.createRenderTarget(t1);
		let t2 = new iron_RenderTargetRaw();
		t2.name = "texpaint_colorid";
		t2.width = 1;
		t2.height = 1;
		t2.format = "RGBA32";
		arm_render_RenderPathPaint.path.createRenderTarget(t2);
		let t3 = new iron_RenderTargetRaw();
		t3.name = "texpaint_picker";
		t3.width = 1;
		t3.height = 1;
		t3.format = "RGBA32";
		arm_render_RenderPathPaint.path.createRenderTarget(t3);
		let t4 = new iron_RenderTargetRaw();
		t4.name = "texpaint_nor_picker";
		t4.width = 1;
		t4.height = 1;
		t4.format = "RGBA32";
		arm_render_RenderPathPaint.path.createRenderTarget(t4);
		let t5 = new iron_RenderTargetRaw();
		t5.name = "texpaint_pack_picker";
		t5.width = 1;
		t5.height = 1;
		t5.format = "RGBA32";
		arm_render_RenderPathPaint.path.createRenderTarget(t5);
		let t6 = new iron_RenderTargetRaw();
		t6.name = "texpaint_uv_picker";
		t6.width = 1;
		t6.height = 1;
		t6.format = "RGBA32";
		arm_render_RenderPathPaint.path.createRenderTarget(t6);
		let t7 = new iron_RenderTargetRaw();
		t7.name = "texpaint_posnortex_picker0";
		t7.width = 1;
		t7.height = 1;
		t7.format = "RGBA128";
		arm_render_RenderPathPaint.path.createRenderTarget(t7);
		let t8 = new iron_RenderTargetRaw();
		t8.name = "texpaint_posnortex_picker1";
		t8.width = 1;
		t8.height = 1;
		t8.format = "RGBA128";
		arm_render_RenderPathPaint.path.createRenderTarget(t8);
		arm_render_RenderPathPaint.path.loadShader("shader_datas/copy_mrt3_pass/copy_mrt3_pass");
		arm_render_RenderPathPaint.path.loadShader("shader_datas/dilate_pass/dilate_pass");
	}
	static commandsPaint(dilation) {
		if(dilation == null) {
			dilation = true;
		}
		let tid = arm_Context.layer.id;
		if(arm_Context.pdirty > 0) {
			if(arm_Context.tool == 7) {
				arm_render_RenderPathPaint.path.setTarget("texparticle");
				arm_render_RenderPathPaint.path.clearTarget(0);
				arm_render_RenderPathPaint.path.bindTarget("_main","gbufferD");
				if((arm_Context.xray || arm_Config.raw.brush_angle_reject) && arm_Config.raw.brush_3d) {
					arm_render_RenderPathPaint.path.bindTarget("gbuffer0","gbuffer0");
				}
				let mo = iron_Scene.active.getChild(".ParticleEmitter");
				mo.visible = true;
				mo.render(arm_render_RenderPathPaint.path.currentG,"mesh",arm_render_RenderPathPaint.path.bindParams);
				mo.visible = false;
				mo = iron_Scene.active.getChild(".Particle");
				mo.visible = true;
				mo.render(arm_render_RenderPathPaint.path.currentG,"mesh",arm_render_RenderPathPaint.path.bindParams);
				mo.visible = false;
				let _this = arm_render_RenderPathPaint.path;
				if(_this.scissorSet) {
					_this.currentG.disableScissor();
					_this.scissorSet = false;
				}
				_this.currentG.end();
				_this.currentG = null;
				_this.bindParams = null;
			}
			if(arm_Context.tool == 8) {
				arm_render_RenderPathPaint.path.setTarget("texpaint_colorid");
				arm_render_RenderPathPaint.path.clearTarget(-16777216);
				arm_render_RenderPathPaint.path.bindTarget("gbuffer2","gbuffer2");
				arm_render_RenderPathPaint.path.drawMeshes("paint");
				arm_ui_UIHeader.inst.headerHandle.redraws = 2;
			} else if(arm_Context.tool == 9) {
				if(arm_Context.pickPosNorTex) {
					if(arm_Context.paint2d) {
						arm_render_RenderPathPaint.path.setTarget("gbuffer0",["gbuffer1","gbuffer2"]);
						arm_render_RenderPathPaint.path.drawMeshes("mesh");
					}
					arm_render_RenderPathPaint.path.setTarget("texpaint_posnortex_picker0",["texpaint_posnortex_picker1"]);
					arm_render_RenderPathPaint.path.bindTarget("gbuffer2","gbuffer2");
					arm_render_RenderPathPaint.path.bindTarget("_main","gbufferD");
					arm_render_RenderPathPaint.path.drawMeshes("paint");
					let texpaint_posnortex_picker1 = arm_render_RenderPathPaint.path.renderTargets.h["texpaint_posnortex_picker1"].image;
					let a = arm_render_RenderPathPaint.path.renderTargets.h["texpaint_posnortex_picker0"].image.getPixels();
					let b = texpaint_posnortex_picker1.getPixels();
					arm_Context.posXPicked = a.getFloat(0);
					arm_Context.posYPicked = a.getFloat(4);
					arm_Context.posZPicked = a.getFloat(8);
					arm_Context.uvxPicked = a.getFloat(12);
					arm_Context.norXPicked = b.getFloat(0);
					arm_Context.norYPicked = b.getFloat(4);
					arm_Context.norZPicked = b.getFloat(8);
					arm_Context.uvyPicked = b.getFloat(12);
				} else {
					arm_render_RenderPathPaint.path.setTarget("texpaint_picker",["texpaint_nor_picker","texpaint_pack_picker","texpaint_uv_picker"]);
					arm_render_RenderPathPaint.path.bindTarget("gbuffer2","gbuffer2");
					tid = arm_Context.layer.id;
					let useLiveLayer = arm_ui_UIHeader.inst.worktab.position == 1;
					if(useLiveLayer) {
						arm_render_RenderPathPaint.useLiveLayer(true);
					}
					arm_render_RenderPathPaint.path.bindTarget("texpaint" + tid,"texpaint");
					arm_render_RenderPathPaint.path.bindTarget("texpaint_nor" + tid,"texpaint_nor");
					arm_render_RenderPathPaint.path.bindTarget("texpaint_pack" + tid,"texpaint_pack");
					arm_render_RenderPathPaint.path.drawMeshes("paint");
					if(useLiveLayer) {
						arm_render_RenderPathPaint.useLiveLayer(false);
					}
					arm_ui_UIHeader.inst.headerHandle.redraws = 2;
					arm_ui_UIStatus.inst.statusHandle.redraws = 2;
					let texpaint_nor_picker = arm_render_RenderPathPaint.path.renderTargets.h["texpaint_nor_picker"].image;
					let texpaint_pack_picker = arm_render_RenderPathPaint.path.renderTargets.h["texpaint_pack_picker"].image;
					let texpaint_uv_picker = arm_render_RenderPathPaint.path.renderTargets.h["texpaint_uv_picker"].image;
					let a = arm_render_RenderPathPaint.path.renderTargets.h["texpaint_picker"].image.getPixels();
					let b = texpaint_nor_picker.getPixels();
					let c = texpaint_pack_picker.getPixels();
					let d = texpaint_uv_picker.getPixels();
					arm_Context.pickedColor.base = arm_Context.pickedColor.base >>> 24 << 24 | a.b[0] << 16 | (arm_Context.pickedColor.base & 65280) >>> 8 << 8 | arm_Context.pickedColor.base & 255;
					arm_Context.pickedColor.base = arm_Context.pickedColor.base >>> 24 << 24 | (arm_Context.pickedColor.base & 16711680) >>> 16 << 16 | a.b[1] << 8 | arm_Context.pickedColor.base & 255;
					arm_Context.pickedColor.base = arm_Context.pickedColor.base >>> 24 << 24 | (arm_Context.pickedColor.base & 16711680) >>> 16 << 16 | (arm_Context.pickedColor.base & 65280) >>> 8 << 8 | a.b[2];
					arm_Context.pickedColor.normal = arm_Context.pickedColor.normal >>> 24 << 24 | b.b[0] << 16 | (arm_Context.pickedColor.normal & 65280) >>> 8 << 8 | arm_Context.pickedColor.normal & 255;
					arm_Context.pickedColor.normal = arm_Context.pickedColor.normal >>> 24 << 24 | (arm_Context.pickedColor.normal & 16711680) >>> 16 << 16 | b.b[1] << 8 | arm_Context.pickedColor.normal & 255;
					arm_Context.pickedColor.normal = arm_Context.pickedColor.normal >>> 24 << 24 | (arm_Context.pickedColor.normal & 16711680) >>> 16 << 16 | (arm_Context.pickedColor.normal & 65280) >>> 8 << 8 | b.b[2];
					arm_Context.pickedColor.occlusion = c.b[0] / 255;
					arm_Context.pickedColor.roughness = c.b[1] / 255;
					arm_Context.pickedColor.metallic = c.b[2] / 255;
					arm_Context.pickedColor.height = c.b[3] / 255;
					arm_Context.pickedColor.opacity = a.b[3] / 255;
					arm_Context.uvxPicked = d.b[0] / 255;
					arm_Context.uvyPicked = d.b[1] / 255;
					if(arm_Context.pickerSelectMaterial) {
						let matid = (b.b[3] - b.b[3] % 3) / 3 | 0;
						let _g = 0;
						let _g1 = arm_Project.materials;
						while(_g < _g1.length) {
							let m = _g1[_g];
							++_g;
							if(m.id == matid) {
								arm_Context.setMaterial(m);
								arm_Context.materialIdPicked = matid;
								break;
							}
						}
					}
				}
			} else {
				if(arm_Context.tool == 11 && arm_Context.bakeType == 0) {
					if(arm_render_RenderPathPaint.initVoxels) {
						arm_render_RenderPathPaint.initVoxels = false;
						let rp_gi = arm_Config.raw.rp_gi;
						arm_Config.raw.rp_gi = true;
						arm_render_Inc.initGI();
						arm_Config.raw.rp_gi = rp_gi;
					}
					arm_render_RenderPathPaint.path.clearImage("voxels",0);
					arm_render_RenderPathPaint.path.setTarget("");
					arm_render_RenderPathPaint.path.setViewport(256,256);
					arm_render_RenderPathPaint.path.bindTarget("voxels","voxels");
					arm_render_RenderPathPaint.path.drawMeshes("voxel");
					arm_render_RenderPathPaint.path.generateMipmaps("voxels");
				}
				let texpaint = "texpaint" + tid;
				if(arm_Context.tool == 11 && arm_Context.brushTime == iron_system_Time.get_delta()) {
					arm_render_RenderPathPaint.path.setTarget(texpaint);
					arm_render_RenderPathPaint.path.clearTarget(-16777216);
				}
				arm_render_RenderPathPaint.path.setTarget("texpaint_blend1");
				arm_render_RenderPathPaint.path.bindTarget("texpaint_blend0","tex");
				arm_render_RenderPathPaint.path.drawShader("shader_datas/copy_pass/copyR8_pass");
				if(arm_Context.layer.isMask()) {
					let ptid = arm_Context.layer.parent.id;
					if(arm_Context.layer.parent.isGroup()) {
						let _g = arm_Context.layer.parent.getChildren();
						while(0 < _g.length) {
							ptid = _g[0].id;
							break;
						}
					}
					arm_render_RenderPathPaint.path.setTarget(texpaint,["texpaint_nor" + ptid,"texpaint_pack" + ptid,"texpaint_blend0"]);
				} else {
					arm_render_RenderPathPaint.path.setTarget(texpaint,["texpaint_nor" + tid,"texpaint_pack" + tid,"texpaint_blend0"]);
				}
				arm_render_RenderPathPaint.path.bindTarget("_main","gbufferD");
				if((arm_Context.xray || arm_Config.raw.brush_angle_reject) && arm_Config.raw.brush_3d) {
					arm_render_RenderPathPaint.path.bindTarget("gbuffer0","gbuffer0");
				}
				arm_render_RenderPathPaint.path.bindTarget("texpaint_blend1","paintmask");
				if(arm_Context.tool == 11 && arm_Context.bakeType == 0) {
					arm_render_RenderPathPaint.path.bindTarget("voxels","voxels");
				}
				if(arm_Context.colorIdPicked) {
					arm_render_RenderPathPaint.path.bindTarget("texpaint_colorid","texpaint_colorid");
				}
				if(arm_Context.tool == 2 && arm_Context.fillTypeHandle.position == 1 || arm_Context.tool == 5 || arm_Context.tool == 6) {
					arm_render_RenderPathPaint.path.bindTarget("gbuffer2","gbuffer2");
				}
				arm_render_RenderPathPaint.path.drawMeshes("paint");
				if(arm_Context.tool == 11 && arm_Context.bakeType == 1 && arm_Context.bakeCurvSmooth > 0) {
					if(arm_render_RenderPathPaint.path.renderTargets.h["texpaint_blur"] == null) {
						let t = new iron_RenderTargetRaw();
						t.name = "texpaint_blur";
						t.width = arm_Config.getTextureResX() * 0.95 | 0;
						t.height = arm_Config.getTextureResY() * 0.95 | 0;
						t.format = "RGBA32";
						arm_render_RenderPathPaint.path.createRenderTarget(t);
					}
					let blurs = Math.round(arm_Context.bakeCurvSmooth);
					let _g = 0;
					while(_g < blurs) {
						++_g;
						arm_render_RenderPathPaint.path.setTarget("texpaint_blur");
						arm_render_RenderPathPaint.path.bindTarget(texpaint,"tex");
						arm_render_RenderPathPaint.path.drawShader("shader_datas/copy_pass/copy_pass");
						arm_render_RenderPathPaint.path.setTarget(texpaint);
						arm_render_RenderPathPaint.path.bindTarget("texpaint_blur","tex");
						arm_render_RenderPathPaint.path.drawShader("shader_datas/copy_pass/copy_pass");
					}
				}
				if(dilation && arm_Config.raw.dilate == 0) {
					arm_render_RenderPathPaint.dilate(true,false);
				}
			}
		}
	}
	static useLiveLayer(use) {
		let tid = arm_Context.layer.id;
		let hid = arm_History.undoI - 1 < 0 ? arm_Config.raw.undo_steps - 1 : arm_History.undoI - 1;
		if(use) {
			arm_render_RenderPathPaint._texpaint = arm_render_RenderPathPaint.path.renderTargets.h["texpaint" + tid];
			arm_render_RenderPathPaint._texpaint_undo = arm_render_RenderPathPaint.path.renderTargets.h["texpaint_undo" + hid];
			arm_render_RenderPathPaint._texpaint_nor_undo = arm_render_RenderPathPaint.path.renderTargets.h["texpaint_nor_undo" + hid];
			arm_render_RenderPathPaint._texpaint_pack_undo = arm_render_RenderPathPaint.path.renderTargets.h["texpaint_pack_undo" + hid];
			arm_render_RenderPathPaint._texpaint_nor = arm_render_RenderPathPaint.path.renderTargets.h["texpaint_nor" + tid];
			arm_render_RenderPathPaint._texpaint_pack = arm_render_RenderPathPaint.path.renderTargets.h["texpaint_pack" + tid];
			arm_render_RenderPathPaint.path.renderTargets.h["texpaint_undo" + hid] = arm_render_RenderPathPaint.path.renderTargets.h["texpaint" + tid];
			arm_render_RenderPathPaint.path.renderTargets.h["texpaint" + tid] = arm_render_RenderPathPaint.path.renderTargets.h["texpaint_live"];
			if(arm_Context.layer.isLayer()) {
				arm_render_RenderPathPaint.path.renderTargets.h["texpaint_nor_undo" + hid] = arm_render_RenderPathPaint.path.renderTargets.h["texpaint_nor" + tid];
				arm_render_RenderPathPaint.path.renderTargets.h["texpaint_pack_undo" + hid] = arm_render_RenderPathPaint.path.renderTargets.h["texpaint_pack" + tid];
				arm_render_RenderPathPaint.path.renderTargets.h["texpaint_nor" + tid] = arm_render_RenderPathPaint.path.renderTargets.h["texpaint_nor_live"];
				arm_render_RenderPathPaint.path.renderTargets.h["texpaint_pack" + tid] = arm_render_RenderPathPaint.path.renderTargets.h["texpaint_pack_live"];
			}
		} else {
			arm_render_RenderPathPaint.path.renderTargets.h["texpaint" + tid] = arm_render_RenderPathPaint._texpaint;
			arm_render_RenderPathPaint.path.renderTargets.h["texpaint_undo" + hid] = arm_render_RenderPathPaint._texpaint_undo;
			if(arm_Context.layer.isLayer()) {
				arm_render_RenderPathPaint.path.renderTargets.h["texpaint_nor_undo" + hid] = arm_render_RenderPathPaint._texpaint_nor_undo;
				arm_render_RenderPathPaint.path.renderTargets.h["texpaint_pack_undo" + hid] = arm_render_RenderPathPaint._texpaint_pack_undo;
				arm_render_RenderPathPaint.path.renderTargets.h["texpaint_nor" + tid] = arm_render_RenderPathPaint._texpaint_nor;
				arm_render_RenderPathPaint.path.renderTargets.h["texpaint_pack" + tid] = arm_render_RenderPathPaint._texpaint_pack;
			}
		}
		arm_render_RenderPathPaint.liveLayerLocked = use;
	}
	static commandsLiveBrush() {
		let tool = arm_Context.tool;
		if(tool != 0 && tool != 1 && tool != 5 && tool != 3 && tool != 4 && tool != 6) {
			return;
		}
		if(arm_render_RenderPathPaint.liveLayerLocked) {
			return;
		}
		if(arm_render_RenderPathPaint.liveLayer == null) {
			arm_render_RenderPathPaint.liveLayer = new arm_data_LayerSlot("_live");
		}
		let tid = arm_Context.layer.id;
		if(arm_Context.layer.isMask()) {
			arm_render_RenderPathPaint.path.setTarget("texpaint_live");
			arm_render_RenderPathPaint.path.bindTarget("texpaint" + tid,"tex");
			arm_render_RenderPathPaint.path.drawShader("shader_datas/copy_pass/copy_pass");
		} else {
			arm_render_RenderPathPaint.path.setTarget("texpaint_live",["texpaint_nor_live","texpaint_pack_live"]);
			arm_render_RenderPathPaint.path.bindTarget("texpaint" + tid,"tex0");
			arm_render_RenderPathPaint.path.bindTarget("texpaint_nor" + tid,"tex1");
			arm_render_RenderPathPaint.path.bindTarget("texpaint_pack" + tid,"tex2");
			arm_render_RenderPathPaint.path.drawShader("shader_datas/copy_mrt3_pass/copy_mrt3_pass");
		}
		arm_render_RenderPathPaint.useLiveLayer(true);
		arm_render_RenderPathPaint.liveLayerDrawn = 2;
		arm_ui_UIView2D.inst.hwnd.redraws = 2;
		let _x = arm_Context.paintVec.x;
		let _y = arm_Context.paintVec.y;
		if(arm_Context.brushLocked) {
			let tmp = arm_Context.lockStartedX - arm_App.x();
			let tmp1 = arm_App.w();
			arm_Context.paintVec.x = tmp / tmp1;
			let tmp2 = arm_Context.lockStartedY - arm_App.y();
			let tmp3 = arm_App.h();
			arm_Context.paintVec.y = tmp2 / tmp3;
		}
		let _lastX = arm_Context.lastPaintVecX;
		let _lastY = arm_Context.lastPaintVecY;
		let _pdirty = arm_Context.pdirty;
		arm_Context.lastPaintVecX = arm_Context.paintVec.x;
		arm_Context.lastPaintVecY = arm_Context.paintVec.y;
		if(arm_Operator.shortcut(arm_Config.keymap.brush_ruler)) {
			arm_Context.lastPaintVecX = arm_Context.lastPaintX;
			arm_Context.lastPaintVecY = arm_Context.lastPaintY;
		}
		arm_Context.pdirty = 2;
		arm_render_RenderPathPaint.commandsSymmetry();
		arm_render_RenderPathPaint.commandsPaint();
		arm_render_RenderPathPaint.useLiveLayer(false);
		arm_Context.paintVec.x = _x;
		arm_Context.paintVec.y = _y;
		arm_Context.lastPaintVecX = _lastX;
		arm_Context.lastPaintVecY = _lastY;
		arm_Context.pdirty = _pdirty;
		arm_Context.brushBlendDirty = true;
	}
	static commandsCursor() {
		let decalMask = (arm_Context.tool == 3 || arm_Context.tool == 4) && arm_Operator.shortcut(arm_Config.keymap.decal_mask,2);
		let tool = arm_Context.tool;
		if(tool != 0 && tool != 1 && tool != 5 && tool != 6 && tool != 7 && !decalMask) {
			return;
		}
		let fillLayer = arm_Context.layer.fill_layer != null;
		let groupLayer = arm_Context.layer.isGroup();
		if(!arm_App.uiEnabled || arm_App.isDragging || fillLayer || groupLayer) {
			return;
		}
		let mx = arm_Context.paintVec.x;
		let my = 1.0 - arm_Context.paintVec.y;
		if(arm_Context.brushLocked) {
			mx = (arm_Context.lockStartedX - arm_App.x()) / arm_App.w();
			my = 1.0 - (arm_Context.lockStartedY - arm_App.y()) / arm_App.h();
		}
		arm_render_RenderPathPaint.drawCursor(mx,my,arm_Context.brushNodesRadius * (decalMask ? arm_Context.brushDecalMaskRadius : arm_Context.brushRadius) / 3.4);
	}
	static drawCursor(mx,my,radius,tintR,tintG,tintB) {
		if(tintB == null) {
			tintB = 1.0;
		}
		if(tintG == null) {
			tintG = 1.0;
		}
		if(tintR == null) {
			tintR = 1.0;
		}
		let geom = (js_Boot.__cast(iron_Scene.active.getChild(".Plane") , iron_object_MeshObject)).data.geom;
		let g = arm_render_RenderPathPaint.path.frameG;
		if(arm_Layers.pipeCursor == null) {
			arm_Layers.makeCursorPipe();
		}
		arm_render_RenderPathPaint.path.setTarget("");
		g.setPipeline(arm_Layers.pipeCursor);
		let decal = arm_Context.tool == 3 || arm_Context.tool == 4;
		let decalMask = decal && arm_Operator.shortcut(arm_Config.keymap.decal_mask,2);
		g.setTexture(arm_Layers.cursorTex,decal && !decalMask ? arm_Context.decalImage : arm_Res.bundled.h["cursor.k"]);
		let gbuffer0 = arm_render_RenderPathPaint.path.renderTargets.h["gbuffer0"].image;
		g.setTextureDepth(arm_Layers.cursorGbufferD,gbuffer0);
		g.setFloat2(arm_Layers.cursorMouse,mx,my);
		g.setFloat2(arm_Layers.cursorTexStep,1 / gbuffer0.get_width(),1 / gbuffer0.get_height());
		g.setFloat(arm_Layers.cursorRadius,radius);
		let _this = iron_Scene.active.camera;
		let x = _this.transform.world.self._00;
		let y = _this.transform.world.self._01;
		let z = _this.transform.world.self._02;
		if(z == null) {
			z = 0.0;
		}
		if(y == null) {
			y = 0.0;
		}
		if(x == null) {
			x = 0.0;
		}
		let right_x = x;
		let right_y = y;
		let right_z = z;
		let n = Math.sqrt(right_x * right_x + right_y * right_y + right_z * right_z);
		if(n > 0.0) {
			let invN = 1.0 / n;
			right_x *= invN;
			right_y *= invN;
			right_z *= invN;
		}
		g.setFloat3(arm_Layers.cursorCameraRight,right_x,right_y,right_z);
		g.setFloat3(arm_Layers.cursorTint,tintR,tintG,tintB);
		let matrix = iron_Scene.active.camera.VP.self;
		kha_graphics4_Graphics.mat[0] = matrix._00;
		kha_graphics4_Graphics.mat[1] = matrix._01;
		kha_graphics4_Graphics.mat[2] = matrix._02;
		kha_graphics4_Graphics.mat[3] = matrix._03;
		kha_graphics4_Graphics.mat[4] = matrix._10;
		kha_graphics4_Graphics.mat[5] = matrix._11;
		kha_graphics4_Graphics.mat[6] = matrix._12;
		kha_graphics4_Graphics.mat[7] = matrix._13;
		kha_graphics4_Graphics.mat[8] = matrix._20;
		kha_graphics4_Graphics.mat[9] = matrix._21;
		kha_graphics4_Graphics.mat[10] = matrix._22;
		kha_graphics4_Graphics.mat[11] = matrix._23;
		kha_graphics4_Graphics.mat[12] = matrix._30;
		kha_graphics4_Graphics.mat[13] = matrix._31;
		kha_graphics4_Graphics.mat[14] = matrix._32;
		kha_graphics4_Graphics.mat[15] = matrix._33;
		Krom.setMatrix(arm_Layers.cursorVP,kha_graphics4_Graphics.mat.buffer);
		let helpMat = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
		let m = iron_Scene.active.camera.VP;
		let a00 = m.self._00;
		let a01 = m.self._01;
		let a02 = m.self._02;
		let a03 = m.self._03;
		let a10 = m.self._10;
		let a11 = m.self._11;
		let a12 = m.self._12;
		let a13 = m.self._13;
		let a20 = m.self._20;
		let a21 = m.self._21;
		let a22 = m.self._22;
		let a23 = m.self._23;
		let a30 = m.self._30;
		let a31 = m.self._31;
		let a32 = m.self._32;
		let a33 = m.self._33;
		let b00 = a00 * a11 - a01 * a10;
		let b01 = a00 * a12 - a02 * a10;
		let b02 = a00 * a13 - a03 * a10;
		let b03 = a01 * a12 - a02 * a11;
		let b04 = a01 * a13 - a03 * a11;
		let b05 = a02 * a13 - a03 * a12;
		let b06 = a20 * a31 - a21 * a30;
		let b07 = a20 * a32 - a22 * a30;
		let b08 = a20 * a33 - a23 * a30;
		let b09 = a21 * a32 - a22 * a31;
		let b10 = a21 * a33 - a23 * a31;
		let b11 = a22 * a33 - a23 * a32;
		let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
		if(det == 0.0) {
			helpMat.self._00 = 1.0;
			helpMat.self._01 = 0.0;
			helpMat.self._02 = 0.0;
			helpMat.self._03 = 0.0;
			helpMat.self._10 = 0.0;
			helpMat.self._11 = 1.0;
			helpMat.self._12 = 0.0;
			helpMat.self._13 = 0.0;
			helpMat.self._20 = 0.0;
			helpMat.self._21 = 0.0;
			helpMat.self._22 = 1.0;
			helpMat.self._23 = 0.0;
			helpMat.self._30 = 0.0;
			helpMat.self._31 = 0.0;
			helpMat.self._32 = 0.0;
			helpMat.self._33 = 1.0;
		} else {
			det = 1.0 / det;
			helpMat.self._00 = (a11 * b11 - a12 * b10 + a13 * b09) * det;
			helpMat.self._01 = (a02 * b10 - a01 * b11 - a03 * b09) * det;
			helpMat.self._02 = (a31 * b05 - a32 * b04 + a33 * b03) * det;
			helpMat.self._03 = (a22 * b04 - a21 * b05 - a23 * b03) * det;
			helpMat.self._10 = (a12 * b08 - a10 * b11 - a13 * b07) * det;
			helpMat.self._11 = (a00 * b11 - a02 * b08 + a03 * b07) * det;
			helpMat.self._12 = (a32 * b02 - a30 * b05 - a33 * b01) * det;
			helpMat.self._13 = (a20 * b05 - a22 * b02 + a23 * b01) * det;
			helpMat.self._20 = (a10 * b10 - a11 * b08 + a13 * b06) * det;
			helpMat.self._21 = (a01 * b08 - a00 * b10 - a03 * b06) * det;
			helpMat.self._22 = (a30 * b04 - a31 * b02 + a33 * b00) * det;
			helpMat.self._23 = (a21 * b02 - a20 * b04 - a23 * b00) * det;
			helpMat.self._30 = (a11 * b07 - a10 * b09 - a12 * b06) * det;
			helpMat.self._31 = (a00 * b09 - a01 * b07 + a02 * b06) * det;
			helpMat.self._32 = (a31 * b01 - a30 * b03 - a32 * b00) * det;
			helpMat.self._33 = (a20 * b03 - a21 * b01 + a22 * b00) * det;
		}
		let matrix1 = helpMat.self;
		kha_graphics4_Graphics.mat[0] = matrix1._00;
		kha_graphics4_Graphics.mat[1] = matrix1._01;
		kha_graphics4_Graphics.mat[2] = matrix1._02;
		kha_graphics4_Graphics.mat[3] = matrix1._03;
		kha_graphics4_Graphics.mat[4] = matrix1._10;
		kha_graphics4_Graphics.mat[5] = matrix1._11;
		kha_graphics4_Graphics.mat[6] = matrix1._12;
		kha_graphics4_Graphics.mat[7] = matrix1._13;
		kha_graphics4_Graphics.mat[8] = matrix1._20;
		kha_graphics4_Graphics.mat[9] = matrix1._21;
		kha_graphics4_Graphics.mat[10] = matrix1._22;
		kha_graphics4_Graphics.mat[11] = matrix1._23;
		kha_graphics4_Graphics.mat[12] = matrix1._30;
		kha_graphics4_Graphics.mat[13] = matrix1._31;
		kha_graphics4_Graphics.mat[14] = matrix1._32;
		kha_graphics4_Graphics.mat[15] = matrix1._33;
		Krom.setMatrix(arm_Layers.cursorInvVP,kha_graphics4_Graphics.mat.buffer);
		g.setVertexBuffer(geom.vertexBuffer);
		g.setIndexBuffer(geom.indexBuffers[0]);
		g.drawIndexedVertices();
		g.disableScissor();
		let _this1 = arm_render_RenderPathPaint.path;
		if(_this1.scissorSet) {
			_this1.currentG.disableScissor();
			_this1.scissorSet = false;
		}
		_this1.currentG.end();
		_this1.currentG = null;
		_this1.bindParams = null;
	}
	static commandsSymmetry() {
		if(arm_Context.symX || arm_Context.symY || arm_Context.symZ) {
			arm_Context.ddirty = 2;
			let t = arm_Context.paintObject.transform;
			let sx = t.scale.x;
			let sy = t.scale.y;
			let sz = t.scale.z;
			if(arm_Context.symX) {
				let _this = t.scale;
				_this.x = -sx;
				_this.y = sy;
				_this.z = sz;
				_this.w = 1.0;
				t.buildMatrix();
				arm_render_RenderPathPaint.commandsPaint(false);
			}
			if(arm_Context.symY) {
				let _this = t.scale;
				_this.x = sx;
				_this.y = -sy;
				_this.z = sz;
				_this.w = 1.0;
				t.buildMatrix();
				arm_render_RenderPathPaint.commandsPaint(false);
			}
			if(arm_Context.symZ) {
				let _this = t.scale;
				_this.x = sx;
				_this.y = sy;
				_this.z = -sz;
				_this.w = 1.0;
				t.buildMatrix();
				arm_render_RenderPathPaint.commandsPaint(false);
			}
			if(arm_Context.symX && arm_Context.symY) {
				let _this = t.scale;
				_this.x = -sx;
				_this.y = -sy;
				_this.z = sz;
				_this.w = 1.0;
				t.buildMatrix();
				arm_render_RenderPathPaint.commandsPaint(false);
			}
			if(arm_Context.symX && arm_Context.symZ) {
				let _this = t.scale;
				_this.x = -sx;
				_this.y = sy;
				_this.z = -sz;
				_this.w = 1.0;
				t.buildMatrix();
				arm_render_RenderPathPaint.commandsPaint(false);
			}
			if(arm_Context.symY && arm_Context.symZ) {
				let _this = t.scale;
				_this.x = sx;
				_this.y = -sy;
				_this.z = -sz;
				_this.w = 1.0;
				t.buildMatrix();
				arm_render_RenderPathPaint.commandsPaint(false);
			}
			if(arm_Context.symX && arm_Context.symY && arm_Context.symZ) {
				let _this = t.scale;
				_this.x = -sx;
				_this.y = -sy;
				_this.z = -sz;
				_this.w = 1.0;
				t.buildMatrix();
				arm_render_RenderPathPaint.commandsPaint(false);
			}
			let _this = t.scale;
			_this.x = sx;
			_this.y = sy;
			_this.z = sz;
			_this.w = 1.0;
			t.buildMatrix();
		}
	}
	static paintEnabled() {
		let fillLayer = arm_Context.layer.fill_layer != null && arm_Context.tool != 9 && arm_Context.tool != 8;
		let groupLayer = arm_Context.layer.isGroup();
		if(!fillLayer && !groupLayer) {
			return !arm_Context.foregroundEvent;
		} else {
			return false;
		}
	}
	static begin() {
		if(!arm_render_RenderPathPaint.paintEnabled()) {
			return;
		}
		arm_render_RenderPathPaint.pushUndoLast = arm_History.pushUndo;
		if(arm_History.pushUndo && arm_History.undoLayers != null) {
			arm_History.paint();
		}
		if(arm_Context.paint2d) {
			arm_render_RenderPathPaint.setPlaneMesh();
		}
		if(arm_render_RenderPathPaint.liveLayerDrawn > 0) {
			arm_render_RenderPathPaint.liveLayerDrawn--;
		}
		if(arm_Config.raw.brush_live && arm_Context.pdirty <= 0 && arm_Context.ddirty <= 0 && arm_Context.brushTime == 0) {
			arm_render_RenderPathPaint.commandsLiveBrush();
		}
	}
	static end() {
		if(arm_Config.raw.brush_3d) {
			arm_render_RenderPathPaint.commandsCursor();
		}
		arm_Context.ddirty--;
		arm_Context.rdirty--;
		if(!arm_render_RenderPathPaint.paintEnabled()) {
			return;
		}
		arm_Context.pdirty--;
	}
	static draw() {
		if(!arm_render_RenderPathPaint.paintEnabled()) {
			return;
		}
		if(arm_Config.raw.brush_live && arm_Context.pdirty <= 0 && arm_Context.ddirty > 0 && arm_Context.brushTime == 0) {
			arm_render_RenderPathPaint.commandsLiveBrush();
		}
		if(arm_History.undoLayers != null) {
			arm_render_RenderPathPaint.commandsSymmetry();
			if(arm_Context.pdirty > 0) {
				arm_render_RenderPathPaint.dilated = false;
			}
			if(arm_Context.tool == 11) {
				if(arm_Context.bakeType == 2 || arm_Context.bakeType == 4 || arm_Context.bakeType == 5) {
					if(!arm_render_RenderPathPaint.baking && arm_Context.pdirty > 0) {
						arm_render_RenderPathPaint.baking = true;
						let _bakeType = arm_Context.bakeType;
						arm_Context.bakeType = arm_Context.bakeType == 2 ? 3 : 6;
						arm_node_MakeMaterial.parsePaintMaterial();
						let _paintObject = arm_Context.paintObject;
						let highPoly = arm_Project.paintObjects[arm_Context.bakeHighPoly];
						let _visible = highPoly.visible;
						highPoly.visible = true;
						arm_Context.selectPaintObject(highPoly);
						arm_render_RenderPathPaint.commandsPaint();
						highPoly.visible = _visible;
						if(arm_render_RenderPathPaint.pushUndoLast) {
							arm_History.paint();
						}
						arm_Context.selectPaintObject(_paintObject);
						let _renderFinal = function() {
							arm_Context.bakeType = _bakeType;
							arm_node_MakeMaterial.parsePaintMaterial();
							arm_Context.pdirty = 1;
							arm_render_RenderPathPaint.commandsPaint();
							arm_Context.pdirty = 0;
							arm_render_RenderPathPaint.baking = false;
						};
						let _renderDeriv = function() {
							arm_Context.bakeType = 4;
							arm_node_MakeMaterial.parsePaintMaterial();
							arm_Context.pdirty = 1;
							arm_render_RenderPathPaint.commandsPaint();
							arm_Context.pdirty = 0;
							if(arm_render_RenderPathPaint.pushUndoLast) {
								arm_History.paint();
							}
							iron_App.notifyOnInit(_renderFinal);
						};
						iron_App.notifyOnInit(arm_Context.bakeType == 5 ? _renderDeriv : _renderFinal);
					}
				} else if(arm_Context.bakeType == 9) {
					let _layerFilter = arm_Context.layerFilter;
					let _paintObject = arm_Context.paintObject;
					let isMerged = arm_Context.mergedObject != null;
					let _visible = isMerged && arm_Context.mergedObject.visible;
					arm_Context.layerFilter = 1;
					if(isMerged) {
						arm_Context.mergedObject.visible = false;
					}
					let _g = 0;
					let _g1 = arm_Project.paintObjects;
					while(_g < _g1.length) {
						arm_Context.selectPaintObject(_g1[_g++]);
						arm_render_RenderPathPaint.commandsPaint();
					}
					arm_Context.layerFilter = _layerFilter;
					arm_Context.selectPaintObject(_paintObject);
					if(isMerged) {
						arm_Context.mergedObject.visible = _visible;
					}
				} else {
					arm_render_RenderPathPaint.commandsPaint();
				}
			} else {
				arm_render_RenderPathPaint.commandsPaint();
			}
		}
		if(arm_Context.brushBlendDirty) {
			arm_Context.brushBlendDirty = false;
			arm_render_RenderPathPaint.path.setTarget("texpaint_blend0",["texpaint_blend1"]);
			arm_render_RenderPathPaint.path.clearTarget(0);
		}
		if(arm_Context.paint2d) {
			arm_render_RenderPathPaint.restorePlaneMesh();
		}
	}
	static setPlaneMesh() {
		arm_Context.paint2dView = true;
		arm_render_RenderPathPaint.painto = arm_Context.paintObject;
		arm_render_RenderPathPaint.visibles = [];
		let _g = 0;
		let _g1 = arm_Project.paintObjects;
		while(_g < _g1.length) {
			let p = _g1[_g];
			++_g;
			arm_render_RenderPathPaint.visibles.push(p.visible);
			p.visible = false;
		}
		if(arm_Context.mergedObject != null) {
			arm_render_RenderPathPaint.mergedObjectVisible = arm_Context.mergedObject.visible;
			arm_Context.mergedObject.visible = false;
		}
		let cam = iron_Scene.active.camera;
		let _this = arm_Context.savedCamera;
		let m = cam.transform.local;
		_this.self._00 = m.self._00;
		_this.self._01 = m.self._01;
		_this.self._02 = m.self._02;
		_this.self._03 = m.self._03;
		_this.self._10 = m.self._10;
		_this.self._11 = m.self._11;
		_this.self._12 = m.self._12;
		_this.self._13 = m.self._13;
		_this.self._20 = m.self._20;
		_this.self._21 = m.self._21;
		_this.self._22 = m.self._22;
		_this.self._23 = m.self._23;
		_this.self._30 = m.self._30;
		_this.self._31 = m.self._31;
		_this.self._32 = m.self._32;
		_this.self._33 = m.self._33;
		arm_render_RenderPathPaint.savedFov = cam.data.raw.fov;
		arm_Viewport.updateCameraType(0);
		let m1 = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
		m1.self._00 += 0 * m1.self._03;
		m1.self._01 += 0 * m1.self._03;
		m1.self._02 += 0.5 * m1.self._03;
		m1.self._10 += 0 * m1.self._13;
		m1.self._11 += 0 * m1.self._13;
		m1.self._12 += 0.5 * m1.self._13;
		m1.self._20 += 0 * m1.self._23;
		m1.self._21 += 0 * m1.self._23;
		m1.self._22 += 0.5 * m1.self._23;
		m1.self._30 += 0 * m1.self._33;
		m1.self._31 += 0 * m1.self._33;
		m1.self._32 += 0.5 * m1.self._33;
		cam.transform.setMatrix(m1);
		cam.data.raw.fov = 0.92;
		cam.buildProjection();
		cam.buildMatrix();
		let tw = 0.95 * arm_ui_UIView2D.inst.panScale;
		let tx = arm_ui_UIView2D.inst.panX / arm_ui_UIView2D.inst.ww;
		let ty = arm_ui_UIView2D.inst.panY / arm_App.h();
		m1.self._00 = 1.0;
		m1.self._01 = 0.0;
		m1.self._02 = 0.0;
		m1.self._03 = 0.0;
		m1.self._10 = 0.0;
		m1.self._11 = 1.0;
		m1.self._12 = 0.0;
		m1.self._13 = 0.0;
		m1.self._20 = 0.0;
		m1.self._21 = 0.0;
		m1.self._22 = 1.0;
		m1.self._23 = 0.0;
		m1.self._30 = 0.0;
		m1.self._31 = 0.0;
		m1.self._32 = 0.0;
		m1.self._33 = 1.0;
		let x = tw;
		let y = tw;
		if(tw == null) {
			y = 0.0;
		}
		if(tw == null) {
			x = 0.0;
		}
		let v_x = x;
		let v_y = y;
		let v_z = 1;
		m1.self._00 *= v_x;
		m1.self._01 *= v_x;
		m1.self._02 *= v_x;
		m1.self._03 *= v_x;
		m1.self._10 *= v_y;
		m1.self._11 *= v_y;
		m1.self._12 *= v_y;
		m1.self._13 *= v_y;
		m1.self._20 *= v_z;
		m1.self._21 *= v_z;
		m1.self._22 *= v_z;
		m1.self._23 *= v_z;
		let x1 = tx;
		let y1 = ty;
		if(ty == null) {
			y1 = 0.0;
		}
		if(tx == null) {
			x1 = 0.0;
		}
		m1.self._30 = x1;
		m1.self._31 = y1;
		m1.self._32 = 0;
		let m2 = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
		let m3 = iron_Scene.active.camera.VP;
		let a00 = m3.self._00;
		let a01 = m3.self._01;
		let a02 = m3.self._02;
		let a03 = m3.self._03;
		let a10 = m3.self._10;
		let a11 = m3.self._11;
		let a12 = m3.self._12;
		let a13 = m3.self._13;
		let a20 = m3.self._20;
		let a21 = m3.self._21;
		let a22 = m3.self._22;
		let a23 = m3.self._23;
		let a30 = m3.self._30;
		let a31 = m3.self._31;
		let a32 = m3.self._32;
		let a33 = m3.self._33;
		let b00 = a00 * a11 - a01 * a10;
		let b01 = a00 * a12 - a02 * a10;
		let b02 = a00 * a13 - a03 * a10;
		let b03 = a01 * a12 - a02 * a11;
		let b04 = a01 * a13 - a03 * a11;
		let b05 = a02 * a13 - a03 * a12;
		let b06 = a20 * a31 - a21 * a30;
		let b07 = a20 * a32 - a22 * a30;
		let b08 = a20 * a33 - a23 * a30;
		let b09 = a21 * a32 - a22 * a31;
		let b10 = a21 * a33 - a23 * a31;
		let b11 = a22 * a33 - a23 * a32;
		let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
		if(det == 0.0) {
			m2.self._00 = 1.0;
			m2.self._01 = 0.0;
			m2.self._02 = 0.0;
			m2.self._03 = 0.0;
			m2.self._10 = 0.0;
			m2.self._11 = 1.0;
			m2.self._12 = 0.0;
			m2.self._13 = 0.0;
			m2.self._20 = 0.0;
			m2.self._21 = 0.0;
			m2.self._22 = 1.0;
			m2.self._23 = 0.0;
			m2.self._30 = 0.0;
			m2.self._31 = 0.0;
			m2.self._32 = 0.0;
			m2.self._33 = 1.0;
		} else {
			det = 1.0 / det;
			m2.self._00 = (a11 * b11 - a12 * b10 + a13 * b09) * det;
			m2.self._01 = (a02 * b10 - a01 * b11 - a03 * b09) * det;
			m2.self._02 = (a31 * b05 - a32 * b04 + a33 * b03) * det;
			m2.self._03 = (a22 * b04 - a21 * b05 - a23 * b03) * det;
			m2.self._10 = (a12 * b08 - a10 * b11 - a13 * b07) * det;
			m2.self._11 = (a00 * b11 - a02 * b08 + a03 * b07) * det;
			m2.self._12 = (a32 * b02 - a30 * b05 - a33 * b01) * det;
			m2.self._13 = (a20 * b05 - a22 * b02 + a23 * b01) * det;
			m2.self._20 = (a10 * b10 - a11 * b08 + a13 * b06) * det;
			m2.self._21 = (a01 * b08 - a00 * b10 - a03 * b06) * det;
			m2.self._22 = (a30 * b04 - a31 * b02 + a33 * b00) * det;
			m2.self._23 = (a21 * b02 - a20 * b04 - a23 * b00) * det;
			m2.self._30 = (a11 * b07 - a10 * b09 - a12 * b06) * det;
			m2.self._31 = (a00 * b09 - a01 * b07 + a02 * b06) * det;
			m2.self._32 = (a31 * b01 - a30 * b03 - a32 * b00) * det;
			m2.self._33 = (a20 * b03 - a21 * b01 + a22 * b00) * det;
		}
		let a001 = m1.self._00;
		let a011 = m1.self._01;
		let a021 = m1.self._02;
		let a031 = m1.self._03;
		let a101 = m1.self._10;
		let a111 = m1.self._11;
		let a121 = m1.self._12;
		let a131 = m1.self._13;
		let a201 = m1.self._20;
		let a211 = m1.self._21;
		let a221 = m1.self._22;
		let a231 = m1.self._23;
		let a301 = m1.self._30;
		let a311 = m1.self._31;
		let a321 = m1.self._32;
		let a331 = m1.self._33;
		let b0 = m2.self._00;
		let b1 = m2.self._10;
		let b2 = m2.self._20;
		let b3 = m2.self._30;
		m1.self._00 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
		m1.self._10 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
		m1.self._20 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
		m1.self._30 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
		b0 = m2.self._01;
		b1 = m2.self._11;
		b2 = m2.self._21;
		b3 = m2.self._31;
		m1.self._01 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
		m1.self._11 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
		m1.self._21 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
		m1.self._31 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
		b0 = m2.self._02;
		b1 = m2.self._12;
		b2 = m2.self._22;
		b3 = m2.self._32;
		m1.self._02 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
		m1.self._12 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
		m1.self._22 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
		m1.self._32 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
		b0 = m2.self._03;
		b1 = m2.self._13;
		b2 = m2.self._23;
		b3 = m2.self._33;
		m1.self._03 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
		m1.self._13 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
		m1.self._23 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
		m1.self._33 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
		let tiled = arm_ui_UIView2D.inst.tiledShow;
		if(tiled && iron_Scene.active.getChild(".PlaneTiled") == null) {
			new iron_data_MeshData({ name : ".PlaneTiled", vertex_arrays : [{ attrib : "pos", values : arm_render_RenderPathPaint.i16([32767,0,-32767,0,10922,0,-10922,0,10922,0,-32767,0,10922,0,-10922,0,-10922,0,10922,0,-10922,0,-10922,0,-10922,0,10922,0,-32767,0,32767,0,-32767,0,10922,0,10922,0,10922,0,-10922,0,32767,0,-10922,0,10922,0,32767,0,10922,0,10922,0,32767,0,10922,0,10922,0,-10922,0,-10922,0,-32767,0,10922,0,-32767,0,-10922,0,32767,0,-10922,0,10922,0,10922,0,10922,0,-10922,0,-10922,0,-32767,0,-32767,0,-10922,0,-32767,0,-32767,0,10922,0,-32767,0,-10922,0,-10922,0,-10922,0,-32767,0,32767,0,-32767,0,32767,0,-10922,0,10922,0,-10922,0,10922,0,-10922,0,10922,0,10922,0,-10922,0,10922,0,-10922,0,10922,0,-10922,0,32767,0,-32767,0,32767,0,10922,0,10922,0,10922,0,32767,0,-10922,0,32767,0,32767,0,10922,0,32767,0,32767,0,10922,0,32767,0,-10922,0,-10922,0,-10922,0,10922,0,-32767,0,10922,0,32767,0,-10922,0,32767,0,10922,0,10922,0,10922,0,-10922,0,-32767,0,-10922,0,-10922,0,-32767,0,-10922,0,10922,0,-32767,0,10922,0,-10922,0,-10922,0,-10922,0]), data : "short4norm"},{ attrib : "nor", values : arm_render_RenderPathPaint.i16([0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767,0,-32767]), data : "short2norm"},{ attrib : "tex", values : arm_render_RenderPathPaint.i16([32767,32767,0,0,0,32767,32767,32767,0,0,0,32767,32767,32767,0,0,0,32767,32767,32767,0,0,0,32767,32767,32767,0,0,0,32767,32767,32767,0,0,0,32767,32767,32767,0,0,0,32767,32767,32767,0,0,0,32767,32767,32767,0,0,0,32767,32767,32767,32767,0,0,0,32767,32767,32767,0,0,0,32767,32767,32767,0,0,0,32767,32767,32767,0,0,0,32767,32767,32767,0,0,0,32767,32767,32767,0,0,0,32767,32767,32767,0,0,0,32767,32767,32767,0,0,0,32767,32767,32767,0,0,0]), data : "short2norm"}], index_arrays : [{ values : arm_render_RenderPathPaint.u32([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53]), material : 0}], scale_pos : 1.5, scale_tex : 1.0},function(md) {
				let materials = (js_Boot.__cast(iron_Scene.active.getChild(".Plane") , iron_object_MeshObject)).materials;
				iron_Scene.active.addMeshObject(md,materials).name = ".PlaneTiled";
			});
		}
		arm_render_RenderPathPaint.planeo = iron_Scene.active.getChild(tiled ? ".PlaneTiled" : ".Plane");
		arm_render_RenderPathPaint.planeo.visible = true;
		arm_Context.paintObject = arm_render_RenderPathPaint.planeo;
		let x2 = m1.self._00;
		let y2 = m1.self._01;
		let z = m1.self._02;
		let sx = Math.sqrt(x2 * x2 + y2 * y2 + z * z);
		let _this1 = arm_render_RenderPathPaint.planeo.transform.rot;
		let f = -Math.PI / 2 / 2;
		let c1 = Math.cos(f);
		let s1 = Math.sin(f);
		f = 0.;
		let c2 = Math.cos(0.);
		let s2 = Math.sin(0.);
		f = 0.;
		let c3 = Math.cos(0.);
		let s3 = Math.sin(0.);
		_this1.x = s1 * c2 * c3 + c1 * s2 * s3;
		_this1.y = c1 * s2 * c3 + s1 * c2 * s3;
		_this1.z = c1 * c2 * s3 - s1 * s2 * c3;
		_this1.w = c1 * c2 * c3 - s1 * s2 * s3;
		let _this2 = arm_render_RenderPathPaint.planeo.transform.scale;
		_this2.x = sx;
		_this2.y = 1.0;
		_this2.z = sx;
		_this2.w = 1.0;
		arm_render_RenderPathPaint.planeo.transform.scale.z *= arm_Config.getTextureResY() / arm_Config.getTextureResX();
		let _this3 = arm_render_RenderPathPaint.planeo.transform.loc;
		_this3.x = m1.self._30;
		_this3.y = -m1.self._31;
		_this3.z = 0.0;
		_this3.w = 1.0;
		arm_render_RenderPathPaint.planeo.transform.buildMatrix();
	}
	static restorePlaneMesh() {
		arm_Context.paint2dView = false;
		arm_render_RenderPathPaint.planeo.visible = false;
		let _this = arm_render_RenderPathPaint.planeo.transform.loc;
		_this.x = 0.0;
		_this.y = 0.0;
		_this.z = 0.0;
		_this.w = 1.0;
		let _g = 0;
		let _g1 = arm_Project.paintObjects.length;
		while(_g < _g1) {
			let i = _g++;
			arm_Project.paintObjects[i].visible = arm_render_RenderPathPaint.visibles[i];
		}
		if(arm_Context.mergedObject != null) {
			arm_Context.mergedObject.visible = arm_render_RenderPathPaint.mergedObjectVisible;
		}
		arm_Context.paintObject = arm_render_RenderPathPaint.painto;
		iron_Scene.active.camera.transform.setMatrix(arm_Context.savedCamera);
		iron_Scene.active.camera.data.raw.fov = arm_render_RenderPathPaint.savedFov;
		arm_Viewport.updateCameraType(arm_Context.cameraType);
		iron_Scene.active.camera.buildProjection();
		iron_Scene.active.camera.buildMatrix();
		arm_render_RenderPathDeferred.drawGbuffer();
	}
	static bindLayers() {
		if(arm_Config.raw.brush_live && arm_render_RenderPathPaint.liveLayerDrawn > 0 || arm_ui_UIHeader.inst.worktab.position == 1) {
			arm_render_RenderPathPaint.useLiveLayer(true);
		}
		let _g = 0;
		let _g1 = arm_Project.layers.length;
		while(_g < _g1) {
			let l = arm_Project.layers[_g++];
			arm_render_RenderPathPaint.path.bindTarget("texpaint" + l.id,"texpaint" + l.id);
			if(l.isLayer()) {
				arm_render_RenderPathPaint.path.bindTarget("texpaint_nor" + l.id,"texpaint_nor" + l.id);
				arm_render_RenderPathPaint.path.bindTarget("texpaint_pack" + l.id,"texpaint_pack" + l.id);
			}
		}
	}
	static unbindLayers() {
		if(arm_Config.raw.brush_live && arm_render_RenderPathPaint.liveLayerDrawn > 0 || arm_ui_UIHeader.inst.worktab.position == 1) {
			arm_render_RenderPathPaint.useLiveLayer(false);
		}
	}
	static dilate(base,nor_pack) {
		if(arm_Config.raw.dilate_radius > 0 && !arm_Context.paint2d) {
			arm_util_UVUtil.cacheDilateMap();
			arm_Layers.makeTempImg();
			let tid = arm_Context.layer.id;
			if(base) {
				arm_render_RenderPathPaint.path.setTarget("temptex0");
				arm_render_RenderPathPaint.path.bindTarget("texpaint" + tid,"tex");
				arm_render_RenderPathPaint.path.drawShader("shader_datas/copy_pass/copy_pass");
				arm_render_RenderPathPaint.path.setTarget("texpaint" + tid);
				arm_render_RenderPathPaint.path.bindTarget("temptex0","tex");
				arm_render_RenderPathPaint.path.drawShader("shader_datas/dilate_pass/dilate_pass");
			}
			if(nor_pack && !arm_Context.layer.isMask()) {
				arm_render_RenderPathPaint.path.setTarget("temptex0");
				arm_render_RenderPathPaint.path.bindTarget("texpaint_nor" + tid,"tex");
				arm_render_RenderPathPaint.path.drawShader("shader_datas/copy_pass/copy_pass");
				arm_render_RenderPathPaint.path.setTarget("texpaint_nor" + tid);
				arm_render_RenderPathPaint.path.bindTarget("temptex0","tex");
				arm_render_RenderPathPaint.path.drawShader("shader_datas/dilate_pass/dilate_pass");
				arm_render_RenderPathPaint.path.setTarget("temptex0");
				arm_render_RenderPathPaint.path.bindTarget("texpaint_pack" + tid,"tex");
				arm_render_RenderPathPaint.path.drawShader("shader_datas/copy_pass/copy_pass");
				arm_render_RenderPathPaint.path.setTarget("texpaint_pack" + tid);
				arm_render_RenderPathPaint.path.bindTarget("temptex0","tex");
				arm_render_RenderPathPaint.path.drawShader("shader_datas/dilate_pass/dilate_pass");
			}
		}
	}
	static u32(ar) {
		let res = new Uint32Array(ar.length);
		let _g = 0;
		let _g1 = ar.length;
		while(_g < _g1) {
			let i = _g++;
			res[i] = ar[i];
		}
		return res;
	}
	static i16(ar) {
		let res = new Int16Array(ar.length);
		let _g = 0;
		let _g1 = ar.length;
		while(_g < _g1) {
			let i = _g++;
			res[i] = ar[i];
		}
		return res;
	}
}
$hxClasses["arm.render.RenderPathPaint"] = arm_render_RenderPathPaint;
arm_render_RenderPathPaint.__name__ = "arm.render.RenderPathPaint";
class arm_render_RenderPathPreview {
	static init(_path) {
		arm_render_RenderPathPreview.path = _path;
		let t = new iron_RenderTargetRaw();
		t.name = "texpreview";
		t.width = 1;
		t.height = 1;
		t.format = "RGBA32";
		arm_render_RenderPathPreview.path.createRenderTarget(t);
		let t1 = new iron_RenderTargetRaw();
		t1.name = "texpreview_icon";
		t1.width = 1;
		t1.height = 1;
		t1.format = "RGBA32";
		arm_render_RenderPathPreview.path.createRenderTarget(t1);
		arm_render_RenderPathPreview.path.createDepthBuffer("mmain","DEPTH24");
		let t2 = new iron_RenderTargetRaw();
		t2.name = "mtex";
		t2.width = 512;
		t2.height = 512;
		t2.format = "RGBA64";
		t2.scale = arm_render_Inc.superSample;
		arm_render_RenderPathPreview.path.createRenderTarget(t2);
		let t3 = new iron_RenderTargetRaw();
		t3.name = "mgbuffer0";
		t3.width = 512;
		t3.height = 512;
		t3.format = "RGBA64";
		t3.scale = arm_render_Inc.superSample;
		t3.depth_buffer = "mmain";
		arm_render_RenderPathPreview.path.createRenderTarget(t3);
		let t4 = new iron_RenderTargetRaw();
		t4.name = "mgbuffer1";
		t4.width = 512;
		t4.height = 512;
		t4.format = "RGBA64";
		t4.scale = arm_render_Inc.superSample;
		arm_render_RenderPathPreview.path.createRenderTarget(t4);
		let t5 = new iron_RenderTargetRaw();
		t5.name = "mgbuffer2";
		t5.width = 512;
		t5.height = 512;
		t5.format = "RGBA64";
		t5.scale = arm_render_Inc.superSample;
		arm_render_RenderPathPreview.path.createRenderTarget(t5);
	}
	static commandsPreview() {
		arm_render_RenderPathPreview.path.setTarget("mgbuffer2");
		arm_render_RenderPathPreview.path.clearTarget(-16777216);
		arm_render_RenderPathPreview.path.setTarget("mgbuffer0");
		arm_render_RenderPathPreview.path.clearTarget(null,1.0);
		arm_render_RenderPathPreview.path.setTarget("mgbuffer0",["mgbuffer1","mgbuffer2"]);
		arm_render_RenderPathPreview.path.drawMeshes("mesh");
		arm_render_RenderPathPreview.path.setTarget("mtex");
		arm_render_RenderPathPreview.path.bindTarget("_mmain","gbufferD");
		arm_render_RenderPathPreview.path.bindTarget("mgbuffer0","gbuffer0");
		arm_render_RenderPathPreview.path.bindTarget("mgbuffer1","gbuffer1");
		arm_render_RenderPathPreview.path.bindTarget("empty_white","ssaotex");
		arm_render_RenderPathPreview.path.drawShader("shader_datas/deferred_light/deferred_light");
		arm_render_RenderPathPreview.path.setDepthFrom("mtex","mgbuffer0");
		arm_render_RenderPathPreview.path.setTarget("mtex");
		arm_render_RenderPathPreview.path.drawSkydome("shader_datas/world_pass/world_pass");
		arm_render_RenderPathPreview.path.setDepthFrom("mtex","mgbuffer1");
		let selectedMat = arm_Context.material;
		iron_RenderPath.active.renderTargets.h["texpreview"].image = selectedMat.image;
		iron_RenderPath.active.renderTargets.h["texpreview_icon"].image = selectedMat.imageIcon;
		arm_render_RenderPathPreview.path.setTarget("texpreview");
		arm_render_RenderPathPreview.path.bindTarget("mtex","tex");
		arm_render_RenderPathPreview.path.drawShader("shader_datas/compositor_pass/compositor_pass");
		arm_render_RenderPathPreview.path.setTarget("texpreview_icon");
		arm_render_RenderPathPreview.path.bindTarget("texpreview","tex");
		arm_render_RenderPathPreview.path.drawShader("shader_datas/supersample_resolve/supersample_resolve");
	}
	static commandsDecal() {
		arm_render_RenderPathPreview.path.setTarget("gbuffer2");
		arm_render_RenderPathPreview.path.clearTarget(-16777216);
		arm_render_RenderPathPreview.path.setTarget("gbuffer0");
		arm_render_RenderPathPreview.path.clearTarget(null,1.0);
		arm_render_RenderPathPreview.path.setTarget("gbuffer0",["gbuffer1","gbuffer2"]);
		arm_render_RenderPathPreview.path.drawMeshes("mesh");
		arm_render_RenderPathPreview.path.setTarget("tex");
		arm_render_RenderPathPreview.path.bindTarget("_main","gbufferD");
		arm_render_RenderPathPreview.path.bindTarget("gbuffer0","gbuffer0");
		arm_render_RenderPathPreview.path.bindTarget("gbuffer1","gbuffer1");
		arm_render_RenderPathPreview.path.bindTarget("empty_white","ssaotex");
		arm_render_RenderPathPreview.path.drawShader("shader_datas/deferred_light/deferred_light");
		arm_render_RenderPathPreview.path.setDepthFrom("tex","gbuffer0");
		arm_render_RenderPathPreview.path.setTarget("tex");
		arm_render_RenderPathPreview.path.drawSkydome("shader_datas/world_pass/world_pass");
		arm_render_RenderPathPreview.path.setDepthFrom("tex","gbuffer1");
		iron_RenderPath.active.renderTargets.h["texpreview"].image = arm_Context.decalImage;
		arm_render_RenderPathPreview.path.setTarget("texpreview");
		arm_render_RenderPathPreview.path.bindTarget("tex","tex");
		arm_render_RenderPathPreview.path.drawShader("shader_datas/compositor_pass/compositor_pass");
	}
}
$hxClasses["arm.render.RenderPathPreview"] = arm_render_RenderPathPreview;
arm_render_RenderPathPreview.__name__ = "arm.render.RenderPathPreview";
class arm_render_Uniforms {
	static init() {
		iron_object_Uniforms.externalFloatLinks = [arm_render_Uniforms.linkFloat];
		iron_object_Uniforms.externalVec2Links = [arm_render_Uniforms.linkVec2];
		iron_object_Uniforms.externalVec3Links = [arm_render_Uniforms.linkVec3];
		iron_object_Uniforms.externalVec4Links = [arm_render_Uniforms.linkVec4];
		iron_object_Uniforms.externalMat4Links = [arm_render_Uniforms.linkMat4];
		iron_object_Uniforms.externalTextureLinks = [arm_render_Uniforms.linkTex];
	}
	static linkFloat(object,mat,link) {
		switch(link) {
		case "_brushHardness":
			let decalMask = arm_Operator.shortcut(arm_Config.keymap.decal_mask + "+" + arm_Config.keymap.action_paint,2);
			if(arm_Context.tool != 0 && arm_Context.tool != 1 && !decalMask) {
				return 1.0;
			}
			let val = arm_Context.brushHardness * arm_Context.brushNodesHardness;
			let pen = iron_system_Input.getPen();
			if(arm_Config.raw.pressure_hardness && pen.down()) {
				val *= pen.pressure * arm_Config.raw.pressure_sensitivity;
			}
			if(arm_Config.raw.brush_3d) {
				if(arm_Context.paint2d) {
					val *= 1.0 / arm_ui_UIView2D.inst.panScale;
				} else {
					val *= val;
				}
			}
			return val;
		case "_brushOpacity":
			let val1 = arm_Context.brushOpacity * arm_Context.brushNodesOpacity;
			let pen1 = iron_system_Input.getPen();
			if(arm_Config.raw.pressure_opacity && pen1.down()) {
				val1 *= pen1.pressure * arm_Config.raw.pressure_sensitivity;
			}
			return val1;
		case "_brushRadius":
			let decal = arm_Context.tool == 3 || arm_Context.tool == 4;
			let decalMask1 = decal && arm_Operator.shortcut(arm_Config.keymap.decal_mask + "+" + arm_Config.keymap.action_paint,2);
			let brushDecalMaskRadius = arm_Context.brushDecalMaskRadius;
			if(arm_Config.raw.brush_3d) {
				brushDecalMaskRadius *= arm_Context.paint2d ? 0.55 * arm_ui_UIView2D.inst.panScale : 2.0;
			}
			let val2 = (decalMask1 ? brushDecalMaskRadius : arm_Context.brushRadius) * arm_Context.brushNodesRadius / 15.0;
			let pen2 = iron_system_Input.getPen();
			if(arm_Config.raw.pressure_radius && pen2.down()) {
				val2 *= pen2.pressure * arm_Config.raw.pressure_sensitivity;
			}
			let scale2d = 900 / arm_App.h() * arm_Config.raw.window_scale;
			if(arm_Config.raw.brush_3d && !decal) {
				val2 *= arm_Context.paint2d ? 0.55 * scale2d * arm_ui_UIView2D.inst.panScale : 2;
			} else {
				val2 *= scale2d;
			}
			return val2;
		case "_brushScale":
			return (arm_Context.layer.fill_layer != null ? arm_Context.layer.scale : arm_Context.brushScale) * arm_Context.brushNodesScale;
		case "_brushScaleX":
			return 1 / arm_Context.brushScaleX;
		case "_coneAperture":
			return arm_Context.vxaoAperture;
		case "_coneOffset":
			return arm_Context.vxaoOffset;
		case "_decalLayerDim":
			let _this = arm_Context.layer.decalMat;
			let x = Math.sqrt(_this.self._00 * _this.self._00 + _this.self._10 * _this.self._10 + _this.self._20 * _this.self._20);
			let y = Math.sqrt(_this.self._01 * _this.self._01 + _this.self._11 * _this.self._11 + _this.self._21 * _this.self._21);
			let z = Math.sqrt(_this.self._02 * _this.self._02 + _this.self._12 * _this.self._12 + _this.self._22 * _this.self._22);
			if(z == null) {
				z = 0.0;
			}
			if(y == null) {
				y = 0.0;
			}
			if(x == null) {
				x = 0.0;
			}
			return z * 0.5;
		case "_dilateRadius":
			if(arm_util_UVUtil.dilatemap != null) {
				return arm_Config.raw.dilate_radius;
			} else {
				return 0.0;
			}
			break;
		case "_objectId":
			return arm_Project.paintObjects.indexOf(object);
		case "_pickerHeight":
			return arm_Context.pickedColor.height;
		case "_pickerMetallic":
			return arm_Context.pickedColor.metallic;
		case "_pickerOcclusion":
			return arm_Context.pickedColor.occlusion;
		case "_pickerOpacity":
			return arm_Context.pickedColor.opacity;
		case "_pickerRoughness":
			return arm_Context.pickedColor.roughness;
		case "_vignetteStrength":
			return arm_Config.raw.rp_vignette;
		}
		if(arm_shader_MaterialParser.script_links != null) {
			let key_keys = Object.keys(arm_shader_MaterialParser.script_links.h);
			let key_length = key_keys.length;
			while(0 < key_length) {
				let script = arm_shader_MaterialParser.script_links.h[key_keys[0]];
				let result = 0.0;
				if(script != "") {
					try {
						result = eval(script);
					} catch( _g ) {
						arm_Console.log(haxe_Exception.caught(_g).unwrap());
					}
				}
				return result;
			}
		}
		return null;
	}
	static linkVec2(object,mat,link) {
		switch(link) {
		case "_brushAngle":
			let angle = arm_Context.layer.fill_layer != null ? arm_Context.layer.angle : arm_Context.brushAngle + arm_Context.brushNodesAngle;
			angle *= Math.PI / 180;
			let pen = iron_system_Input.getPen();
			if(arm_Config.raw.pressure_angle && pen.down()) {
				angle *= pen.pressure * arm_Config.raw.pressure_sensitivity;
			}
			let _this = arm_render_Uniforms.vec;
			let y = Math.sin(angle);
			_this.x = Math.cos(angle);
			_this.y = y;
			_this.z = 0;
			_this.w = 1.0;
			return arm_render_Uniforms.vec;
		case "_cloneDelta":
			let _this1 = arm_render_Uniforms.vec;
			_this1.x = arm_Context.cloneDeltaX;
			_this1.y = arm_Context.cloneDeltaY;
			_this1.z = 0;
			_this1.w = 1.0;
			return arm_render_Uniforms.vec;
		case "_gbufferSize":
			let _this2 = arm_render_Uniforms.vec;
			_this2.x = 0;
			_this2.y = 0;
			_this2.z = 0;
			_this2.w = 1.0;
			let gbuffer2 = iron_RenderPath.active.renderTargets.h["gbuffer2"];
			let _this3 = arm_render_Uniforms.vec;
			let x = gbuffer2.image.get_width();
			let y1 = gbuffer2.image.get_height();
			_this3.x = x;
			_this3.y = y1;
			_this3.z = 0;
			_this3.w = 1.0;
			return arm_render_Uniforms.vec;
		case "_texpaintSize":
			let _this4 = arm_render_Uniforms.vec;
			let y2 = arm_Config.getTextureResY();
			_this4.x = arm_Config.getTextureResX();
			_this4.y = y2;
			_this4.z = 0;
			_this4.w = 1.0;
			return arm_render_Uniforms.vec;
		}
		return null;
	}
	static linkVec3(object,mat,link) {
		let v = null;
		switch(link) {
		case "_brushDirection":
			v = iron_object_Uniforms.helpVec;
			let allowPaint = arm_Context.prevPaintVecX != arm_Context.lastPaintVecX && arm_Context.prevPaintVecY != arm_Context.lastPaintVecY && arm_Context.prevPaintVecX > 0 && arm_Context.prevPaintVecY > 0;
			let x = arm_Context.paintVec.x;
			let y = arm_Context.paintVec.y;
			let lastx = arm_Context.prevPaintVecX;
			let lasty = arm_Context.prevPaintVecY;
			if(arm_Context.paint2d) {
				x = arm_render_Uniforms.vec2d(x);
				lastx = arm_render_Uniforms.vec2d(lastx);
			}
			let angle = Math.atan2(-y + lasty,x - lastx) - Math.PI / 2;
			let y1 = Math.sin(angle);
			v.x = Math.cos(angle);
			v.y = y1;
			v.z = allowPaint ? 1 : 0;
			v.w = 1.0;
			arm_Context.prevPaintVecX = arm_Context.lastPaintVecX;
			arm_Context.prevPaintVecY = arm_Context.lastPaintVecY;
			return v;
		case "_decalLayerLoc":
			v = iron_object_Uniforms.helpVec;
			v.x = arm_Context.layer.decalMat.self._30;
			v.y = arm_Context.layer.decalMat.self._31;
			v.z = arm_Context.layer.decalMat.self._32;
			v.w = 1.0;
			return v;
		case "_decalLayerNor":
			v = iron_object_Uniforms.helpVec;
			v.x = arm_Context.layer.decalMat.self._20;
			v.y = arm_Context.layer.decalMat.self._21;
			v.z = arm_Context.layer.decalMat.self._22;
			v.w = 1.0;
			let _this = v;
			let n = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z);
			if(n > 0.0) {
				let invN = 1.0 / n;
				_this.x *= invN;
				_this.y *= invN;
				_this.z *= invN;
			}
			return v;
		case "_particleHit":
			v = iron_object_Uniforms.helpVec;
			v.x = arm_Context.particleHitX;
			v.y = arm_Context.particleHitY;
			v.z = arm_Context.particleHitZ;
			v.w = 1.0;
			return v;
		case "_pickerBase":
			v = iron_object_Uniforms.helpVec;
			v.x = ((arm_Context.pickedColor.base & 16711680) >>> 16) * 0.00392156862745098;
			v.y = ((arm_Context.pickedColor.base & 65280) >>> 8) * 0.00392156862745098;
			v.z = (arm_Context.pickedColor.base & 255) * 0.00392156862745098;
			v.w = 1.0;
			return v;
		case "_pickerNormal":
			v = iron_object_Uniforms.helpVec;
			v.x = ((arm_Context.pickedColor.normal & 16711680) >>> 16) * 0.00392156862745098;
			v.y = ((arm_Context.pickedColor.normal & 65280) >>> 8) * 0.00392156862745098;
			v.z = (arm_Context.pickedColor.normal & 255) * 0.00392156862745098;
			v.w = 1.0;
			return v;
		}
		return v;
	}
	static vec2d(x) {
		arm_Context.paint2dView = false;
		let res = (x * arm_App.w() - arm_App.w()) / arm_ui_UIView2D.inst.ww;
		arm_Context.paint2dView = true;
		return res;
	}
	static linkVec4(object,mat,link) {
		switch(link) {
		case "_decalMask":
			let decalMask = arm_Operator.shortcut(arm_Config.keymap.decal_mask + "+" + arm_Config.keymap.action_paint,2);
			let val = arm_Context.brushRadius * arm_Context.brushNodesRadius / 15.0;
			val *= 900 / arm_App.h() * arm_Config.raw.window_scale;
			let _this = arm_render_Uniforms.vec;
			let w = val;
			if(w == null) {
				w = 1.0;
			}
			_this.x = arm_Context.decalX;
			_this.y = arm_Context.decalY;
			_this.z = decalMask ? 1 : 0;
			_this.w = w;
			if(arm_Context.paint2d) {
				arm_render_Uniforms.vec.x = arm_render_Uniforms.vec2d(arm_render_Uniforms.vec.x);
			}
			return arm_render_Uniforms.vec;
		case "_envmapData":
			let _this1 = arm_render_Uniforms.vec;
			let y = Math.sin(-arm_Context.envmapAngle);
			let z = Math.cos(-arm_Context.envmapAngle);
			let w1 = iron_Scene.active.world.probe.raw.strength;
			if(w1 == null) {
				w1 = 1.0;
			}
			_this1.x = arm_Context.envmapAngle;
			_this1.y = y;
			_this1.z = z;
			_this1.w = w1;
			return arm_render_Uniforms.vec;
		case "_envmapDataWorld":
			let _this2 = arm_render_Uniforms.vec;
			let y1 = Math.sin(-arm_Context.envmapAngle);
			let z1 = Math.cos(-arm_Context.envmapAngle);
			let w2 = arm_Context.showEnvmap ? iron_Scene.active.world.probe.raw.strength : 4.0;
			if(w2 == null) {
				w2 = 1.0;
			}
			_this2.x = arm_Context.envmapAngle;
			_this2.y = y1;
			_this2.z = z1;
			_this2.w = w2;
			return arm_render_Uniforms.vec;
		case "_inputBrush":
			let down = iron_system_Input.getMouse().down() || iron_system_Input.getPen().down();
			let _this3 = arm_render_Uniforms.vec;
			_this3.x = arm_Context.paintVec.x;
			_this3.y = arm_Context.paintVec.y;
			_this3.z = down ? 1.0 : 0.0;
			_this3.w = 0.0;
			if(arm_Context.paint2d) {
				arm_render_Uniforms.vec.x = arm_render_Uniforms.vec2d(arm_render_Uniforms.vec.x);
			}
			return arm_render_Uniforms.vec;
		case "_inputBrushLast":
			let down1 = iron_system_Input.getMouse().down() || iron_system_Input.getPen().down();
			let _this4 = arm_render_Uniforms.vec;
			_this4.x = arm_Context.lastPaintVecX;
			_this4.y = arm_Context.lastPaintVecY;
			_this4.z = down1 ? 1.0 : 0.0;
			_this4.w = 0.0;
			if(arm_Context.paint2d) {
				arm_render_Uniforms.vec.x = arm_render_Uniforms.vec2d(arm_render_Uniforms.vec.x);
			}
			return arm_render_Uniforms.vec;
		case "_stencilTransform":
			let _this5 = arm_render_Uniforms.vec;
			let w3 = arm_Context.brushStencilAngle;
			if(w3 == null) {
				w3 = 1.0;
			}
			_this5.x = arm_Context.brushStencilX;
			_this5.y = arm_Context.brushStencilY;
			_this5.z = arm_Context.brushStencilScale;
			_this5.w = w3;
			if(arm_Context.paint2d) {
				arm_render_Uniforms.vec.x = arm_render_Uniforms.vec2d(arm_render_Uniforms.vec.x);
			}
			return arm_render_Uniforms.vec;
		}
		return null;
	}
	static linkMat4(object,mat,link) {
		if(link == "_decalLayerMatrix") {
			let m = iron_object_Uniforms.helpMat;
			let m1 = arm_Context.layer.decalMat;
			m.self._00 = m1.self._00;
			m.self._01 = m1.self._01;
			m.self._02 = m1.self._02;
			m.self._03 = m1.self._03;
			m.self._10 = m1.self._10;
			m.self._11 = m1.self._11;
			m.self._12 = m1.self._12;
			m.self._13 = m1.self._13;
			m.self._20 = m1.self._20;
			m.self._21 = m1.self._21;
			m.self._22 = m1.self._22;
			m.self._23 = m1.self._23;
			m.self._30 = m1.self._30;
			m.self._31 = m1.self._31;
			m.self._32 = m1.self._32;
			m.self._33 = m1.self._33;
			let a00 = m.self._00;
			let a01 = m.self._01;
			let a02 = m.self._02;
			let a03 = m.self._03;
			let a10 = m.self._10;
			let a11 = m.self._11;
			let a12 = m.self._12;
			let a13 = m.self._13;
			let a20 = m.self._20;
			let a21 = m.self._21;
			let a22 = m.self._22;
			let a23 = m.self._23;
			let a30 = m.self._30;
			let a31 = m.self._31;
			let a32 = m.self._32;
			let a33 = m.self._33;
			let b00 = a00 * a11 - a01 * a10;
			let b01 = a00 * a12 - a02 * a10;
			let b02 = a00 * a13 - a03 * a10;
			let b03 = a01 * a12 - a02 * a11;
			let b04 = a01 * a13 - a03 * a11;
			let b05 = a02 * a13 - a03 * a12;
			let b06 = a20 * a31 - a21 * a30;
			let b07 = a20 * a32 - a22 * a30;
			let b08 = a20 * a33 - a23 * a30;
			let b09 = a21 * a32 - a22 * a31;
			let b10 = a21 * a33 - a23 * a31;
			let b11 = a22 * a33 - a23 * a32;
			let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
			if(det == 0.0) {
				m.self._00 = 1.0;
				m.self._01 = 0.0;
				m.self._02 = 0.0;
				m.self._03 = 0.0;
				m.self._10 = 0.0;
				m.self._11 = 1.0;
				m.self._12 = 0.0;
				m.self._13 = 0.0;
				m.self._20 = 0.0;
				m.self._21 = 0.0;
				m.self._22 = 1.0;
				m.self._23 = 0.0;
				m.self._30 = 0.0;
				m.self._31 = 0.0;
				m.self._32 = 0.0;
				m.self._33 = 1.0;
			} else {
				det = 1.0 / det;
				m.self._00 = (a11 * b11 - a12 * b10 + a13 * b09) * det;
				m.self._01 = (a02 * b10 - a01 * b11 - a03 * b09) * det;
				m.self._02 = (a31 * b05 - a32 * b04 + a33 * b03) * det;
				m.self._03 = (a22 * b04 - a21 * b05 - a23 * b03) * det;
				m.self._10 = (a12 * b08 - a10 * b11 - a13 * b07) * det;
				m.self._11 = (a00 * b11 - a02 * b08 + a03 * b07) * det;
				m.self._12 = (a32 * b02 - a30 * b05 - a33 * b01) * det;
				m.self._13 = (a20 * b05 - a22 * b02 + a23 * b01) * det;
				m.self._20 = (a10 * b10 - a11 * b08 + a13 * b06) * det;
				m.self._21 = (a01 * b08 - a00 * b10 - a03 * b06) * det;
				m.self._22 = (a30 * b04 - a31 * b02 + a33 * b00) * det;
				m.self._23 = (a21 * b02 - a20 * b04 - a23 * b00) * det;
				m.self._30 = (a11 * b07 - a10 * b09 - a12 * b06) * det;
				m.self._31 = (a00 * b09 - a01 * b07 + a02 * b06) * det;
				m.self._32 = (a31 * b01 - a30 * b03 - a32 * b00) * det;
				m.self._33 = (a20 * b03 - a21 * b01 + a22 * b00) * det;
			}
			let m2 = arm_render_Uniforms.orthoP;
			let a001 = m.self._00;
			let a011 = m.self._01;
			let a021 = m.self._02;
			let a031 = m.self._03;
			let a101 = m.self._10;
			let a111 = m.self._11;
			let a121 = m.self._12;
			let a131 = m.self._13;
			let a201 = m.self._20;
			let a211 = m.self._21;
			let a221 = m.self._22;
			let a231 = m.self._23;
			let a301 = m.self._30;
			let a311 = m.self._31;
			let a321 = m.self._32;
			let a331 = m.self._33;
			let b0 = m2.self._00;
			let b1 = m2.self._10;
			let b2 = m2.self._20;
			let b3 = m2.self._30;
			m.self._00 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
			m.self._10 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
			m.self._20 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
			m.self._30 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
			b0 = m2.self._01;
			b1 = m2.self._11;
			b2 = m2.self._21;
			b3 = m2.self._31;
			m.self._01 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
			m.self._11 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
			m.self._21 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
			m.self._31 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
			b0 = m2.self._02;
			b1 = m2.self._12;
			b2 = m2.self._22;
			b3 = m2.self._32;
			m.self._02 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
			m.self._12 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
			m.self._22 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
			m.self._32 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
			b0 = m2.self._03;
			b1 = m2.self._13;
			b2 = m2.self._23;
			b3 = m2.self._33;
			m.self._03 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
			m.self._13 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
			m.self._23 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
			m.self._33 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
			return m;
		}
		return null;
	}
	static linkTex(object,mat,link) {
		switch(link) {
		case "_ltcMag":
			if(arm_data_ConstData.ltcMagTex == null) {
				arm_data_ConstData.initLTC();
			}
			return arm_data_ConstData.ltcMagTex;
		case "_ltcMat":
			if(arm_data_ConstData.ltcMatTex == null) {
				arm_data_ConstData.initLTC();
			}
			return arm_data_ConstData.ltcMatTex;
		case "_texbrushmask":
			return arm_Context.brushMaskImage;
		case "_texbrushstencil":
			return arm_Context.brushStencilImage;
		case "_texcolorid":
			if(arm_Project.assets.length == 0) {
				return iron_RenderPath.active.renderTargets.h["empty_white"].image;
			} else {
				return arm_Project.getImage(arm_Project.assets[arm_Context.colorIdHandle.position]);
			}
			break;
		case "_texdilatemap":
			return arm_util_UVUtil.dilatemap;
		case "_texpaint_nor_undo":
			return iron_RenderPath.active.renderTargets.h["texpaint_nor_undo" + (arm_History.undoI - 1 < 0 ? arm_Config.raw.undo_steps - 1 : arm_History.undoI - 1)].image;
		case "_texpaint_pack_undo":
			return iron_RenderPath.active.renderTargets.h["texpaint_pack_undo" + (arm_History.undoI - 1 < 0 ? arm_Config.raw.undo_steps - 1 : arm_History.undoI - 1)].image;
		case "_texpaint_undo":
			return iron_RenderPath.active.renderTargets.h["texpaint_undo" + (arm_History.undoI - 1 < 0 ? arm_Config.raw.undo_steps - 1 : arm_History.undoI - 1)].image;
		case "_texparticle":
			return iron_RenderPath.active.renderTargets.h["texparticle"].image;
		case "_textexttool":
			return arm_Context.textToolImage;
		case "_textrianglemap":
			if(!arm_util_UVUtil.trianglemapCached) {
				iron_App.notifyOnInit(function() {
					arm_util_UVUtil.cacheTriangleMap();
				});
			}
			return arm_util_UVUtil.trianglemap;
		case "_texuvislandmap":
			iron_App.notifyOnInit(function() {
				arm_util_UVUtil.cacheUVIslandMap();
			});
			if(arm_util_UVUtil.uvislandmapCached) {
				return arm_util_UVUtil.uvislandmap;
			} else {
				return iron_RenderPath.active.renderTargets.h["empty_black"].image;
			}
			break;
		case "_texuvmap":
			if(!arm_util_UVUtil.uvmapCached) {
				iron_App.notifyOnInit(function() {
					arm_util_UVUtil.cacheUVMap();
				});
			}
			return arm_util_UVUtil.uvmap;
		}
		if(link.startsWith("_texpaint_pack_vert")) {
			return iron_RenderPath.active.renderTargets.h["texpaint_pack" + HxOverrides.substr(link,link.length - 1,null)].image;
		}
		if(link.startsWith("_texpaint_vert")) {
			let tid = Std.parseInt(HxOverrides.substr(link,link.length - 1,null));
			if(tid < arm_Project.layers.length) {
				return arm_Project.layers[tid].texpaint;
			} else {
				return null;
			}
		}
		if(link.startsWith("_texpaint_nor")) {
			let tid = Std.parseInt(HxOverrides.substr(link,link.length - 1,null));
			if(tid < arm_Project.layers.length) {
				return arm_Project.layers[tid].texpaint_nor;
			} else {
				return null;
			}
		}
		if(link.startsWith("_texpaint_pack")) {
			let tid = Std.parseInt(HxOverrides.substr(link,link.length - 1,null));
			if(tid < arm_Project.layers.length) {
				return arm_Project.layers[tid].texpaint_pack;
			} else {
				return null;
			}
		}
		if(link.startsWith("_texpaint")) {
			let tid = Std.parseInt(HxOverrides.substr(link,link.length - 1,null));
			if(tid < arm_Project.layers.length) {
				return arm_Project.layers[tid].texpaint;
			} else {
				return null;
			}
		}
		if(link.startsWith("_texblur_")) {
			if(arm_Context.nodePreviews != null) {
				return arm_Context.nodePreviews.h[HxOverrides.substr(link,9,null)];
			} else {
				return iron_RenderPath.active.renderTargets.h["empty_black"].image;
			}
		}
		if(link.startsWith("_texwarp_")) {
			if(arm_Context.nodePreviews != null) {
				return arm_Context.nodePreviews.h[HxOverrides.substr(link,9,null)];
			} else {
				return iron_RenderPath.active.renderTargets.h["empty_black"].image;
			}
		}
		if(link.startsWith("_texbake_")) {
			if(arm_Context.nodePreviews != null) {
				return arm_Context.nodePreviews.h[HxOverrides.substr(link,9,null)];
			} else {
				return iron_RenderPath.active.renderTargets.h["empty_black"].image;
			}
		}
		return null;
	}
}
$hxClasses["arm.render.Uniforms"] = arm_render_Uniforms;
arm_render_Uniforms.__name__ = "arm.render.Uniforms";
class arm_shader_NodeShader {
	constructor(context,shader_type) {
		this.dotNV = false;
		this.nAttr = false;
		this.n = false;
		this.vVecCam = false;
		this.vVec = false;
		this.wtangent = false;
		this.ndcpos = false;
		this.wvpposition = false;
		this.vposition = false;
		this.mposition = false;
		this.wposition = false;
		this.bposition = false;
		this.lock = false;
		this.vstruct_as_vsin = true;
		this.write_textures = 0;
		this.write_normal = 0;
		this.write_pre = false;
		this.header = "";
		this.main_attribs = "";
		this.main_textures = "";
		this.main_normal = "";
		this.main_end = "";
		this.main_init = "";
		this.main = "";
		this.functions = new haxe_ds_StringMap();
		this.uniforms = [];
		this.sharedSamplers = [];
		this.outs = [];
		this.ins = [];
		this.includes = [];
		this.shader_type = "";
		this.context = context;
		this.shader_type = shader_type;
	}
	add_in(s) {
		this.ins.push(s);
	}
	add_out(s) {
		this.outs.push(s);
	}
	add_uniform(s,link,included) {
		if(included == null) {
			included = false;
		}
		let ar = s.split(" ");
		let utype = ar[ar.length - 2];
		let uname = ar[ar.length - 1];
		if(utype.startsWith("sampler") || utype.startsWith("image") || utype.startsWith("uimage")) {
			let is_image = utype.startsWith("image") || utype.startsWith("uimage");
			this.context.add_texture_unit(utype,uname,link,is_image);
		} else {
			if(ar[0] == "float" && ar[1].indexOf("[") >= 0) {
				ar[0] = "floats";
				ar[1] = ar[1].split("[")[0];
			} else if(ar[0] == "vec4" && ar[1].indexOf("[") >= 0) {
				ar[0] = "floats";
				ar[1] = ar[1].split("[")[0];
			}
			this.context.add_constant(ar[0],ar[1],link);
		}
		if(included == false && this.uniforms.indexOf(s) == -1) {
			this.uniforms.push(s);
		}
	}
	add_shared_sampler(s) {
		if(this.sharedSamplers.indexOf(s) == -1) {
			this.sharedSamplers.push(s);
			let ar = s.split(" ");
			this.context.add_texture_unit(ar[ar.length - 2],ar[ar.length - 1],null,false);
		}
	}
	add_function(s) {
		let fname = s.split("(")[0];
		if(Object.prototype.hasOwnProperty.call(this.functions.h,fname)) {
			return;
		}
		this.functions.h[fname] = s;
	}
	write(s) {
		if(this.lock) {
			return;
		}
		if(this.write_textures > 0) {
			this.main_textures += s + "\n";
		} else if(this.write_normal > 0) {
			this.main_normal += s + "\n";
		} else if(this.write_pre) {
			this.main_init += s + "\n";
		} else {
			this.main += s + "\n";
		}
	}
	write_end(s) {
		this.main_end += s + "\n";
	}
	write_attrib(s) {
		this.main_attribs += s + "\n";
	}
	dataSize(data) {
		if(data == "float1") {
			return "1";
		} else if(data == "float2") {
			return "2";
		} else if(data == "float3") {
			return "3";
		} else if(data == "float4") {
			return "4";
		} else if(data == "short2norm") {
			return "2";
		} else if(data == "short4norm") {
			return "4";
		} else {
			return "1";
		}
	}
	vstruct_to_vsin() {
		let vs = this.context.data.vertex_elements;
		let _g = 0;
		while(_g < vs.length) {
			let e = vs[_g];
			++_g;
			this.add_in("vec" + this.dataSize(e.data) + " " + e.name);
		}
	}
	get() {
		if(this.shader_type == "vert" && this.vstruct_as_vsin) {
			this.vstruct_to_vsin();
		}
		let sharedSampler = "shared_sampler";
		if(this.sharedSamplers.length > 0) {
			sharedSampler = this.sharedSamplers[0].split(" ")[1] + "_sampler";
		}
		let s = "#define HLSL\n";
		s = "#define HLSL\n" + "#define textureArg(tex) Texture2D tex,SamplerState tex ## _sampler\n";
		s += "#define texturePass(tex) tex,tex ## _sampler\n";
		s += "#define sampler2D Texture2D\n";
		s += "#define sampler3D Texture3D\n";
		s += "#define texture(tex, coord) tex.Sample(tex ## _sampler, coord)\n";
		s += "#define textureShared(tex, coord) tex.Sample(" + sharedSampler + ", coord)\n";
		s += "#define textureLod(tex, coord, lod) tex.SampleLevel(tex ## _sampler, coord, lod)\n";
		s += "#define textureLodShared(tex, coord, lod) tex.SampleLevel(" + sharedSampler + ", coord, lod)\n";
		s += "#define texelFetch(tex, coord, lod) tex.Load(float3(coord.xy, lod))\n";
		s += "uint2 _GetDimensions(Texture2D tex, uint lod) { uint x, y; tex.GetDimensions(x, y); return uint2(x, y); }\n";
		s += "#define textureSize _GetDimensions\n";
		s += "#define mod(a, b) (a % b)\n";
		s += "#define vec2 float2\n";
		s += "#define vec3 float3\n";
		s += "#define vec4 float4\n";
		s += "#define ivec2 int2\n";
		s += "#define ivec3 int3\n";
		s += "#define ivec4 int4\n";
		s += "#define mat2 float2x2\n";
		s += "#define mat3 float3x3\n";
		s += "#define mat4 float4x4\n";
		s += "#define dFdx ddx\n";
		s += "#define dFdy ddy\n";
		s += "#define inversesqrt rsqrt\n";
		s += "#define fract frac\n";
		s += "#define mix lerp\n";
		s += this.header;
		let _g = 0;
		let _g1 = this.includes;
		while(_g < _g1.length) s += "#include \"" + _g1[_g++] + "\"\n";
		let index = 0;
		if(this.ins.length > 0) {
			s += "struct SPIRV_Cross_Input {\n";
			index = 0;
			this.ins.sort(function(a,b) {
				if(a.substring(4) >= b.substring(4)) {
					return 1;
				} else {
					return -1;
				}
			});
			let _g = 0;
			let _g1 = this.ins;
			while(_g < _g1.length) {
				s += "" + _g1[_g++] + "" + " : TEXCOORD" + index + ";\n";
				++index;
			}
			if(this.shader_type == "vert" && this.main.indexOf("gl_VertexID") >= 0) {
				s += "uint gl_VertexID : SV_VertexID;\n";
				this.ins.push("uint gl_VertexID");
			}
			if(this.shader_type == "vert" && this.main.indexOf("gl_InstanceID") >= 0) {
				s += "uint gl_InstanceID : SV_InstanceID;\n";
				this.ins.push("uint gl_InstanceID");
			}
			s += "};\n";
		}
		let num = 0;
		if(this.outs.length > 0 || this.shader_type == "vert") {
			s += "struct SPIRV_Cross_Output {\n";
			this.outs.sort(function(a,b) {
				if(a.substring(4) >= b.substring(4)) {
					return 1;
				} else {
					return -1;
				}
			});
			index = 0;
			if(this.shader_type == "vert") {
				let _g = 0;
				let _g1 = this.outs;
				while(_g < _g1.length) {
					s += "" + _g1[_g++] + "" + " : TEXCOORD" + index + ";\n";
					++index;
				}
				s += "float4 svpos : SV_POSITION;\n";
			} else {
				let out = this.outs[0];
				if(out.charAt(out.length - 1) == "]") {
					num = Std.parseInt(out.charAt(out.length - 2));
					s += "vec4 fragColor[" + num + "] : SV_TARGET0;\n";
				} else {
					s += "vec4 fragColor : SV_TARGET0;\n";
				}
			}
			s += "};\n";
		}
		let _g2 = 0;
		let _g3 = this.uniforms;
		while(_g2 < _g3.length) {
			let a = _g3[_g2];
			++_g2;
			s += "uniform " + a + ";\n";
			if(a.startsWith("sampler")) {
				s += "SamplerState " + a.split(" ")[1] + "_sampler;\n";
			}
		}
		if(this.sharedSamplers.length > 0) {
			let _g = 0;
			let _g1 = this.sharedSamplers;
			while(_g < _g1.length) s += "uniform " + _g1[_g++] + ";\n";
			s += "SamplerState " + sharedSampler + ";\n";
		}
		let h = this.functions.h;
		let f_keys = Object.keys(h);
		let f_length = f_keys.length;
		let f_current = 0;
		while(f_current < f_length) s += h[f_keys[f_current++]] + "\n";
		if(this.outs.length > 0 || this.shader_type == "vert") {
			if(this.ins.length > 0) {
				s += "SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) {\n";
			} else {
				s += "SPIRV_Cross_Output main() {\n";
			}
		} else if(this.ins.length > 0) {
			s += "void main(SPIRV_Cross_Input stage_input) {\n";
		} else {
			s += "void main() {\n";
		}
		let _g4 = 0;
		let _g5 = this.ins;
		while(_g4 < _g5.length) {
			let a = _g5[_g4];
			++_g4;
			s += "" + a + " = stage_input." + a.substring(5) + ";\n";
		}
		if(this.shader_type == "vert") {
			s += "vec4 gl_Position;\n";
			let _g = 0;
			let _g1 = this.outs;
			while(_g < _g1.length) s += "" + _g1[_g++] + ";\n";
		} else if(this.outs.length > 0) {
			if(num > 0) {
				s += "vec4 fragColor[" + num + "];\n";
			} else {
				s += "vec4 fragColor;\n";
			}
		}
		s += this.main_attribs;
		s += this.main_textures;
		s += this.main_normal;
		s += this.main_init;
		s += this.main;
		s += this.main_end;
		if(this.outs.length > 0 || this.shader_type == "vert") {
			s += "SPIRV_Cross_Output stage_output;\n";
			if(this.shader_type == "vert") {
				s += "gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n";
				s += "stage_output.svpos = gl_Position;\n";
				let _g = 0;
				let _g1 = this.outs;
				while(_g < _g1.length) {
					let b = _g1[_g++].substring(5);
					s += "stage_output." + b + " = " + b + ";\n";
				}
			} else if(num > 0) {
				let _g = 0;
				let _g1 = num;
				while(_g < _g1) {
					let i = _g++;
					s += "stage_output.fragColor[" + i + "] = fragColor[" + i + "];\n";
				}
			} else {
				s += "stage_output.fragColor = fragColor;\n";
			}
			s += "return stage_output;\n";
		}
		s += "}\n";
		return s;
	}
}
$hxClasses["arm.shader.NodeShader"] = arm_shader_NodeShader;
arm_shader_NodeShader.__name__ = "arm.shader.NodeShader";
Object.assign(arm_shader_NodeShader.prototype, {
	__class__: arm_shader_NodeShader
});
class arm_shader_NodeShaderContext {
	constructor(material,props) {
		this.allow_vcols = false;
		this.material = material;
		this.data = { name : props.name, depth_write : props.depth_write, compare_mode : props.compare_mode, cull_mode : props.cull_mode, blend_source : props.blend_source, blend_destination : props.blend_destination, blend_operation : props.blend_operation, alpha_blend_source : props.alpha_blend_source, alpha_blend_destination : props.alpha_blend_destination, alpha_blend_operation : props.alpha_blend_operation, fragment_shader : "", vertex_shader : "", vertex_elements : Object.prototype.hasOwnProperty.call(props,"vertex_elements") ? props.vertex_elements : [{ name : "pos", data : "short4norm"},{ name : "nor", data : "short2norm"}], color_attachments : props.color_attachments, depth_attachment : props.depth_attachment};
		if(props.color_writes_red != null) {
			this.data.color_writes_red = props.color_writes_red;
		}
		if(props.color_writes_green != null) {
			this.data.color_writes_green = props.color_writes_green;
		}
		if(props.color_writes_blue != null) {
			this.data.color_writes_blue = props.color_writes_blue;
		}
		if(props.color_writes_alpha != null) {
			this.data.color_writes_alpha = props.color_writes_alpha;
		}
		this.tunits = this.data.texture_units = [];
		this.constants = this.data.constants = [];
	}
	add_elem(name,data_type) {
		let _g = 0;
		let _g1 = this.data.vertex_elements;
		while(_g < _g1.length) if(_g1[_g++].name == name) {
			return;
		}
		this.data.vertex_elements.push({ name : name, data : data_type});
	}
	is_elem(name) {
		let _g = 0;
		let _g1 = this.data.vertex_elements;
		while(_g < _g1.length) if(_g1[_g++].name == name) {
			return true;
		}
		return false;
	}
	add_constant(ctype,name,link) {
		let _g = 0;
		let _g1 = this.constants;
		while(_g < _g1.length) if(_g1[_g++].name == name) {
			return;
		}
		let c = { name : name, type : ctype};
		if(link != null) {
			c.link = link;
		}
		this.constants.push(c);
	}
	add_texture_unit(ctype,name,link,is_image) {
		if(is_image == null) {
			is_image = false;
		}
		let _g = 0;
		let _g1 = this.tunits;
		while(_g < _g1.length) if(_g1[_g++].name == name) {
			return;
		}
		let c = { name : name};
		if(link != null) {
			c.link = link;
		}
		if(is_image) {
			c.is_image = is_image;
		}
		this.tunits.push(c);
	}
	make_vert() {
		this.data.vertex_shader = this.material.name + "_" + this.data.name + ".vert";
		this.vert = new arm_shader_NodeShader(this,"vert");
		return this.vert;
	}
	make_frag() {
		this.data.fragment_shader = this.material.name + "_" + this.data.name + ".frag";
		this.frag = new arm_shader_NodeShader(this,"frag");
		return this.frag;
	}
}
$hxClasses["arm.shader.NodeShaderContext"] = arm_shader_NodeShaderContext;
arm_shader_NodeShaderContext.__name__ = "arm.shader.NodeShaderContext";
Object.assign(arm_shader_NodeShaderContext.prototype, {
	__class__: arm_shader_NodeShaderContext
});
class arm_shader_NodeShaderData {
	constructor(material) {
		this.material = material;
	}
	add_context(props) {
		return new arm_shader_NodeShaderContext(this.material,props);
	}
}
$hxClasses["arm.shader.NodeShaderData"] = arm_shader_NodeShaderData;
arm_shader_NodeShaderData.__name__ = "arm.shader.NodeShaderData";
Object.assign(arm_shader_NodeShaderData.prototype, {
	__class__: arm_shader_NodeShaderData
});
class arm_shader_ShaderFunctions {
}
$hxClasses["arm.shader.ShaderFunctions"] = arm_shader_ShaderFunctions;
arm_shader_ShaderFunctions.__name__ = "arm.shader.ShaderFunctions";
class arm_ui_BoxExport {
	static showTextures() {
		arm_ui_UIBox.showCustom(function(ui) {
			if(arm_ui_BoxExport.files == null) {
				arm_ui_BoxExport.fetchPresets();
				arm_ui_BoxExport.hpreset.position = arm_ui_BoxExport.files.indexOf("generic");
			}
			if(arm_ui_BoxExport.preset == null) {
				arm_ui_BoxExport.parsePreset();
				arm_ui_BoxExport.hpreset.children = null;
			}
			arm_ui_BoxExport.tabExportTextures(ui,arm_Translator.tr("Export Textures"));
			arm_ui_BoxExport.tabPresets(ui);
			arm_ui_BoxExport.tabAtlases(ui);
		},540,310);
	}
	static showBakeMaterial() {
		arm_ui_UIBox.showCustom(function(ui) {
			if(arm_ui_BoxExport.files == null) {
				arm_ui_BoxExport.fetchPresets();
				arm_ui_BoxExport.hpreset.position = arm_ui_BoxExport.files.indexOf("generic");
			}
			if(arm_ui_BoxExport.preset == null) {
				arm_ui_BoxExport.parsePreset();
				arm_ui_BoxExport.hpreset.children = null;
			}
			arm_ui_BoxExport.tabExportTextures(ui,arm_Translator.tr("Bake to Textures"),true);
			arm_ui_BoxExport.tabPresets(ui);
		},540,310);
	}
	static tabExportTextures(ui,title,bakeMaterial) {
		if(bakeMaterial == null) {
			bakeMaterial = false;
		}
		if(ui.tab(arm_ui_BoxExport.htab,title)) {
			ui.row([0.5,0.5]);
			ui.combo(arm_App.resHandle,["128","256","512","1K","2K","4K","8K","16K"],arm_Translator.tr("Resolution"),true);
			if(arm_App.resHandle.changed) {
				iron_App.notifyOnInit(arm_Layers.resizeLayers);
				arm_util_UVUtil.uvmap = null;
				arm_util_UVUtil.uvmapCached = false;
				arm_util_UVUtil.trianglemap = null;
				arm_util_UVUtil.trianglemapCached = false;
				arm_util_UVUtil.dilatemapCached = false;
			}
			ui.combo(arm_App.bitsHandle,["8bit","16bit","32bit"],arm_Translator.tr("Color"),true);
			if(arm_App.bitsHandle.changed) {
				iron_App.notifyOnInit(arm_Layers.setLayerBits);
			}
			ui.row([0.5,0.5]);
			if(arm_App.bitsHandle.position == 0) {
				arm_Context.formatType = ui.combo(zui_Handle.global.nest(11,{ position : arm_Context.formatType}),["png","jpg"],arm_Translator.tr("Format"),true);
			} else {
				arm_Context.formatType = ui.combo(zui_Handle.global.nest(12,{ position : arm_Context.formatType}),["exr"],arm_Translator.tr("Format"),true);
			}
			ui.enabled = arm_Context.formatType == 1 && arm_App.bitsHandle.position == 0;
			arm_Context.formatQuality = ui.slider(zui_Handle.global.nest(13,{ value : arm_Context.formatQuality}),arm_Translator.tr("Quality"),0.0,100.0,true,1);
			ui.enabled = true;
			ui.row([0.5,0.5]);
			ui.enabled = !bakeMaterial;
			let layersExportHandle = zui_Handle.global.nest(14,null);
			layersExportHandle.position = arm_Context.layersExport;
			arm_Context.layersExport = ui.combo(layersExportHandle,[arm_Translator.tr("Visible"),arm_Translator.tr("Selected"),arm_Translator.tr("Per Object"),arm_Translator.tr("Per Udim Tile")],arm_Translator.tr("Layers"),true);
			ui.enabled = true;
			ui.combo(arm_ui_BoxExport.hpreset,arm_ui_BoxExport.files,arm_Translator.tr("Preset"),true);
			if(arm_ui_BoxExport.hpreset.changed) {
				arm_ui_BoxExport.preset = null;
			}
			let layersDestinationHandle = zui_Handle.global.nest(15,null);
			layersDestinationHandle.position = arm_Context.layersDestination;
			arm_Context.layersDestination = ui.combo(layersDestinationHandle,[arm_Translator.tr("Disk"),arm_Translator.tr("Packed")],arm_Translator.tr("Destination"),true);
			ui.endElement();
			ui.row([0.5,0.5]);
			if(ui.button(arm_Translator.tr("Cancel"))) {
				arm_ui_UIBox.show = false;
			}
			if(ui.button(arm_Translator.tr("Export"))) {
				arm_ui_UIBox.show = false;
				if(arm_Context.layersDestination == 1) {
					arm_Context.textureExportPath = "/";
					iron_App.notifyOnInit(function() {
						arm_io_ExportTexture.run(arm_Context.textureExportPath,bakeMaterial);
					});
				} else {
					arm_ui_UIFiles.show(arm_App.bitsHandle.position != 0 ? "exr" : arm_Context.formatType == 0 ? "png" : "jpg",true,false,function(path) {
						arm_Context.textureExportPath = path;
						(function() {
							iron_App.notifyOnInit(function() {
								arm_io_ExportTexture.run(arm_Context.textureExportPath,bakeMaterial);
							});
						})();
					});
				}
			}
			if(ui.isHovered) {
				ui.tooltip(arm_Translator.tr("Export texture files") + (" (" + arm_Config.keymap.file_export_textures + ")"));
			}
		}
	}
	static tabPresets(ui) {
		if(ui.tab(arm_ui_BoxExport.htab,arm_Translator.tr("Presets"))) {
			ui.row([0.6,0.2,0.2]);
			ui.combo(arm_ui_BoxExport.hpreset,arm_ui_BoxExport.files,arm_Translator.tr("Preset"));
			if(arm_ui_BoxExport.hpreset.changed) {
				arm_ui_BoxExport.preset = null;
			}
			if(ui.button(arm_Translator.tr("New"))) {
				arm_ui_UIBox.showCustom(function(ui) {
					if(ui.tab(zui_Handle.global.nest(16,null),arm_Translator.tr("New Preset"))) {
						ui.row([0.5,0.5]);
						let presetName = ui.textInput(zui_Handle.global.nest(17,{ text : "new_preset"}),arm_Translator.tr("Name"));
						if(ui.button(arm_Translator.tr("OK")) || ui.isReturnDown) {
							arm_ui_BoxExport.newPreset(presetName);
							arm_ui_BoxExport.fetchPresets();
							arm_ui_BoxExport.preset = null;
							arm_ui_BoxExport.hpreset.position = arm_ui_BoxExport.files.indexOf(presetName);
							arm_ui_UIBox.show = false;
							arm_ui_BoxExport.htab.position = 1;
							arm_ui_BoxExport.showTextures();
						}
					}
				});
			}
			if(ui.button(arm_Translator.tr("Import"))) {
				arm_ui_UIFiles.show("json",false,false,function(path) {
					path = path.toLowerCase();
					if(path.endsWith(".json")) {
						let filename = HxOverrides.substr(path,path.lastIndexOf(arm_sys_Path.sep) + 1,null);
						arm_sys_File.copy(path,arm_sys_Path.data() + arm_sys_Path.sep + "export_presets" + arm_sys_Path.sep + filename);
						arm_ui_BoxExport.fetchPresets();
						arm_ui_BoxExport.preset = null;
						arm_ui_BoxExport.hpreset.position = arm_ui_BoxExport.files.indexOf(HxOverrides.substr(filename,0,filename.length - 5));
						arm_Console.info(arm_Translator.tr("Preset imported:") + " " + filename);
					} else {
						arm_Console.error(arm_Strings.error1());
					}
				});
			}
			if(arm_ui_BoxExport.preset == null) {
				arm_ui_BoxExport.parsePreset();
				arm_ui_BoxExport.hpreset.children = null;
			}
			ui.separator(10,false);
			ui.row([0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666]);
			ui.text(arm_Translator.tr("Texture"));
			ui.text(arm_Translator.tr("R"));
			ui.text(arm_Translator.tr("G"));
			ui.text(arm_Translator.tr("B"));
			ui.text(arm_Translator.tr("A"));
			ui.text(arm_Translator.tr("Color Space"));
			ui.changed = false;
			let _g = 0;
			let _g1 = arm_ui_BoxExport.preset.textures.length;
			while(_g < _g1) {
				let i = _g++;
				let t = arm_ui_BoxExport.preset.textures[i];
				ui.row([0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666]);
				let htex = arm_ui_BoxExport.hpreset.nest(i);
				htex.text = t.name;
				t.name = ui.textInput(htex);
				if(ui.isHovered && ui.inputReleasedR) {
					arm_ui_UIMenu.draw(function(ui) {
						ui.text(t.name,2,ui.t.HIGHLIGHT_COL);
						if(ui.button(arm_Translator.tr("Delete"),0)) {
							HxOverrides.remove(arm_ui_BoxExport.preset.textures,t);
							arm_ui_BoxExport.savePreset();
						}
					},2);
				}
				let hr = htex.nest(0);
				hr.position = arm_ui_BoxExport.channels.indexOf(t.channels[0]);
				let hg = htex.nest(1);
				hg.position = arm_ui_BoxExport.channels.indexOf(t.channels[1]);
				let hb = htex.nest(2);
				hb.position = arm_ui_BoxExport.channels.indexOf(t.channels[2]);
				let ha = htex.nest(3);
				ha.position = arm_ui_BoxExport.channels.indexOf(t.channels[3]);
				ui.combo(hr,arm_ui_BoxExport.channels,arm_Translator.tr("R"));
				if(hr.changed) {
					t.channels[0] = arm_ui_BoxExport.channels[hr.position];
				}
				ui.combo(hg,arm_ui_BoxExport.channels,arm_Translator.tr("G"));
				if(hg.changed) {
					t.channels[1] = arm_ui_BoxExport.channels[hg.position];
				}
				ui.combo(hb,arm_ui_BoxExport.channels,arm_Translator.tr("B"));
				if(hb.changed) {
					t.channels[2] = arm_ui_BoxExport.channels[hb.position];
				}
				ui.combo(ha,arm_ui_BoxExport.channels,arm_Translator.tr("A"));
				if(ha.changed) {
					t.channels[3] = arm_ui_BoxExport.channels[ha.position];
				}
				let hspace = htex.nest(4);
				hspace.position = arm_ui_BoxExport.colorSpaces.indexOf(t.color_space);
				ui.combo(hspace,arm_ui_BoxExport.colorSpaces,arm_Translator.tr("Color Space"));
				if(hspace.changed) {
					t.color_space = arm_ui_BoxExport.colorSpaces[hspace.position];
				}
			}
			if(ui.changed) {
				arm_ui_BoxExport.savePreset();
			}
			ui.row([0.125]);
			if(ui.button(arm_Translator.tr("Add"))) {
				arm_ui_BoxExport.preset.textures.push({ name : "base", channels : ["base_r","base_g","base_b","1.0"], color_space : "linear"});
				arm_ui_BoxExport.hpreset.children = null;
				arm_ui_BoxExport.savePreset();
			}
		}
	}
	static tabAtlases(ui) {
		if(ui.tab(arm_ui_BoxExport.htab,arm_Translator.tr("Atlases"))) {
			if(arm_Project.atlasObjects == null || arm_Project.atlasObjects.length != arm_Project.paintObjects.length) {
				arm_Project.atlasObjects = [];
				arm_Project.atlasNames = [];
				let _g = 0;
				let _g1 = arm_Project.paintObjects.length;
				while(_g < _g1) {
					arm_Project.atlasObjects.push(0);
					arm_Project.atlasNames.push(arm_Translator.tr("Atlas") + " " + (_g++ + 1));
				}
			}
			let _g = 0;
			let _g1 = arm_Project.paintObjects.length;
			while(_g < _g1) {
				let i = _g++;
				ui.row([0.5,0.5]);
				ui.text(arm_Project.paintObjects[i].name);
				let hatlas = zui_Handle.global.nest(18,null).nest(i);
				hatlas.position = arm_Project.atlasObjects[i];
				arm_Project.atlasObjects[i] = ui.combo(hatlas,arm_Project.atlasNames,arm_Translator.tr("Atlas"));
			}
		}
	}
	static showMesh() {
		arm_ui_BoxExport.exportMeshHandle.position = arm_Context.exportMeshIndex;
		arm_ui_UIBox.showCustom(function(ui) {
			arm_ui_BoxExport.tabExportMesh(ui,zui_Handle.global.nest(39,null));
		});
	}
	static tabExportMesh(ui,htab) {
		if(ui.tab(htab,arm_Translator.tr("Export Mesh"))) {
			ui.row([0.5,0.5]);
			arm_Context.exportMeshFormat = ui.combo(zui_Handle.global.nest(40,{ position : arm_Context.exportMeshFormat}),["obj","arm"],arm_Translator.tr("Format"),true);
			let ar = [arm_Translator.tr("All")];
			let _g = 0;
			let _g1 = arm_Project.paintObjects;
			while(_g < _g1.length) ar.push(_g1[_g++].name);
			ui.combo(arm_ui_BoxExport.exportMeshHandle,ar,arm_Translator.tr("Meshes"),true);
			let applyDisplacement = ui.check(zui_Handle.global.nest(41,null),arm_Translator.tr("Apply Displacement"));
			let tris = 0;
			let _g2 = 0;
			let _g3 = arm_Project.paintObjects;
			while(_g2 < _g3.length) {
				let _g = 0;
				let _g1 = _g3[_g2++].data.raw.index_arrays;
				while(_g < _g1.length) tris += _g1[_g++].values.length / 3 | 0;
			}
			ui.text(tris + " " + arm_Translator.tr("triangles"));
			ui.row([0.5,0.5]);
			if(ui.button(arm_Translator.tr("Cancel"))) {
				arm_ui_UIBox.show = false;
			}
			if(ui.button(arm_Translator.tr("Export"))) {
				arm_ui_UIBox.show = false;
				arm_ui_UIFiles.show(arm_Context.exportMeshFormat == 0 ? "obj" : "arm",true,false,function(path) {
					let f = arm_ui_UIFiles.filename;
					if(f == "") {
						f = arm_Translator.tr("untitled");
					}
					(function() {
						arm_io_ExportMesh.run(path + arm_sys_Path.sep + f,arm_ui_BoxExport.exportMeshHandle.position == 0 ? null : [arm_Project.paintObjects[arm_ui_BoxExport.exportMeshHandle.position - 1]],applyDisplacement);
					})();
				});
			}
		}
	}
	static showMaterial() {
		arm_ui_UIBox.showCustom(function(ui) {
			if(ui.tab(zui_Handle.global.nest(6,null),arm_Translator.tr("Export Material"))) {
				let h1 = zui_Handle.global.nest(7,null);
				let h2 = zui_Handle.global.nest(8,null);
				h1.selected = arm_Context.packAssetsOnExport;
				h2.selected = arm_Context.writeIconOnExport;
				arm_Context.packAssetsOnExport = ui.check(h1,arm_Translator.tr("Pack Assets"));
				arm_Context.writeIconOnExport = ui.check(h2,arm_Translator.tr("Export Icon"));
				ui.row([0.5,0.5]);
				if(ui.button(arm_Translator.tr("Cancel"))) {
					arm_ui_UIBox.show = false;
				}
				if(ui.button(arm_Translator.tr("Export"))) {
					arm_ui_UIBox.show = false;
					arm_ui_UIFiles.show("arm",true,false,function(path) {
						let f = arm_ui_UIFiles.filename;
						if(f == "") {
							f = arm_Translator.tr("untitled");
						}
						iron_App.notifyOnInit(function() {
							arm_io_ExportArm.runMaterial(path + arm_sys_Path.sep + f);
						});
					});
				}
			}
		});
	}
	static showBrush() {
		arm_ui_UIBox.showCustom(function(ui) {
			if(ui.tab(zui_Handle.global.nest(167,null),arm_Translator.tr("Export Brush"))) {
				let h1 = zui_Handle.global.nest(168,null);
				let h2 = zui_Handle.global.nest(169,null);
				h1.selected = arm_Context.packAssetsOnExport;
				h2.selected = arm_Context.writeIconOnExport;
				arm_Context.packAssetsOnExport = ui.check(h1,arm_Translator.tr("Pack Assets"));
				arm_Context.writeIconOnExport = ui.check(h2,arm_Translator.tr("Export Icon"));
				ui.row([0.5,0.5]);
				if(ui.button(arm_Translator.tr("Cancel"))) {
					arm_ui_UIBox.show = false;
				}
				if(ui.button(arm_Translator.tr("Export"))) {
					arm_ui_UIBox.show = false;
					arm_ui_UIFiles.show("arm",true,false,function(path) {
						let f = arm_ui_UIFiles.filename;
						if(f == "") {
							f = arm_Translator.tr("untitled");
						}
						iron_App.notifyOnInit(function() {
							arm_io_ExportArm.runBrush(path + arm_sys_Path.sep + f);
						});
					});
				}
			}
		});
	}
	static fetchPresets() {
		arm_ui_BoxExport.files = arm_sys_File.readDirectory(arm_sys_Path.data() + arm_sys_Path.sep + "export_presets");
		let _g = 0;
		let _g1 = arm_ui_BoxExport.files.length;
		while(_g < _g1) {
			let i = _g++;
			arm_ui_BoxExport.files[i] = HxOverrides.substr(arm_ui_BoxExport.files[i],0,arm_ui_BoxExport.files[i].length - 5);
		}
	}
	static parsePreset() {
		let file = "export_presets/" + arm_ui_BoxExport.files[arm_ui_BoxExport.hpreset.position] + ".json";
		iron_data_Data.getBlob(file,function(blob) {
			arm_ui_BoxExport.preset = JSON.parse(blob.toString());
			iron_data_Data.deleteBlob("export_presets/" + file);
		});
	}
	static newPreset(name) {
		if(!name.endsWith(".json")) {
			name += ".json";
		}
		Krom.fileSaveBytes(arm_sys_Path.data() + arm_sys_Path.sep + "export_presets" + arm_sys_Path.sep + name,haxe_io_Bytes.ofString("{\r\n\t\"textures\": [\r\n\t\t{ \"name\": \"base\", \"channels\": [\"base_r\", \"base_g\", \"base_b\", \"1.0\"], \"color_space\": \"linear\" }\r\n\t]\r\n}\r\n").b.bufferValue);
	}
	static savePreset() {
		let name = arm_ui_BoxExport.files[arm_ui_BoxExport.hpreset.position];
		if(name == "generic") {
			return;
		}
		Krom.fileSaveBytes(arm_sys_Path.data() + arm_sys_Path.sep + "export_presets" + arm_sys_Path.sep + name + ".json",haxe_io_Bytes.ofString(JSON.stringify(arm_ui_BoxExport.preset)).b.bufferValue);
	}
}
$hxClasses["arm.ui.BoxExport"] = arm_ui_BoxExport;
arm_ui_BoxExport.__name__ = "arm.ui.BoxExport";
class kha_Color {
	static fromValue(value) {
		return kha_Color._new(value);
	}
	static fromBytes(r,g,b,a) {
		if(a == null) {
			a = 255;
		}
		return kha_Color._new(a << 24 | r << 16 | g << 8 | b);
	}
	static fromFloats(r,g,b,a) {
		if(a == null) {
			a = 1;
		}
		return kha_Color._new(Math.round(a * 255) << 24 | Math.round(r * 255) << 16 | Math.round(g * 255) << 8 | Math.round(b * 255));
	}
	static fromString(value) {
		if((value.length == 7 || value.length == 9) && value.charCodeAt(0) == 35) {
			let colorValue = Std.parseInt("0x" + HxOverrides.substr(value,1,null));
			if(value.length == 7) {
				colorValue += -16777216;
			}
			return kha_Color._new(colorValue | 0);
		} else {
			throw haxe_Exception.thrown("Invalid Color string: '" + value + "'");
		}
	}
	static _new(value) {
		return value;
	}
	static get_value(this1) {
		return this1;
	}
	static set_value(this1,value) {
		this1 = value;
		return value;
	}
	static get_Rb(this1) {
		return (this1 & 16711680) >>> 16;
	}
	static get_Gb(this1) {
		return (this1 & 65280) >>> 8;
	}
	static get_Bb(this1) {
		return this1 & 255;
	}
	static get_Ab(this1) {
		return this1 >>> 24;
	}
	static set_Rb(this1,i) {
		this1 = this1 >>> 24 << 24 | i << 16 | (this1 & 65280) >>> 8 << 8 | this1 & 255;
		return i;
	}
	static set_Gb(this1,i) {
		this1 = this1 >>> 24 << 24 | (this1 & 16711680) >>> 16 << 16 | i << 8 | this1 & 255;
		return i;
	}
	static set_Bb(this1,i) {
		this1 = this1 >>> 24 << 24 | (this1 & 16711680) >>> 16 << 16 | (this1 & 65280) >>> 8 << 8 | i;
		return i;
	}
	static set_Ab(this1,i) {
		this1 = i << 24 | (this1 & 16711680) >>> 16 << 16 | (this1 & 65280) >>> 8 << 8 | this1 & 255;
		return i;
	}
	static get_R(this1) {
		return ((this1 & 16711680) >>> 16) * 0.00392156862745098;
	}
	static get_G(this1) {
		return ((this1 & 65280) >>> 8) * 0.00392156862745098;
	}
	static get_B(this1) {
		return (this1 & 255) * 0.00392156862745098;
	}
	static get_A(this1) {
		return (this1 >>> 24) * 0.00392156862745098;
	}
	static set_R(this1,f) {
		this1 = Math.round((this1 >>> 24) * 0.00392156862745098 * 255) << 24 | Math.round(f * 255) << 16 | Math.round(((this1 & 65280) >>> 8) * 0.00392156862745098 * 255) << 8 | Math.round((this1 & 255) * 0.00392156862745098 * 255);
		return f;
	}
	static set_G(this1,f) {
		this1 = Math.round((this1 >>> 24) * 0.00392156862745098 * 255) << 24 | Math.round(((this1 & 16711680) >>> 16) * 0.00392156862745098 * 255) << 16 | Math.round(f * 255) << 8 | Math.round((this1 & 255) * 0.00392156862745098 * 255);
		return f;
	}
	static set_B(this1,f) {
		this1 = Math.round((this1 >>> 24) * 0.00392156862745098 * 255) << 24 | Math.round(((this1 & 16711680) >>> 16) * 0.00392156862745098 * 255) << 16 | Math.round(((this1 & 65280) >>> 8) * 0.00392156862745098 * 255) << 8 | Math.round(f * 255);
		return f;
	}
	static set_A(this1,f) {
		this1 = Math.round(f * 255) << 24 | Math.round(((this1 & 16711680) >>> 16) * 0.00392156862745098 * 255) << 16 | Math.round(((this1 & 65280) >>> 8) * 0.00392156862745098 * 255) << 8 | Math.round((this1 & 255) * 0.00392156862745098 * 255);
		return f;
	}
}
$hx_exports["kha"]["Color"] = kha_Color;
kha_Color.__properties__ = {set_value: "set_value",get_value: "get_value",set_A: "set_A",get_A: "get_A",set_B: "set_B",get_B: "get_B",set_G: "set_G",get_G: "get_G",set_R: "set_R",get_R: "get_R",set_Ab: "set_Ab",get_Ab: "get_Ab",set_Bb: "set_Bb",get_Bb: "get_Bb",set_Gb: "set_Gb",get_Gb: "get_Gb",set_Rb: "set_Rb",get_Rb: "get_Rb"};
class arm_ui_BoxPreferences {
	static show() {
		arm_ui_UIBox.showCustom(function(ui) {
			if(ui.tab(arm_ui_BoxPreferences.htab,arm_Translator.tr("Interface"),true)) {
				if(arm_ui_BoxPreferences.locales == null) {
					arm_ui_BoxPreferences.locales = arm_Translator.getSupportedLocales();
				}
				let localeHandle = zui_Handle.global.nest(43,{ position : arm_ui_BoxPreferences.locales.indexOf(arm_Config.raw.locale)});
				ui.combo(localeHandle,arm_ui_BoxPreferences.locales,arm_Translator.tr("Language"),true);
				if(localeHandle.changed) {
					let localeCode = arm_ui_BoxPreferences.locales[localeHandle.position];
					arm_Config.raw.locale = localeCode;
					arm_Translator.loadTranslations(localeCode);
					arm_ui_UISidebar.inst.tagUIRedraw();
				}
				let hscale = zui_Handle.global.nest(44,{ value : arm_Config.raw.window_scale});
				ui.slider(hscale,arm_Translator.tr("UI Scale"),1.0,4.0,true,10);
				if(!hscale.changed && arm_Context.hscaleWasChanged) {
					let tmp;
					if(hscale.value != null) {
						let f = hscale.value;
						tmp = isNaN(f);
					} else {
						tmp = true;
					}
					if(tmp) {
						hscale.value = 1.0;
					}
					arm_Config.raw.window_scale = hscale.value;
					arm_ui_BoxPreferences.setScale();
				}
				arm_Context.hscaleWasChanged = hscale.changed;
				let hspeed = zui_Handle.global.nest(45,{ value : arm_Config.raw.camera_speed});
				let tmp = arm_Translator.tr("Camera Speed");
				arm_Config.raw.camera_speed = ui.slider(hspeed,tmp,0.1,4.0,true);
				let zoomDirectionHandle = zui_Handle.global.nest(46,{ position : arm_Config.raw.zoom_direction});
				ui.combo(zoomDirectionHandle,[arm_Translator.tr("Vertical"),arm_Translator.tr("Vertical Inverted"),arm_Translator.tr("Horizontal"),arm_Translator.tr("Horizontal Inverted"),arm_Translator.tr("Vertical and Horizontal"),arm_Translator.tr("Vertical and Horizontal Inverted")],arm_Translator.tr("Direction to Zoom"),true);
				if(zoomDirectionHandle.changed) {
					arm_Config.raw.zoom_direction = zoomDirectionHandle.position;
				}
				let tmp1 = zui_Handle.global.nest(47,{ selected : arm_Config.raw.wrap_mouse});
				let tmp2 = arm_Translator.tr("Wrap Mouse");
				arm_Config.raw.wrap_mouse = ui.check(tmp1,tmp2);
				if(ui.isHovered) {
					ui.tooltip(arm_Translator.tr("Wrap mouse around view boundaries during camera control"));
				}
				let tmp3 = zui_Handle.global.nest(48,{ selected : arm_Config.raw.node_preview});
				let tmp4 = arm_Translator.tr("Show Node Preview");
				arm_Config.raw.node_preview = ui.check(tmp3,tmp4);
				ui.changed = false;
				let tmp5 = zui_Handle.global.nest(49,{ selected : arm_Config.raw.show_asset_names});
				let tmp6 = arm_Translator.tr("Show Asset Names");
				arm_Config.raw.show_asset_names = ui.check(tmp5,tmp6);
				if(ui.changed) {
					arm_ui_UISidebar.inst.tagUIRedraw();
				}
				ui.endElement();
				ui.row([0.5,0.5]);
				if(ui.button(arm_Translator.tr("Restore"))) {
					arm_ui_UIMenu.draw(function(ui) {
						ui.text(arm_Translator.tr("Restore defaults?"),2,ui.t.HIGHLIGHT_COL);
						if(ui.button(arm_Translator.tr("Confirm"),0)) {
							iron_App.notifyOnInit(function() {
								ui.t.ELEMENT_H = arm_App.defaultElementH;
								arm_Config.restore();
								arm_ui_BoxPreferences.setScale();
								if(arm_ui_BoxPreferences.filesPlugin != null) {
									let _g = 0;
									let _g1 = arm_ui_BoxPreferences.filesPlugin;
									while(_g < _g1.length) {
										let f = _g1[_g];
										++_g;
										arm_Plugin.stop(f);
									}
								}
								arm_ui_BoxPreferences.filesPlugin = null;
								arm_ui_BoxPreferences.filesKeymap = null;
								arm_node_MakeMaterial.parseMeshMaterial();
								arm_node_MakeMaterial.parsePaintMaterial();
							});
						}
						if(ui.button(arm_Translator.tr("Import..."),0)) {
							arm_ui_UIFiles.show("arm",false,false,function(path) {
								iron_data_Data.getBlob(path,function(b) {
									let raw = JSON.parse(b.toString());
									iron_App.notifyOnInit(function() {
										ui.t.ELEMENT_H = arm_App.defaultElementH;
										arm_Config.importFrom(raw);
										arm_ui_BoxPreferences.setScale();
										arm_node_MakeMaterial.parseMeshMaterial();
										arm_node_MakeMaterial.parsePaintMaterial();
									});
								});
							});
						}
					},3);
				}
				if(ui.button(arm_Translator.tr("Reset Layout"))) {
					arm_ui_UIMenu.draw(function(ui) {
						ui.text(arm_Translator.tr("Reset layout?"),2,ui.t.HIGHLIGHT_COL);
						if(ui.button(arm_Translator.tr("Confirm"),0)) {
							arm_App.initLayout();
							arm_Config.save();
						}
					},2);
				}
			}
			if(ui.tab(arm_ui_BoxPreferences.htab,arm_Translator.tr("Theme"),true)) {
				if(arm_ui_BoxPreferences.themes == null) {
					arm_ui_BoxPreferences.fetchThemes();
				}
				arm_ui_BoxPreferences.themeHandle = zui_Handle.global.nest(50,{ position : arm_ui_BoxPreferences.getThemeIndex()});
				ui.beginSticky();
				ui.row([0.25,0.25,0.25,0.25]);
				ui.combo(arm_ui_BoxPreferences.themeHandle,arm_ui_BoxPreferences.themes,arm_Translator.tr("Theme"));
				if(arm_ui_BoxPreferences.themeHandle.changed) {
					arm_Config.raw.theme = arm_ui_BoxPreferences.themes[arm_ui_BoxPreferences.themeHandle.position] + ".json";
					arm_Config.loadTheme(arm_Config.raw.theme);
				}
				if(ui.button(arm_Translator.tr("New"))) {
					arm_ui_UIBox.showCustom(function(ui) {
						if(ui.tab(zui_Handle.global.nest(51,null),arm_Translator.tr("New Theme"))) {
							ui.row([0.5,0.5]);
							let themeName = ui.textInput(zui_Handle.global.nest(52,{ text : "new_theme"}),arm_Translator.tr("Name"));
							if(ui.button(arm_Translator.tr("OK")) || ui.isReturnDown) {
								let template = JSON.stringify(arm_App.theme);
								if(!themeName.endsWith(".json")) {
									themeName += ".json";
								}
								let path = arm_sys_Path.data() + arm_sys_Path.sep + "themes" + arm_sys_Path.sep + themeName;
								Krom.fileSaveBytes(path,haxe_io_Bytes.ofString(template).b.bufferValue);
								arm_ui_BoxPreferences.fetchThemes();
								arm_Config.raw.theme = themeName;
								arm_ui_BoxPreferences.themeHandle.position = arm_ui_BoxPreferences.getThemeIndex();
								arm_ui_UIBox.show = false;
								arm_App.redrawUI();
								arm_ui_BoxPreferences.htab.position = 1;
								arm_ui_BoxPreferences.show();
							}
						}
					});
				}
				if(ui.button(arm_Translator.tr("Import"))) {
					arm_ui_UIFiles.show("json",false,false,function(path) {
						arm_io_ImportTheme.run(path);
					});
				}
				if(ui.button(arm_Translator.tr("Export"))) {
					arm_ui_UIFiles.show("json",true,false,function(path) {
						path += arm_sys_Path.sep + arm_ui_UIFiles.filename;
						if(!path.endsWith(".json")) {
							path += ".json";
						}
						Krom.fileSaveBytes(path,haxe_io_Bytes.ofString(JSON.stringify(arm_App.theme)).b.bufferValue);
					});
				}
				ui.endSticky();
				let i = 0;
				let theme = arm_App.theme;
				let hlist = zui_Handle.global.nest(53,null);
				let h = hlist.nest(i++,{ color : arm_ui_BoxPreferences.worldColor});
				ui.row([0.125,0.875]);
				ui.text("",0,h.color);
				if(ui.isHovered && ui.inputReleased) {
					arm_ui_UIMenu.draw(function(ui) {
						ui.changed = false;
						zui_Ext.colorWheel(ui,h,false,null,11 * ui.t.ELEMENT_H * ui.ops.scaleFactor,true);
						if(ui.changed) {
							arm_ui_UIMenu.keepOpen = true;
						}
					},11);
				}
				let val = h.color;
				if(val < 0) {
					val += 4294967296;
				}
				h.text = val.toString(16);
				ui.textInput(h,"VIEWPORT_COL");
				h.color = parseInt(h.text,16);
				if(arm_ui_BoxPreferences.worldColor != h.color) {
					arm_ui_BoxPreferences.worldColor = h.color;
					let b = new haxe_io_Bytes(new ArrayBuffer(4));
					b.b[0] = (arm_ui_BoxPreferences.worldColor & 16711680) >>> 16;
					b.b[1] = (arm_ui_BoxPreferences.worldColor & 65280) >>> 8;
					b.b[2] = arm_ui_BoxPreferences.worldColor & 255;
					b.b[3] = 255;
					arm_Context.emptyEnvmap = kha_Image.fromBytes(b,1,1);
					arm_Context.ddirty = 2;
					if(!arm_Context.showEnvmap) {
						iron_Scene.active.world.envmap = arm_Context.emptyEnvmap;
					}
				}
				let _g = 0;
				let _g1 = Reflect.fields(theme);
				while(_g < _g1.length) {
					let key = _g1[_g];
					++_g;
					if(key == "NAME") {
						continue;
					}
					let h = hlist.nest(i++);
					let val = theme[key];
					let isHex = key.endsWith("_COL");
					if(isHex && val < 0) {
						val += 4294967296;
					}
					if(isHex) {
						ui.row([0.125,0.875]);
						ui.text("",0,val);
						if(ui.isHovered && ui.inputReleased) {
							h.color = theme[key];
							arm_ui_UIMenu.draw(function(ui) {
								ui.changed = false;
								theme[key] = zui_Ext.colorWheel(ui,h,false,null,11 * ui.t.ELEMENT_H * ui.ops.scaleFactor,true);
								if(ui.changed) {
									arm_ui_UIMenu.keepOpen = true;
								}
							},11);
						}
					}
					if(typeof(val) == "boolean") {
						h.selected = val;
						theme[key] = ui.check(h,key);
					} else if(key == "LINK_STYLE") {
						let styles = [arm_Translator.tr("Straight"),arm_Translator.tr("Curved")];
						h.position = val;
						theme[key] = ui.combo(h,styles,key,true);
					} else {
						let tmp = isHex ? val.toString(16) : val.toString();
						h.text = tmp;
						let res = ui.textInput(h,key);
						if(isHex) {
							theme[key] = parseInt(h.text,16);
						} else {
							theme[key] = parseInt(h.text);
						}
					}
				}
			}
			if(ui.tab(arm_ui_BoxPreferences.htab,arm_Translator.tr("Usage"),true)) {
				arm_Context.undoHandle = zui_Handle.global.nest(55,{ value : arm_Config.raw.undo_steps});
				let tmp = ui.slider(arm_Context.undoHandle,arm_Translator.tr("Undo Steps"),1,64,false,1) | 0;
				arm_Config.raw.undo_steps = tmp;
				if(arm_Config.raw.undo_steps < 1) {
					arm_Config.raw.undo_steps = (arm_Context.undoHandle.value = 1) | 0;
				}
				if(arm_Context.undoHandle.changed) {
					ui.g.end();
					while(arm_History.undoLayers.length < arm_Config.raw.undo_steps) {
						let l = new arm_data_LayerSlot("_undo" + arm_History.undoLayers.length);
						arm_History.undoLayers.push(l);
					}
					while(arm_History.undoLayers.length > arm_Config.raw.undo_steps) {
						let l = arm_History.undoLayers.pop();
						l.unload();
					}
					arm_History.reset();
					ui.g.begin(false);
				}
				let tmp1 = ui.slider(zui_Handle.global.nest(56,{ value : arm_Config.raw.dilate_radius}),arm_Translator.tr("Dilate Radius"),0.0,16.0,true,1) | 0;
				arm_Config.raw.dilate_radius = tmp1;
				if(ui.isHovered) {
					ui.tooltip(arm_Translator.tr("Dilate painted textures to prevent seams"));
				}
				let dilateHandle = zui_Handle.global.nest(57,{ position : arm_Config.raw.dilate});
				ui.combo(dilateHandle,[arm_Translator.tr("Instant"),arm_Translator.tr("Delayed")],arm_Translator.tr("Dilate"),true);
				if(dilateHandle.changed) {
					arm_Config.raw.dilate = dilateHandle.position;
				}
				let workspaceHandle = zui_Handle.global.nest(58,{ position : arm_Config.raw.workspace});
				ui.combo(workspaceHandle,[arm_Translator.tr("Paint"),arm_Translator.tr("Material"),arm_Translator.tr("Bake")],arm_Translator.tr("Default Workspace"),true);
				if(workspaceHandle.changed) {
					arm_Config.raw.workspace = workspaceHandle.position;
				}
				let layerResHandle = zui_Handle.global.nest(59,{ position : arm_Config.raw.layer_res});
				ui.combo(layerResHandle,["128","256","512","1K","2K","4K","8K"],arm_Translator.tr("Default Layer Resolution"),true);
				if(layerResHandle.changed) {
					arm_Config.raw.layer_res = layerResHandle.position;
				}
				let serverHandle = zui_Handle.global.nest(60,{ text : arm_Config.raw.server});
				let tmp2 = arm_Translator.tr("Cloud Server");
				arm_Config.raw.server = ui.textInput(serverHandle,tmp2);
				let materialLiveHandle = zui_Handle.global.nest(61,{ selected : arm_Config.raw.material_live});
				let tmp3 = arm_Translator.tr("Live Material Preview");
				arm_Config.raw.material_live = ui.check(materialLiveHandle,tmp3);
				if(ui.isHovered) {
					ui.tooltip(arm_Translator.tr("Instantly update material preview on node change"));
				}
				let brushLiveHandle = zui_Handle.global.nest(62,{ selected : arm_Config.raw.brush_live});
				let tmp4 = arm_Translator.tr("Live Brush Preview");
				arm_Config.raw.brush_live = ui.check(brushLiveHandle,tmp4);
				if(ui.isHovered) {
					ui.tooltip(arm_Translator.tr("Draw live brush preview in viewport"));
				}
				if(brushLiveHandle.changed) {
					arm_Context.ddirty = 2;
				}
				let brush3dHandle = zui_Handle.global.nest(63,{ selected : arm_Config.raw.brush_3d});
				let tmp5 = arm_Translator.tr("3D Cursor");
				arm_Config.raw.brush_3d = ui.check(brush3dHandle,tmp5);
				if(brush3dHandle.changed) {
					arm_node_MakeMaterial.parsePaintMaterial();
				}
				ui.enabled = arm_Config.raw.brush_3d;
				let brushDepthRejectHandle = zui_Handle.global.nest(64,{ selected : arm_Config.raw.brush_depth_reject});
				let tmp6 = arm_Translator.tr("Depth Reject");
				arm_Config.raw.brush_depth_reject = ui.check(brushDepthRejectHandle,tmp6);
				if(brushDepthRejectHandle.changed) {
					arm_node_MakeMaterial.parsePaintMaterial();
				}
				ui.row([0.5,0.5]);
				let brushAngleRejectHandle = zui_Handle.global.nest(65,{ selected : arm_Config.raw.brush_angle_reject});
				let tmp7 = arm_Translator.tr("Angle Reject");
				arm_Config.raw.brush_angle_reject = ui.check(brushAngleRejectHandle,tmp7);
				if(brushAngleRejectHandle.changed) {
					arm_node_MakeMaterial.parsePaintMaterial();
				}
				if(!arm_Config.raw.brush_angle_reject) {
					ui.enabled = false;
				}
				let angleDotHandle = zui_Handle.global.nest(66,{ value : arm_Context.brushAngleRejectDot});
				arm_Context.brushAngleRejectDot = ui.slider(angleDotHandle,arm_Translator.tr("Angle"),0.0,1.0,true);
				if(angleDotHandle.changed) {
					arm_node_MakeMaterial.parsePaintMaterial();
				}
				ui.enabled = true;
			}
			if(ui.tab(arm_ui_BoxPreferences.htab,arm_Translator.tr("Pen"),true)) {
				ui.text(arm_Translator.tr("Pressure controls"));
				let tmp = zui_Handle.global.nest(67,{ selected : arm_Config.raw.pressure_radius});
				let tmp1 = arm_Translator.tr("Brush Radius");
				arm_Config.raw.pressure_radius = ui.check(tmp,tmp1);
				let tmp2 = zui_Handle.global.nest(68,{ selected : arm_Config.raw.pressure_hardness});
				let tmp3 = arm_Translator.tr("Brush Hardness");
				arm_Config.raw.pressure_hardness = ui.check(tmp2,tmp3);
				let tmp4 = zui_Handle.global.nest(69,{ selected : arm_Config.raw.pressure_opacity});
				let tmp5 = arm_Translator.tr("Brush Opacity");
				arm_Config.raw.pressure_opacity = ui.check(tmp4,tmp5);
				let tmp6 = zui_Handle.global.nest(70,{ selected : arm_Config.raw.pressure_angle});
				let tmp7 = arm_Translator.tr("Brush Angle");
				arm_Config.raw.pressure_angle = ui.check(tmp6,tmp7);
				let tmp8 = zui_Handle.global.nest(71,{ value : arm_Config.raw.pressure_sensitivity});
				let tmp9 = arm_Translator.tr("Sensitivity");
				arm_Config.raw.pressure_sensitivity = ui.slider(tmp8,tmp9,0.0,2.0,true);
				ui.endElement();
				ui.row([0.5]);
				if(ui.button(arm_Translator.tr("Help"))) {
					arm_sys_File.loadUrl("https://github.com/armory3d/armorpaint_docs#pen");
				}
			}
			arm_Context.hssgi = zui_Handle.global.nest(72,{ selected : arm_Config.raw.rp_ssgi});
			arm_Context.hssr = zui_Handle.global.nest(73,{ selected : arm_Config.raw.rp_ssr});
			arm_Context.hbloom = zui_Handle.global.nest(74,{ selected : arm_Config.raw.rp_bloom});
			let f = arm_Config.raw.rp_supersample;
			arm_Context.hsupersample = zui_Handle.global.nest(75,{ position : f == 0.25 ? 0 : f == 0.5 ? 1 : f == 1.0 ? 2 : f == 1.5 ? 3 : f == 2.0 ? 4 : 5});
			arm_Context.hvxao = zui_Handle.global.nest(76,{ selected : arm_Config.raw.rp_gi});
			if(ui.tab(arm_ui_BoxPreferences.htab,arm_Translator.tr("Viewport"),true)) {
				let hrendermode = zui_Handle.global.nest(77,{ position : arm_Context.renderMode});
				arm_Context.renderMode = ui.combo(hrendermode,[arm_Translator.tr("Full"),arm_Translator.tr("Mobile")],arm_Translator.tr("Renderer"),true);
				if(hrendermode.changed) {
					arm_Context.setRenderPath();
				}
				ui.combo(arm_Context.hsupersample,["0.25x","0.5x","1.0x","1.5x","2.0x","4.0x"],arm_Translator.tr("Super Sample"),true);
				if(arm_Context.hsupersample.changed) {
					arm_Config.applyConfig();
				}
				if(arm_Context.renderMode == 0) {
					ui.check(arm_Context.hvxao,arm_Translator.tr("Voxel AO"));
					if(ui.isHovered) {
						ui.tooltip(arm_Translator.tr("Cone-traced AO and shadows"));
					}
					if(arm_Context.hvxao.changed) {
						arm_Config.applyConfig();
					}
					ui.enabled = arm_Context.hvxao.selected;
					let h = zui_Handle.global.nest(78,{ value : arm_Context.vxaoOffset});
					arm_Context.vxaoOffset = ui.slider(h,arm_Translator.tr("Cone Offset"),1.0,4.0,true);
					if(h.changed) {
						arm_Context.ddirty = 2;
					}
					let h1 = zui_Handle.global.nest(79,{ value : arm_Context.vxaoAperture});
					arm_Context.vxaoAperture = ui.slider(h1,arm_Translator.tr("Aperture"),1.0,4.0,true);
					if(h1.changed) {
						arm_Context.ddirty = 2;
					}
					ui.enabled = true;
					ui.check(arm_Context.hssgi,arm_Translator.tr("SSAO"));
					if(arm_Context.hssgi.changed) {
						arm_Config.applyConfig();
					}
					ui.check(arm_Context.hssr,arm_Translator.tr("SSR"));
					if(arm_Context.hssr.changed) {
						arm_Config.applyConfig();
					}
					ui.check(arm_Context.hbloom,arm_Translator.tr("Bloom"));
					if(arm_Context.hbloom.changed) {
						arm_Config.applyConfig();
					}
				}
				let h = zui_Handle.global.nest(80,{ value : arm_Config.raw.rp_vignette});
				let tmp = arm_Translator.tr("Vignette");
				arm_Config.raw.rp_vignette = ui.slider(h,tmp,0.0,1.0,true);
				if(h.changed) {
					arm_Context.ddirty = 2;
				}
				let cam = iron_Scene.active.camera;
				let camRaw = cam.data.raw;
				let near_handle = zui_Handle.global.nest(81,null);
				let far_handle = zui_Handle.global.nest(82,null);
				near_handle.value = (camRaw.near_plane * 1000 | 0) / 1000;
				far_handle.value = (camRaw.far_plane * 100 | 0) / 100;
				camRaw.near_plane = ui.slider(near_handle,arm_Translator.tr("Clip Start"),0.001,1.0,true);
				camRaw.far_plane = ui.slider(far_handle,arm_Translator.tr("Clip End"),50.0,100.0,true);
				if(near_handle.changed || far_handle.changed) {
					cam.buildProjection();
				}
				let dispHandle = zui_Handle.global.nest(83,{ value : arm_Config.raw.displace_strength});
				let tmp1 = arm_Translator.tr("Displacement Strength");
				arm_Config.raw.displace_strength = ui.slider(dispHandle,tmp1,0.0,10.0,true);
				if(dispHandle.changed) {
					arm_Context.ddirty = 2;
					arm_node_MakeMaterial.parseMeshMaterial();
				}
			}
			if(ui.tab(arm_ui_BoxPreferences.htab,arm_Translator.tr("Keymap"),true)) {
				if(arm_ui_BoxPreferences.filesKeymap == null) {
					arm_ui_BoxPreferences.fetchKeymaps();
				}
				ui.beginSticky();
				ui.row([0.5,0.25,0.25]);
				arm_ui_BoxPreferences.presetHandle = zui_Handle.global.nest(84,{ position : arm_ui_BoxPreferences.getPresetIndex()});
				ui.combo(arm_ui_BoxPreferences.presetHandle,arm_ui_BoxPreferences.filesKeymap,arm_Translator.tr("Preset"));
				if(arm_ui_BoxPreferences.presetHandle.changed) {
					arm_Config.raw.keymap = arm_ui_BoxPreferences.filesKeymap[arm_ui_BoxPreferences.presetHandle.position] + ".json";
					arm_Config.applyConfig();
					arm_Config.loadKeymap();
				}
				if(ui.button(arm_Translator.tr("Import"))) {
					arm_ui_UIFiles.show("json",false,false,function(path) {
						arm_io_ImportKeymap.run(path);
					});
				}
				if(ui.button(arm_Translator.tr("Export"))) {
					arm_ui_UIFiles.show("json",true,false,function(dest) {
						if(!arm_ui_UIFiles.filename.endsWith(".json")) {
							arm_ui_UIFiles.filename += ".json";
						}
						let path = arm_sys_Path.data() + arm_sys_Path.sep + "keymap_presets" + arm_sys_Path.sep + arm_Config.raw.keymap;
						arm_sys_File.copy(path,dest + arm_sys_Path.sep + arm_ui_UIFiles.filename);
					});
				}
				ui.endSticky();
				ui.separator(8,false);
				let i = 0;
				ui.changed = false;
				let _g = 0;
				let _g1 = Reflect.fields(arm_Config.keymap);
				while(_g < _g1.length) {
					let key = _g1[_g];
					++_g;
					let h = zui_Handle.global.nest(85,null).nest(i++);
					h.text = Reflect.field(arm_Config.keymap,key);
					let text = ui.textInput(h,key,0);
					arm_Config.keymap[key] = text;
				}
				if(ui.changed) {
					arm_Config.applyConfig();
					arm_Config.saveKeymap();
				}
			}
			if(ui.tab(arm_ui_BoxPreferences.htab,arm_Translator.tr("Plugins"),true)) {
				ui.beginSticky();
				ui.row([0.25,0.25]);
				if(ui.button(arm_Translator.tr("New"))) {
					arm_ui_UIBox.showCustom(function(ui) {
						if(ui.tab(zui_Handle.global.nest(86,null),arm_Translator.tr("New Plugin"))) {
							ui.row([0.5,0.5]);
							let pluginName = ui.textInput(zui_Handle.global.nest(87,{ text : "new_plugin"}),arm_Translator.tr("Name"));
							if(ui.button(arm_Translator.tr("OK")) || ui.isReturnDown) {
								let template = "let plugin = new arm.Plugin();\r\nlet h1 = new zui.Handle();\r\nplugin.drawUI = function(ui) {\r\n\tif (ui.panel(h1, 'New Plugin')) {\r\n\t\tif (ui.button('Button')) {\r\n\t\t\tconsole.error('Hello');\r\n\t\t}\r\n\t}\r\n}\r\n";
								if(!pluginName.endsWith(".js")) {
									pluginName += ".js";
								}
								let path = arm_sys_Path.data() + arm_sys_Path.sep + "plugins" + arm_sys_Path.sep + pluginName;
								Krom.fileSaveBytes(path,haxe_io_Bytes.ofString(template).b.bufferValue);
								arm_ui_BoxPreferences.filesPlugin = null;
								arm_ui_UIBox.show = false;
								arm_App.redrawUI();
								arm_ui_BoxPreferences.htab.position = 6;
								arm_ui_BoxPreferences.show();
							}
						}
					});
				}
				if(ui.button(arm_Translator.tr("Import"))) {
					arm_ui_UIFiles.show("js,wasm,zip",false,false,function(path) {
						arm_io_ImportPlugin.run(path);
					});
				}
				ui.endSticky();
				if(arm_ui_BoxPreferences.filesPlugin == null) {
					arm_ui_BoxPreferences.fetchPlugins();
				}
				if(arm_Config.raw.plugins == null) {
					arm_Config.raw.plugins = [];
				}
				let h = zui_Handle.global.nest(88,{ selected : false});
				let _g = 0;
				let _g1 = arm_ui_BoxPreferences.filesPlugin;
				while(_g < _g1.length) {
					let f = _g1[_g];
					++_g;
					let isJs = f.endsWith(".js");
					let isWasm = false;
					if(!isJs && !isWasm) {
						continue;
					}
					let enabled = arm_Config.raw.plugins.indexOf(f) >= 0;
					h.selected = enabled;
					let tag = isJs ? f.split(".")[0] : f;
					ui.check(h,tag);
					if(h.changed && h.selected != enabled) {
						if(h.selected) {
							arm_Config.enablePlugin(f);
						} else {
							arm_Config.disablePlugin(f);
						}
						arm_App.redrawUI();
					}
					if(ui.isHovered && ui.inputReleasedR) {
						arm_ui_UIMenu.draw(function(ui) {
							ui.text(f,2,ui.t.HIGHLIGHT_COL);
							let path = arm_sys_Path.data() + arm_sys_Path.sep + "plugins" + arm_sys_Path.sep + f;
							if(ui.button(arm_Translator.tr("Edit in Text Editor"),0)) {
								arm_sys_File.start(path);
							}
							if(ui.button(arm_Translator.tr("Edit in Script Tab"),0)) {
								iron_data_Data.getBlob("plugins/" + f,function(blob) {
									arm_ui_TabScript.hscript.text = blob.toString();
									iron_data_Data.deleteBlob("plugins/" + f);
									arm_Console.info("Script opened");
								});
							}
							if(ui.button(arm_Translator.tr("Export"),0)) {
								arm_ui_UIFiles.show("js",true,false,function(dest) {
									if(!arm_ui_UIFiles.filename.endsWith(".js")) {
										arm_ui_UIFiles.filename += ".js";
									}
									arm_sys_File.copy(path,dest + arm_sys_Path.sep + arm_ui_UIFiles.filename);
								});
							}
							if(ui.button(arm_Translator.tr("Delete"),0)) {
								if(arm_Config.raw.plugins.indexOf(f) >= 0) {
									HxOverrides.remove(arm_Config.raw.plugins,f);
									arm_Plugin.stop(f);
								}
								HxOverrides.remove(arm_ui_BoxPreferences.filesPlugin,f);
								arm_sys_File.delete(path);
							}
						},5);
					}
				}
			}
		},600,400,function() {
			arm_Config.save();
		});
	}
	static fetchThemes() {
		arm_ui_BoxPreferences.themes = arm_sys_File.readDirectory(arm_sys_Path.data() + arm_sys_Path.sep + "themes");
		let _g = 0;
		let _g1 = arm_ui_BoxPreferences.themes.length;
		while(_g < _g1) {
			let i = _g++;
			arm_ui_BoxPreferences.themes[i] = HxOverrides.substr(arm_ui_BoxPreferences.themes[i],0,arm_ui_BoxPreferences.themes[i].length - 5);
		}
		arm_ui_BoxPreferences.themes.unshift("default");
	}
	static fetchKeymaps() {
		arm_ui_BoxPreferences.filesKeymap = arm_sys_File.readDirectory(arm_sys_Path.data() + arm_sys_Path.sep + "keymap_presets");
		let _g = 0;
		let _g1 = arm_ui_BoxPreferences.filesKeymap.length;
		while(_g < _g1) {
			let i = _g++;
			arm_ui_BoxPreferences.filesKeymap[i] = HxOverrides.substr(arm_ui_BoxPreferences.filesKeymap[i],0,arm_ui_BoxPreferences.filesKeymap[i].length - 5);
		}
	}
	static fetchPlugins() {
		arm_ui_BoxPreferences.filesPlugin = arm_sys_File.readDirectory(arm_sys_Path.data() + arm_sys_Path.sep + "plugins");
	}
	static getThemeIndex() {
		return arm_ui_BoxPreferences.themes.indexOf(HxOverrides.substr(arm_Config.raw.theme,0,arm_Config.raw.theme.length - 5));
	}
	static getPresetIndex() {
		return arm_ui_BoxPreferences.filesKeymap.indexOf(HxOverrides.substr(arm_Config.raw.keymap,0,arm_Config.raw.keymap.length - 5));
	}
	static setScale() {
		let scale = arm_Config.raw.window_scale;
		arm_ui_UISidebar.inst.ui.setScale(scale);
		arm_Config.raw.layout[0] = 280 * scale | 0;
		arm_ui_UIToolbar.inst.toolbarw = 36 * scale | 0;
		arm_ui_UIHeader.inst.headerh = 28 * scale | 0;
		arm_Config.raw.layout[5] = 32 * scale | 0;
		arm_ui_UIMenubar.inst.menubarw = 330 * scale | 0;
		arm_ui_UISidebar.inst.setIconScale();
		arm_ui_UINodes.inst.ui.setScale(scale);
		arm_ui_UIView2D.inst.ui.setScale(scale);
		arm_App.uiBox.setScale(scale);
		arm_App.uiMenu.setScale(scale);
		arm_App.resize();
	}
}
$hxClasses["arm.ui.BoxPreferences"] = arm_ui_BoxPreferences;
arm_ui_BoxPreferences.__name__ = "arm.ui.BoxPreferences";
class arm_ui_TabBrowser {
	static showDirectory(directory) {
		arm_ui_TabBrowser.hpath.text = directory;
		arm_ui_TabBrowser.hsearch.text = "";
		arm_ui_UIStatus.inst.statustab.position = 0;
	}
	static draw() {
		let ui = arm_ui_UISidebar.inst.ui;
		let statush = arm_Config.raw.layout[5];
		if(ui.tab(arm_ui_UIStatus.inst.statustab,arm_Translator.tr("Browser")) && statush > 32 * ui.ops.scaleFactor) {
			if(arm_Config.raw.bookmarks == null) {
				arm_Config.raw.bookmarks = [];
			}
			let bookmarksW = 100 * ui.ops.scaleFactor | 0;
			if(arm_ui_TabBrowser.hpath.text == "" && arm_Config.raw.bookmarks.length > 0) {
				arm_ui_TabBrowser.hpath.text = arm_Config.raw.bookmarks[0];
			}
			ui.beginSticky();
			if(arm_ui_TabBrowser.hsearch.text != "") {
				ui.row([bookmarksW / ui._w,(1 - bookmarksW / ui._w) * 0.75,(1 - bookmarksW / ui._w) * 0.05,(1 - bookmarksW / ui._w) * 0.17,(1 - bookmarksW / ui._w) * 0.03]);
			} else {
				ui.row([bookmarksW / ui._w,(1 - bookmarksW / ui._w) * 0.75,(1 - bookmarksW / ui._w) * 0.05,(1 - bookmarksW / ui._w) * 0.2]);
			}
			if(ui.button("+")) {
				arm_Config.raw.bookmarks.push(arm_ui_TabBrowser.hpath.text);
				arm_Config.save();
			}
			let tmp = arm_ui_TabBrowser.hpath;
			let tmp1 = arm_Translator.tr("Path");
			arm_ui_TabBrowser.hpath.text = ui.textInput(tmp,tmp1);
			let refresh = false;
			let inFocus = ui.inputX > ui._windowX && ui.inputX < ui._windowX + ui._windowW && ui.inputY > ui._windowY && ui.inputY < ui._windowY + ui._windowH;
			if(ui.button(arm_Translator.tr("Refresh")) || inFocus && ui.isKeyPressed && ui.key == 116) {
				refresh = true;
			}
			let tmp2 = arm_ui_TabBrowser.hsearch;
			let tmp3 = arm_Translator.tr("Search");
			arm_ui_TabBrowser.hsearch.text = ui.textInput(tmp2,tmp3);
			if(arm_ui_TabBrowser.hsearch.text != "" && ui.button(arm_Translator.tr("X"))) {
				arm_ui_TabBrowser.hsearch.text = "";
			}
			ui.endSticky();
			if(arm_ui_TabBrowser.lastPath != arm_ui_TabBrowser.hpath.text) {
				arm_ui_TabBrowser.hsearch.text = "";
			}
			arm_ui_TabBrowser.lastPath = arm_ui_TabBrowser.hpath.text;
			let _y = ui._y;
			ui._x = bookmarksW;
			ui._w -= bookmarksW;
			arm_ui_UIFiles.fileBrowser(ui,arm_ui_TabBrowser.hpath,false,true,arm_ui_TabBrowser.hsearch.text,refresh);
			if(arm_ui_TabBrowser.known) {
				let path = arm_ui_TabBrowser.hpath.text;
				iron_App.notifyOnInit(function() {
					arm_io_ImportAsset.run(path);
				});
				arm_ui_TabBrowser.hpath.text = HxOverrides.substr(arm_ui_TabBrowser.hpath.text,0,arm_ui_TabBrowser.hpath.text.lastIndexOf(arm_sys_Path.sep));
			}
			arm_ui_TabBrowser.known = HxOverrides.substr(arm_ui_TabBrowser.hpath.text,arm_ui_TabBrowser.hpath.text.lastIndexOf(arm_sys_Path.sep),null).indexOf(".") > 0;
			let bottomY = ui._y;
			ui._x = 0;
			ui._y = _y;
			ui._w = bookmarksW;
			if(ui.button(arm_Translator.tr("Cloud"),0)) {
				arm_ui_TabBrowser.hpath.text = "cloud";
			}
			if(ui.button(arm_Translator.tr("Disk"),0)) {
				arm_ui_TabBrowser.hpath.text = "C:\\Users";
			}
			let _g = 0;
			let _g1 = arm_Config.raw.bookmarks;
			while(_g < _g1.length) {
				let b = _g1[_g];
				++_g;
				let folder = HxOverrides.substr(b,b.lastIndexOf(arm_sys_Path.sep) + 1,null);
				if(ui.button(folder,0)) {
					arm_ui_TabBrowser.hpath.text = b;
				}
				if(ui.isHovered && ui.inputReleasedR) {
					arm_ui_UIMenu.draw(function(ui) {
						ui.text(folder,2,ui.t.HIGHLIGHT_COL);
						if(ui.button(arm_Translator.tr("Delete"),0)) {
							HxOverrides.remove(arm_Config.raw.bookmarks,b);
							arm_Config.save();
						}
					},2);
				}
			}
			if(ui._y < bottomY) {
				ui._y = bottomY;
			}
		}
	}
}
$hxClasses["arm.ui.TabBrowser"] = arm_ui_TabBrowser;
arm_ui_TabBrowser.__name__ = "arm.ui.TabBrowser";
class arm_ui_TabBrushes {
	static draw() {
		let ui = arm_ui_UISidebar.inst.ui;
		if(ui.tab(arm_ui_UISidebar.inst.htab1,arm_Translator.tr("Brushes"))) {
			ui.beginSticky();
			ui.row([0.25,0.25,0.25]);
			if(ui.button(arm_Translator.tr("New"))) {
				arm_Context.brush = new arm_data_BrushSlot();
				arm_Project.brushes.push(arm_Context.brush);
				arm_node_MakeMaterial.parseBrush();
				arm_ui_UINodes.inst.hwnd.redraws = 2;
			}
			if(ui.button(arm_Translator.tr("Import"))) {
				arm_Project.importBrush();
			}
			if(ui.button(arm_Translator.tr("Nodes"))) {
				arm_ui_UISidebar.inst.showBrushNodes();
			}
			ui.endSticky();
			ui.separator(3,false);
			let slotw = 51 * ui.ops.scaleFactor | 0;
			let num = arm_Config.raw.layout[0] / slotw | 0;
			let _g = 0;
			let _g1 = Math.ceil(arm_Project.brushes.length / num) | 0;
			while(_g < _g1) {
				let row = _g++;
				let _g1 = [];
				let _g2 = 0;
				let _g3 = num * (arm_Config.raw.show_asset_names ? 2 : 1);
				while(_g2 < _g3) {
					++_g2;
					_g1.push(1 / num);
				}
				ui.row(_g1);
				ui._x += 2;
				if(row > 0) {
					ui._y += arm_Config.raw.show_asset_names ? ui.t.ELEMENT_OFFSET * ui.ops.scaleFactor * 10.0 : 6;
				}
				let _g4 = 0;
				while(_g4 < num) {
					let j = _g4++;
					let imgw = 50 * ui.ops.scaleFactor | 0;
					let i = j + row * num;
					if(i >= arm_Project.brushes.length) {
						ui.endElement(imgw);
						if(arm_Config.raw.show_asset_names) {
							ui.endElement(0);
						}
						continue;
					}
					let img = ui.ops.scaleFactor > 1 ? arm_Project.brushes[i].image : arm_Project.brushes[i].imageIcon;
					let imgFull = arm_Project.brushes[i].image;
					if(arm_Context.brush == arm_Project.brushes[i]) {
						let off = row % 2 == 1 ? 1 : 0;
						let w = 50;
						if(arm_Config.raw.window_scale > 1) {
							w = 50 + (arm_Config.raw.window_scale * 2 | 0);
						}
						ui.fill(-1,-2,w + 3,2,ui.t.HIGHLIGHT_COL);
						ui.fill(-1,w - off,w + 3,2 + off,ui.t.HIGHLIGHT_COL);
						ui.fill(-1,-2,2,w + 3,ui.t.HIGHLIGHT_COL);
						ui.fill(w + 1,-2,2,w + 4,ui.t.HIGHLIGHT_COL);
					}
					let uix = ui._x;
					let tile = ui.ops.scaleFactor > 1 ? 100 : 50;
					if((arm_Project.brushes[i].previewReady ? ui.image(img) : ui.image(arm_Res.bundled.h["icons.k"],-1,null,tile * 5,tile,tile,tile)) == 1) {
						if(arm_Context.brush != arm_Project.brushes[i]) {
							arm_Context.selectBrush(i);
						}
						if(kha_Scheduler.time() - arm_Context.selectTime < 0.25) {
							arm_ui_UISidebar.inst.showBrushNodes();
						}
						arm_Context.selectTime = kha_Scheduler.time();
					}
					if(ui.isHovered && ui.inputReleasedR) {
						arm_Context.selectBrush(i);
						arm_ui_UIMenu.draw(function(ui) {
							ui.text(arm_Project.brushes[i].canvas.name,2,ui.t.HIGHLIGHT_COL);
							if(ui.button(arm_Translator.tr("Export"),0)) {
								arm_Context.selectBrush(i);
								arm_ui_BoxExport.showBrush();
							}
							if(ui.button(arm_Translator.tr("Duplicate"),0)) {
								iron_App.notifyOnInit(function() {
									arm_Context.brush = new arm_data_BrushSlot();
									arm_Project.brushes.push(arm_Context.brush);
									let cloned = JSON.parse(JSON.stringify(arm_Project.brushes[i].canvas));
									arm_Context.brush.canvas = cloned;
									arm_Context.setBrush(arm_Context.brush);
									arm_util_RenderUtil.makeBrushPreview();
								});
							}
							if(arm_Project.brushes.length > 1 && ui.button(arm_Translator.tr("Delete"),0)) {
								arm_ui_TabBrushes.deleteBrush(arm_Project.brushes[i]);
							}
						},3 + (arm_Project.brushes.length > 1 ? 1 : 0));
					}
					if(ui.isHovered) {
						if(imgFull == null) {
							iron_App.notifyOnInit(function() {
								let _brush = arm_Context.brush;
								arm_Context.brush = arm_Project.brushes[i];
								arm_node_MakeMaterial.parseBrush();
								arm_util_RenderUtil.makeBrushPreview();
								arm_Context.brush = _brush;
							});
						} else {
							ui.tooltipImage(imgFull);
							ui.tooltip(arm_Project.brushes[i].canvas.name);
						}
					}
					if(arm_Config.raw.show_asset_names) {
						ui._x = uix;
						ui._y += slotw * 0.9;
						ui.text(arm_Project.brushes[i].canvas.name,1);
						if(ui.isHovered) {
							ui.tooltip(arm_Project.brushes[i].canvas.name);
						}
						ui._y -= slotw * 0.9;
						if(i == arm_Project.brushes.length - 1) {
							ui._y += j == num - 1 ? imgw : imgw + ui.t.ELEMENT_H * ui.ops.scaleFactor + ui.t.ELEMENT_OFFSET * ui.ops.scaleFactor;
						}
					}
				}
				ui._y += 6;
			}
			if(ui.inputX > ui._windowX && ui.inputX < ui._windowX + ui._windowW && ui.inputY > ui._windowY && ui.inputY < ui._windowY + ui._windowH && ui.isDeleteDown && arm_Project.brushes.length > 1) {
				ui.isDeleteDown = false;
				arm_ui_TabBrushes.deleteBrush(arm_Context.brush);
			}
		}
	}
	static deleteBrush(b) {
		let i = arm_Project.brushes.indexOf(b);
		arm_Context.selectBrush(i == arm_Project.brushes.length - 1 ? i - 1 : i + 1);
		arm_Project.brushes.splice(i,1);
		arm_ui_UISidebar.inst.hwnd1.redraws = 2;
	}
}
$hxClasses["arm.ui.TabBrushes"] = arm_ui_TabBrushes;
arm_ui_TabBrushes.__name__ = "arm.ui.TabBrushes";
class arm_ui_TabConsole {
	static draw() {
		let ui = arm_ui_UISidebar.inst.ui;
		let title = arm_Console.messageTimer > 0 ? arm_Console.message + "        " : arm_Translator.tr("Console");
		let statush = arm_Config.raw.layout[5];
		if(ui.tab(arm_ui_UIStatus.inst.statustab,title,false,arm_Console.messageTimer > 0 ? arm_Console.messageColor : -1) && statush > 32 * ui.ops.scaleFactor) {
			ui.beginSticky();
			ui.row([0.071428571428571425,0.071428571428571425,0.071428571428571425]);
			if(ui.button(arm_Translator.tr("Clear"))) {
				arm_Console.lastTraces = [];
			}
			if(ui.button(arm_Translator.tr("Export"))) {
				let str = arm_Console.lastTraces.join("\n");
				arm_ui_UIFiles.show("txt",true,false,function(path) {
					let f = arm_ui_UIFiles.filename;
					if(f == "") {
						f = arm_Translator.tr("untitled");
					}
					path = path + arm_sys_Path.sep + f;
					if(!path.endsWith(".txt")) {
						path += ".txt";
					}
					Krom.fileSaveBytes(path,haxe_io_Bytes.ofString(str).b.bufferValue);
				});
			}
			if(ui.button(arm_Translator.tr("Copy"))) {
				Krom.copyToClipboard(arm_Console.lastTraces.join("\n"));
			}
			ui.endSticky();
			let _g = 0;
			let _g1 = arm_Console.lastTraces;
			while(_g < _g1.length) ui.text(_g1[_g++]);
		}
	}
}
$hxClasses["arm.ui.TabConsole"] = arm_ui_TabConsole;
arm_ui_TabConsole.__name__ = "arm.ui.TabConsole";
class arm_ui_TabFonts {
	static draw() {
		let ui = arm_ui_UISidebar.inst.ui;
		let statush = arm_Config.raw.layout[5];
		if(ui.tab(arm_ui_UIStatus.inst.statustab,arm_Translator.tr("Fonts")) && statush > 32 * ui.ops.scaleFactor) {
			ui.beginSticky();
			ui.row([0.071428571428571425,0.071428571428571425]);
			if(ui.button(arm_Translator.tr("Import"))) {
				arm_Project.importAsset("ttf,ttc,otf");
			}
			if(ui.isHovered) {
				ui.tooltip(arm_Translator.tr("Import font file"));
			}
			if(ui.button(arm_Translator.tr("2D View"))) {
				arm_ui_UISidebar.inst.show2DView(2);
			}
			ui.endSticky();
			ui.separator(3,false);
			let statusw = kha_System.windowWidth() - arm_ui_UIToolbar.inst.toolbarw;
			let slotw = 51 * ui.ops.scaleFactor | 0;
			let num = (statusw - arm_Config.raw.layout[0]) / slotw | 0;
			let _g = 0;
			let _g1 = Math.ceil(arm_Project.fonts.length / num) | 0;
			while(_g < _g1) {
				let row = _g++;
				let _g1 = [];
				let _g2 = 0;
				let _g3 = num * (arm_Config.raw.show_asset_names ? 2 : 1);
				while(_g2 < _g3) {
					++_g2;
					_g1.push(1 / num);
				}
				ui.row(_g1);
				ui._x += 2;
				if(row > 0) {
					ui._y += arm_Config.raw.show_asset_names ? ui.t.ELEMENT_OFFSET * ui.ops.scaleFactor * 10.0 : 6;
				}
				let _g4 = 0;
				while(_g4 < num) {
					let j = _g4++;
					let imgw = 50 * ui.ops.scaleFactor | 0;
					let i = j + row * num;
					if(i >= arm_Project.fonts.length) {
						ui.endElement(imgw);
						if(arm_Config.raw.show_asset_names) {
							ui.endElement(0);
						}
						continue;
					}
					let img = arm_Project.fonts[i].image;
					if(arm_Context.font == arm_Project.fonts[i]) {
						let off = row % 2 == 1 ? 1 : 0;
						let w = 50;
						if(arm_Config.raw.window_scale > 1) {
							w = 50 + (arm_Config.raw.window_scale * 2 | 0);
						}
						ui.fill(-1,-2,w + 3,2,ui.t.HIGHLIGHT_COL);
						ui.fill(-1,w - off,w + 3,2 + off,ui.t.HIGHLIGHT_COL);
						ui.fill(-1,-2,2,w + 3,ui.t.HIGHLIGHT_COL);
						ui.fill(w + 1,-2,2,w + 4,ui.t.HIGHLIGHT_COL);
					}
					let uix = ui._x;
					let tile = ui.ops.scaleFactor > 1 ? 100 : 50;
					let state = 0;
					if(arm_Project.fonts[i].previewReady) {
						state = ui.image(img);
					} else {
						state = ui.image(arm_Res.bundled.h["icons.k"],-1,null,tile * 6,tile,tile,tile);
					}
					if(state == 1) {
						if(arm_Context.font != arm_Project.fonts[i]) {
							iron_App.notifyOnInit(function() {
								arm_Context.selectFont(i);
							});
						}
						if(kha_Scheduler.time() - arm_Context.selectTime < 0.25) {
							arm_ui_UISidebar.inst.show2DView(2);
						}
						arm_Context.selectTime = kha_Scheduler.time();
					}
					if(ui.isHovered && ui.inputReleasedR) {
						arm_Context.selectFont(i);
						let fontName = arm_Project.fonts[i].name;
						arm_ui_UIMenu.draw(function(ui) {
							ui.text(fontName,2,ui.t.HIGHLIGHT_COL);
							if(arm_Project.fonts.length > 1 && ui.button(arm_Translator.tr("Delete"),0) && arm_Project.fonts[i].file != "") {
								arm_ui_TabFonts.deleteFont(arm_Project.fonts[i]);
							}
						},1 + (arm_Project.fonts.length > 1 ? 1 : 0));
					}
					if(ui.isHovered) {
						if(img == null) {
							iron_App.notifyOnInit(function() {
								let _font = arm_Context.font;
								arm_Context.font = arm_Project.fonts[i];
								arm_util_RenderUtil.makeFontPreview();
								arm_Context.font = _font;
							});
						} else {
							ui.tooltipImage(img);
							ui.tooltip(arm_Project.fonts[i].name);
						}
					}
					if(arm_Config.raw.show_asset_names) {
						ui._x = uix;
						ui._y += slotw * 0.9;
						ui.text(arm_Project.fonts[i].name,1);
						if(ui.isHovered) {
							ui.tooltip(arm_Project.fonts[i].name);
						}
						ui._y -= slotw * 0.9;
						if(i == arm_Project.fonts.length - 1) {
							ui._y += j == num - 1 ? imgw : imgw + ui.t.ELEMENT_H * ui.ops.scaleFactor + ui.t.ELEMENT_OFFSET * ui.ops.scaleFactor;
						}
					}
				}
				ui._y += 6;
			}
			if(ui.inputX > ui._windowX && ui.inputX < ui._windowX + ui._windowW && ui.inputY > ui._windowY && ui.inputY < ui._windowY + ui._windowH && ui.isDeleteDown && arm_Project.fonts.length > 1 && arm_Context.font.file != "") {
				ui.isDeleteDown = false;
				arm_ui_TabFonts.deleteFont(arm_Context.font);
			}
		}
	}
	static deleteFont(font) {
		let i = arm_Project.fonts.indexOf(font);
		iron_App.notifyOnInit(function() {
			arm_Context.selectFont(i == arm_Project.fonts.length - 1 ? i - 1 : i + 1);
			iron_data_Data.deleteFont(arm_Project.fonts[i].file);
			arm_Project.fonts.splice(i,1);
		});
		arm_ui_UIStatus.inst.statusHandle.redraws = 2;
	}
}
$hxClasses["arm.ui.TabFonts"] = arm_ui_TabFonts;
arm_ui_TabFonts.__name__ = "arm.ui.TabFonts";
class arm_ui_TabHistory {
	static draw() {
		let ui = arm_ui_UISidebar.inst.ui;
		if(ui.tab(arm_ui_UISidebar.inst.htab0,arm_Translator.tr("History"))) {
			let _g = 0;
			let _g1 = arm_History.steps.length;
			while(_g < _g1) {
				let i = _g++;
				let active = arm_History.steps.length - 1 - arm_History.redos;
				if(i == active) {
					ui.fill(0,0,ui._windowW,ui.t.ELEMENT_H,ui.t.HIGHLIGHT_COL);
				}
				ui.text(arm_History.steps[i].name);
				if(ui.isReleased) {
					let diff = i - active;
					while(diff > 0) {
						--diff;
						arm_History.redo();
					}
					while(diff < 0) {
						++diff;
						arm_History.undo();
					}
				}
				ui.fill(0,0,ui._windowW / ui.ops.scaleFactor - 2,ui.ops.scaleFactor,ui.t.SEPARATOR_COL);
			}
		}
	}
}
$hxClasses["arm.ui.TabHistory"] = arm_ui_TabHistory;
arm_ui_TabHistory.__name__ = "arm.ui.TabHistory";
class arm_ui_TabLayers {
	static draw() {
		let ui = arm_ui_UISidebar.inst.ui;
		if(ui.tab(arm_ui_UISidebar.inst.htab0,arm_Translator.tr("Layers"))) {
			ui.beginSticky();
			ui.row([0.25,0.25,0.5]);
			if(ui.button(arm_Translator.tr("New"))) {
				arm_ui_UIMenu.draw(function(ui) {
					let l = arm_Context.layer;
					ui.text("New",2,ui.t.HIGHLIGHT_COL);
					if(ui.button(arm_Translator.tr("Paint Layer"),0)) {
						arm_Layers.newLayer();
						arm_History.newLayer();
					}
					if(ui.button(arm_Translator.tr("Fill Layer"),0)) {
						arm_Layers.createFillLayer(0);
					}
					if(ui.button(arm_Translator.tr("Decal Layer"),0)) {
						arm_Layers.createFillLayer(2);
					}
					if(ui.button(arm_Translator.tr("Black Mask"),0)) {
						if(l.isMask()) {
							arm_Context.setLayer(l.parent);
						}
						let m = arm_Layers.newMask(false,arm_Context.layer);
						arm_App.notifyOnNextFrame(function() {
							m.clear(0);
						});
						arm_Context.layerPreviewDirty = true;
						arm_History.newLayer();
					}
					if(ui.button(arm_Translator.tr("White Mask"),0)) {
						if(l.isMask()) {
							arm_Context.setLayer(l.parent);
						}
						let m = arm_Layers.newMask(false,arm_Context.layer);
						arm_App.notifyOnNextFrame(function() {
							m.clear(-1);
						});
						arm_Context.layerPreviewDirty = true;
						arm_History.newLayer();
					}
					if(ui.button(arm_Translator.tr("Fill Mask"),0)) {
						if(l.isMask()) {
							arm_Context.setLayer(l.parent);
						}
						let m = arm_Layers.newMask(false,arm_Context.layer);
						iron_App.notifyOnInit(function() {
							m.toFillLayer();
						});
						arm_Context.layerPreviewDirty = true;
						arm_History.newLayer();
					}
					if(ui.button(arm_Translator.tr("Group"),0) && !arm_Context.layer.isGroup() && arm_Context.layer.parent == null) {
						if(l.parent != null || l.isGroup()) {
							return;
						}
						let pointers = arm_ui_TabLayers.initLayerMap();
						let group = arm_Layers.newGroup();
						arm_Context.setLayer(l);
						HxOverrides.remove(arm_Project.layers,group);
						arm_Project.layers.splice(arm_Project.layers.indexOf(l) + 1,0,group);
						l.parent = group;
						let _g = 0;
						let _g1 = arm_Project.materials;
						while(_g < _g1.length) arm_ui_TabLayers.remapLayerPointers(_g1[_g++].canvas.nodes,arm_ui_TabLayers.fillLayerMap(pointers));
						arm_Context.setLayer(group);
					}
				},8);
			}
			if(ui.button(arm_Translator.tr("2D View"))) {
				arm_ui_UISidebar.inst.show2DView(0);
			} else if(ui.isHovered) {
				ui.tooltip(arm_Translator.tr("Show 2D View") + (" (" + arm_Config.keymap.toggle_2d_view + ")"));
			}
			let ar = [arm_Translator.tr("All")];
			let _g = 0;
			let _g1 = arm_Project.paintObjects;
			while(_g < _g1.length) ar.push(_g1[_g++].name);
			let atlases = arm_Project.getUsedAtlases();
			if(atlases != null) {
				let _g = 0;
				while(_g < atlases.length) ar.push(atlases[_g++]);
			}
			let filterHandle = zui_Handle.global.nest(147,null);
			filterHandle.position = arm_Context.layerFilter;
			arm_Context.layerFilter = ui.combo(filterHandle,ar,arm_Translator.tr("Filter"),false,0);
			if(filterHandle.changed) {
				let _g = 0;
				let _g1 = arm_Project.paintObjects;
				while(_g < _g1.length) {
					let p = _g1[_g];
					++_g;
					p.visible = arm_Context.layerFilter == 0 || p.name == ar[arm_Context.layerFilter] || arm_Project.isAtlasObject(p);
				}
				if(arm_Context.layerFilter == 0 && arm_Context.mergedObjectIsAtlas) {
					arm_util_MeshUtil.mergeMesh();
				} else if(arm_Context.layerFilter > arm_Project.paintObjects.length) {
					let visibles = [];
					let _g = 0;
					let _g1 = arm_Project.paintObjects;
					while(_g < _g1.length) {
						let p = _g1[_g];
						++_g;
						if(p.visible) {
							visibles.push(p);
						}
					}
					arm_util_MeshUtil.mergeMesh(visibles);
				}
				arm_Layers.setObjectMask();
				arm_util_UVUtil.uvmapCached = false;
				arm_Context.ddirty = 2;
			}
			ui.endSticky();
			ui._y += 2;
			let step = ui.t.ELEMENT_H * 2;
			let _g2 = 0;
			let _g3 = (ui._windowH - arm_ui_UISidebar.inst.hwnd0.scrollOffset) / step | 0;
			while(_g2 < _g3) {
				let i = _g2++;
				if(i % 2 == 0) {
					ui.fill(0,i * step,ui._w / ui.ops.scaleFactor - 2,step,ui.t.WINDOW_BG_COL - 263172);
				}
			}
			let _g4 = 0;
			let _g5 = arm_Project.layers.length;
			while(_g4 < _g5) {
				let i = _g4++;
				if(i >= arm_Project.layers.length) {
					break;
				}
				let j = arm_Project.layers.length - 1 - i;
				arm_ui_TabLayers.drawLayerSlot(arm_Project.layers[j],j);
			}
		}
	}
	static remapLayerPointers(nodes,pointerMap) {
		let _g = 0;
		while(_g < nodes.length) {
			let n = nodes[_g];
			++_g;
			if(n.type == "LAYER" || n.type == "LAYER_MASK") {
				let i = n.buttons[0].default_value;
				if(pointerMap.h.hasOwnProperty(i)) {
					n.buttons[0].default_value = pointerMap.h[i];
				}
			}
		}
	}
	static initLayerMap() {
		let res = new haxe_ds_ObjectMap();
		let _g = 0;
		let _g1 = arm_Project.layers.length;
		while(_g < _g1) {
			let i = _g++;
			res.set(arm_Project.layers[i],i);
		}
		return res;
	}
	static fillLayerMap(map) {
		let res = new haxe_ds_IntMap();
		let l = map.keys();
		while(l.hasNext()) {
			let l1 = l.next();
			res.h[map.h[l1.__id__]] = arm_Project.layers.indexOf(l1) > -1 ? arm_Project.layers.indexOf(l1) : 9999;
		}
		return res;
	}
	static setDragLayer(layer,offX,offY) {
		arm_App.dragOffX = offX;
		arm_App.dragOffY = offY;
		arm_App.dragLayer = layer;
		arm_Context.dragDestination = arm_Project.layers.indexOf(layer);
	}
	static drawLayerSlot(l,i) {
		let ui = arm_ui_UISidebar.inst.ui;
		if(arm_Context.layerFilter > 0 && l.getObjectMask() > 0 && l.getObjectMask() != arm_Context.layerFilter) {
			return;
		}
		if(l.parent != null && !l.parent.show_panel) {
			return;
		}
		if(l.parent != null && l.parent.parent != null && !l.parent.parent.show_panel) {
			return;
		}
		let step = ui.t.ELEMENT_H;
		let checkw = ui._windowW / 100 * 8 / ui.ops.scaleFactor;
		let mouse = iron_system_Input.getMouse();
		let my = mouse.y;
		if(arm_App.isDragging && arm_App.dragLayer != null && (mouse.x > arm_ui_UISidebar.inst.tabx && my < arm_Config.raw.layout[1])) {
			if(my > ui._y + step && my < ui._y + step * 3) {
				let down = arm_Project.layers.indexOf(arm_App.dragLayer) >= i;
				arm_Context.dragDestination = down ? i : i - 1;
				let ls = arm_Project.layers;
				let dest = arm_Context.dragDestination;
				let toGroup = down ? dest > 0 && ls[dest - 1].parent != null && ls[dest - 1].parent.show_panel : dest < ls.length && ls[dest].parent != null && ls[dest].parent.show_panel;
				if(!(arm_App.dragLayer.isGroup() && toGroup)) {
					if(arm_Context.layer.canMove(arm_Context.dragDestination)) {
						ui.fill(checkw,step * 2,ui._windowW / ui.ops.scaleFactor - 2 - checkw,2 * ui.ops.scaleFactor,ui.t.HIGHLIGHT_COL);
					}
				}
			} else if(i == arm_Project.layers.length - 1 && my < ui._y + step) {
				arm_Context.dragDestination = arm_Project.layers.length - 1;
				if(arm_Context.layer.canMove(arm_Context.dragDestination)) {
					ui.fill(checkw,0,ui._windowW / ui.ops.scaleFactor - 2 - checkw,2 * ui.ops.scaleFactor,ui.t.HIGHLIGHT_COL);
				}
			}
		}
		let hasPanel = l.isGroup() || l.isLayer() && l.getMasks(false) != null;
		if(hasPanel) {
			ui.row([0.08,0.16,0.36,0.3,0.1]);
		} else {
			ui.row([0.08,0.16,0.36,0.3]);
		}
		let icons = arm_Res.bundled.h["icons.k"];
		let r = arm_Res.tile18(icons,l.visible ? 0 : 1,0);
		let center = step / 2 * ui.ops.scaleFactor;
		ui._x += 2;
		ui._y = (ui._y += 3) + center;
		let col = ui.t.ACCENT_SELECT_COL;
		if(l.parent != null && (!l.parent.visible || l.parent.parent != null && !l.parent.parent.visible)) {
			col -= -1728053248;
		}
		if(ui.image(icons,col,null,r.x,r.y,r.w,r.h) == 3) {
			l.visible = !l.visible;
			arm_ui_UIView2D.inst.hwnd.redraws = 2;
			arm_node_MakeMaterial.parseMeshMaterial();
		}
		ui._x -= 2;
		ui._y = (ui._y -= 3) - center;
		let contextMenu = false;
		let uix = ui._x;
		let uiy = ui._y;
		ui._x += 2;
		ui._y += 3;
		if(l.parent != null) {
			ui._x += 10 * ui.ops.scaleFactor;
			if(l.parent.parent != null) {
				ui._x += 10 * ui.ops.scaleFactor;
			}
		}
		let state = 0;
		let iconH = (ui.t.ELEMENT_H * ui.ops.scaleFactor - 3) * 2;
		if(!l.isGroup()) {
			let icon = l.fill_layer == null ? l.texpaint_preview : l.fill_layer.imageIcon;
			if(l.fill_layer == null) {
				let r = arm_Res.tile50(icons,4,1);
				let _x = ui._x;
				let _y = ui._y;
				let _w = ui._w;
				ui.image(icons,-1,iconH,r.x,r.y,r.w,r.h);
				ui.curRatio--;
				ui._x = _x;
				ui._y = _y;
				ui._w = _w;
			}
			if(l.fill_layer == null && l.isMask()) {
				ui.g.set_pipeline(arm_ui_UIView2D.pipe);
				ui.currentWindow.texture.get_g4().setInt(arm_ui_UIView2D.channelLocation,1);
			}
			state = ui.image(icon,-1,iconH);
			if(l.fill_layer == null && l.isMask()) {
				ui.g.set_pipeline(null);
			}
		} else {
			let folder = l.show_panel ? arm_Res.tile50(icons,8,1) : arm_Res.tile50(icons,2,1);
			state = ui.image(icons,ui.t.LABEL_COL - 2105376,iconH,folder.x,folder.y,folder.w,folder.h);
		}
		ui._x -= 2;
		ui._y -= 3;
		if(ui.isHovered && l.texpaint_preview != null) {
			if(l.isMask()) {
				arm_ui_TabLayers.makeMaskPreviewRgba32(l);
				ui.tooltipImage(arm_Context.maskPreviewRgba32);
			} else {
				ui.tooltipImage(l.texpaint_preview);
			}
			if(i < 9) {
				ui.tooltip(l.name + " - (" + arm_Config.keymap.select_layer + " " + (i + 1) + ")");
			} else {
				ui.tooltip(l.name);
			}
		}
		if(ui.isHovered && ui.inputReleasedR) {
			arm_Context.setLayer(l);
			contextMenu = true;
		}
		if(state == 1) {
			arm_Context.setLayer(l);
			let mouse = iron_system_Input.getMouse();
			arm_ui_TabLayers.setDragLayer(arm_Context.layer,-(mouse.x - uix - ui._windowX - 3),-(mouse.y - uiy - ui._windowY + 1));
		} else if(state == 3) {
			if(kha_Scheduler.time() - arm_Context.selectTime < 0.2) {
				arm_ui_UISidebar.inst.show2DView(0);
			}
			if(kha_Scheduler.time() - arm_Context.selectTime > 0.2) {
				arm_Context.selectTime = kha_Scheduler.time();
			}
			if(l.fill_layer != null) {
				arm_Context.setMaterial(l.fill_layer);
			}
		}
		ui._y += center;
		if(arm_ui_TabLayers.layerNameEdit == l.id) {
			arm_ui_TabLayers.layerNameHandle.text = l.name;
			l.name = ui.textInput(arm_ui_TabLayers.layerNameHandle);
			if(ui.textSelectedHandle != arm_ui_TabLayers.layerNameHandle) {
				arm_ui_TabLayers.layerNameEdit = -1;
			}
		} else {
			if(ui.enabled && ui.inputEnabled && ui.inputX > ui._windowX + ui._x && ui.inputX < ui._windowX + ui._x + ui._w && ui.inputY > ui._windowY + ui._y - center && ui.inputY < ui._windowY + ui._y - center + step * ui.ops.scaleFactor * 2) {
				if(ui.inputStarted) {
					arm_Context.setLayer(l);
					let mouse = iron_system_Input.getMouse();
					arm_ui_TabLayers.setDragLayer(arm_Context.layer,-(mouse.x - uix - ui._windowX - 3),-(mouse.y - uiy - ui._windowY + 1));
				} else if(ui.inputReleased) {
					if(kha_Scheduler.time() - arm_Context.selectTime > 0.2) {
						arm_Context.selectTime = kha_Scheduler.time();
					}
				} else if(ui.inputReleasedR) {
					arm_Context.setLayer(l);
					contextMenu = true;
				}
			}
			if(ui.text(l.name) == 3) {
				let td = kha_Scheduler.time() - arm_Context.selectTime;
				if(td < 0.2 && td > 0.0) {
					arm_ui_TabLayers.layerNameEdit = l.id;
					arm_ui_TabLayers.layerNameHandle.text = l.name;
					ui.startTextEdit(arm_ui_TabLayers.layerNameHandle);
				}
			}
			if(ui.inputX > ui._windowX && ui.inputX < ui._windowX + ui._windowW && ui.inputY > ui._windowY && ui.inputY < ui._windowY + ui._windowH && ui.isDeleteDown && arm_ui_TabLayers.canDelete(arm_Context.layer)) {
				ui.isDeleteDown = false;
				arm_ui_TabLayers.deleteLayer(arm_Context.layer);
			}
		}
		ui._y -= center;
		if(l.parent != null) {
			ui._x -= 10 * ui.ops.scaleFactor;
			if(l.parent.parent != null) {
				ui._x -= 10 * ui.ops.scaleFactor;
			}
		}
		if(contextMenu) {
			arm_ui_TabLayers.drawLayerContextMenu(l);
		}
		if(l.isGroup()) {
			ui.endElement();
		} else {
			if(l.isMask()) {
				ui._y += center;
			}
			let blendingHandle = zui_Handle.global.nest(164,null).nest(l.id);
			blendingHandle.position = l.blending;
			ui.combo(blendingHandle,[arm_Translator.tr("Mix"),arm_Translator.tr("Darken"),arm_Translator.tr("Multiply"),arm_Translator.tr("Burn"),arm_Translator.tr("Lighten"),arm_Translator.tr("Screen"),arm_Translator.tr("Dodge"),arm_Translator.tr("Add"),arm_Translator.tr("Overlay"),arm_Translator.tr("Soft Light"),arm_Translator.tr("Linear Light"),arm_Translator.tr("Difference"),arm_Translator.tr("Subtract"),arm_Translator.tr("Divide"),arm_Translator.tr("Hue"),arm_Translator.tr("Saturation"),arm_Translator.tr("Color"),arm_Translator.tr("Value")],arm_Translator.tr("Blending"));
			if(blendingHandle.changed) {
				arm_Context.setLayer(l);
				arm_History.layerBlending();
				l.blending = blendingHandle.position;
				arm_node_MakeMaterial.parseMeshMaterial();
			}
			if(l.isMask()) {
				ui._y -= center;
			}
		}
		if(hasPanel) {
			ui._y += center;
			let layerPanel = zui_Handle.global.nest(165,null).nest(l.id);
			layerPanel.selected = l.show_panel;
			l.show_panel = ui.panel(layerPanel,"",true,false,false);
			ui._y -= center;
		}
		if(l.isGroup() || l.isMask()) {
			ui._y -= ui.t.ELEMENT_OFFSET * ui.ops.scaleFactor;
			ui.endElement();
		} else {
			ui._y -= ui.t.ELEMENT_OFFSET * ui.ops.scaleFactor;
			ui.row([0.08,0.16,0.36,0.3,0.1]);
			ui.endElement();
			ui.endElement();
			ui.endElement();
			let ar = [arm_Translator.tr("Shared")];
			let _g = 0;
			let _g1 = arm_Project.paintObjects;
			while(_g < _g1.length) ar.push(_g1[_g++].name);
			let atlases = arm_Project.getUsedAtlases();
			if(atlases != null) {
				let _g = 0;
				while(_g < atlases.length) ar.push(atlases[_g++]);
			}
			let objectHandle = zui_Handle.global.nest(166,null).nest(l.id);
			objectHandle.position = l.objectMask;
			let tmp = arm_Translator.tr("Object");
			l.objectMask = ui.combo(objectHandle,ar,tmp,false,0);
			if(objectHandle.changed) {
				arm_Context.setLayer(l);
				arm_node_MakeMaterial.parseMeshMaterial();
				if(l.fill_layer != null) {
					iron_App.notifyOnInit(function() {
						arm_Context.material = l.fill_layer;
						l.clear();
						arm_Layers.updateFillLayers();
					});
				} else {
					arm_Layers.setObjectMask();
				}
			}
			ui.endElement();
		}
		ui._y -= ui.t.ELEMENT_OFFSET * ui.ops.scaleFactor;
		ui.fill(0,0,ui._w / ui.ops.scaleFactor - 2,ui.ops.scaleFactor,ui.t.SEPARATOR_COL);
		if(arm_Context.layer == l) {
			ui.rect(1,-step * 2 - 1,ui._w / ui.ops.scaleFactor - 2,step * 2 + 1,ui.t.HIGHLIGHT_COL,2);
		}
	}
	static drawLayerContextMenu(l) {
		let add = 0;
		let li = arm_Project.layers.indexOf(l);
		let canMergeDown = li > 0 && (l.isGroup() || l.isLayer() || l.isMask() && arm_Project.layers[li - 1].isMask());
		if(l.isLayer() && l.hasMasks() && li == l.getMasks().length) {
			canMergeDown = false;
		}
		let firstGroup = true;
		let _g = 0;
		let _g1 = li - 1;
		while(_g < _g1) {
			let i = _g++;
			if(!arm_Project.layers[i].isMask() && arm_Project.layers[i].parent != l) {
				firstGroup = false;
			}
		}
		if(l.isGroup() && firstGroup) {
			canMergeDown = false;
		}
		if(l.fill_layer == null) {
			add = 1;
		}
		if(l.fill_layer != null && !l.isMask()) {
			add += 3;
		}
		if(l.fill_layer != null && l.isMask()) {
			add += 2;
		}
		if(l.isMask()) {
			add += 2;
		}
		arm_ui_UIMenu.draw(function(ui) {
			ui.text(l.name,2,ui.t.HIGHLIGHT_COL);
			if(ui.button(arm_Translator.tr("Export"),0)) {
				if(l.isMask()) {
					arm_ui_UIFiles.show("png",true,false,function(path) {
						let f = arm_ui_UIFiles.filename;
						if(f == "") {
							f = arm_Translator.tr("untitled");
						}
						if(!f.endsWith(".png")) {
							f += ".png";
						}
						Krom.writePng(path + arm_sys_Path.sep + f,l.texpaint.getPixels().b.bufferValue,l.texpaint.get_width(),l.texpaint.get_height(),3);
					});
				} else {
					arm_Context.layersExport = 1;
					arm_ui_BoxExport.showTextures();
				}
			}
			let toFillString = l.isLayer() ? arm_Translator.tr("To Fill Layer") : arm_Translator.tr("To Fill Mask");
			let toPaintString = l.isLayer() ? arm_Translator.tr("To Paint Layer") : arm_Translator.tr("To Paint Mask");
			if(!l.isGroup() && l.fill_layer == null && ui.button(toFillString,0)) {
				iron_App.notifyOnInit(function() {
					arm_History.toFillLayer();
					l.toFillLayer();
				});
			}
			if(!l.isGroup() && l.fill_layer != null && ui.button(toPaintString,0)) {
				iron_App.notifyOnInit(function() {
					arm_History.toPaintLayer();
					l.toPaintLayer();
				});
			}
			ui.enabled = arm_ui_TabLayers.canDelete(l);
			if(ui.button(arm_Translator.tr("Delete"),0)) {
				arm_ui_TabLayers.deleteLayer(l);
			}
			ui.enabled = true;
			if(l.fill_layer == null && ui.button(arm_Translator.tr("Clear"),0)) {
				arm_Context.setLayer(l);
				iron_App.notifyOnInit(function() {
					if(!l.isGroup()) {
						arm_History.clearLayer();
						l.clear();
					} else {
						let _g = 0;
						let _g1 = l.getChildren();
						while(_g < _g1.length) {
							let c = _g1[_g];
							++_g;
							arm_Context.layer = c;
							arm_History.clearLayer();
							c.clear();
						}
						arm_Context.layersPreviewDirty = true;
						arm_Context.layer = l;
					}
				});
			}
			if(l.isMask() && l.fill_layer == null && ui.button(arm_Translator.tr("Invert"),0)) {
				iron_App.notifyOnInit(function() {
					l.invertMask();
				});
			}
			if(l.isMask() && ui.button(arm_Translator.tr("Apply"),0)) {
				iron_App.notifyOnInit(function() {
					arm_Context.setLayer(l);
					arm_History.applyMask();
					l.applyMask();
					arm_Context.setLayer(l.parent);
					arm_node_MakeMaterial.parseMeshMaterial();
					arm_Context.layersPreviewDirty = true;
				});
			}
			if(l.isGroup() && ui.button(arm_Translator.tr("Merge Group"),0)) {
				iron_App.notifyOnInit(function() {
					let children = l.getChildren();
					if(children.length == 1 && children[0].hasMasks()) {
						arm_Layers.applyMasks(children[0]);
					}
					let _g = 0;
					let _g1 = children.length - 1;
					while(_g < _g1) {
						arm_Context.setLayer(children[children.length - 1 - _g++]);
						arm_History.mergeLayers();
						arm_Layers.mergeDown();
					}
					children[0].parent = null;
					children[0].name = l.name;
					if(children[0].fill_layer != null) {
						children[0].toPaintLayer();
					}
					l.delete();
				});
			}
			ui.enabled = canMergeDown;
			if(ui.button(arm_Translator.tr("Merge Down"),0)) {
				iron_App.notifyOnInit(function() {
					arm_Context.setLayer(l);
					arm_History.mergeLayers();
					arm_Layers.mergeDown();
					if(arm_Context.layer.fill_layer != null) {
						arm_Context.layer.toPaintLayer();
					}
				});
			}
			ui.enabled = true;
			if(ui.button(arm_Translator.tr("Duplicate"),0)) {
				iron_App.notifyOnInit(function() {
					if(!l.isGroup()) {
						let masks = l.getMasks();
						arm_Context.setLayer(l);
						arm_History.duplicateLayer();
						l = l.duplicate();
						arm_Context.setLayer(l);
						if(masks != null) {
							let _g = 0;
							while(_g < masks.length) {
								let m = masks[_g];
								++_g;
								arm_Context.setLayer(m);
								arm_History.duplicateLayer();
								m = m.duplicate();
								m.parent = l;
								HxOverrides.remove(arm_Project.layers,m);
								arm_Project.layers.splice(arm_Project.layers.indexOf(l),0,m);
							}
						}
					} else {
						let group = arm_Layers.newGroup();
						HxOverrides.remove(arm_Project.layers,group);
						arm_Project.layers.splice(arm_Project.layers.indexOf(l) + 1,0,group);
						let _g = 0;
						let _g1 = l.getChildren();
						while(_g < _g1.length) {
							let c = _g1[_g];
							++_g;
							let masks = c.getMasks();
							arm_Context.setLayer(c);
							arm_History.duplicateLayer();
							c = c.duplicate();
							c.parent = group;
							HxOverrides.remove(arm_Project.layers,c);
							arm_Project.layers.splice(arm_Project.layers.indexOf(group),0,c);
							if(masks != null) {
								let _g = 0;
								while(_g < masks.length) {
									let m = masks[_g];
									++_g;
									arm_Context.setLayer(m);
									arm_History.duplicateLayer();
									m = m.duplicate();
									m.parent = c;
									HxOverrides.remove(arm_Project.layers,m);
									arm_Project.layers.splice(arm_Project.layers.indexOf(c),0,m);
								}
							}
						}
						arm_Context.setLayer(group);
					}
				});
			}
			ui.row([0.7,0.3]);
			let layerOpacHandle = zui_Handle.global.nest(149,null).nest(l.id);
			layerOpacHandle.value = l.maskOpacity;
			ui.slider(layerOpacHandle,"",0.0,1.0,true);
			if(layerOpacHandle.changed) {
				if(ui.inputStarted) {
					arm_History.layerOpacity();
				}
				l.maskOpacity = layerOpacHandle.value;
				arm_node_MakeMaterial.parseMeshMaterial();
				arm_ui_UIMenu.keepOpen = true;
			}
			ui.text(arm_Translator.tr("Opacity"));
			if(!l.isGroup()) {
				ui.row([0.7,0.3]);
				let resHandleChangedLast = arm_App.resHandle.changed;
				let ar = ["128","256","512","1K","2K","4K","8K","16K"];
				arm_App.resHandle.value = arm_App.resHandle.position;
				let tmp = ui.slider(arm_App.resHandle,ar[arm_App.resHandle.position],0,ar.length - 1,false,1,false,0,false) | 0;
				arm_App.resHandle.position = tmp;
				if(arm_App.resHandle.changed) {
					arm_ui_UIMenu.keepOpen = true;
				}
				if(resHandleChangedLast && !arm_App.resHandle.changed) {
					iron_App.notifyOnInit(arm_Layers.resizeLayers);
					arm_util_UVUtil.uvmap = null;
					arm_util_UVUtil.uvmapCached = false;
					arm_util_UVUtil.trianglemap = null;
					arm_util_UVUtil.trianglemapCached = false;
					arm_util_UVUtil.dilatemapCached = false;
				}
				ui.text(arm_Translator.tr("Res"));
				ui.row([0.7,0.3]);
				zui_Ext.inlineRadio(ui,arm_App.bitsHandle,["8bit","16bit","32bit"]);
				if(arm_App.bitsHandle.changed) {
					iron_App.notifyOnInit(arm_Layers.setLayerBits);
					arm_ui_UIMenu.keepOpen = true;
				}
				ui.text(arm_Translator.tr("Color"));
			}
			if(l.fill_layer != null) {
				ui.row([0.7,0.3]);
				let scaleHandle = zui_Handle.global.nest(150,null).nest(l.id);
				scaleHandle.value = l.scale;
				l.scale = ui.slider(scaleHandle,"",0.0,5.0,true);
				if(scaleHandle.changed) {
					arm_Context.setMaterial(l.fill_layer);
					arm_Context.setLayer(l);
					iron_App.notifyOnInit(function() {
						arm_Layers.updateFillLayers();
					});
					arm_ui_UIMenu.keepOpen = true;
				}
				ui.text(arm_Translator.tr("UV Scale"));
				ui.row([0.7,0.3]);
				let angleHandle = zui_Handle.global.nest(151,null).nest(l.id);
				angleHandle.value = l.angle;
				l.angle = ui.slider(angleHandle,"",0.0,360,true,1);
				if(angleHandle.changed) {
					arm_Context.setMaterial(l.fill_layer);
					arm_Context.setLayer(l);
					arm_node_MakeMaterial.parsePaintMaterial();
					iron_App.notifyOnInit(function() {
						arm_Layers.updateFillLayers();
					});
					arm_ui_UIMenu.keepOpen = true;
				}
				ui.text(arm_Translator.tr("Angle"));
				ui.row([0.7,0.3]);
				let uvTypeHandle = zui_Handle.global.nest(152,null).nest(l.id);
				uvTypeHandle.position = l.uvType;
				let tmp = arm_Translator.tr("UV Map");
				let tmp1 = arm_Translator.tr("Triplanar");
				let tmp2 = arm_Translator.tr("Project");
				l.uvType = zui_Ext.inlineRadio(ui,uvTypeHandle,[tmp,tmp1,tmp2],0);
				if(uvTypeHandle.changed) {
					arm_Context.setMaterial(l.fill_layer);
					arm_Context.setLayer(l);
					arm_node_MakeMaterial.parsePaintMaterial();
					iron_App.notifyOnInit(function() {
						arm_Layers.updateFillLayers();
					});
					arm_ui_UIMenu.keepOpen = true;
				}
				ui.text(arm_Translator.tr("TexCoord"));
			}
			if(!l.isGroup()) {
				let baseHandle = zui_Handle.global.nest(153,null).nest(l.id);
				let opacHandle = zui_Handle.global.nest(154,null).nest(l.id);
				let norHandle = zui_Handle.global.nest(155,null).nest(l.id);
				let norBlendHandle = zui_Handle.global.nest(156,null).nest(l.id);
				let occHandle = zui_Handle.global.nest(157,null).nest(l.id);
				let roughHandle = zui_Handle.global.nest(158,null).nest(l.id);
				let metHandle = zui_Handle.global.nest(159,null).nest(l.id);
				let heightHandle = zui_Handle.global.nest(160,null).nest(l.id);
				let heightBlendHandle = zui_Handle.global.nest(161,null).nest(l.id);
				let emisHandle = zui_Handle.global.nest(162,null).nest(l.id);
				let subsHandle = zui_Handle.global.nest(163,null).nest(l.id);
				baseHandle.selected = l.paintBase;
				opacHandle.selected = l.paintOpac;
				norHandle.selected = l.paintNor;
				norBlendHandle.selected = l.paintNorBlend;
				occHandle.selected = l.paintOcc;
				roughHandle.selected = l.paintRough;
				metHandle.selected = l.paintMet;
				heightHandle.selected = l.paintHeight;
				heightBlendHandle.selected = l.paintHeightBlend;
				emisHandle.selected = l.paintEmis;
				subsHandle.selected = l.paintSubs;
				let tmp = arm_Translator.tr("Base Color");
				l.paintBase = ui.check(baseHandle,tmp);
				let tmp1 = arm_Translator.tr("Opacity");
				l.paintOpac = ui.check(opacHandle,tmp1);
				let tmp2 = arm_Translator.tr("Normal");
				l.paintNor = ui.check(norHandle,tmp2);
				let tmp3 = arm_Translator.tr("Normal Blending");
				l.paintNorBlend = ui.check(norBlendHandle,tmp3);
				let tmp4 = arm_Translator.tr("Occlusion");
				l.paintOcc = ui.check(occHandle,tmp4);
				let tmp5 = arm_Translator.tr("Roughness");
				l.paintRough = ui.check(roughHandle,tmp5);
				let tmp6 = arm_Translator.tr("Metallic");
				l.paintMet = ui.check(metHandle,tmp6);
				let tmp7 = arm_Translator.tr("Height");
				l.paintHeight = ui.check(heightHandle,tmp7);
				let tmp8 = arm_Translator.tr("Height Blending");
				l.paintHeightBlend = ui.check(heightBlendHandle,tmp8);
				let tmp9 = arm_Translator.tr("Emission");
				l.paintEmis = ui.check(emisHandle,tmp9);
				let tmp10 = arm_Translator.tr("Subsurface");
				l.paintSubs = ui.check(subsHandle,tmp10);
				if(baseHandle.changed || opacHandle.changed || norHandle.changed || norBlendHandle.changed || occHandle.changed || roughHandle.changed || metHandle.changed || heightHandle.changed || heightBlendHandle.changed || emisHandle.changed || subsHandle.changed) {
					arm_node_MakeMaterial.parseMeshMaterial();
					arm_ui_UIMenu.keepOpen = true;
				}
			}
		},l.isGroup() ? 8 : 20 + add);
	}
	static makeMaskPreviewRgba32(l) {
		if(arm_Context.maskPreviewRgba32 == null) {
			arm_Context.maskPreviewRgba32 = kha_Image.createRenderTarget(200,200);
		}
		if(arm_Context.maskPreviewLast != l) {
			arm_Context.maskPreviewLast = l;
			iron_App.notifyOnInit(function() {
				arm_Context.maskPreviewRgba32.get_g2().begin();
				arm_Context.maskPreviewRgba32.get_g2().set_pipeline(arm_ui_UIView2D.pipe);
				arm_Context.maskPreviewRgba32.get_g4().setInt(arm_ui_UIView2D.channelLocation,1);
				arm_Context.maskPreviewRgba32.get_g2().drawImage(l.texpaint_preview,0,0);
				arm_Context.maskPreviewRgba32.get_g2().end();
				arm_Context.maskPreviewRgba32.get_g2().set_pipeline(null);
			});
		}
	}
	static getSlotCount(layers) {
		let count = 0;
		let _g = 0;
		while(_g < layers.length) {
			let l = layers[_g];
			++_g;
			++count;
			if(l.getMasks() != null) {
				count += l.getMasks().length;
			}
		}
		return count;
	}
	static deleteLayer(l) {
		let pointers = arm_ui_TabLayers.initLayerMap();
		arm_Context.layer = l;
		if(!l.isGroup()) {
			arm_History.deleteLayer();
		} else {
			let _g = 0;
			let _g1 = l.getChildren();
			while(_g < _g1.length) {
				let c = _g1[_g];
				++_g;
				arm_Context.layer = c;
				arm_History.deleteLayer();
				c.delete();
			}
		}
		l.delete();
		if(l.parent != null && l.parent.isGroup() && l.parent.getChildren() == null) {
			let masks = l.parent.getMasks();
			if(masks != null) {
				let _g = 0;
				while(_g < masks.length) masks[_g++].delete();
			}
			l.parent.delete();
		}
		arm_Context.ddirty = 2;
		let _g = 0;
		let _g1 = arm_Project.materials;
		while(_g < _g1.length) arm_ui_TabLayers.remapLayerPointers(_g1[_g++].canvas.nodes,arm_ui_TabLayers.fillLayerMap(pointers));
	}
	static canDelete(l) {
		let result = arm_Project.layers.length > 1;
		if(l.isLayer() && l.parent != null && l.parent.getChildren().length == 1 && arm_Project.layers.length == 2) {
			result = false;
		}
		if(l.isLayer() && l.parent != null && l.getMasks() != null && arm_Project.layers.length == l.getMasks().length + 2) {
			result = false;
		}
		if(l.isLayer() && l.parent == null && l.getMasks() != null && arm_Project.layers.length == l.getMasks().length + 1) {
			result = false;
		}
		if(l.isGroup() && arm_Project.layers.length == arm_ui_TabLayers.getSlotCount(l.getChildren()) + 1) {
			result = false;
		}
		return result;
	}
}
$hxClasses["arm.ui.TabLayers"] = arm_ui_TabLayers;
arm_ui_TabLayers.__name__ = "arm.ui.TabLayers";
class arm_ui_TabMaterials {
	static draw() {
		let ui = arm_ui_UISidebar.inst.ui;
		if(ui.tab(arm_ui_UISidebar.inst.htab1,arm_Translator.tr("Materials"))) {
			ui.beginSticky();
			ui.row([0.25,0.25,0.25]);
			if(ui.button(arm_Translator.tr("New"))) {
				ui.g.end();
				arm_Context.material = new arm_data_MaterialSlot(arm_Project.materials[0].data);
				arm_Project.materials.push(arm_Context.material);
				arm_ui_TabMaterials.updateMaterial();
				ui.g.begin(false);
				arm_History.newMaterial();
			}
			if(ui.button(arm_Translator.tr("Import"))) {
				arm_Project.importMaterial();
			}
			if(ui.button(arm_Translator.tr("Nodes"))) {
				arm_ui_UISidebar.inst.showMaterialNodes();
			} else if(ui.isHovered) {
				ui.tooltip(arm_Translator.tr("Show Node Editor") + (" (" + arm_Config.keymap.toggle_node_editor + ")"));
			}
			ui.endSticky();
			ui.separator(3,false);
			let slotw = 51 * ui.ops.scaleFactor | 0;
			let num = arm_Config.raw.layout[0] / slotw | 0;
			let _g = 0;
			let _g1 = Math.ceil(arm_Project.materials.length / num) | 0;
			while(_g < _g1) {
				let row = _g++;
				let _g1 = [];
				let _g2 = 0;
				let _g3 = num * (arm_Config.raw.show_asset_names ? 2 : 1);
				while(_g2 < _g3) {
					++_g2;
					_g1.push(1 / num);
				}
				ui.row(_g1);
				ui._x += 2;
				if(row > 0) {
					ui._y += arm_Config.raw.show_asset_names ? ui.t.ELEMENT_OFFSET * ui.ops.scaleFactor * 10.0 : 6;
				}
				let _g4 = 0;
				while(_g4 < num) {
					let j = _g4++;
					let imgw = 50 * ui.ops.scaleFactor | 0;
					let i = j + row * num;
					if(i >= arm_Project.materials.length) {
						ui.endElement(imgw);
						if(arm_Config.raw.show_asset_names) {
							ui.endElement(0);
						}
						continue;
					}
					let img = ui.ops.scaleFactor > 1 ? arm_Project.materials[i].image : arm_Project.materials[i].imageIcon;
					let imgFull = arm_Project.materials[i].image;
					if(arm_Context.material == arm_Project.materials[i]) {
						let off = row % 2 == 1 ? 1 : 0;
						let w = 50;
						if(arm_Config.raw.window_scale > 1) {
							w = 50 + (arm_Config.raw.window_scale * 2 | 0);
						}
						ui.fill(-1,-2,w + 3,2,ui.t.HIGHLIGHT_COL);
						ui.fill(-1,w - off,w + 3,2 + off,ui.t.HIGHLIGHT_COL);
						ui.fill(-1,-2,2,w + 3,ui.t.HIGHLIGHT_COL);
						ui.fill(w + 1,-2,2,w + 4,ui.t.HIGHLIGHT_COL);
					}
					let uix = ui._x;
					let uiy = ui._y;
					let tile = ui.ops.scaleFactor > 1 ? 100 : 50;
					if((arm_Project.materials[i].previewReady ? ui.image(img) : ui.image(arm_Res.bundled.h["icons.k"],-1,null,tile,tile,tile,tile)) == 1 && ui.inputY > ui._windowY) {
						if(arm_Context.material != arm_Project.materials[i]) {
							arm_Context.selectMaterial(i);
							if(arm_ui_UIHeader.inst.worktab.position == 1) {
								iron_App.notifyOnInit(function() {
									arm_Layers.updateFillLayers();
								});
							}
						}
						let mouse = iron_system_Input.getMouse();
						arm_App.dragOffX = -(mouse.x - uix - ui._windowX - 3);
						arm_App.dragOffY = -(mouse.y - uiy - ui._windowY + 1);
						arm_App.dragMaterial = arm_Context.material;
						if(kha_Scheduler.time() - arm_Context.selectTime < 0.25) {
							arm_ui_UISidebar.inst.showMaterialNodes();
							arm_App.dragMaterial = null;
							arm_App.isDragging = false;
						}
						arm_Context.selectTime = kha_Scheduler.time();
					}
					if(ui.isHovered && ui.inputReleasedR) {
						arm_Context.selectMaterial(i);
						arm_ui_UIMenu.draw(function(ui) {
							let m = arm_Project.materials[i];
							ui.text(arm_Project.materials[i].canvas.name,2,ui.t.HIGHLIGHT_COL);
							if(ui.button(arm_Translator.tr("To Fill Layer"),0)) {
								arm_Context.selectMaterial(i);
								arm_Layers.createFillLayer();
							}
							if(ui.button(arm_Translator.tr("Export"),0)) {
								arm_Context.selectMaterial(i);
								arm_ui_BoxExport.showMaterial();
							}
							if(ui.button(arm_Translator.tr("Bake"),0)) {
								arm_Context.selectMaterial(i);
								arm_ui_BoxExport.showBakeMaterial();
							}
							if(ui.button(arm_Translator.tr("Duplicate"),0)) {
								iron_App.notifyOnInit(function() {
									arm_Context.material = new arm_data_MaterialSlot(arm_Project.materials[0].data);
									arm_Project.materials.push(arm_Context.material);
									let cloned = JSON.parse(JSON.stringify(arm_Project.materials[i].canvas));
									arm_Context.material.canvas = cloned;
									arm_ui_TabMaterials.updateMaterial();
									arm_History.duplicateMaterial();
								});
							}
							if(arm_Project.materials.length > 1 && ui.button(arm_Translator.tr("Delete"),0)) {
								arm_ui_TabMaterials.deleteMaterial(m);
							}
							let baseHandle = zui_Handle.global.nest(19,null).nest(m.id,{ selected : m.paintBase});
							let opacHandle = zui_Handle.global.nest(20,null).nest(m.id,{ selected : m.paintOpac});
							let norHandle = zui_Handle.global.nest(21,null).nest(m.id,{ selected : m.paintNor});
							let occHandle = zui_Handle.global.nest(22,null).nest(m.id,{ selected : m.paintOcc});
							let roughHandle = zui_Handle.global.nest(23,null).nest(m.id,{ selected : m.paintRough});
							let metHandle = zui_Handle.global.nest(24,null).nest(m.id,{ selected : m.paintMet});
							let heightHandle = zui_Handle.global.nest(25,null).nest(m.id,{ selected : m.paintHeight});
							let emisHandle = zui_Handle.global.nest(26,null).nest(m.id,{ selected : m.paintEmis});
							let subsHandle = zui_Handle.global.nest(27,null).nest(m.id,{ selected : m.paintSubs});
							m.paintBase = ui.check(baseHandle,arm_Translator.tr("Base Color"));
							m.paintOpac = ui.check(opacHandle,arm_Translator.tr("Opacity"));
							m.paintNor = ui.check(norHandle,arm_Translator.tr("Normal"));
							m.paintOcc = ui.check(occHandle,arm_Translator.tr("Occlusion"));
							m.paintRough = ui.check(roughHandle,arm_Translator.tr("Roughness"));
							m.paintMet = ui.check(metHandle,arm_Translator.tr("Metallic"));
							m.paintHeight = ui.check(heightHandle,arm_Translator.tr("Height"));
							m.paintEmis = ui.check(emisHandle,arm_Translator.tr("Emission"));
							m.paintSubs = ui.check(subsHandle,arm_Translator.tr("Subsurface"));
							if(baseHandle.changed || opacHandle.changed || norHandle.changed || occHandle.changed || roughHandle.changed || metHandle.changed || heightHandle.changed || emisHandle.changed || subsHandle.changed) {
								arm_node_MakeMaterial.parsePaintMaterial();
								arm_ui_UIMenu.keepOpen = true;
							}
						},14 + (arm_Project.materials.length > 1 ? 1 : 0));
					}
					if(ui.isHovered) {
						ui.tooltipImage(imgFull);
						if(i < 9) {
							ui.tooltip(arm_Project.materials[i].canvas.name + " - (" + arm_Config.keymap.select_material + " " + (i + 1) + ")");
						} else {
							ui.tooltip(arm_Project.materials[i].canvas.name);
						}
					}
					if(arm_Config.raw.show_asset_names) {
						ui._x = uix;
						ui._y += slotw * 0.9;
						ui.text(arm_Project.materials[i].canvas.name,1);
						if(ui.isHovered) {
							if(i < 9) {
								ui.tooltip(arm_Project.materials[i].canvas.name + " - (" + arm_Config.keymap.select_material + " " + (i + 1) + ")");
							} else {
								ui.tooltip(arm_Project.materials[i].canvas.name);
							}
						}
						ui._y -= slotw * 0.9;
						if(i == arm_Project.materials.length - 1) {
							ui._y += j == num - 1 ? imgw : imgw + ui.t.ELEMENT_H * ui.ops.scaleFactor + ui.t.ELEMENT_OFFSET * ui.ops.scaleFactor;
						}
					}
				}
				ui._y += 6;
			}
			if(ui.inputX > ui._windowX && ui.inputX < ui._windowX + ui._windowW && ui.inputY > ui._windowY && ui.inputY < ui._windowY + ui._windowH && ui.isDeleteDown && arm_Project.materials.length > 1) {
				ui.isDeleteDown = false;
				arm_ui_TabMaterials.deleteMaterial(arm_Context.material);
			}
		}
	}
	static updateMaterial() {
		arm_ui_UIHeader.inst.headerHandle.redraws = 2;
		arm_ui_UINodes.inst.hwnd.redraws = 2;
		arm_ui_UINodes.inst.groupStack = [];
		arm_node_MakeMaterial.parsePaintMaterial();
		arm_util_RenderUtil.makeMaterialPreview();
		if(arm_Context.tool == 3 || arm_Context.tool == 4) {
			arm_util_RenderUtil.makeDecalPreview();
		}
	}
	static updateMaterialPointers(nodes,i) {
		let _g = 0;
		while(_g < nodes.length) {
			let n = nodes[_g];
			++_g;
			if(n.type == "MATERIAL") {
				if(n.buttons[0].default_value == i) {
					n.buttons[0].default_value = 9999;
				} else if(n.buttons[0].default_value > i) {
					let fh = n.buttons[0];
					fh.default_value--;
				}
			}
		}
	}
	static acceptSwatchDrag(index) {
		arm_Context.material = new arm_data_MaterialSlot(arm_Project.materials[0].data);
		let _g = 0;
		let _g1 = arm_Context.material.canvas.nodes;
		while(_g < _g1.length) {
			let node = _g1[_g];
			++_g;
			if(node.type == "RGB") {
				let color = arm_Project.raw.swatches[index].base;
				node.outputs[0].default_value = [((color & 16711680) >>> 16) * 0.00392156862745098,((color & 65280) >>> 8) * 0.00392156862745098,(color & 255) * 0.00392156862745098,(color >>> 24) * 0.00392156862745098];
			}
		}
		arm_Project.materials.push(arm_Context.material);
		arm_ui_TabMaterials.updateMaterial();
		arm_History.newMaterial();
	}
	static deleteMaterial(m) {
		let i = arm_Project.materials.indexOf(m);
		let _g = 0;
		let _g1 = arm_Project.layers;
		while(_g < _g1.length) {
			let l = _g1[_g];
			++_g;
			if(l.fill_layer == m) {
				l.fill_layer = null;
			}
		}
		arm_History.deleteMaterial();
		arm_Context.selectMaterial(i == arm_Project.materials.length - 1 ? i - 1 : i + 1);
		arm_Project.materials.splice(i,1);
		arm_ui_UISidebar.inst.hwnd1.redraws = 2;
		let _g2 = 0;
		let _g3 = arm_Project.materials;
		while(_g2 < _g3.length) arm_ui_TabMaterials.updateMaterialPointers(_g3[_g2++].canvas.nodes,i);
		let _g4 = 0;
		let _g5 = m.canvas.nodes;
		while(_g4 < _g5.length) arm_ui_UINodes.onNodeRemove(_g5[_g4++]);
	}
}
$hxClasses["arm.ui.TabMaterials"] = arm_ui_TabMaterials;
arm_ui_TabMaterials.__name__ = "arm.ui.TabMaterials";
class arm_ui_TabMeshes {
	static draw() {
		let ui = arm_ui_UISidebar.inst.ui;
		let statush = arm_Config.raw.layout[5];
		if(ui.tab(arm_ui_UIStatus.inst.statustab,arm_Translator.tr("Meshes")) && statush > 32 * ui.ops.scaleFactor) {
			ui.beginSticky();
			ui.row([0.071428571428571425,0.1111111111111111,0.1111111111111111,0.1111111111111111,0.1111111111111111,0.071428571428571425,0.071428571428571425,0.071428571428571425]);
			if(ui.button(arm_Translator.tr("Import"))) {
				arm_ui_UIMenu.draw(function(ui) {
					ui.text(arm_Translator.tr("Import"),2,ui.t.HIGHLIGHT_COL);
					if(ui.button(arm_Translator.tr("Replace Existing"),0,"" + arm_Config.keymap.file_import_assets)) {
						arm_Project.importMesh(true);
					}
					if(ui.button(arm_Translator.tr("Append"),0)) {
						arm_Project.importMesh(false);
					}
				},3);
			}
			if(ui.isHovered) {
				ui.tooltip(arm_Translator.tr("Import mesh file"));
			}
			if(ui.button(arm_Translator.tr("Flip Normals"))) {
				arm_util_MeshUtil.flipNormals();
				arm_Context.ddirty = 2;
			}
			if(ui.button(arm_Translator.tr("Calculate Normals"))) {
				arm_util_MeshUtil.calcNormals();
				arm_Context.ddirty = 2;
			}
			if(ui.button(arm_Translator.tr("Geometry to Origin"))) {
				arm_util_MeshUtil.toOrigin();
				arm_Context.ddirty = 2;
			}
			if(ui.button(arm_Translator.tr("Apply Displacement"))) {
				arm_util_MeshUtil.applyDisplacement();
				arm_util_MeshUtil.calcNormals();
				arm_Context.ddirty = 2;
			}
			if(ui.button(arm_Translator.tr("Rotate X"))) {
				arm_util_MeshUtil.swapAxis(1,2);
				arm_Context.ddirty = 2;
			}
			if(ui.button(arm_Translator.tr("Rotate Y"))) {
				arm_util_MeshUtil.swapAxis(2,0);
				arm_Context.ddirty = 2;
			}
			if(ui.button(arm_Translator.tr("Rotate Z"))) {
				arm_util_MeshUtil.swapAxis(0,1);
				arm_Context.ddirty = 2;
			}
			ui.endSticky();
			let _g = 0;
			let _g1 = arm_Project.paintObjects.length;
			while(_g < _g1) {
				let i = _g++;
				let o = arm_Project.paintObjects[i];
				let h = zui_Handle.global.nest(146,null);
				h.selected = o.visible;
				o.visible = ui.check(h,o.name);
				if(ui.isHovered && ui.inputReleasedR) {
					arm_ui_UIMenu.draw(function(ui) {
						ui.text(o.name,2,ui.t.HIGHLIGHT_COL);
						if(ui.button(arm_Translator.tr("Export"),0)) {
							arm_Context.exportMeshIndex = i + 1;
							arm_ui_BoxExport.showMesh();
						}
						if(arm_Project.paintObjects.length > 1 && ui.button(arm_Translator.tr("Delete"),0)) {
							HxOverrides.remove(arm_Project.paintObjects,o);
							while(o.children.length > 0) {
								let child = o.children[0];
								child.setParent(null);
								if(arm_Project.paintObjects[0] != child) {
									child.setParent(arm_Project.paintObjects[0]);
								}
								if(o.children.length == 0) {
									let _this = arm_Project.paintObjects[0].transform.scale;
									let v = o.transform.scale;
									_this.x = v.x;
									_this.y = v.y;
									_this.z = v.z;
									_this.w = v.w;
									arm_Project.paintObjects[0].transform.buildMatrix();
								}
							}
							iron_data_Data.deleteMesh(o.data.handle);
							o.remove();
							arm_Context.paintObject = arm_Context.mainObject();
							arm_util_MeshUtil.mergeMesh();
							arm_Context.ddirty = 2;
						}
					},arm_Project.paintObjects.length > 1 ? 3 : 2);
				}
				if(h.changed) {
					let visibles = [];
					let _g = 0;
					let _g1 = arm_Project.paintObjects;
					while(_g < _g1.length) {
						let p = _g1[_g];
						++_g;
						if(p.visible) {
							visibles.push(p);
						}
					}
					arm_util_MeshUtil.mergeMesh(visibles);
					arm_Context.ddirty = 2;
				}
			}
		}
	}
}
$hxClasses["arm.ui.TabMeshes"] = arm_ui_TabMeshes;
arm_ui_TabMeshes.__name__ = "arm.ui.TabMeshes";
class arm_ui_TabParticles {
	static draw() {
		let ui = arm_ui_UISidebar.inst.ui;
		if(ui.tab(arm_ui_UISidebar.inst.htab1,arm_Translator.tr("Particles"))) {
			ui.beginSticky();
			ui.row([0.25,0.25,0.25]);
			ui.button(arm_Translator.tr("New"));
			ui.button(arm_Translator.tr("Import"));
			ui.button(arm_Translator.tr("Nodes"));
			ui.endSticky();
		}
	}
}
$hxClasses["arm.ui.TabParticles"] = arm_ui_TabParticles;
arm_ui_TabParticles.__name__ = "arm.ui.TabParticles";
class arm_ui_TabPlugins {
	static draw() {
		let ui = arm_ui_UISidebar.inst.ui;
		if(ui.tab(arm_ui_UISidebar.inst.htab0,arm_Translator.tr("Plugins"))) {
			ui.beginSticky();
			ui.row([0.25]);
			if(ui.button(arm_Translator.tr("Manager"))) {
				arm_ui_BoxPreferences.htab.position = 6;
				arm_ui_BoxPreferences.show();
			}
			ui.endSticky();
			let h = arm_Plugin.plugins.h;
			let p_keys = Object.keys(h);
			let p_length = p_keys.length;
			let p_current = 0;
			while(p_current < p_length) {
				let p = h[p_keys[p_current++]];
				if(p.drawUI != null) {
					p.drawUI(ui);
				}
			}
		}
	}
}
$hxClasses["arm.ui.TabPlugins"] = arm_ui_TabPlugins;
arm_ui_TabPlugins.__name__ = "arm.ui.TabPlugins";
class arm_ui_TabScript {
	static draw() {
		let ui = arm_ui_UISidebar.inst.ui;
		let statush = arm_Config.raw.layout[5];
		if(ui.tab(arm_ui_UIStatus.inst.statustab,arm_Translator.tr("Script")) && statush > 32 * ui.ops.scaleFactor) {
			ui.beginSticky();
			ui.row([0.071428571428571425,0.071428571428571425,0.071428571428571425,0.071428571428571425]);
			if(ui.button(arm_Translator.tr("Run"))) {
				try {
					let code = arm_ui_TabScript.hscript.text;
					eval(code);
				} catch( _g ) {
					arm_Console.log(haxe_Exception.caught(_g).unwrap());
				}
			}
			if(ui.button(arm_Translator.tr("Clear"))) {
				arm_ui_TabScript.hscript.text = "";
			}
			if(ui.button(arm_Translator.tr("Import"))) {
				arm_ui_UIFiles.show("js",false,false,function(path) {
					iron_data_Data.getBlob(path,function(b) {
						arm_ui_TabScript.hscript.text = b.toString();
						iron_data_Data.deleteBlob(path);
					});
				});
			}
			if(ui.button(arm_Translator.tr("Export"))) {
				let str = arm_ui_TabScript.hscript.text;
				arm_ui_UIFiles.show("js",true,false,function(path) {
					let f = arm_ui_UIFiles.filename;
					if(f == "") {
						f = arm_Translator.tr("untitled");
					}
					path = path + arm_sys_Path.sep + f;
					if(!path.endsWith(".js")) {
						path += ".js";
					}
					Krom.fileSaveBytes(path,haxe_io_Bytes.ofString(str).b.bufferValue);
				});
			}
			ui.endSticky();
			let _font = ui.ops.font;
			let _fontSize = ui.fontSize;
			iron_data_Data.getFont("font_mono.ttf",function(f) {
				ui.ops.font = f;
			});
			ui.fontSize = 15;
			zui_Ext.textArea(ui,arm_ui_TabScript.hscript);
			ui.ops.font = _font;
			ui.fontSize = _fontSize;
		}
	}
}
$hxClasses["arm.ui.TabScript"] = arm_ui_TabScript;
arm_ui_TabScript.__name__ = "arm.ui.TabScript";
class arm_ui_TabSwatches {
	static draw() {
		let ui = arm_ui_UISidebar.inst.ui;
		let statush = arm_Config.raw.layout[5];
		if(ui.tab(arm_ui_UIStatus.inst.statustab,arm_Translator.tr("Swatches")) && statush > 32 * ui.ops.scaleFactor) {
			ui.beginSticky();
			ui.row([0.071428571428571425,0.071428571428571425,0.071428571428571425,0.071428571428571425,0.071428571428571425]);
			if(ui.button(arm_Translator.tr("New"))) {
				arm_Context.setSwatch(arm_Project.makeSwatch());
				arm_Project.raw.swatches.push(arm_Context.swatch);
			}
			if(ui.isHovered) {
				ui.tooltip(arm_Translator.tr("Add new swatch"));
			}
			if(ui.button(arm_Translator.tr("Import"))) {
				arm_ui_UIMenu.draw(function(ui) {
					ui.text(arm_Translator.tr("Import"),2,ui.t.HIGHLIGHT_COL);
					if(ui.button(arm_Translator.tr("Replace Existing"),0)) {
						arm_Project.importSwatches(true);
						arm_Context.setSwatch(arm_Project.raw.swatches[0]);
					}
					if(ui.button(arm_Translator.tr("Append"),0)) {
						arm_Project.importSwatches(false);
					}
				},3);
			}
			if(ui.isHovered) {
				ui.tooltip(arm_Translator.tr("Import swatches"));
			}
			if(ui.button(arm_Translator.tr("Export"))) {
				arm_Project.exportSwatches();
			}
			if(ui.isHovered) {
				ui.tooltip(arm_Translator.tr("Export swatches"));
			}
			if(ui.button(arm_Translator.tr("Clear"))) {
				arm_Context.setSwatch(arm_Project.makeSwatch());
				arm_Project.raw.swatches = [arm_Context.swatch];
			}
			if(ui.button(arm_Translator.tr("Restore"))) {
				arm_Project.setDefaultSwatches();
				arm_Context.setSwatch(arm_Project.raw.swatches[0]);
			}
			if(ui.isHovered) {
				ui.tooltip(arm_Translator.tr("Restore default swatches"));
			}
			ui.endSticky();
			ui.separator(3,false);
			let statusw = kha_System.windowWidth() - arm_ui_UIToolbar.inst.toolbarw - arm_Config.raw.layout[0];
			let slotw = 26 * ui.ops.scaleFactor | 0;
			let num = statusw / (slotw + 3) | 0;
			let _g = 0;
			let _g1 = Math.ceil(arm_Project.raw.swatches.length / num) | 0;
			while(_g < _g1) {
				let row = _g++;
				let _g1 = [];
				let _g2 = 0;
				let _g3 = num;
				while(_g2 < _g3) {
					let i = _g2++;
					_g1.push(1 / num);
				}
				ui.row(_g1);
				ui._x += 2;
				if(row > 0) {
					ui._y += 6;
				}
				let _g4 = 0;
				let _g5 = num;
				while(_g4 < _g5) {
					let j = _g4++;
					let i = j + row * num;
					if(i >= arm_Project.raw.swatches.length) {
						ui.endElement(slotw);
						continue;
					}
					if(arm_Context.swatch == arm_Project.raw.swatches[i]) {
						let off = row % 2 == 1 ? 1 : 0;
						let w = 32;
						ui.fill(-2,-2,w,w,ui.t.HIGHLIGHT_COL);
					}
					if(arm_ui_TabSwatches.empty == null) {
						let b = new haxe_io_Bytes(new ArrayBuffer(4));
						b.b[0] = 255;
						b.b[1] = 255;
						b.b[2] = 255;
						b.b[3] = 255;
						arm_ui_TabSwatches.empty = kha_Image.fromBytes(b,1,1);
					}
					let uix = ui._x;
					let uiy = ui._y;
					let state = ui.image(arm_ui_TabSwatches.empty,arm_Project.raw.swatches[i].base,slotw);
					if(state == 1) {
						arm_Context.setSwatch(arm_Project.raw.swatches[i]);
						let mouse = iron_system_Input.getMouse();
						arm_App.dragOffX = -(mouse.x - uix - ui._windowX - 3);
						arm_App.dragOffY = -(mouse.y - uiy - ui._windowY + 1);
						arm_App.dragSwatch = arm_Context.swatch;
					} else if(state == 3) {
						if(kha_Scheduler.time() - arm_Context.selectTime < 0.25) {
							arm_ui_UIMenu.draw(function(ui) {
								ui.changed = false;
								let h = zui_Handle.global.nest(103,null);
								h.color = arm_Context.swatch.base;
								arm_Context.swatch.base = zui_Ext.colorWheel(ui,h,false,null,11 * ui.t.ELEMENT_H * ui.ops.scaleFactor,true);
								if(ui.changed || ui.isTyping) {
									arm_ui_UIMenu.keepOpen = true;
								}
								if(ui.inputReleased) {
									arm_Context.setSwatch(arm_Context.swatch);
								}
							},11,iron_system_Input.getMouse().x - 200 * ui.ops.scaleFactor | 0,iron_system_Input.getMouse().y - 250 * ui.ops.scaleFactor | 0);
						}
						arm_Context.selectTime = kha_Scheduler.time();
					}
					if(ui.isHovered && ui.inputReleasedR) {
						arm_Context.setSwatch(arm_Project.raw.swatches[i]);
						let add = arm_Project.raw.swatches.length > 1 ? 1 : 0;
						++add;
						arm_ui_UIMenu.draw(function(ui) {
							ui.text(arm_Translator.tr("Swatch"),2,ui.t.HIGHLIGHT_COL);
							if(ui.button(arm_Translator.tr("Duplicate"),0)) {
								arm_Context.setSwatch(arm_Project.makeSwatch(arm_Context.swatch.base));
								arm_Project.raw.swatches.push(arm_Context.swatch);
							} else if(ui.button(arm_Translator.tr("Copy"),0)) {
								let val = arm_Context.swatch.base;
								if(val < 0) {
									val += 4294967296;
								}
								Krom.copyToClipboard(val.toString(16));
							} else if(arm_Project.raw.swatches.length > 1 && ui.button(arm_Translator.tr("Delete"),0)) {
								arm_ui_TabSwatches.deleteSwatch(arm_Project.raw.swatches[i]);
							}
						},2 + add);
					}
					if(ui.isHovered) {
						let val = arm_Project.raw.swatches[i].base;
						if(val < 0) {
							val += 4294967296;
						}
						ui.tooltip("#" + val.toString(16));
					}
				}
			}
			let inFocus = ui.inputX > ui._windowX && ui.inputX < ui._windowX + ui._windowW && ui.inputY > ui._windowY && ui.inputY < ui._windowY + ui._windowH;
			if(inFocus && ui.isDeleteDown && arm_Project.raw.swatches.length > 1) {
				ui.isDeleteDown = false;
				arm_ui_TabSwatches.deleteSwatch(arm_Context.swatch);
			}
		}
	}
	static deleteSwatch(swatch) {
		let i = arm_Project.raw.swatches.indexOf(swatch);
		arm_Context.setSwatch(arm_Project.raw.swatches[i == arm_Project.raw.swatches.length - 1 ? i - 1 : i + 1]);
		arm_Project.raw.swatches.splice(i,1);
		arm_ui_UIStatus.inst.statusHandle.redraws = 2;
	}
}
$hxClasses["arm.ui.TabSwatches"] = arm_ui_TabSwatches;
arm_ui_TabSwatches.__name__ = "arm.ui.TabSwatches";
class arm_ui_TabTextures {
	static draw() {
		let ui = arm_ui_UISidebar.inst.ui;
		let statush = arm_Config.raw.layout[5];
		if(ui.tab(arm_ui_UIStatus.inst.statustab,arm_Translator.tr("Textures")) && statush > 32 * ui.ops.scaleFactor) {
			ui.beginSticky();
			ui.row([0.071428571428571425,0.071428571428571425]);
			if(ui.button(arm_Translator.tr("Import"))) {
				arm_ui_UIFiles.show(arm_sys_Path.textureFormats.join(","),false,true,function(path) {
					arm_io_ImportAsset.run(path,-1.0,-1.0,true,false);
					arm_ui_UIStatus.inst.statusHandle.redraws = 2;
				});
			}
			if(ui.isHovered) {
				ui.tooltip(arm_Translator.tr("Import texture file") + (" (" + arm_Config.keymap.file_import_assets + ")"));
			}
			if(ui.button(arm_Translator.tr("2D View"))) {
				arm_ui_UISidebar.inst.show2DView(1);
			}
			ui.endSticky();
			if(arm_Project.assets.length > 0) {
				let statusw = kha_System.windowWidth() - arm_ui_UIToolbar.inst.toolbarw;
				let slotw = 52 * ui.ops.scaleFactor | 0;
				let num = (statusw - arm_Config.raw.layout[0]) / slotw | 0;
				let _g = 0;
				let _g1 = Math.ceil(arm_Project.assets.length / num) | 0;
				while(_g < _g1) {
					let row = _g++;
					let _g1 = [];
					let _g2 = 0;
					let _g3 = num * (arm_Config.raw.show_asset_names ? 2 : 1);
					while(_g2 < _g3) {
						++_g2;
						_g1.push(1 / num);
					}
					ui.row(_g1);
					ui._x += 2;
					if(row > 0) {
						ui._y += arm_Config.raw.show_asset_names ? ui.t.ELEMENT_OFFSET * ui.ops.scaleFactor * 10.0 : 6;
					}
					let _g4 = 0;
					while(_g4 < num) {
						let j = _g4++;
						let imgw = 50 * ui.ops.scaleFactor | 0;
						let i = j + row * num;
						if(i >= arm_Project.assets.length) {
							ui.endElement(imgw);
							if(arm_Config.raw.show_asset_names) {
								ui.endElement(0);
							}
							continue;
						}
						let asset = arm_Project.assets[i];
						let img = arm_Project.getImage(asset);
						let uix = ui._x;
						let uiy = ui._y;
						let sw = img.get_height() < img.get_width() ? img.get_height() : 0;
						if(ui.image(img,-1,slotw,0,0,sw,sw) == 1 && ui.inputY > ui._windowY) {
							let mouse = iron_system_Input.getMouse();
							arm_App.dragOffX = -(mouse.x - uix - ui._windowX - 3);
							arm_App.dragOffY = -(mouse.y - uiy - ui._windowY + 1);
							arm_App.dragAsset = asset;
							arm_Context.texture = asset;
							if(kha_Scheduler.time() - arm_Context.selectTime < 0.25) {
								arm_ui_UISidebar.inst.show2DView(1);
							}
							arm_Context.selectTime = kha_Scheduler.time();
							arm_ui_UIView2D.inst.hwnd.redraws = 2;
						}
						if(asset == arm_Context.texture) {
							let _uix = ui._x;
							let _uiy = ui._y;
							ui._x = uix;
							ui._y = uiy;
							let off = i % 2 == 1 ? 1 : 0;
							ui.fill(0,0,53,2,ui.t.HIGHLIGHT_COL);
							ui.fill(0,50 - off + 2,53,2 + off,ui.t.HIGHLIGHT_COL);
							ui.fill(0,0,2,53,ui.t.HIGHLIGHT_COL);
							ui.fill(52,0,2,54,ui.t.HIGHLIGHT_COL);
							ui._x = _uix;
							ui._y = _uiy;
						}
						if(ui.isHovered) {
							ui.tooltipImage(img,256);
							ui.tooltip(asset.name);
						}
						if(ui.isHovered && ui.inputReleasedR) {
							arm_Context.texture = asset;
							let isPacked = arm_Project.raw.packed_assets != null && arm_Project.packedAssetExists(arm_Project.raw.packed_assets,asset.file);
							arm_ui_UIMenu.draw(function(ui) {
								ui.text(asset.name + (isPacked ? " " + arm_Translator.tr("(packed)") : ""),2,ui.t.HIGHLIGHT_COL);
								if(ui.button(arm_Translator.tr("Export"),0)) {
									arm_ui_UIFiles.show("png",true,false,function(path) {
										arm_App.notifyOnNextFrame(function() {
											if(arm_Layers.pipeMerge == null) {
												arm_Layers.makePipe();
											}
											let target = kha_Image.createRenderTarget(arm_ui_TabTextures.to_pow2(img.get_width()),arm_ui_TabTextures.to_pow2(img.get_height()));
											target.get_g2().begin(false);
											target.get_g2().set_pipeline(arm_Layers.pipeCopy);
											target.get_g2().drawScaledImage(img,0,0,target.get_width(),target.get_height());
											target.get_g2().set_pipeline(null);
											target.get_g2().end();
											arm_App.notifyOnNextFrame(function() {
												let f = arm_ui_UIFiles.filename;
												if(f == "") {
													f = arm_Translator.tr("untitled");
												}
												if(!f.endsWith(".png")) {
													f += ".png";
												}
												Krom.writePng(path + arm_sys_Path.sep + f,target.getPixels().b.bufferValue,target.get_width(),target.get_height(),0);
												target.unload();
											});
										});
									});
								}
								if(ui.button(arm_Translator.tr("Reimport"),0)) {
									arm_Project.reimportTexture(asset);
								}
								if(ui.button(arm_Translator.tr("To Mask"),0)) {
									arm_App.notifyOnNextFrame(function() {
										arm_Layers.createImageMask(asset);
									});
								}
								if(ui.button(arm_Translator.tr("Delete"),0)) {
									arm_ui_TabTextures.deleteTexture(asset);
								}
								if(!isPacked && ui.button(arm_Translator.tr("Open Containing Directory..."),0)) {
									arm_sys_File.start(HxOverrides.substr(asset.file,0,asset.file.lastIndexOf(arm_sys_Path.sep)));
								}
								if(!isPacked && ui.button(arm_Translator.tr("Open in Browser"),0)) {
									arm_ui_TabBrowser.showDirectory(HxOverrides.substr(asset.file,0,asset.file.lastIndexOf(arm_sys_Path.sep)));
								}
							},isPacked ? 5 : 7);
						}
						if(arm_Config.raw.show_asset_names) {
							ui._x = uix;
							ui._y += slotw * 0.9;
							ui.text(arm_Project.assets[i].name,1);
							if(ui.isHovered) {
								ui.tooltip(arm_Project.assets[i].name);
							}
							ui._y -= slotw * 0.9;
							if(i == arm_Project.assets.length - 1) {
								ui._y += j == num - 1 ? imgw : imgw + ui.t.ELEMENT_H * ui.ops.scaleFactor + ui.t.ELEMENT_OFFSET * ui.ops.scaleFactor;
							}
						}
					}
				}
			} else {
				let img = arm_Res.bundled.h["icons.k"];
				let r = arm_Res.tile50(img,0,1);
				ui.image(img,ui.t.BUTTON_COL,r.h,r.x,r.y,r.w,r.h);
				if(ui.isHovered) {
					ui.tooltip(arm_Translator.tr("Drag and drop files here"));
				}
			}
			if(ui.inputX > ui._windowX && ui.inputX < ui._windowX + ui._windowW && ui.inputY > ui._windowY && ui.inputY < ui._windowY + ui._windowH && ui.isDeleteDown && arm_Project.assets.length > 0 && arm_Project.assets.indexOf(arm_Context.texture) >= 0) {
				ui.isDeleteDown = false;
				arm_ui_TabTextures.deleteTexture(arm_Context.texture);
			}
		}
	}
	static to_pow2(i) {
		--i;
		i |= i >> 1;
		i |= i >> 2;
		i |= i >> 4;
		i |= i >> 8;
		i |= i >> 16;
		return ++i;
	}
	static updateTexturePointers(nodes,i) {
		let _g = 0;
		while(_g < nodes.length) {
			let n = nodes[_g];
			++_g;
			if(n.type == "TEX_IMAGE") {
				if(n.buttons[0].default_value == i) {
					n.buttons[0].default_value = 9999;
				} else if(n.buttons[0].default_value > i) {
					let fh = n.buttons[0];
					fh.default_value--;
				}
			}
		}
	}
	static deleteTexture(asset) {
		let i = arm_Project.assets.indexOf(asset);
		if(arm_Project.assets.length > 1) {
			arm_Context.texture = arm_Project.assets[i == arm_Project.assets.length - 1 ? i - 1 : i + 1];
		}
		arm_ui_UIStatus.inst.statusHandle.redraws = 2;
		iron_data_Data.deleteImage(asset.file);
		arm_Project.assetMap.remove(asset.id);
		arm_Project.assets.splice(i,1);
		arm_Project.assetNames.splice(i,1);
		arm_App.notifyOnNextFrame(function() {
			arm_node_MakeMaterial.parsePaintMaterial();
			arm_util_RenderUtil.makeMaterialPreview();
			arm_ui_UISidebar.inst.hwnd1.redraws = 2;
		});
		let _g = 0;
		let _g1 = arm_Project.materials;
		while(_g < _g1.length) arm_ui_TabTextures.updateTexturePointers(_g1[_g++].canvas.nodes,i);
		let _g2 = 0;
		let _g3 = arm_Project.brushes;
		while(_g2 < _g3.length) arm_ui_TabTextures.updateTexturePointers(_g3[_g2++].canvas.nodes,i);
	}
}
$hxClasses["arm.ui.TabTextures"] = arm_ui_TabTextures;
arm_ui_TabTextures.__name__ = "arm.ui.TabTextures";
class arm_ui_UIHeader {
	constructor() {
		this.worktab = zui_Handle.global.nest(2,null);
		this.headerh = 28;
		this.headerHandle = new zui_Handle({ layout : 1});
		arm_ui_UIHeader.inst = this;
	}
	renderUI(g) {
		let ui = arm_ui_UISidebar.inst.ui;
		let panelx = arm_App.x();
		if(ui.window(this.headerHandle,panelx,this.headerh,kha_System.windowWidth() - arm_ui_UIToolbar.inst.toolbarw - arm_Config.raw.layout[0],28 * ui.ops.scaleFactor | 0)) {
			ui._y += 2;
			if(arm_Context.tool == 8) {
				ui.text(arm_Translator.tr("Picked Color"));
				if(arm_Context.colorIdPicked) {
					ui.image(iron_RenderPath.active.renderTargets.h["texpaint_colorid"].image,-1,64);
				}
				if(ui.button(arm_Translator.tr("Clear"))) {
					arm_Context.colorIdPicked = false;
				}
				ui.text(arm_Translator.tr("Color ID Map"));
				let cid = ui.combo(arm_Context.colorIdHandle,arm_App.enumTexts("TEX_IMAGE"),arm_Translator.tr("Color ID"));
				if(arm_Context.colorIdHandle.changed) {
					arm_Context.ddirty = 2;
				}
				if(arm_Project.assets.length > 0) {
					ui.image(arm_Project.getImage(arm_Project.assets[cid]));
				}
			} else if(arm_Context.tool == 9) {
				let baseRPicked = Math.round(((arm_Context.pickedColor.base & 16711680) >>> 16) * 0.00392156862745098 * 10) / 10;
				let baseGPicked = Math.round(((arm_Context.pickedColor.base & 65280) >>> 8) * 0.00392156862745098 * 10) / 10;
				let baseBPicked = Math.round((arm_Context.pickedColor.base & 255) * 0.00392156862745098 * 10) / 10;
				let normalRPicked = Math.round(((arm_Context.pickedColor.normal & 16711680) >>> 16) * 0.00392156862745098 * 10) / 10;
				let normalGPicked = Math.round(((arm_Context.pickedColor.normal & 65280) >>> 8) * 0.00392156862745098 * 10) / 10;
				let normalBPicked = Math.round((arm_Context.pickedColor.normal & 255) * 0.00392156862745098 * 10) / 10;
				let occlusionPicked = Math.round(arm_Context.pickedColor.occlusion * 100) / 100;
				let roughnessPicked = Math.round(arm_Context.pickedColor.roughness * 100) / 100;
				let metallicPicked = Math.round(arm_Context.pickedColor.metallic * 100) / 100;
				let heightPicked = Math.round(arm_Context.pickedColor.height * 100) / 100;
				let opacityPicked = Math.round(arm_Context.pickedColor.opacity * 100) / 100;
				let h = zui_Handle.global.nest(122,null);
				h.color = Math.round((h.color >>> 24) * 0.00392156862745098 * 255) << 24 | Math.round(baseRPicked * 255) << 16 | Math.round(((h.color & 65280) >>> 8) * 0.00392156862745098 * 255) << 8 | Math.round((h.color & 255) * 0.00392156862745098 * 255);
				h.color = Math.round((h.color >>> 24) * 0.00392156862745098 * 255) << 24 | Math.round(((h.color & 16711680) >>> 16) * 0.00392156862745098 * 255) << 16 | Math.round(baseGPicked * 255) << 8 | Math.round((h.color & 255) * 0.00392156862745098 * 255);
				h.color = Math.round((h.color >>> 24) * 0.00392156862745098 * 255) << 24 | Math.round(((h.color & 16711680) >>> 16) * 0.00392156862745098 * 255) << 16 | Math.round(((h.color & 65280) >>> 8) * 0.00392156862745098 * 255) << 8 | Math.round(baseBPicked * 255);
				ui.text("",0,h.color);
				if(ui.isHovered && ui.inputReleased) {
					arm_ui_UIMenu.draw(function(ui) {
						ui.fill(0,0,ui._w / ui.ops.scaleFactor,ui.t.ELEMENT_H * 9,ui.t.SEPARATOR_COL);
						ui.changed = false;
						zui_Ext.colorWheel(ui,h,false,null,10 * ui.t.ELEMENT_H * ui.ops.scaleFactor,false);
						if(ui.changed) {
							arm_ui_UIMenu.keepOpen = true;
						}
					},10);
				}
				if(ui.button(arm_Translator.tr("Add Swatch"))) {
					let newSwatch = arm_Project.makeSwatch(arm_Context.pickedColor.base);
					arm_Context.setSwatch(newSwatch);
					arm_Project.raw.swatches.push(newSwatch);
					arm_ui_UIStatus.inst.statusHandle.redraws = 1;
				}
				if(ui.isHovered) {
					ui.tooltip(arm_Translator.tr("Add picker color to swatches"));
				}
				ui.text(arm_Translator.tr("Base") + (" (" + baseRPicked + "," + baseGPicked + "," + baseBPicked + ")"));
				ui.text(arm_Translator.tr("Normal") + (" (" + normalRPicked + "," + normalGPicked + "," + normalBPicked + ")"));
				ui.text(arm_Translator.tr("Occlusion") + (" (" + occlusionPicked + ")"));
				ui.text(arm_Translator.tr("Roughness") + (" (" + roughnessPicked + ")"));
				ui.text(arm_Translator.tr("Metallic") + (" (" + metallicPicked + ")"));
				ui.text(arm_Translator.tr("Height") + (" (" + heightPicked + ")"));
				ui.text(arm_Translator.tr("Opacity") + (" (" + opacityPicked + ")"));
				arm_Context.pickerSelectMaterial = ui.check(zui_Handle.global.nest(123,{ selected : arm_Context.pickerSelectMaterial}),arm_Translator.tr("Select Material"));
				ui.combo(arm_Context.pickerMaskHandle,[arm_Translator.tr("None"),arm_Translator.tr("Material")],arm_Translator.tr("Mask"),true);
				if(arm_Context.pickerMaskHandle.changed) {
					arm_node_MakeMaterial.parsePaintMaterial();
				}
			} else if(arm_Context.tool == 11) {
				ui.changed = false;
				if(ui.button(arm_Translator.tr("Bake"))) {
					arm_Context.pdirty = 1;
					arm_Context.rdirty = 3;
					arm_App.notifyOnNextFrame(function() {
						arm_Context.layerPreviewDirty = true;
					});
					arm_ui_UISidebar.inst.hwnd0.redraws = 2;
					arm_History.pushUndo = true;
				}
				arm_Context.bakeType = ui.combo(zui_Handle.global.nest(124,{ position : arm_Context.bakeType}),[arm_Translator.tr("AO"),arm_Translator.tr("Curvature"),arm_Translator.tr("Normal"),arm_Translator.tr("Object Normal"),arm_Translator.tr("Height"),arm_Translator.tr("Derivative"),arm_Translator.tr("Position"),arm_Translator.tr("TexCoord"),arm_Translator.tr("Material ID"),arm_Translator.tr("Object ID"),arm_Translator.tr("Vertex Color")],arm_Translator.tr("Bake"));
				if(arm_Context.bakeType == 3 || arm_Context.bakeType == 6 || arm_Context.bakeType == 12) {
					arm_Context.bakeUpAxis = ui.combo(zui_Handle.global.nest(125,{ position : arm_Context.bakeUpAxis}),[arm_Translator.tr("Z"),arm_Translator.tr("Y")],arm_Translator.tr("Up Axis"),true);
				}
				if(arm_Context.bakeType == 0 || arm_Context.bakeType == 1) {
					arm_Context.bakeAxis = ui.combo(zui_Handle.global.nest(126,{ position : arm_Context.bakeAxis}),[arm_Translator.tr("XYZ"),arm_Translator.tr("X"),arm_Translator.tr("Y"),arm_Translator.tr("Z"),arm_Translator.tr("-X"),arm_Translator.tr("-Y"),arm_Translator.tr("-Z")],arm_Translator.tr("Axis"),true);
				}
				if(arm_Context.bakeType == 0) {
					arm_Context.bakeAoStrength = ui.slider(zui_Handle.global.nest(127,{ value : arm_Context.bakeAoStrength}),arm_Translator.tr("Strength"),0.0,2.0,true);
					arm_Context.bakeAoRadius = ui.slider(zui_Handle.global.nest(128,{ value : arm_Context.bakeAoRadius}),arm_Translator.tr("Radius"),0.0,2.0,true);
					arm_Context.bakeAoOffset = ui.slider(zui_Handle.global.nest(129,{ value : arm_Context.bakeAoOffset}),arm_Translator.tr("Offset"),0.0,2.0,true);
				}
				if(arm_Context.bakeType == 1) {
					arm_Context.bakeCurvStrength = ui.slider(zui_Handle.global.nest(130,{ value : arm_Context.bakeCurvStrength}),arm_Translator.tr("Strength"),0.0,2.0,true);
					arm_Context.bakeCurvRadius = ui.slider(zui_Handle.global.nest(131,{ value : arm_Context.bakeCurvRadius}),arm_Translator.tr("Radius"),0.0,2.0,true);
					arm_Context.bakeCurvOffset = ui.slider(zui_Handle.global.nest(132,{ value : arm_Context.bakeCurvOffset}),arm_Translator.tr("Offset"),-2.0,2.0,true);
					arm_Context.bakeCurvSmooth = ui.slider(zui_Handle.global.nest(133,{ value : arm_Context.bakeCurvSmooth}),arm_Translator.tr("Smooth"),0,5,false,1) | 0;
				}
				if(arm_Context.bakeType == 2 || arm_Context.bakeType == 4 || arm_Context.bakeType == 5) {
					let _g = [];
					let _g1 = 0;
					let _g2 = arm_Project.paintObjects;
					while(_g1 < _g2.length) _g.push(_g2[_g1++].name);
					arm_Context.bakeHighPoly = ui.combo(zui_Handle.global.nest(134,{ position : arm_Context.bakeHighPoly}),_g,arm_Translator.tr("High Poly"));
				}
				if(ui.changed) {
					arm_node_MakeMaterial.parsePaintMaterial();
				}
			} else if(arm_Context.tool == 0 || arm_Context.tool == 1 || arm_Context.tool == 2 || arm_Context.tool == 3 || arm_Context.tool == 4 || arm_Context.tool == 5 || arm_Context.tool == 6 || arm_Context.tool == 7) {
				let decalMask = (arm_Context.tool == 3 || arm_Context.tool == 4) && arm_Operator.shortcut(arm_Config.keymap.decal_mask,2);
				if(arm_Context.tool != 2) {
					if(decalMask) {
						arm_Context.brushDecalMaskRadius = ui.slider(arm_Context.brushDecalMaskRadiusHandle,arm_Translator.tr("Radius"),0.01,2.0,true);
						if(ui.isHovered) {
							let _g = new haxe_ds_StringMap();
							_g.h["brush_radius"] = arm_Config.keymap.brush_radius;
							_g.h["brush_radius_decrease"] = arm_Config.keymap.brush_radius_decrease;
							_g.h["brush_radius_increase"] = arm_Config.keymap.brush_radius_increase;
							ui.tooltip(arm_Translator.tr("Hold {brush_radius} and move mouse to the left or press {brush_radius_decrease} to decrease the radius\nHold {brush_radius} and move mouse to the right or press {brush_radius_increase} to increase the radius",_g));
						}
					} else {
						arm_Context.brushRadius = ui.slider(arm_Context.brushRadiusHandle,arm_Translator.tr("Radius"),0.01,2.0,true);
						if(ui.isHovered) {
							let _g = new haxe_ds_StringMap();
							_g.h["brush_radius"] = arm_Config.keymap.brush_radius;
							_g.h["brush_radius_decrease"] = arm_Config.keymap.brush_radius_decrease;
							_g.h["brush_radius_increase"] = arm_Config.keymap.brush_radius_increase;
							ui.tooltip(arm_Translator.tr("Hold {brush_radius} and move mouse to the left or press {brush_radius_decrease} to decrease the radius\nHold {brush_radius} and move mouse to the right or press {brush_radius_increase} to increase the radius",_g));
						}
					}
				}
				if(arm_Context.tool == 3 || arm_Context.tool == 4) {
					arm_Context.brushScaleX = ui.slider(arm_Context.brushScaleXHandle,arm_Translator.tr("Scale X"),0.01,2.0,true);
				}
				if(arm_Context.tool == 0 || arm_Context.tool == 2 || arm_Context.tool == 3 || arm_Context.tool == 4) {
					let brushScaleHandle = zui_Handle.global.nest(135,{ value : arm_Context.brushScale});
					arm_Context.brushScale = ui.slider(brushScaleHandle,arm_Translator.tr("UV Scale"),0.01,5.0,true);
					if(brushScaleHandle.changed) {
						if(arm_Context.tool == 3 || arm_Context.tool == 4) {
							ui.g.end();
							arm_util_RenderUtil.makeDecalPreview();
							ui.g.begin(false);
						}
					}
					arm_Context.brushAngle = ui.slider(arm_Context.brushAngleHandle,arm_Translator.tr("Angle"),0.0,360.0,true,1);
					if(ui.isHovered) {
						let _g = new haxe_ds_StringMap();
						_g.h["brush_angle"] = arm_Config.keymap.brush_angle;
						ui.tooltip(arm_Translator.tr("Hold {brush_angle} and move mouse to the left to decrease the angle\nHold {brush_angle} and move mouse to the right to increase the angle",_g));
					}
					if(arm_Context.brushAngleHandle.changed) {
						arm_node_MakeMaterial.parsePaintMaterial();
					}
				}
				arm_Context.brushOpacity = ui.slider(arm_Context.brushOpacityHandle,arm_Translator.tr("Opacity"),0.0,1.0,true);
				if(ui.isHovered) {
					let _g = new haxe_ds_StringMap();
					_g.h["brush_opacity"] = arm_Config.keymap.brush_opacity;
					ui.tooltip(arm_Translator.tr("Hold {brush_opacity} and move mouse to the left to decrease the opacity\nHold {brush_opacity} and move mouse to the right to increase the opacity",_g));
				}
				if(arm_Context.tool == 0 || arm_Context.tool == 1 || decalMask) {
					arm_Context.brushHardness = ui.slider(zui_Handle.global.nest(136,{ value : arm_Context.brushHardness}),arm_Translator.tr("Hardness"),0.0,1.0,true);
				}
				if(arm_Context.tool != 1) {
					let brushBlendingHandle = zui_Handle.global.nest(137,{ value : arm_Context.brushBlending});
					arm_Context.brushBlending = ui.combo(brushBlendingHandle,[arm_Translator.tr("Mix"),arm_Translator.tr("Darken"),arm_Translator.tr("Multiply"),arm_Translator.tr("Burn"),arm_Translator.tr("Lighten"),arm_Translator.tr("Screen"),arm_Translator.tr("Dodge"),arm_Translator.tr("Add"),arm_Translator.tr("Overlay"),arm_Translator.tr("Soft Light"),arm_Translator.tr("Linear Light"),arm_Translator.tr("Difference"),arm_Translator.tr("Subtract"),arm_Translator.tr("Divide"),arm_Translator.tr("Hue"),arm_Translator.tr("Saturation"),arm_Translator.tr("Color"),arm_Translator.tr("Value")],arm_Translator.tr("Blending"));
					if(brushBlendingHandle.changed) {
						arm_node_MakeMaterial.parsePaintMaterial();
					}
				}
				if(arm_Context.tool == 0 || arm_Context.tool == 2) {
					let paintHandle = zui_Handle.global.nest(138,null);
					arm_Context.brushPaint = ui.combo(paintHandle,[arm_Translator.tr("UV Map"),arm_Translator.tr("Triplanar"),arm_Translator.tr("Project")],arm_Translator.tr("TexCoord"));
					if(paintHandle.changed) {
						arm_node_MakeMaterial.parsePaintMaterial();
					}
				}
				if(arm_Context.tool == 4) {
					let h = zui_Handle.global.nest(139,null);
					h.text = arm_Context.textToolText;
					arm_Context.textToolText = ui.textInput(h,"");
					if(h.changed) {
						ui.g.end();
						arm_util_RenderUtil.makeTextPreview();
						arm_util_RenderUtil.makeDecalPreview();
						ui.g.begin(false);
					}
				}
				if(arm_Context.tool == 2) {
					ui.combo(arm_Context.fillTypeHandle,[arm_Translator.tr("Object"),arm_Translator.tr("Face"),arm_Translator.tr("Angle"),arm_Translator.tr("UV Island")],arm_Translator.tr("Fill Mode"));
					if(arm_Context.fillTypeHandle.changed) {
						if(arm_Context.fillTypeHandle.position == 1) {
							ui.g.end();
							arm_util_UVUtil.cacheTriangleMap();
							ui.g.begin(false);
						}
						arm_node_MakeMaterial.parsePaintMaterial();
						arm_node_MakeMaterial.parseMeshMaterial();
					}
				} else {
					let _w = ui._w;
					let sc = ui.ops.scaleFactor;
					ui._w = 60 * sc | 0;
					let xrayHandle = zui_Handle.global.nest(140,{ selected : arm_Context.xray});
					arm_Context.xray = ui.check(xrayHandle,arm_Translator.tr("X-Ray"));
					if(xrayHandle.changed) {
						arm_node_MakeMaterial.parsePaintMaterial();
					}
					let symXHandle = zui_Handle.global.nest(141,{ selected : false});
					let symYHandle = zui_Handle.global.nest(142,{ selected : false});
					let symZHandle = zui_Handle.global.nest(143,{ selected : false});
					ui._w = 56 * sc | 0;
					ui.text(arm_Translator.tr("Symmetry"));
					ui._w = 25 * sc | 0;
					arm_Context.symX = ui.check(symXHandle,arm_Translator.tr("X"));
					arm_Context.symY = ui.check(symYHandle,arm_Translator.tr("Y"));
					arm_Context.symZ = ui.check(symZHandle,arm_Translator.tr("Z"));
					if(symXHandle.changed || symYHandle.changed || symZHandle.changed) {
						arm_node_MakeMaterial.parsePaintMaterial();
					}
					ui._w = _w;
				}
				if(arm_Context.tool == 6) {
					ui._x += 10 * ui.ops.scaleFactor;
					let dirHandle = zui_Handle.global.nest(144,{ selected : false});
					arm_Context.blurDirectional = ui.check(dirHandle,arm_Translator.tr("Directional"));
					if(dirHandle.changed) {
						arm_node_MakeMaterial.parsePaintMaterial();
					}
				}
				if(arm_Context.tool == 7) {
					ui._x += 10 * ui.ops.scaleFactor;
					zui_Handle.global.nest(145,{ selected : false});
				}
			}
		}
	}
}
$hxClasses["arm.ui.UIHeader"] = arm_ui_UIHeader;
arm_ui_UIHeader.__name__ = "arm.ui.UIHeader";
Object.assign(arm_ui_UIHeader.prototype, {
	__class__: arm_ui_UIHeader
});
class arm_ui_UIMenubar {
	constructor() {
		this.menubarw = 330;
		this.menuHandle = new zui_Handle({ layout : 1});
		this.workspaceHandle = new zui_Handle({ layout : 1});
		arm_ui_UIMenubar.inst = this;
	}
	renderUI(g) {
		let ui = arm_ui_UISidebar.inst.ui;
		let panelx = arm_App.x() - arm_ui_UIToolbar.inst.toolbarw;
		if(ui.window(this.menuHandle,panelx,0,this.menubarw,28 * ui.ops.scaleFactor | 0)) {
			ui._x += 1;
			zui_Ext.beginMenu(ui);
			let categories = [arm_Translator.tr("File"),arm_Translator.tr("Edit"),arm_Translator.tr("Viewport"),arm_Translator.tr("Mode"),arm_Translator.tr("Camera"),arm_Translator.tr("Help")];
			let _g = 0;
			let _g1 = categories.length;
			while(_g < _g1) {
				let i = _g++;
				if(zui_Ext.menuButton(ui,categories[i]) || arm_ui_UIMenu.show && arm_ui_UIMenu.menuCommands == null && ui.isHovered) {
					this.showMenu(ui,i);
				}
			}
			if(this.menubarw < ui._x + 10) {
				this.menubarw = ui._x + 10 | 0;
				arm_ui_UIToolbar.inst.toolbarHandle.redraws = 2;
			}
			zui_Ext.endMenu(ui);
		}
		let panelx1 = arm_App.x() - arm_ui_UIToolbar.inst.toolbarw + this.menubarw;
		if(ui.window(this.workspaceHandle,panelx1,0,kha_System.windowWidth() - arm_Config.raw.layout[0] - this.menubarw,28 * ui.ops.scaleFactor | 0)) {
			ui.tab(arm_ui_UIHeader.inst.worktab,arm_Translator.tr("Paint"));
			ui.tab(arm_ui_UIHeader.inst.worktab,arm_Translator.tr("Material"));
			ui.tab(arm_ui_UIHeader.inst.worktab,arm_Translator.tr("Bake"));
			if(arm_ui_UIHeader.inst.worktab.changed) {
				arm_Context.ddirty = 2;
				arm_Context.brushBlendDirty = true;
				arm_ui_UIToolbar.inst.toolbarHandle.redraws = 2;
				arm_ui_UIHeader.inst.headerHandle.redraws = 2;
				arm_ui_UISidebar.inst.hwnd0.redraws = 2;
				arm_ui_UISidebar.inst.hwnd1.redraws = 2;
				if(arm_ui_UIHeader.inst.worktab.position == 0) {
					arm_Context.selectTool(0);
				} else if(arm_ui_UIHeader.inst.worktab.position == 2) {
					arm_Context.selectTool(11);
				} else if(arm_ui_UIHeader.inst.worktab.position == 1) {
					arm_Context.selectTool(9);
					arm_Layers.updateFillLayers();
				}
				arm_Context.mainObject().skip_context = null;
			}
		}
	}
	showMenu(ui,category) {
		arm_ui_UIMenu.show = true;
		arm_ui_UIMenu.menuCategory = category;
		arm_ui_UIMenu.menuX = ui._x - ui._w | 0;
		arm_ui_UIMenu.menuY = ui.t.BUTTON_H * ui.ops.scaleFactor * 1.1 + 2 + ui.buttonOffsetY | 0;
	}
}
$hxClasses["arm.ui.UIMenubar"] = arm_ui_UIMenubar;
arm_ui_UIMenubar.__name__ = "arm.ui.UIMenubar";
Object.assign(arm_ui_UIMenubar.prototype, {
	__class__: arm_ui_UIMenubar
});
class arm_ui_UIToolbar {
	constructor() {
		this.toolCount = [10,2,1,1];
		this.toolNames = ["Brush","Eraser","Fill","Decal","Text","Clone","Blur","Particle","ColorID","Picker","Gizmo","Bake"];
		this.toolbarw = 36;
		this.toolbarHandle = new zui_Handle();
		arm_ui_UIToolbar.inst = this;
	}
	renderUI(g) {
		let ui = arm_ui_UISidebar.inst.ui;
		if(ui.window(this.toolbarHandle,0,arm_ui_UIHeader.inst.headerh,this.toolbarw,kha_System.windowHeight() - arm_ui_UIHeader.inst.headerh)) {
			ui._y -= 4 * ui.ops.scaleFactor;
			ui.imageScrollAlign = false;
			let img = arm_Res.bundled.h["icons.k"];
			let imgw = ui.ops.scaleFactor > 1 ? 100 : 50;
			let col = ui.t.WINDOW_BG_COL;
			if(col < 0) {
				col += 4294967296;
			}
			let light = col > 4284900966.;
			let iconAccent = light ? -10066330 : -1;
			let rect = arm_Res.tile50(img,7,1);
			ui.image(img,light ? -10066330 : ui.t.BUTTON_COL,null,rect.x,rect.y,rect.w,rect.h);
			ui._y -= 4 * ui.ops.scaleFactor;
			if(arm_ui_UIHeader.inst.worktab.position == 0) {
				let _g = new haxe_ds_StringMap();
				_g.h["key"] = arm_Config.keymap.brush_ruler;
				_g.h["action_paint"] = arm_Config.keymap.action_paint;
				let keys = "(" + arm_Config.keymap.tool_brush + ") - " + arm_Translator.tr("Hold {action_paint} to paint\nHold {key} and press {action_paint} to paint a straight line (ruler mode)",_g);
				let _g1 = new haxe_ds_StringMap();
				_g1.h["key"] = arm_Config.keymap.brush_ruler;
				_g1.h["action_paint"] = arm_Config.keymap.action_paint;
				let keys1 = "(" + arm_Config.keymap.tool_eraser + ") - " + arm_Translator.tr("Hold {action_paint} to erase\nHold {key} and press {action_paint} to erase a straight line (ruler mode)",_g1);
				let keys2 = "(" + arm_Config.keymap.tool_fill + ")";
				let _g2 = new haxe_ds_StringMap();
				_g2.h["key"] = arm_Config.keymap.decal_mask;
				let keys3 = "(" + arm_Config.keymap.tool_decal + ") - " + arm_Translator.tr("Hold {key} to paint on a decal mask",_g2);
				let _g3 = new haxe_ds_StringMap();
				_g3.h["key"] = arm_Config.keymap.decal_mask;
				let keys4 = "(" + arm_Config.keymap.tool_text + ") - " + arm_Translator.tr("Hold {key} to use the text as a mask",_g3);
				let _g4 = new haxe_ds_StringMap();
				_g4.h["key"] = arm_Config.keymap.set_clone_source;
				let keys5 = [keys,keys1,keys2,keys3,keys4,"(" + arm_Config.keymap.tool_clone + ") - " + arm_Translator.tr("Hold {key} to set source",_g4),"(" + arm_Config.keymap.tool_blur + ")","(" + arm_Config.keymap.tool_particle + ")","(" + arm_Config.keymap.tool_colorid + ")","(" + arm_Config.keymap.tool_picker + ")"];
				let _g5 = 0;
				let _g6 = this.toolCount[0];
				while(_g5 < _g6) {
					let i = _g5++;
					ui._x += 2;
					if(arm_Context.tool == i) {
						ui.fill(-1,2,34,34,ui.t.HIGHLIGHT_COL);
					}
					let rect = arm_Res.tile50(img,i,0);
					if(ui.image(img,iconAccent,null,rect.x,rect.y,rect.w,rect.h) == 1) {
						arm_Context.selectTool(i);
					}
					if(ui.isHovered) {
						ui.tooltip(arm_Translator.tr(this.toolNames[i]) + " " + keys5[i]);
					}
					ui._x -= 2;
					ui._y += 2;
				}
			} else if(arm_ui_UIHeader.inst.worktab.position == 1) {
				ui._x += 2;
				if(arm_Context.tool == 9) {
					ui.fill(-1,2,34,34,ui.t.HIGHLIGHT_COL);
				}
				if(ui.image(img,iconAccent,null,imgw * 9,0,imgw,imgw) == 1) {
					arm_Context.selectTool(9);
				}
				if(ui.isHovered) {
					ui.tooltip(arm_Translator.tr("Picker") + " (V)");
				}
				ui._x -= 2;
				ui._y += 2;
			} else if(arm_ui_UIHeader.inst.worktab.position == 2) {
				ui._x += 2;
				if(arm_Context.tool == 11) {
					ui.fill(-1,2,34,34,ui.t.HIGHLIGHT_COL);
				}
				if(ui.image(img,iconAccent,null,imgw * 11,0,imgw,imgw) == 1) {
					arm_Context.selectTool(11);
				}
				if(ui.isHovered) {
					ui.tooltip(arm_Translator.tr("Bake") + " (K)");
				}
				ui._x -= 2;
				ui._y += 2;
				ui._x += 2;
				if(arm_Context.tool == 9) {
					ui.fill(-1,2,34,34,ui.t.HIGHLIGHT_COL);
				}
				if(ui.image(img,iconAccent,null,imgw * 9,0,imgw,imgw) == 1) {
					arm_Context.selectTool(9);
				}
				if(ui.isHovered) {
					ui.tooltip(arm_Translator.tr("Picker") + " (V)");
				}
				ui._x -= 2;
				ui._y += 2;
			}
			ui.imageScrollAlign = true;
		}
	}
}
$hxClasses["arm.ui.UIToolbar"] = arm_ui_UIToolbar;
arm_ui_UIToolbar.__name__ = "arm.ui.UIToolbar";
Object.assign(arm_ui_UIToolbar.prototype, {
	__class__: arm_ui_UIToolbar
});
class arm_util_ParticleUtil {
	static f32(ar) {
		let res = new Float32Array(ar.length);
		let _g = 0;
		let _g1 = ar.length;
		while(_g < _g1) {
			let i = _g++;
			res[i] = ar[i];
		}
		return res;
	}
	static initParticle() {
		if(arm_Context.particleMaterial != null) {
			return;
		}
		let raw = { name : "Particles", type : 0, loop : false, count : 1000, frame_start : 0, frame_end : 1000, lifetime : 400, lifetime_random : 0.5, emit_from : 1, object_align_factor : arm_util_ParticleUtil.f32([0,0,-40]), factor_random : 2.0, physics_type : 0, particle_size : 1.0, size_random : 0, mass : 1, instance_object : ".Particle", weight_gravity : 1};
		iron_Scene.active.raw.particle_datas = [raw];
		let particle_refs = [{ name : "Particles", particle : "Particles", seed : 0}];
		let t = new iron_RenderTargetRaw();
		t.name = "texparticle";
		t.width = 0;
		t.height = 0;
		t.format = "R8";
		t.scale = arm_render_Inc.superSample;
		iron_RenderPath.active.createRenderTarget(t);
		let _g = 0;
		let _g1 = iron_Scene.active.raw.material_datas;
		while(_g < _g1.length) {
			let mat = _g1[_g];
			++_g;
			if(mat.name == "Material2") {
				let m = JSON.parse(JSON.stringify(mat));
				m.name = "MaterialParticle";
				iron_Scene.active.raw.material_datas.push(m);
				break;
			}
		}
		iron_data_Data.getMaterial("Scene","MaterialParticle",function(md) {
			arm_Context.particleMaterial = md;
			let _g = 0;
			let _g1 = iron_Scene.active.raw.objects;
			while(_g < _g1.length) {
				let obj = _g1[_g];
				++_g;
				if(obj.name == ".Sphere") {
					let particle = JSON.parse(JSON.stringify(obj));
					particle.name = ".Particle";
					particle.is_particle = true;
					particle.material_refs = ["MaterialParticle"];
					iron_Scene.active.raw.objects.push(particle);
					particle.transform.values[0] *= 0.01;
					particle.transform.values[1] *= 0.01;
					particle.transform.values[2] *= 0.01;
					particle.transform.values[3] *= 0.01;
					particle.transform.values[4] *= 0.01;
					particle.transform.values[5] *= 0.01;
					particle.transform.values[6] *= 0.01;
					particle.transform.values[7] *= 0.01;
					particle.transform.values[8] *= 0.01;
					particle.transform.values[9] *= 0.01;
					particle.transform.values[10] *= 0.01;
					particle.transform.values[11] *= 0.01;
					particle.transform.values[12] *= 0.01;
					particle.transform.values[13] *= 0.01;
					particle.transform.values[14] *= 0.01;
					particle.transform.values[15] *= 0.01;
					break;
				}
			}
			iron_Scene.active.spawnObject(".Sphere",null,function(o) {
				let mo = o;
				mo.name = ".ParticleEmitter";
				mo.raw = JSON.parse(JSON.stringify(mo.raw));
				mo.raw.particle_refs = particle_refs;
				mo.setupParticleSystem("Scene",particle_refs[0]);
			});
		});
	}
}
$hxClasses["arm.util.ParticleUtil"] = arm_util_ParticleUtil;
arm_util_ParticleUtil.__name__ = "arm.util.ParticleUtil";
class haxe_IMap {
}
$hxClasses["haxe.IMap"] = haxe_IMap;
haxe_IMap.__name__ = "haxe.IMap";
haxe_IMap.__isInterface__ = true;
class haxe_Exception extends Error {
	constructor(message,previous,native) {
		super(message);
		this.message = message;
		this.__previousException = previous;
		this.__nativeException = native != null ? native : this;
	}
	unwrap() {
		return this.__nativeException;
	}
	toString() {
		return this.get_message();
	}
	get_message() {
		return this.message;
	}
	get_native() {
		return this.__nativeException;
	}
	static caught(value) {
		if(((value) instanceof haxe_Exception)) {
			return value;
		} else if(((value) instanceof Error)) {
			return new haxe_Exception(value.message,null,value);
		} else {
			return new haxe_ValueException(value,null,value);
		}
	}
	static thrown(value) {
		if(((value) instanceof haxe_Exception)) {
			return value.get_native();
		} else if(((value) instanceof Error)) {
			return value;
		} else {
			let e = new haxe_ValueException(value);
			return e;
		}
	}
}
$hxClasses["haxe.Exception"] = haxe_Exception;
haxe_Exception.__name__ = "haxe.Exception";
haxe_Exception.__super__ = Error;
Object.assign(haxe_Exception.prototype, {
	__class__: haxe_Exception
	,__properties__: {get_native: "get_native",get_message: "get_message"}
});
class haxe__$Int64__$_$_$Int64 {
	constructor(high,low) {
		this.high = high;
		this.low = low;
	}
}
$hxClasses["haxe._Int64.___Int64"] = haxe__$Int64__$_$_$Int64;
haxe__$Int64__$_$_$Int64.__name__ = "haxe._Int64.___Int64";
Object.assign(haxe__$Int64__$_$_$Int64.prototype, {
	__class__: haxe__$Int64__$_$_$Int64
});
class haxe_Log {
	static formatOutput(v,infos) {
		let str = Std.string(v);
		if(infos == null) {
			return str;
		}
		let pstr = infos.fileName + ":" + infos.lineNumber;
		if(infos.customParams != null) {
			let _g = 0;
			let _g1 = infos.customParams;
			while(_g < _g1.length) str += ", " + Std.string(_g1[_g++]);
		}
		return pstr + ": " + str;
	}
	static trace(v,infos) {
		let str = haxe_Log.formatOutput(v,infos);
		if(typeof(console) != "undefined" && console.log != null) {
			console.log(str);
		}
	}
}
$hxClasses["haxe.Log"] = haxe_Log;
haxe_Log.__name__ = "haxe.Log";
class haxe_ValueException extends haxe_Exception {
	constructor(value,previous,native) {
		super(String(value),previous,native);
		this.value = value;
	}
	unwrap() {
		return this.value;
	}
}
$hxClasses["haxe.ValueException"] = haxe_ValueException;
haxe_ValueException.__name__ = "haxe.ValueException";
haxe_ValueException.__super__ = haxe_Exception;
Object.assign(haxe_ValueException.prototype, {
	__class__: haxe_ValueException
});
class haxe_ds_IntMap {
	constructor() {
		this.h = { };
	}
	remove(key) {
		if(!this.h.hasOwnProperty(key)) {
			return false;
		}
		delete(this.h[key]);
		return true;
	}
	keys() {
		let a = [];
		for( var key in this.h ) if(this.h.hasOwnProperty(key)) a.push(+key);
		return new haxe_iterators_ArrayIterator(a);
	}
	iterator() {
		return { ref : this.h, it : this.keys(), hasNext : function() {
			return this.it.hasNext();
		}, next : function() {
			let i = this.it.next();
			return this.ref[i];
		}};
	}
}
$hxClasses["haxe.ds.IntMap"] = haxe_ds_IntMap;
haxe_ds_IntMap.__name__ = "haxe.ds.IntMap";
haxe_ds_IntMap.__interfaces__ = [haxe_IMap];
Object.assign(haxe_ds_IntMap.prototype, {
	__class__: haxe_ds_IntMap
});
class haxe_ds_ObjectMap {
	constructor() {
		this.h = { __keys__ : { }};
	}
	set(key,value) {
		let id = key.__id__;
		if(id == null) {
			id = (key.__id__ = $global.$haxeUID++);
		}
		this.h[id] = value;
		this.h.__keys__[id] = key;
	}
	remove(key) {
		let id = key.__id__;
		if(this.h.__keys__[id] == null) {
			return false;
		}
		delete(this.h[id]);
		delete(this.h.__keys__[id]);
		return true;
	}
	keys() {
		let a = [];
		for( var key in this.h.__keys__ ) {
		if(this.h.hasOwnProperty(key)) {
			a.push(this.h.__keys__[key]);
		}
		}
		return new haxe_iterators_ArrayIterator(a);
	}
}
$hxClasses["haxe.ds.ObjectMap"] = haxe_ds_ObjectMap;
haxe_ds_ObjectMap.__name__ = "haxe.ds.ObjectMap";
haxe_ds_ObjectMap.__interfaces__ = [haxe_IMap];
Object.assign(haxe_ds_ObjectMap.prototype, {
	__class__: haxe_ds_ObjectMap
});
class haxe_ds_StringMap {
	constructor() {
		this.h = Object.create(null);
	}
}
$hxClasses["haxe.ds.StringMap"] = haxe_ds_StringMap;
haxe_ds_StringMap.__name__ = "haxe.ds.StringMap";
haxe_ds_StringMap.__interfaces__ = [haxe_IMap];
Object.assign(haxe_ds_StringMap.prototype, {
	__class__: haxe_ds_StringMap
});
class haxe_ds__$StringMap_StringMapKeyIterator {
	constructor(h) {
		this.h = h;
		this.keys = Object.keys(h);
		this.length = this.keys.length;
		this.current = 0;
	}
	hasNext() {
		return this.current < this.length;
	}
	next() {
		return this.keys[this.current++];
	}
}
$hxClasses["haxe.ds._StringMap.StringMapKeyIterator"] = haxe_ds__$StringMap_StringMapKeyIterator;
haxe_ds__$StringMap_StringMapKeyIterator.__name__ = "haxe.ds._StringMap.StringMapKeyIterator";
Object.assign(haxe_ds__$StringMap_StringMapKeyIterator.prototype, {
	__class__: haxe_ds__$StringMap_StringMapKeyIterator
});
class haxe_exceptions_PosException extends haxe_Exception {
	constructor(message,previous,pos) {
		super(message,previous);
		if(pos == null) {
			this.posInfos = { fileName : "(unknown)", lineNumber : 0, className : "(unknown)", methodName : "(unknown)"};
		} else {
			this.posInfos = pos;
		}
	}
	toString() {
		return "" + super.toString() + " in " + this.posInfos.className + "." + this.posInfos.methodName + " at " + this.posInfos.fileName + ":" + this.posInfos.lineNumber;
	}
}
$hxClasses["haxe.exceptions.PosException"] = haxe_exceptions_PosException;
haxe_exceptions_PosException.__name__ = "haxe.exceptions.PosException";
haxe_exceptions_PosException.__super__ = haxe_Exception;
Object.assign(haxe_exceptions_PosException.prototype, {
	__class__: haxe_exceptions_PosException
});
class haxe_exceptions_NotImplementedException extends haxe_exceptions_PosException {
	constructor(message,previous,pos) {
		if(message == null) {
			message = "Not implemented";
		}
		super(message,previous,pos);
	}
}
$hxClasses["haxe.exceptions.NotImplementedException"] = haxe_exceptions_NotImplementedException;
haxe_exceptions_NotImplementedException.__name__ = "haxe.exceptions.NotImplementedException";
haxe_exceptions_NotImplementedException.__super__ = haxe_exceptions_PosException;
Object.assign(haxe_exceptions_NotImplementedException.prototype, {
	__class__: haxe_exceptions_NotImplementedException
});
class haxe_io_BytesBuffer {
	constructor() {
		this.pos = 0;
		this.size = 0;
	}
	addByte(byte) {
		if(this.pos == this.size) {
			this.grow(1);
		}
		this.view.setUint8(this.pos++,byte);
	}
	addBytes(src,pos,len) {
		if(pos < 0 || len < 0 || pos + len > src.length) {
			throw haxe_Exception.thrown(haxe_io_Error.OutsideBounds);
		}
		if(this.pos + len > this.size) {
			this.grow(len);
		}
		if(this.size == 0) {
			return;
		}
		this.u8.set(new Uint8Array(src.b.buffer,src.b.byteOffset + pos,len),this.pos);
		this.pos += len;
	}
	grow(delta) {
		let req = this.pos + delta;
		let nsize = this.size == 0 ? 16 : this.size;
		while(nsize < req) nsize = nsize * 3 >> 1;
		let nbuf = new ArrayBuffer(nsize);
		let nu8 = new Uint8Array(nbuf);
		if(this.size > 0) {
			nu8.set(this.u8);
		}
		this.size = nsize;
		this.buffer = nbuf;
		this.u8 = nu8;
		this.view = new DataView(this.buffer);
	}
	getBytes() {
		if(this.size == 0) {
			return new haxe_io_Bytes(new ArrayBuffer(0));
		}
		let b = new haxe_io_Bytes(this.buffer);
		b.length = this.pos;
		return b;
	}
}
$hxClasses["haxe.io.BytesBuffer"] = haxe_io_BytesBuffer;
haxe_io_BytesBuffer.__name__ = "haxe.io.BytesBuffer";
Object.assign(haxe_io_BytesBuffer.prototype, {
	__class__: haxe_io_BytesBuffer
});
var haxe_io_Encoding = $hxEnums["haxe.io.Encoding"] = { __ename__:true,__constructs__:null
	,UTF8: {_hx_name:"UTF8",_hx_index:0,__enum__:"haxe.io.Encoding",toString:$estr}
	,RawNative: {_hx_name:"RawNative",_hx_index:1,__enum__:"haxe.io.Encoding",toString:$estr}
};
haxe_io_Encoding.__constructs__ = [haxe_io_Encoding.UTF8,haxe_io_Encoding.RawNative];
class haxe_io_Eof {
	constructor() {
	}
	toString() {
		return "Eof";
	}
}
$hxClasses["haxe.io.Eof"] = haxe_io_Eof;
haxe_io_Eof.__name__ = "haxe.io.Eof";
Object.assign(haxe_io_Eof.prototype, {
	__class__: haxe_io_Eof
});
var haxe_io_Error = $hxEnums["haxe.io.Error"] = { __ename__:true,__constructs__:null
	,Blocked: {_hx_name:"Blocked",_hx_index:0,__enum__:"haxe.io.Error",toString:$estr}
	,Overflow: {_hx_name:"Overflow",_hx_index:1,__enum__:"haxe.io.Error",toString:$estr}
	,OutsideBounds: {_hx_name:"OutsideBounds",_hx_index:2,__enum__:"haxe.io.Error",toString:$estr}
	,Custom: ($_=function(e) { return {_hx_index:3,e:e,__enum__:"haxe.io.Error",toString:$estr}; },$_._hx_name="Custom",$_.__params__ = ["e"],$_)
};
haxe_io_Error.__constructs__ = [haxe_io_Error.Blocked,haxe_io_Error.Overflow,haxe_io_Error.OutsideBounds,haxe_io_Error.Custom];
class haxe_io_FPHelper {
	static i32ToFloat(i) {
		haxe_io_FPHelper.helper.setInt32(0,i,true);
		return haxe_io_FPHelper.helper.getFloat32(0,true);
	}
	static floatToI32(f) {
		haxe_io_FPHelper.helper.setFloat32(0,f,true);
		return haxe_io_FPHelper.helper.getInt32(0,true);
	}
	static i64ToDouble(low,high) {
		haxe_io_FPHelper.helper.setInt32(0,low,true);
		haxe_io_FPHelper.helper.setInt32(4,high,true);
		return haxe_io_FPHelper.helper.getFloat64(0,true);
	}
}
$hxClasses["haxe.io.FPHelper"] = haxe_io_FPHelper;
haxe_io_FPHelper.__name__ = "haxe.io.FPHelper";
class haxe_iterators_ArrayIterator {
	constructor(array) {
		this.current = 0;
		this.array = array;
	}
	hasNext() {
		return this.current < this.array.length;
	}
	next() {
		return this.array[this.current++];
	}
}
$hxClasses["haxe.iterators.ArrayIterator"] = haxe_iterators_ArrayIterator;
haxe_iterators_ArrayIterator.__name__ = "haxe.iterators.ArrayIterator";
Object.assign(haxe_iterators_ArrayIterator.prototype, {
	__class__: haxe_iterators_ArrayIterator
});
class haxe_xml_XmlParserException {
	constructor(message,xml,position) {
		this.xml = xml;
		this.message = message;
		this.position = position;
		this.lineNumber = 1;
		this.positionAtLine = 0;
		let _g = 0;
		while(_g < position) {
			let c = xml.charCodeAt(_g++);
			if(c == 10) {
				this.lineNumber++;
				this.positionAtLine = 0;
			} else if(c != 13) {
				this.positionAtLine++;
			}
		}
	}
	toString() {
		let c = js_Boot.getClass(this);
		return c.__name__ + ": " + this.message + " at line " + this.lineNumber + " char " + this.positionAtLine;
	}
}
$hxClasses["haxe.xml.XmlParserException"] = haxe_xml_XmlParserException;
haxe_xml_XmlParserException.__name__ = "haxe.xml.XmlParserException";
Object.assign(haxe_xml_XmlParserException.prototype, {
	__class__: haxe_xml_XmlParserException
});
class haxe_xml_Parser {
	static parse(str,strict) {
		if(strict == null) {
			strict = false;
		}
		let doc = Xml.createDocument();
		haxe_xml_Parser.doParse(str,strict,0,doc);
		return doc;
	}
	static doParse(str,strict,p,parent) {
		if(p == null) {
			p = 0;
		}
		let xml = null;
		let state = 1;
		let next = 1;
		let aname = null;
		let start = 0;
		let nsubs = 0;
		let nbrackets = 0;
		let buf = new StringBuf();
		let escapeNext = 1;
		let attrValQuote = -1;
		while(p < str.length) {
			let c = str.charCodeAt(p);
			switch(state) {
			case 0:
				switch(c) {
				case 9:case 10:case 13:case 32:
					break;
				default:
					state = next;
					continue;
				}
				break;
			case 1:
				if(c == 60) {
					state = 0;
					next = 2;
				} else {
					start = p;
					state = 13;
					continue;
				}
				break;
			case 2:
				switch(c) {
				case 33:
					if(str.charCodeAt(p + 1) == 91) {
						p += 2;
						if(HxOverrides.substr(str,p,6).toUpperCase() != "CDATA[") {
							throw haxe_Exception.thrown(new haxe_xml_XmlParserException("Expected <![CDATA[",str,p));
						}
						p += 5;
						state = 17;
						start = p + 1;
					} else if(str.charCodeAt(p + 1) == 68 || str.charCodeAt(p + 1) == 100) {
						if(HxOverrides.substr(str,p + 2,6).toUpperCase() != "OCTYPE") {
							throw haxe_Exception.thrown(new haxe_xml_XmlParserException("Expected <!DOCTYPE",str,p));
						}
						p += 8;
						state = 16;
						start = p + 1;
					} else if(str.charCodeAt(p + 1) != 45 || str.charCodeAt(p + 2) != 45) {
						throw haxe_Exception.thrown(new haxe_xml_XmlParserException("Expected <!--",str,p));
					} else {
						p += 2;
						state = 15;
						start = p + 1;
					}
					break;
				case 47:
					if(parent == null) {
						throw haxe_Exception.thrown(new haxe_xml_XmlParserException("Expected node name",str,p));
					}
					start = p + 1;
					state = 0;
					next = 10;
					break;
				case 63:
					state = 14;
					start = p;
					break;
				default:
					state = 3;
					start = p;
					continue;
				}
				break;
			case 3:
				if(!(c >= 97 && c <= 122 || c >= 65 && c <= 90 || c >= 48 && c <= 57 || c == 58 || c == 46 || c == 95 || c == 45)) {
					if(p == start) {
						throw haxe_Exception.thrown(new haxe_xml_XmlParserException("Expected node name",str,p));
					}
					xml = Xml.createElement(HxOverrides.substr(str,start,p - start));
					parent.addChild(xml);
					++nsubs;
					state = 0;
					next = 4;
					continue;
				}
				break;
			case 4:
				switch(c) {
				case 47:
					state = 11;
					break;
				case 62:
					state = 9;
					break;
				default:
					state = 5;
					start = p;
					continue;
				}
				break;
			case 5:
				if(!(c >= 97 && c <= 122 || c >= 65 && c <= 90 || c >= 48 && c <= 57 || c == 58 || c == 46 || c == 95 || c == 45)) {
					if(start == p) {
						throw haxe_Exception.thrown(new haxe_xml_XmlParserException("Expected attribute name",str,p));
					}
					aname = HxOverrides.substr(str,start,p - start);
					if(xml.exists(aname)) {
						throw haxe_Exception.thrown(new haxe_xml_XmlParserException("Duplicate attribute [" + aname + "]",str,p));
					}
					state = 0;
					next = 6;
					continue;
				}
				break;
			case 6:
				if(c == 61) {
					state = 0;
					next = 7;
				} else {
					throw haxe_Exception.thrown(new haxe_xml_XmlParserException("Expected =",str,p));
				}
				break;
			case 7:
				switch(c) {
				case 34:case 39:
					buf = new StringBuf();
					state = 8;
					start = p + 1;
					attrValQuote = c;
					break;
				default:
					throw haxe_Exception.thrown(new haxe_xml_XmlParserException("Expected \"",str,p));
				}
				break;
			case 8:
				switch(c) {
				case 38:
					let len = p - start;
					buf.b += len == null ? HxOverrides.substr(str,start,null) : HxOverrides.substr(str,start,len);
					state = 18;
					escapeNext = 8;
					start = p + 1;
					break;
				case 60:case 62:
					if(strict) {
						throw haxe_Exception.thrown(new haxe_xml_XmlParserException("Invalid unescaped " + String.fromCodePoint(c) + " in attribute value",str,p));
					} else if(c == attrValQuote) {
						let len = p - start;
						buf.b += len == null ? HxOverrides.substr(str,start,null) : HxOverrides.substr(str,start,len);
						let val = buf.b;
						buf = new StringBuf();
						xml.set(aname,val);
						state = 0;
						next = 4;
					}
					break;
				default:
					if(c == attrValQuote) {
						let len = p - start;
						buf.b += len == null ? HxOverrides.substr(str,start,null) : HxOverrides.substr(str,start,len);
						let val = buf.b;
						buf = new StringBuf();
						xml.set(aname,val);
						state = 0;
						next = 4;
					}
				}
				break;
			case 9:
				p = haxe_xml_Parser.doParse(str,strict,p,xml);
				start = p;
				state = 1;
				break;
			case 10:
				if(!(c >= 97 && c <= 122 || c >= 65 && c <= 90 || c >= 48 && c <= 57 || c == 58 || c == 46 || c == 95 || c == 45)) {
					if(start == p) {
						throw haxe_Exception.thrown(new haxe_xml_XmlParserException("Expected node name",str,p));
					}
					let v = HxOverrides.substr(str,start,p - start);
					if(parent == null || parent.nodeType != 0) {
						throw haxe_Exception.thrown(new haxe_xml_XmlParserException("Unexpected </" + v + ">, tag is not open",str,p));
					}
					if(parent.nodeType != Xml.Element) {
						throw haxe_Exception.thrown("Bad node type, expected Element but found " + (parent.nodeType == null ? "null" : XmlType.toString(parent.nodeType)));
					}
					if(v != parent.nodeName) {
						if(parent.nodeType != Xml.Element) {
							throw haxe_Exception.thrown("Bad node type, expected Element but found " + (parent.nodeType == null ? "null" : XmlType.toString(parent.nodeType)));
						}
						throw haxe_Exception.thrown(new haxe_xml_XmlParserException("Expected </" + parent.nodeName + ">",str,p));
					}
					state = 0;
					next = 12;
					continue;
				}
				break;
			case 11:
				if(c == 62) {
					state = 1;
				} else {
					throw haxe_Exception.thrown(new haxe_xml_XmlParserException("Expected >",str,p));
				}
				break;
			case 12:
				if(c == 62) {
					if(nsubs == 0) {
						parent.addChild(Xml.createPCData(""));
					}
					return p;
				} else {
					throw haxe_Exception.thrown(new haxe_xml_XmlParserException("Expected >",str,p));
				}
				break;
			case 13:
				if(c == 60) {
					let len = p - start;
					buf.b += len == null ? HxOverrides.substr(str,start,null) : HxOverrides.substr(str,start,len);
					let child = Xml.createPCData(buf.b);
					buf = new StringBuf();
					parent.addChild(child);
					++nsubs;
					state = 0;
					next = 2;
				} else if(c == 38) {
					let len = p - start;
					buf.b += len == null ? HxOverrides.substr(str,start,null) : HxOverrides.substr(str,start,len);
					state = 18;
					escapeNext = 13;
					start = p + 1;
				}
				break;
			case 14:
				if(c == 63 && str.charCodeAt(p + 1) == 62) {
					++p;
					parent.addChild(Xml.createProcessingInstruction(HxOverrides.substr(str,start + 1,p - start - 2)));
					++nsubs;
					state = 1;
				}
				break;
			case 15:
				if(c == 45 && str.charCodeAt(p + 1) == 45 && str.charCodeAt(p + 2) == 62) {
					parent.addChild(Xml.createComment(HxOverrides.substr(str,start,p - start)));
					++nsubs;
					p += 2;
					state = 1;
				}
				break;
			case 16:
				if(c == 91) {
					++nbrackets;
				} else if(c == 93) {
					--nbrackets;
				} else if(c == 62 && nbrackets == 0) {
					parent.addChild(Xml.createDocType(HxOverrides.substr(str,start,p - start)));
					++nsubs;
					state = 1;
				}
				break;
			case 17:
				if(c == 93 && str.charCodeAt(p + 1) == 93 && str.charCodeAt(p + 2) == 62) {
					parent.addChild(Xml.createCData(HxOverrides.substr(str,start,p - start)));
					++nsubs;
					p += 2;
					state = 1;
				}
				break;
			case 18:
				if(c == 59) {
					let s = HxOverrides.substr(str,start,p - start);
					if(s.charCodeAt(0) == 35) {
						let c = s.charCodeAt(1) == 120 ? Std.parseInt("0" + HxOverrides.substr(s,1,s.length - 1)) : Std.parseInt(HxOverrides.substr(s,1,s.length - 1));
						buf.b += String.fromCodePoint(c);
					} else if(!Object.prototype.hasOwnProperty.call(haxe_xml_Parser.escapes.h,s)) {
						if(strict) {
							throw haxe_Exception.thrown(new haxe_xml_XmlParserException("Undefined entity: " + s,str,p));
						}
						buf.b += Std.string("&" + s + ";");
					} else {
						buf.b += Std.string(haxe_xml_Parser.escapes.h[s]);
					}
					start = p + 1;
					state = escapeNext;
				} else if(!(c >= 97 && c <= 122 || c >= 65 && c <= 90 || c >= 48 && c <= 57 || c == 58 || c == 46 || c == 95 || c == 45) && c != 35) {
					if(strict) {
						throw haxe_Exception.thrown(new haxe_xml_XmlParserException("Invalid character in entity: " + String.fromCodePoint(c),str,p));
					}
					buf.b += String.fromCodePoint(38);
					let len = p - start;
					buf.b += len == null ? HxOverrides.substr(str,start,null) : HxOverrides.substr(str,start,len);
					--p;
					start = p + 1;
					state = escapeNext;
				}
				break;
			}
			++p;
		}
		if(state == 1) {
			start = p;
			state = 13;
		}
		if(state == 13) {
			if(parent.nodeType == 0) {
				if(parent.nodeType != Xml.Element) {
					throw haxe_Exception.thrown("Bad node type, expected Element but found " + (parent.nodeType == null ? "null" : XmlType.toString(parent.nodeType)));
				}
				throw haxe_Exception.thrown(new haxe_xml_XmlParserException("Unclosed node <" + parent.nodeName + ">",str,p));
			}
			if(p != start || nsubs == 0) {
				let len = p - start;
				buf.b += len == null ? HxOverrides.substr(str,start,null) : HxOverrides.substr(str,start,len);
				parent.addChild(Xml.createPCData(buf.b));
				++nsubs;
			}
			return p;
		}
		if(!strict && state == 18 && escapeNext == 13) {
			buf.b += String.fromCodePoint(38);
			let len = p - start;
			buf.b += len == null ? HxOverrides.substr(str,start,null) : HxOverrides.substr(str,start,len);
			parent.addChild(Xml.createPCData(buf.b));
			++nsubs;
			return p;
		}
		throw haxe_Exception.thrown(new haxe_xml_XmlParserException("Unexpected end",str,p));
	}
}
$hxClasses["haxe.xml.Parser"] = haxe_xml_Parser;
haxe_xml_Parser.__name__ = "haxe.xml.Parser";
class haxe_xml_Printer {
	constructor(pretty) {
		this.output = new StringBuf();
		this.pretty = pretty;
	}
	writeNode(value,tabs) {
		switch(value.nodeType) {
		case 0:
			this.output.b += Std.string(tabs + "<");
			if(value.nodeType != Xml.Element) {
				throw haxe_Exception.thrown("Bad node type, expected Element but found " + (value.nodeType == null ? "null" : XmlType.toString(value.nodeType)));
			}
			this.output.b += Std.string(value.nodeName);
			let attribute = value.attributes();
			while(attribute.hasNext()) {
				let attribute1 = attribute.next();
				this.output.b += Std.string(" " + attribute1 + "=\"");
				let input = StringTools.htmlEscape(value.get(attribute1),true);
				this.output.b += Std.string(input);
				this.output.b += "\"";
			}
			if(this.hasChildren(value)) {
				this.output.b += ">";
				if(this.pretty) {
					this.output.b += "\n";
				}
				if(value.nodeType != Xml.Document && value.nodeType != Xml.Element) {
					throw haxe_Exception.thrown("Bad node type, expected Element or Document but found " + (value.nodeType == null ? "null" : XmlType.toString(value.nodeType)));
				}
				let _this = value.children;
				let _g_current = 0;
				while(_g_current < _this.length) this.writeNode(_this[_g_current++],this.pretty ? tabs + "\t" : tabs);
				this.output.b += Std.string(tabs + "</");
				if(value.nodeType != Xml.Element) {
					throw haxe_Exception.thrown("Bad node type, expected Element but found " + (value.nodeType == null ? "null" : XmlType.toString(value.nodeType)));
				}
				this.output.b += Std.string(value.nodeName);
				this.output.b += ">";
				if(this.pretty) {
					this.output.b += "\n";
				}
			} else {
				this.output.b += "/>";
				if(this.pretty) {
					this.output.b += "\n";
				}
			}
			break;
		case 1:
			if(value.nodeType == Xml.Document || value.nodeType == Xml.Element) {
				throw haxe_Exception.thrown("Bad node type, unexpected " + (value.nodeType == null ? "null" : XmlType.toString(value.nodeType)));
			}
			let nodeValue = value.nodeValue;
			if(nodeValue.length != 0) {
				let input = tabs + StringTools.htmlEscape(nodeValue);
				this.output.b += Std.string(input);
				if(this.pretty) {
					this.output.b += "\n";
				}
			}
			break;
		case 2:
			this.output.b += Std.string(tabs + "<![CDATA[");
			if(value.nodeType == Xml.Document || value.nodeType == Xml.Element) {
				throw haxe_Exception.thrown("Bad node type, unexpected " + (value.nodeType == null ? "null" : XmlType.toString(value.nodeType)));
			}
			this.output.b += Std.string(value.nodeValue);
			this.output.b += "]]>";
			if(this.pretty) {
				this.output.b += "\n";
			}
			break;
		case 3:
			if(value.nodeType == Xml.Document || value.nodeType == Xml.Element) {
				throw haxe_Exception.thrown("Bad node type, unexpected " + (value.nodeType == null ? "null" : XmlType.toString(value.nodeType)));
			}
			let commentContent = value.nodeValue;
			let _this_r = new RegExp("[\n\r\t]+","g".split("u").join(""));
			commentContent = commentContent.replace(_this_r,"");
			commentContent = "<!--" + commentContent + "-->";
			this.output.b += tabs == null ? "null" : "" + tabs;
			this.output.b += Std.string(StringTools.trim(commentContent));
			if(this.pretty) {
				this.output.b += "\n";
			}
			break;
		case 4:
			if(value.nodeType == Xml.Document || value.nodeType == Xml.Element) {
				throw haxe_Exception.thrown("Bad node type, unexpected " + (value.nodeType == null ? "null" : XmlType.toString(value.nodeType)));
			}
			this.output.b += Std.string("<!DOCTYPE " + value.nodeValue + ">");
			if(this.pretty) {
				this.output.b += "\n";
			}
			break;
		case 5:
			if(value.nodeType == Xml.Document || value.nodeType == Xml.Element) {
				throw haxe_Exception.thrown("Bad node type, unexpected " + (value.nodeType == null ? "null" : XmlType.toString(value.nodeType)));
			}
			this.output.b += Std.string("<?" + value.nodeValue + "?>");
			if(this.pretty) {
				this.output.b += "\n";
			}
			break;
		case 6:
			if(value.nodeType != Xml.Document && value.nodeType != Xml.Element) {
				throw haxe_Exception.thrown("Bad node type, expected Element or Document but found " + (value.nodeType == null ? "null" : XmlType.toString(value.nodeType)));
			}
			let _this = value.children;
			let _g_current = 0;
			while(_g_current < _this.length) this.writeNode(_this[_g_current++],tabs);
			break;
		}
	}
	hasChildren(value) {
		if(value.nodeType != Xml.Document && value.nodeType != Xml.Element) {
			throw haxe_Exception.thrown("Bad node type, expected Element or Document but found " + (value.nodeType == null ? "null" : XmlType.toString(value.nodeType)));
		}
		let _this = value.children;
		let _g_current = 0;
		while(_g_current < _this.length) {
			let child = _this[_g_current++];
			switch(child.nodeType) {
			case 0:case 1:
				return true;
			case 2:case 3:
				if(child.nodeType == Xml.Document || child.nodeType == Xml.Element) {
					throw haxe_Exception.thrown("Bad node type, unexpected " + (child.nodeType == null ? "null" : XmlType.toString(child.nodeType)));
				}
				if(StringTools.ltrim(child.nodeValue).length != 0) {
					return true;
				}
				break;
			default:
			}
		}
		return false;
	}
	static print(xml,pretty) {
		if(pretty == null) {
			pretty = false;
		}
		let printer = new haxe_xml_Printer(pretty);
		printer.writeNode(xml,"");
		return printer.output.b;
	}
}
$hxClasses["haxe.xml.Printer"] = haxe_xml_Printer;
haxe_xml_Printer.__name__ = "haxe.xml.Printer";
Object.assign(haxe_xml_Printer.prototype, {
	__class__: haxe_xml_Printer
});
class iron_RenderTargetRaw {
	constructor() {
		this.is_cubemap = null;
		this.is_image = null;
		this.depth = null;
		this.mipmaps = null;
		this.depth_buffer = null;
		this.displayp = null;
		this.scale = null;
		this.format = null;
	}
}
$hxClasses["iron.RenderTargetRaw"] = iron_RenderTargetRaw;
iron_RenderTargetRaw.__name__ = "iron.RenderTargetRaw";
Object.assign(iron_RenderTargetRaw.prototype, {
	__class__: iron_RenderTargetRaw
});
class iron_RenderTarget {
	constructor(raw) {
		this.isCubeMap = false;
		this.is3D = false;
		this.hasDepth = false;
		this.cubeMap = null;
		this.image = null;
		this.depthStencilFrom = "";
		this.raw = raw;
	}
	unload() {
		if(this.image != null) {
			this.image.unload();
		}
		if(this.cubeMap != null) {
			this.cubeMap.unload();
		}
	}
}
$hxClasses["iron.RenderTarget"] = iron_RenderTarget;
iron_RenderTarget.__name__ = "iron.RenderTarget";
Object.assign(iron_RenderTarget.prototype, {
	__class__: iron_RenderTarget
});
class iron_CachedShaderContext {
	constructor() {
	}
}
$hxClasses["iron.CachedShaderContext"] = iron_CachedShaderContext;
iron_CachedShaderContext.__name__ = "iron.CachedShaderContext";
Object.assign(iron_CachedShaderContext.prototype, {
	__class__: iron_CachedShaderContext
});
class iron_data_CameraData {
	constructor(raw,done) {
		this.raw = raw;
		this.name = raw.name;
		done(this);
	}
	static parse(name,id,done) {
		iron_data_Data.getSceneRaw(name,function(format) {
			let raw = iron_data_Data.getCameraRawByName(format.camera_datas,id);
			if(raw == null) {
				haxe_Log.trace("Camera data \"" + id + "\" not found!",{ fileName : "Sources/iron/data/CameraData.hx", lineNumber : 20, className : "iron.data.CameraData", methodName : "parse"});
				done(null);
			}
			new iron_data_CameraData(raw,done);
		});
	}
}
$hxClasses["iron.data.CameraData"] = iron_data_CameraData;
iron_data_CameraData.__name__ = "iron.data.CameraData";
Object.assign(iron_data_CameraData.prototype, {
	__class__: iron_data_CameraData
});
class iron_data_ConstData {
	static createScreenAlignedData() {
		let data = [-1.0,-1.0,3.0,-1.0,-1.0,3.0];
		let indices = [0,1,2];
		let structure = new kha_graphics4_VertexStructure();
		structure.add("pos",1);
		iron_data_ConstData.screenAlignedVB = new kha_graphics4_VertexBuffer(data.length / (structure.byteSize() / 4 | 0) | 0,structure,0);
		let vertices = iron_data_ConstData.screenAlignedVB.lock();
		let _g = 0;
		let _g1 = vertices.byteLength / 4 | 0;
		while(_g < _g1) {
			let i = _g++;
			vertices.setFloat32(i * 4,data[i],true);
		}
		iron_data_ConstData.screenAlignedVB.unlock();
		iron_data_ConstData.screenAlignedIB = new kha_graphics4_IndexBuffer(indices.length,0);
		let id = iron_data_ConstData.screenAlignedIB.lock();
		let _g2 = 0;
		let _g3 = id.length;
		while(_g2 < _g3) {
			let i = _g2++;
			id[i] = indices[i];
		}
		iron_data_ConstData.screenAlignedIB.unlock();
	}
	static createSkydomeData() {
		let pos = iron_data_ConstData.skydomePos;
		let nor = iron_data_ConstData.skydomeNor;
		let structure = new kha_graphics4_VertexStructure();
		structure.add("pos",2);
		structure.add("nor",2);
		let structLength = structure.byteSize() / 4 | 0;
		iron_data_ConstData.skydomeVB = new kha_graphics4_VertexBuffer(pos.length / 3 | 0,structure,0);
		let vertices = iron_data_ConstData.skydomeVB.lock();
		let _g = 0;
		let _g1 = vertices.byteLength / 4 / structLength | 0;
		while(_g < _g1) {
			let i = _g++;
			vertices.setFloat32(i * structLength * 4,pos[i * 3],true);
			vertices.setFloat32((i * structLength + 1) * 4,pos[i * 3 + 1],true);
			vertices.setFloat32((i * structLength + 2) * 4,pos[i * 3 + 2],true);
			vertices.setFloat32((i * structLength + 3) * 4,nor[i * 3],true);
			vertices.setFloat32((i * structLength + 4) * 4,nor[i * 3 + 1],true);
			vertices.setFloat32((i * structLength + 5) * 4,nor[i * 3 + 2],true);
		}
		iron_data_ConstData.skydomeVB.unlock();
		let indices = iron_data_ConstData.skydomeIndices;
		iron_data_ConstData.skydomeIB = new kha_graphics4_IndexBuffer(indices.length,0);
		let id = iron_data_ConstData.skydomeIB.lock();
		let _g2 = 0;
		let _g3 = id.length;
		while(_g2 < _g3) {
			let i = _g2++;
			id[i] = indices[i];
		}
		iron_data_ConstData.skydomeIB.unlock();
	}
}
$hxClasses["iron.data.ConstData"] = iron_data_ConstData;
iron_data_ConstData.__name__ = "iron.data.ConstData";
class iron_data_Geometry {
	constructor(data,indices,materialIndices,usage) {
		this.aabbMax = null;
		this.aabbMin = null;
		this.aabb = null;
		this.instanceCount = 0;
		this.instanced = false;
		this.instancedVB = null;
		this.numTris = 0;
		this.ready = false;
		this.name = "";
		this.count = -1;
		this.start = 0;
		this.vertexBufferMap = new haxe_ds_StringMap();
		if(usage == null) {
			usage = 0;
		}
		this.indices = indices;
		this.materialIndices = materialIndices;
		this.usage = usage;
		this.vertexArrays = data.raw.vertex_arrays;
		this.positions = this.getVArray("pos");
		this.normals = this.getVArray("nor");
		this.uvs = this.getVArray("tex");
		this.cols = this.getVArray("col");
		this.data = data;
		this.struct = iron_data_Geometry.getVertexStructure(this.vertexArrays);
		this.structLength = this.struct.byteSize() / 2 | 0;
		this.structStr = "";
		let _g = 0;
		let _g1 = this.struct.elements;
		while(_g < _g1.length) this.structStr += _g1[_g++].name;
	}
	delete() {
		let h = this.vertexBufferMap.h;
		let buf_keys = Object.keys(h);
		let buf_length = buf_keys.length;
		let buf_current = 0;
		while(buf_current < buf_length) {
			let buf = h[buf_keys[buf_current++]];
			if(buf != null) {
				buf.delete();
			}
		}
		let _g = 0;
		let _g1 = this.indexBuffers;
		while(_g < _g1.length) _g1[_g++].delete();
	}
	getVArray(name) {
		let _g = 0;
		let _g1 = this.vertexArrays.length;
		while(_g < _g1) {
			let i = _g++;
			if(this.vertexArrays[i].attrib == name) {
				return this.vertexArrays[i];
			}
		}
		return null;
	}
	setupInstanced(data,instancedType,usage) {
		let structure = new kha_graphics4_VertexStructure();
		structure.instanced = true;
		this.instanced = true;
		structure.add("ipos",2);
		if(instancedType == 2 || instancedType == 4) {
			structure.add("irot",2);
		}
		if(instancedType == 3 || instancedType == 4) {
			structure.add("iscl",2);
		}
		this.instanceCount = data.length / (structure.byteSize() / 4 | 0) | 0;
		this.instancedVB = new kha_graphics4_VertexBuffer(this.instanceCount,structure,usage,1);
		let vertices = this.instancedVB.lock();
		let _g = 0;
		let _g1 = vertices.byteLength / 4 | 0;
		while(_g < _g1) {
			let i = _g++;
			vertices.setFloat32(i * 4,data[i],true);
		}
		this.instancedVB.unlock();
	}
	get(vs) {
		let key = "";
		let _g = 0;
		while(_g < vs.length) key += vs[_g++].name;
		let vb = this.vertexBufferMap.h[key];
		if(vb == null) {
			let nVertexArrays = [];
			let atex = false;
			let texOffset = -1;
			let acol = false;
			let _g = 0;
			let _g1 = vs.length;
			while(_g < _g1) {
				let e = _g++;
				if(vs[e].name == "tex") {
					atex = true;
					texOffset = e;
				}
				if(vs[e].name == "col") {
					acol = true;
				}
				let _g1 = 0;
				let _g2 = this.vertexArrays.length;
				while(_g1 < _g2) {
					let va = _g1++;
					if(vs[e].name == this.vertexArrays[va].attrib) {
						nVertexArrays.push(this.vertexArrays[va]);
					}
				}
			}
			let struct = iron_data_Geometry.getVertexStructure(nVertexArrays);
			vb = new kha_graphics4_VertexBuffer(this.positions.values.length / this.positions.size | 0,struct,this.usage);
			this.vertices = vb.lock();
			iron_data_Geometry.buildVertices(this.vertices,nVertexArrays,0,atex && this.uvs == null,texOffset);
			vb.unlock();
			this.vertexBufferMap.h[key] = vb;
			if(atex && this.uvs == null) {
				haxe_Log.trace("Armory Warning: Geometry " + this.name + " is missing UV map",{ fileName : "Sources/iron/data/Geometry.hx", lineNumber : 228, className : "iron.data.Geometry", methodName : "get"});
			}
			if(acol && this.cols == null) {
				haxe_Log.trace("Armory Warning: Geometry " + this.name + " is missing vertex colors",{ fileName : "Sources/iron/data/Geometry.hx", lineNumber : 229, className : "iron.data.Geometry", methodName : "get"});
			}
		}
		return vb;
	}
	build() {
		if(this.ready) {
			return;
		}
		this.vertexBuffer = new kha_graphics4_VertexBuffer(this.positions.values.length / this.positions.size | 0,this.struct,this.usage);
		this.vertices = this.vertexBuffer.lock();
		iron_data_Geometry.buildVertices(this.vertices,this.vertexArrays);
		this.vertexBuffer.unlock();
		this.vertexBufferMap.h[this.structStr] = this.vertexBuffer;
		this.indexBuffers = [];
		let _g = 0;
		let _g1 = this.indices;
		while(_g < _g1.length) {
			let id = _g1[_g];
			++_g;
			if(id.length == 0) {
				continue;
			}
			let indexBuffer = new kha_graphics4_IndexBuffer(id.length,this.usage);
			this.numTris += id.length / 3 | 0;
			let indicesA = indexBuffer.lock();
			let _g2 = 0;
			let _g3 = indicesA.length;
			while(_g2 < _g3) {
				let i = _g2++;
				indicesA[i] = id[i];
			}
			indexBuffer.unlock();
			this.indexBuffers.push(indexBuffer);
		}
		if(this.data.raw.instanced_data != null) {
			this.setupInstanced(this.data.raw.instanced_data,this.data.raw.instanced_type,this.usage);
		}
		this.ready = true;
	}
	calculateAABB() {
		this.aabbMin = new iron_math_Vec4(-0.01,-0.01,-0.01);
		this.aabbMax = new iron_math_Vec4(0.01,0.01,0.01);
		this.aabb = new iron_math_Vec4();
		let i = 0;
		while(i < this.positions.values.length) {
			if(this.positions.values[i] > this.aabbMax.x) {
				this.aabbMax.x = this.positions.values[i];
			}
			if(this.positions.values[i + 1] > this.aabbMax.y) {
				this.aabbMax.y = this.positions.values[i + 1];
			}
			if(this.positions.values[i + 2] > this.aabbMax.z) {
				this.aabbMax.z = this.positions.values[i + 2];
			}
			if(this.positions.values[i] < this.aabbMin.x) {
				this.aabbMin.x = this.positions.values[i];
			}
			if(this.positions.values[i + 1] < this.aabbMin.y) {
				this.aabbMin.y = this.positions.values[i + 1];
			}
			if(this.positions.values[i + 2] < this.aabbMin.z) {
				this.aabbMin.z = this.positions.values[i + 2];
			}
			i += 4;
		}
		this.aabb.x = (Math.abs(this.aabbMin.x) + Math.abs(this.aabbMax.x)) / 32767 * this.data.scalePos;
		this.aabb.y = (Math.abs(this.aabbMin.y) + Math.abs(this.aabbMax.y)) / 32767 * this.data.scalePos;
		this.aabb.z = (Math.abs(this.aabbMin.z) + Math.abs(this.aabbMax.z)) / 32767 * this.data.scalePos;
	}
	static getVertexStructure(vertexArrays) {
		let structure = new kha_graphics4_VertexStructure();
		let _g = 0;
		let _g1 = vertexArrays.length;
		while(_g < _g1) {
			let i = _g++;
			structure.add(vertexArrays[i].attrib,iron_data_Geometry.getVertexData(vertexArrays[i].data));
		}
		return structure;
	}
	static getVertexData(data) {
		switch(data) {
		case "short2norm":
			return 23;
		case "short4norm":
			return 27;
		default:
			return 27;
		}
	}
	static buildVertices(vertices,vertexArrays,offset,fakeUVs,uvsIndex) {
		if(uvsIndex == null) {
			uvsIndex = -1;
		}
		if(fakeUVs == null) {
			fakeUVs = false;
		}
		if(offset == null) {
			offset = 0;
		}
		let arr = vertexArrays[0];
		let numVertices = arr.values.length / arr.size | 0;
		let di = -1 + offset;
		let _g = 0;
		while(_g < numVertices) {
			let i = _g++;
			let _g1 = 0;
			let _g2 = vertexArrays.length;
			while(_g1 < _g2) {
				let va = _g1++;
				let l = vertexArrays[va].size;
				if(fakeUVs && va == uvsIndex) {
					let _g = 0;
					while(_g < l) {
						++_g;
						vertices.setInt16(++di * 2,0,kha_arrays_ByteArray.LITTLE_ENDIAN);
					}
					continue;
				}
				let _g = 0;
				while(_g < l) vertices.setInt16(++di * 2,vertexArrays[va].values[i * l + _g++],kha_arrays_ByteArray.LITTLE_ENDIAN);
				if(vertexArrays[va].padding != null) {
					if(vertexArrays[va].padding == 1) {
						vertices.setInt16(++di * 2,0,kha_arrays_ByteArray.LITTLE_ENDIAN);
					}
				}
			}
		}
	}
}
$hxClasses["iron.data.Geometry"] = iron_data_Geometry;
iron_data_Geometry.__name__ = "iron.data.Geometry";
Object.assign(iron_data_Geometry.prototype, {
	__class__: iron_data_Geometry
});
class iron_data_LightData {
	constructor(raw,done) {
		this.raw = raw;
		this.name = raw.name;
		done(this);
	}
	static parse(name,id,done) {
		iron_data_Data.getSceneRaw(name,function(format) {
			let raw = iron_data_Data.getLightRawByName(format.light_datas,id);
			if(raw == null) {
				haxe_Log.trace("Light data \"" + id + "\" not found!",{ fileName : "Sources/iron/data/LightData.hx", lineNumber : 30, className : "iron.data.LightData", methodName : "parse"});
				done(null);
			}
			new iron_data_LightData(raw,done);
		});
	}
}
$hxClasses["iron.data.LightData"] = iron_data_LightData;
iron_data_LightData.__name__ = "iron.data.LightData";
Object.assign(iron_data_LightData.prototype, {
	__class__: iron_data_LightData
});
class iron_data_MaterialData {
	constructor(raw,done,file) {
		if(file == null) {
			file = "";
		}
		this.contexts = null;
		this.uid = ++iron_data_MaterialData.uidCounter;
		this.raw = raw;
		this.name = raw.name;
		let ref = raw.shader.split("/");
		let object_file = "";
		let data_ref = "";
		if(ref.length == 2) {
			object_file = ref[0];
			data_ref = ref[1];
		} else {
			object_file = file;
			data_ref = raw.shader;
		}
		let _gthis = this;
		iron_data_Data.getShader(object_file,data_ref,function(b) {
			_gthis.shader = b;
			_gthis.contexts = [];
			while(_gthis.contexts.length < raw.contexts.length) _gthis.contexts.push(null);
			let contextsLoaded = 0;
			let _g = 0;
			let _g1 = raw.contexts.length;
			while(_g < _g1) {
				let i = _g++;
				new iron_data_MaterialContext(raw.contexts[i],function(self) {
					_gthis.contexts[i] = self;
					contextsLoaded += 1;
					if(contextsLoaded == raw.contexts.length) {
						done(_gthis);
					}
				});
			}
		},raw.override_context);
	}
	getContext(name) {
		let _g = 0;
		let _g1 = this.contexts;
		while(_g < _g1.length) {
			let c = _g1[_g];
			++_g;
			if(HxOverrides.substr(c.raw.name,0,name.length) == name) {
				return c;
			}
		}
		return null;
	}
	static parse(file,name,done) {
		iron_data_Data.getSceneRaw(file,function(format) {
			let raw = iron_data_Data.getMaterialRawByName(format.material_datas,name);
			if(raw == null) {
				haxe_Log.trace("Material data \"" + name + "\" not found!",{ fileName : "Sources/iron/data/MaterialData.hx", lineNumber : 58, className : "iron.data.MaterialData", methodName : "parse"});
				done(null);
			}
			new iron_data_MaterialData(raw,done,file);
		});
	}
}
$hxClasses["iron.data.MaterialData"] = iron_data_MaterialData;
iron_data_MaterialData.__name__ = "iron.data.MaterialData";
Object.assign(iron_data_MaterialData.prototype, {
	__class__: iron_data_MaterialData
});
class iron_data_MaterialContext {
	constructor(raw,done) {
		this.id = 0;
		this.textures = null;
		this.raw = raw;
		this.id = iron_data_MaterialContext.num++;
		let _gthis = this;
		if(raw.bind_textures != null && raw.bind_textures.length > 0) {
			this.textures = new Array(raw.bind_textures.length);
			let texturesLoaded = 0;
			let _g = 0;
			let _g1 = raw.bind_textures.length;
			while(_g < _g1) {
				let i = _g++;
				let tex = raw.bind_textures[i];
				if(tex.file == "" || tex.source == "movie") {
					texturesLoaded += 1;
					if(texturesLoaded == raw.bind_textures.length) {
						done(this);
					}
					continue;
				}
				iron_data_Data.getImage(tex.file,function(image) {
					_gthis.textures[i] = image;
					texturesLoaded += 1;
					if(tex.mipmaps != null) {
						let mipmaps = [];
						while(mipmaps.length < tex.mipmaps.length) mipmaps.push(null);
						let mipmapsLoaded = 0;
						let _g = 0;
						let _g1 = tex.mipmaps.length;
						while(_g < _g1) {
							let j = _g++;
							iron_data_Data.getImage(tex.mipmaps[j],function(mipimg) {
								mipmaps[j] = mipimg;
								mipmapsLoaded += 1;
								if(mipmapsLoaded == tex.mipmaps.length) {
									image.setMipmaps(mipmaps);
									tex.mipmaps = null;
									tex.generate_mipmaps = false;
									if(texturesLoaded == raw.bind_textures.length) {
										done(_gthis);
									}
								}
							});
						}
					} else if(tex.generate_mipmaps == true && image != null) {
						image.generateMipmaps(1000);
						tex.mipmaps = null;
						tex.generate_mipmaps = false;
						if(texturesLoaded == raw.bind_textures.length) {
							done(_gthis);
						}
					} else if(texturesLoaded == raw.bind_textures.length) {
						done(_gthis);
					}
				},false,tex.format != null ? tex.format : "RGBA32");
			}
		} else {
			done(this);
		}
	}
	setTextureParameters(g,textureIndex,context,unitIndex) {
		context.setTextureParameters(g,unitIndex,this.raw.bind_textures[textureIndex]);
	}
}
$hxClasses["iron.data.MaterialContext"] = iron_data_MaterialContext;
iron_data_MaterialContext.__name__ = "iron.data.MaterialContext";
Object.assign(iron_data_MaterialContext.prototype, {
	__class__: iron_data_MaterialContext
});
class iron_data_MeshData {
	constructor(raw,done) {
		this.scaleTex = 1.0;
		this.scalePos = 1.0;
		this.refcount = 0;
		this.raw = raw;
		this.name = raw.name;
		if(raw.scale_pos != null) {
			this.scalePos = raw.scale_pos;
		}
		if(raw.scale_tex != null) {
			this.scaleTex = raw.scale_tex;
		}
		let indices = [];
		let materialIndices = [];
		let _g = 0;
		let _g1 = raw.index_arrays;
		while(_g < _g1.length) {
			let ind = _g1[_g];
			++_g;
			indices.push(ind.values);
			materialIndices.push(ind.material);
		}
		this.isSkinned = raw.skin != null;
		let vertexArrays = raw.vertex_arrays;
		if(this.isSkinned) {
			vertexArrays.push({ attrib : "bone", values : null, data : "short4norm"});
			vertexArrays.push({ attrib : "weight", values : null, data : "short4norm"});
		}
		let _g2 = 0;
		let _g3 = vertexArrays.length;
		while(_g2 < _g3) {
			let i = _g2++;
			let padding = vertexArrays[i].padding;
			vertexArrays[i].size = this.getVertexSize(vertexArrays[i].data,padding != null ? padding : 0);
		}
		let parsedUsage = 0;
		if(raw.dynamic_usage != null && raw.dynamic_usage == true) {
			parsedUsage = 1;
		}
		let usage = parsedUsage;
		if(this.isSkinned) {
			let bonea = null;
			let weighta = null;
			let vertex_length = vertexArrays[0].values.length / vertexArrays[0].size | 0;
			let l = vertex_length * 4;
			bonea = new Int16Array(l);
			weighta = new Int16Array(l);
			let index = 0;
			let ai = 0;
			let _g = 0;
			while(_g < vertex_length) {
				let boneCount = raw.skin.bone_count_array[_g++];
				let _g1 = index;
				let _g2 = index + boneCount;
				while(_g1 < _g2) {
					let j = _g1++;
					bonea[ai] = raw.skin.bone_index_array[j];
					weighta[ai] = raw.skin.bone_weight_array[j];
					++ai;
				}
				let _g3 = boneCount;
				while(_g3 < 4) {
					++_g3;
					bonea[ai] = 0;
					weighta[ai] = 0;
					++ai;
				}
				index += boneCount;
			}
			vertexArrays[vertexArrays.length - 2].values = bonea;
			vertexArrays[vertexArrays.length - 1].values = weighta;
		}
		this.geom = new iron_data_Geometry(this,indices,materialIndices,usage);
		this.geom.name = this.name;
		done(this);
	}
	delete() {
		this.geom.delete();
	}
	getVertexSize(vertex_data,padding) {
		if(padding == null) {
			padding = 0;
		}
		switch(vertex_data) {
		case "short2norm":
			return 2 - padding;
		case "short4norm":
			return 4 - padding;
		default:
			return 0;
		}
	}
	static parse(name,id,done) {
		iron_data_Data.getSceneRaw(name,function(format) {
			let raw = iron_data_Data.getMeshRawByName(format.mesh_datas,id);
			if(raw == null) {
				haxe_Log.trace("Mesh data \"" + id + "\" not found!",{ fileName : "Sources/iron/data/MeshData.hx", lineNumber : 100, className : "iron.data.MeshData", methodName : "parse"});
				done(null);
			}
			new iron_data_MeshData(raw,function(dat) {
				dat.format = format;
				done(dat);
			});
		});
	}
}
$hxClasses["iron.data.MeshData"] = iron_data_MeshData;
iron_data_MeshData.__name__ = "iron.data.MeshData";
Object.assign(iron_data_MeshData.prototype, {
	__class__: iron_data_MeshData
});
class iron_data_ParticleData {
	constructor(raw,done) {
		this.raw = raw;
		this.name = raw.name;
		done(this);
	}
	static parse(name,id,done) {
		iron_data_Data.getSceneRaw(name,function(format) {
			let raw = iron_data_Data.getParticleRawByName(format.particle_datas,id);
			if(raw == null) {
				haxe_Log.trace("Particle data \"" + id + "\" not found!",{ fileName : "Sources/iron/data/ParticleData.hx", lineNumber : 21, className : "iron.data.ParticleData", methodName : "parse"});
				done(null);
			}
			new iron_data_ParticleData(raw,done);
		});
	}
}
$hxClasses["iron.data.ParticleData"] = iron_data_ParticleData;
iron_data_ParticleData.__name__ = "iron.data.ParticleData";
Object.assign(iron_data_ParticleData.prototype, {
	__class__: iron_data_ParticleData
});
class iron_data_ShaderData {
	constructor(raw,done,overrideContext) {
		this.contexts = [];
		this.raw = raw;
		this.name = raw.name;
		let _g = 0;
		let _g1 = raw.contexts;
		while(_g < _g1.length) {
			++_g;
			this.contexts.push(null);
		}
		let contextsLoaded = 0;
		let _gthis = this;
		let _g2 = 0;
		let _g3 = raw.contexts.length;
		while(_g2 < _g3) {
			let i = _g2++;
			new iron_data_ShaderContext(raw.contexts[i],function(con) {
				_gthis.contexts[i] = con;
				contextsLoaded += 1;
				if(contextsLoaded == raw.contexts.length) {
					done(_gthis);
				}
			},overrideContext);
		}
	}
	getContext(name) {
		let _g = 0;
		let _g1 = this.contexts;
		while(_g < _g1.length) {
			let c = _g1[_g];
			++_g;
			if(c.raw.name == name) {
				return c;
			}
		}
		return null;
	}
	static parse(file,name,done,overrideContext) {
		iron_data_Data.getSceneRaw(file,function(format) {
			let raw = iron_data_Data.getShaderRawByName(format.shader_datas,name);
			if(raw == null) {
				haxe_Log.trace("Shader data \"" + name + "\" not found!",{ fileName : "Sources/iron/data/ShaderData.hx", lineNumber : 54, className : "iron.data.ShaderData", methodName : "parse"});
				done(null);
			}
			new iron_data_ShaderData(raw,done,overrideContext);
		});
	}
}
$hxClasses["iron.data.ShaderData"] = iron_data_ShaderData;
iron_data_ShaderData.__name__ = "iron.data.ShaderData";
Object.assign(iron_data_ShaderData.prototype, {
	__class__: iron_data_ShaderData
});
class iron_data_ShaderContext {
	constructor(raw,done,overrideContext) {
		this.instancingType = 0;
		this.raw = raw;
		this.overrideContext = overrideContext;
		this.parseVertexStructure();
		this.compile(done);
	}
	compile(done) {
		if(this.pipeState != null) {
			this.pipeState.delete();
		}
		this.pipeState = new kha_graphics4_PipelineState();
		this.constants = [];
		this.textureUnits = [];
		if(this.instancingType > 0) {
			let instStruct = new kha_graphics4_VertexStructure();
			instStruct.add("ipos",2);
			if(this.instancingType == 2 || this.instancingType == 4) {
				instStruct.add("irot",2);
			}
			if(this.instancingType == 3 || this.instancingType == 4) {
				instStruct.add("iscl",2);
			}
			instStruct.instanced = true;
			this.pipeState.inputLayout = [this.structure,instStruct];
		} else {
			this.pipeState.inputLayout = [this.structure];
		}
		this.pipeState.depthWrite = this.raw.depth_write;
		this.pipeState.depthMode = this.getCompareMode(this.raw.compare_mode);
		this.pipeState.cullMode = this.getCullMode(this.raw.cull_mode);
		if(this.raw.blend_source != null) {
			this.pipeState.blendSource = this.getBlendingFactor(this.raw.blend_source);
		}
		if(this.raw.blend_destination != null) {
			this.pipeState.blendDestination = this.getBlendingFactor(this.raw.blend_destination);
		}
		if(this.raw.blend_operation != null) {
			this.pipeState.blendOperation = this.getBlendingOperation(this.raw.blend_operation);
		}
		if(this.raw.alpha_blend_source != null) {
			this.pipeState.alphaBlendSource = this.getBlendingFactor(this.raw.alpha_blend_source);
		}
		if(this.raw.alpha_blend_destination != null) {
			this.pipeState.alphaBlendDestination = this.getBlendingFactor(this.raw.alpha_blend_destination);
		}
		if(this.raw.alpha_blend_operation != null) {
			this.pipeState.alphaBlendOperation = this.getBlendingOperation(this.raw.alpha_blend_operation);
		}
		if(this.raw.color_writes_red != null) {
			let _g = 0;
			let _g1 = this.raw.color_writes_red.length;
			while(_g < _g1) {
				let i = _g++;
				this.pipeState.colorWriteMasksRed[i] = this.raw.color_writes_red[i];
			}
		}
		if(this.raw.color_writes_green != null) {
			let _g = 0;
			let _g1 = this.raw.color_writes_green.length;
			while(_g < _g1) {
				let i = _g++;
				this.pipeState.colorWriteMasksGreen[i] = this.raw.color_writes_green[i];
			}
		}
		if(this.raw.color_writes_blue != null) {
			let _g = 0;
			let _g1 = this.raw.color_writes_blue.length;
			while(_g < _g1) {
				let i = _g++;
				this.pipeState.colorWriteMasksBlue[i] = this.raw.color_writes_blue[i];
			}
		}
		if(this.raw.color_writes_alpha != null) {
			let _g = 0;
			let _g1 = this.raw.color_writes_alpha.length;
			while(_g < _g1) {
				let i = _g++;
				this.pipeState.colorWriteMasksAlpha[i] = this.raw.color_writes_alpha[i];
			}
		}
		if(this.raw.color_attachments != null) {
			this.pipeState.colorAttachmentCount = this.raw.color_attachments.length;
			let _g = 0;
			let _g1 = this.raw.color_attachments.length;
			while(_g < _g1) {
				let i = _g++;
				this.pipeState.colorAttachments[i] = this.getTextureFormat(this.raw.color_attachments[i]);
			}
		}
		if(this.raw.depth_attachment != null) {
			this.pipeState.depthStencilAttachment = this.getDepthStencilFormat(this.raw.depth_attachment);
		}
		if(this.raw.conservative_raster != null) {
			this.pipeState.conservativeRasterization = this.raw.conservative_raster;
		}
		let _gthis = this;
		if(this.raw.shader_from_source) {
			this.pipeState.vertexShader = kha_graphics4_VertexShader.fromSource(this.raw.vertex_shader);
			this.pipeState.fragmentShader = kha_graphics4_FragmentShader.fromSource(this.raw.fragment_shader);
			if(this.pipeState.vertexShader.shader == null || this.pipeState.fragmentShader.shader == null) {
				done(null);
				return;
			}
			this.finishCompile(done);
		} else {
			let shadersLoaded = 0;
			let numShaders = 2;
			if(this.raw.geometry_shader != null) {
				numShaders += 1;
			}
			if(this.raw.tesscontrol_shader != null) {
				numShaders += 1;
			}
			if(this.raw.tesseval_shader != null) {
				numShaders += 1;
			}
			let loadShader = function(file,type) {
				iron_data_Data.getBlob(iron_data_ShaderData.shaderPath + file + ".d3d11",function(b) {
					if(type == 0) {
						_gthis.pipeState.vertexShader = new kha_graphics4_VertexShader([b],[file]);
					} else if(type == 1) {
						_gthis.pipeState.fragmentShader = new kha_graphics4_FragmentShader([b],[file]);
					} else if(type == 2) {
						_gthis.pipeState.geometryShader = new kha_graphics4_GeometryShader([b],[file]);
					} else if(type == 3) {
						_gthis.pipeState.tessellationControlShader = new kha_graphics4_TessellationControlShader([b],[file]);
					} else if(type == 4) {
						_gthis.pipeState.tessellationEvaluationShader = new kha_graphics4_TessellationEvaluationShader([b],[file]);
					}
					shadersLoaded += 1;
					if(shadersLoaded >= numShaders) {
						_gthis.finishCompile(done);
					}
				});
			};
			loadShader(this.raw.vertex_shader,0);
			loadShader(this.raw.fragment_shader,1);
			if(this.raw.geometry_shader != null) {
				loadShader(this.raw.geometry_shader,2);
			}
			if(this.raw.tesscontrol_shader != null) {
				loadShader(this.raw.tesscontrol_shader,3);
			}
			if(this.raw.tesseval_shader != null) {
				loadShader(this.raw.tesseval_shader,4);
			}
		}
	}
	finishCompile(done) {
		if(this.overrideContext != null) {
			if(this.overrideContext.cull_mode != null) {
				this.pipeState.cullMode = this.getCullMode(this.overrideContext.cull_mode);
			}
		}
		this.pipeState.compile();
		if(this.raw.constants != null) {
			let _g = 0;
			let _g1 = this.raw.constants;
			while(_g < _g1.length) this.addConstant(_g1[_g++]);
		}
		if(this.raw.texture_units != null) {
			let _g = 0;
			let _g1 = this.raw.texture_units;
			while(_g < _g1.length) this.addTexture(_g1[_g++]);
		}
		done(this);
	}
	parseVertexStructure() {
		this.structure = new kha_graphics4_VertexStructure();
		let ipos = false;
		let irot = false;
		let iscl = false;
		let _g = 0;
		let _g1 = this.raw.vertex_elements;
		while(_g < _g1.length) {
			let elem = _g1[_g];
			++_g;
			if(elem.name == "ipos") {
				ipos = true;
				continue;
			}
			if(elem.name == "irot") {
				irot = true;
				continue;
			}
			if(elem.name == "iscl") {
				iscl = true;
				continue;
			}
			this.structure.add(elem.name,iron_data_ShaderContext.parseData(elem.data));
		}
		if(ipos && !irot && !iscl) {
			this.instancingType = 1;
		} else if(ipos && irot && !iscl) {
			this.instancingType = 2;
		} else if(ipos && !irot && iscl) {
			this.instancingType = 3;
		} else if(ipos && irot && iscl) {
			this.instancingType = 4;
		}
	}
	delete() {
		if(this.pipeState.fragmentShader != null) {
			this.pipeState.fragmentShader.delete();
		}
		if(this.pipeState.vertexShader != null) {
			this.pipeState.vertexShader.delete();
		}
		if(this.pipeState.geometryShader != null) {
			this.pipeState.geometryShader.delete();
		}
		if(this.pipeState.tessellationControlShader != null) {
			this.pipeState.tessellationControlShader.delete();
		}
		if(this.pipeState.tessellationEvaluationShader != null) {
			this.pipeState.tessellationEvaluationShader.delete();
		}
		this.pipeState.delete();
	}
	getCompareMode(s) {
		switch(s) {
		case "always":
			return 0;
		case "equal":
			return 2;
		case "greater":
			return 6;
		case "greater_equal":
			return 7;
		case "less":
			return 4;
		case "less_equal":
			return 5;
		case "never":
			return 1;
		case "not_equal":
			return 3;
		default:
			return 4;
		}
	}
	getCullMode(s) {
		switch(s) {
		case "clockwise":
			return 0;
		case "none":
			return 2;
		default:
			return 1;
		}
	}
	getBlendingOperation(s) {
		switch(s) {
		case "add":
			return 0;
		case "max":
			return 4;
		case "min":
			return 3;
		case "reverse_subtract":
			return 2;
		case "subtract":
			return 1;
		default:
			return 0;
		}
	}
	getBlendingFactor(s) {
		switch(s) {
		case "blend_one":
			return 1;
		case "blend_zero":
			return 2;
		case "destination_alpha":
			return 4;
		case "destination_color":
			return 8;
		case "inverse_destination_alpha":
			return 6;
		case "inverse_destination_color":
			return 10;
		case "inverse_source_alpha":
			return 5;
		case "inverse_source_color":
			return 9;
		case "source_alpha":
			return 3;
		case "source_color":
			return 7;
		default:
			return 0;
		}
	}
	getTextureAddresing(s) {
		switch(s) {
		case "mirror":
			return 1;
		case "repeat":
			return 0;
		default:
			return 2;
		}
	}
	getTextureFilter(s) {
		switch(s) {
		case "linear":
			return 1;
		case "point":
			return 0;
		default:
			return 2;
		}
	}
	getMipmapFilter(s) {
		switch(s) {
		case "no":
			return 0;
		case "point":
			return 1;
		default:
			return 2;
		}
	}
	getTextureFormat(s) {
		switch(s) {
		case "DEPTH16":
			return 3;
		case "R16":
			return 6;
		case "R32":
			return 5;
		case "R8":
			return 1;
		case "RGBA128":
			return 2;
		case "RGBA32":
			return 0;
		case "RGBA64":
			return 4;
		default:
			return 0;
		}
	}
	getDepthStencilFormat(s) {
		switch(s) {
		case "DEPTH32":
			return 1;
		case "NONE":
			return 0;
		default:
			return 1;
		}
	}
	addConstant(c) {
		this.constants.push(this.pipeState.getConstantLocation(c.name));
	}
	addTexture(tu) {
		let unit = this.pipeState.getTextureUnit(tu.name);
		this.textureUnits.push(unit);
	}
	setTextureParameters(g,unitIndex,tex) {
		g.setTextureParameters(this.textureUnits[unitIndex],tex.u_addressing == null ? 0 : this.getTextureAddresing(tex.u_addressing),tex.v_addressing == null ? 0 : this.getTextureAddresing(tex.v_addressing),tex.min_filter == null ? 1 : this.getTextureFilter(tex.min_filter),tex.mag_filter == null ? 1 : this.getTextureFilter(tex.mag_filter),tex.mipmap_filter == null ? 0 : this.getMipmapFilter(tex.mipmap_filter));
	}
	static parseData(data) {
		if(data == "float1") {
			return 0;
		} else if(data == "float2") {
			return 1;
		} else if(data == "float3") {
			return 2;
		} else if(data == "float4") {
			return 3;
		} else if(data == "short2norm") {
			return 23;
		} else if(data == "short4norm") {
			return 27;
		}
		return 0;
	}
}
$hxClasses["iron.data.ShaderContext"] = iron_data_ShaderContext;
iron_data_ShaderContext.__name__ = "iron.data.ShaderContext";
Object.assign(iron_data_ShaderContext.prototype, {
	__class__: iron_data_ShaderContext
});
class iron_data_WorldData {
	constructor(raw,done) {
		this.raw = raw;
		this.name = raw.name;
		let _gthis = this;
		if(raw.probe != null) {
			new iron_data_Probe(raw.probe,function(self) {
				_gthis.probe = self;
				done(_gthis);
			});
		} else {
			done(this);
		}
	}
	loadEnvmap(done) {
		let _gthis = this;
		if(this.raw.envmap != null) {
			iron_data_Data.getImage(this.raw.envmap,function(image) {
				_gthis.envmap = image;
				done(_gthis);
			});
		} else {
			done(this);
		}
	}
	static parse(name,id,done) {
		iron_data_Data.getSceneRaw(name,function(format) {
			let raw = iron_data_Data.getWorldRawByName(format.world_datas,id);
			if(raw == null) {
				haxe_Log.trace("World data \"" + id + "\" not found!",{ fileName : "Sources/iron/data/WorldData.hx", lineNumber : 57, className : "iron.data.WorldData", methodName : "parse"});
				done(null);
			}
			new iron_data_WorldData(raw,done);
		});
	}
	static getEmptyIrradiance() {
		if(iron_data_WorldData.emptyIrr == null) {
			iron_data_WorldData.emptyIrr = new Float32Array(28);
			let _g = 0;
			let _g1 = iron_data_WorldData.emptyIrr.length;
			while(_g < _g1) iron_data_WorldData.emptyIrr[_g++] = 0.0;
		}
		return iron_data_WorldData.emptyIrr;
	}
}
$hxClasses["iron.data.WorldData"] = iron_data_WorldData;
iron_data_WorldData.__name__ = "iron.data.WorldData";
Object.assign(iron_data_WorldData.prototype, {
	__class__: iron_data_WorldData
});
class iron_data_Probe {
	constructor(raw,done) {
		this.radianceMipmaps = [];
		this.raw = raw;
		let _gthis = this;
		this.setIrradiance(function(irr) {
			_gthis.irradiance = irr;
			if(raw.radiance != null) {
				iron_data_Data.getImage(raw.radiance,function(rad) {
					_gthis.radiance = rad;
					while(_gthis.radianceMipmaps.length < raw.radiance_mipmaps) _gthis.radianceMipmaps.push(null);
					let dot = raw.radiance.lastIndexOf(".");
					let ext = raw.radiance.substring(dot);
					let base = raw.radiance.substring(0,dot);
					let mipsLoaded = 0;
					let _g = 0;
					let _g1 = raw.radiance_mipmaps;
					while(_g < _g1) {
						let i = _g++;
						iron_data_Data.getImage(base + "_" + i + ext,function(mipimg) {
							_gthis.radianceMipmaps[i] = mipimg;
							mipsLoaded += 1;
							if(mipsLoaded == raw.radiance_mipmaps) {
								_gthis.radiance.setMipmaps(_gthis.radianceMipmaps);
								done(_gthis);
							}
						},true);
					}
				});
			} else {
				done(_gthis);
			}
		});
	}
	setIrradiance(done) {
		if(this.raw.irradiance == null) {
			done(iron_data_WorldData.getEmptyIrradiance());
		} else {
			let ext = this.raw.irradiance.endsWith(".json") ? "" : ".arm";
			iron_data_Data.getBlob(this.raw.irradiance + ext,function(b) {
				let irradianceParsed;
				if(ext == "") {
					irradianceParsed = JSON.parse(b.toString());
				} else {
					let i = new haxe_io_BytesInput(b.toBytes());
					i.set_bigEndian(false);
					irradianceParsed = iron_system_ArmPack.read(i);
				}
				let irr = new Float32Array(28);
				irr[0] = irradianceParsed.irradiance[0];
				irr[1] = irradianceParsed.irradiance[1];
				irr[2] = irradianceParsed.irradiance[2];
				irr[3] = irradianceParsed.irradiance[3];
				irr[4] = irradianceParsed.irradiance[4];
				irr[5] = irradianceParsed.irradiance[5];
				irr[6] = irradianceParsed.irradiance[6];
				irr[7] = irradianceParsed.irradiance[7];
				irr[8] = irradianceParsed.irradiance[8];
				irr[9] = irradianceParsed.irradiance[9];
				irr[10] = irradianceParsed.irradiance[10];
				irr[11] = irradianceParsed.irradiance[11];
				irr[12] = irradianceParsed.irradiance[12];
				irr[13] = irradianceParsed.irradiance[13];
				irr[14] = irradianceParsed.irradiance[14];
				irr[15] = irradianceParsed.irradiance[15];
				irr[16] = irradianceParsed.irradiance[16];
				irr[17] = irradianceParsed.irradiance[17];
				irr[18] = irradianceParsed.irradiance[18];
				irr[19] = irradianceParsed.irradiance[19];
				irr[20] = irradianceParsed.irradiance[20];
				irr[21] = irradianceParsed.irradiance[21];
				irr[22] = irradianceParsed.irradiance[22];
				irr[23] = irradianceParsed.irradiance[23];
				irr[24] = irradianceParsed.irradiance[24];
				irr[25] = irradianceParsed.irradiance[25];
				irr[26] = irradianceParsed.irradiance[26];
				done(irr);
			});
		}
	}
}
$hxClasses["iron.data.Probe"] = iron_data_Probe;
iron_data_Probe.__name__ = "iron.data.Probe";
Object.assign(iron_data_Probe.prototype, {
	__class__: iron_data_Probe
});
class iron_math_Mat3 {
	constructor(_00,_10,_20,_01,_11,_21,_02,_12,_22) {
		this.self = new kha_math_FastMatrix3(_00,_10,_20,_01,_11,_21,_02,_12,_22);
	}
}
$hxClasses["iron.math.Mat3"] = iron_math_Mat3;
iron_math_Mat3.__name__ = "iron.math.Mat3";
Object.assign(iron_math_Mat3.prototype, {
	__class__: iron_math_Mat3
});
class iron_math_Ray {
	constructor(origin,direction) {
		this.origin = origin == null ? new iron_math_Vec4() : origin;
		this.direction = direction == null ? new iron_math_Vec4() : direction;
	}
	at(t) {
		let result = new iron_math_Vec4();
		let v = this.direction;
		result.x = v.x;
		result.y = v.y;
		result.z = v.z;
		result.w = v.w;
		result.x *= t;
		result.y *= t;
		result.z *= t;
		let v1 = this.origin;
		result.x += v1.x;
		result.y += v1.y;
		result.z += v1.z;
		return result;
	}
	distanceToPlane(plane) {
		let _this = plane.normal;
		let v = this.direction;
		let denominator = _this.x * v.x + _this.y * v.y + _this.z * v.z;
		if(denominator == 0) {
			if(plane.distanceToPoint(this.origin) == 0) {
				return 0;
			}
			return -1;
		}
		let _this1 = this.origin;
		let v1 = plane.normal;
		let t = -(_this1.x * v1.x + _this1.y * v1.y + _this1.z * v1.z + plane.constant) / denominator;
		if(t >= 0) {
			return t;
		} else {
			return -1;
		}
	}
	intersectPlane(plane) {
		let t = this.distanceToPlane(plane);
		if(t == -1) {
			return null;
		}
		return this.at(t);
	}
	intersectBox(center,dim) {
		let tmin;
		let tmax;
		let tymin;
		let tymax;
		let tzmin;
		let tzmax;
		let halfX = dim.x / 2;
		let halfY = dim.y / 2;
		let halfZ = dim.z / 2;
		let boxMinX = center.x - halfX;
		let boxMinY = center.y - halfY;
		let boxMinZ = center.z - halfZ;
		let boxMaxX = center.x + halfX;
		let boxMaxY = center.y + halfY;
		let boxMaxZ = center.z + halfZ;
		let invdirx = 1 / this.direction.x;
		let invdiry = 1 / this.direction.y;
		let invdirz = 1 / this.direction.z;
		let origin = this.origin;
		if(invdirx >= 0) {
			tmin = (boxMinX - origin.x) * invdirx;
			tmax = (boxMaxX - origin.x) * invdirx;
		} else {
			tmin = (boxMaxX - origin.x) * invdirx;
			tmax = (boxMinX - origin.x) * invdirx;
		}
		if(invdiry >= 0) {
			tymin = (boxMinY - origin.y) * invdiry;
			tymax = (boxMaxY - origin.y) * invdiry;
		} else {
			tymin = (boxMaxY - origin.y) * invdiry;
			tymax = (boxMinY - origin.y) * invdiry;
		}
		if(tmin > tymax || tymin > tmax) {
			return null;
		}
		if(tymin > tmin || tmin != tmin) {
			tmin = tymin;
		}
		if(tymax < tmax || tmax != tmax) {
			tmax = tymax;
		}
		if(invdirz >= 0) {
			tzmin = (boxMinZ - origin.z) * invdirz;
			tzmax = (boxMaxZ - origin.z) * invdirz;
		} else {
			tzmin = (boxMaxZ - origin.z) * invdirz;
			tzmax = (boxMinZ - origin.z) * invdirz;
		}
		if(tmin > tzmax || tzmin > tmax) {
			return null;
		}
		if(tzmin > tmin || tmin != tmin) {
			tmin = tzmin;
		}
		if(tzmax < tmax || tmax != tmax) {
			tmax = tzmax;
		}
		if(tmax < 0) {
			return null;
		}
		return this.at(tmin >= 0 ? tmin : tmax);
	}
}
$hxClasses["iron.math.Ray"] = iron_math_Ray;
iron_math_Ray.__name__ = "iron.math.Ray";
Object.assign(iron_math_Ray.prototype, {
	__class__: iron_math_Ray
});
class iron_math_Plane {
	constructor() {
		this.constant = 0.0;
		this.normal = new iron_math_Vec4(1.0,0.0,0.0);
	}
	distanceToPoint(point) {
		let _this = this.normal;
		return _this.x * point.x + _this.y * point.y + _this.z * point.z + this.constant;
	}
	set(normal,point) {
		let _this = this.normal;
		_this.x = normal.x;
		_this.y = normal.y;
		_this.z = normal.z;
		_this.w = normal.w;
		let v = this.normal;
		this.constant = -(point.x * v.x + point.y * v.y + point.z * v.z);
		return this;
	}
}
$hxClasses["iron.math.Plane"] = iron_math_Plane;
iron_math_Plane.__name__ = "iron.math.Plane";
Object.assign(iron_math_Plane.prototype, {
	__class__: iron_math_Plane
});
class iron_math_RayCaster {
	static getRay(inputX,inputY,camera) {
		let start = new iron_math_Vec4();
		let end = new iron_math_Vec4();
		iron_math_RayCaster.getDirection(start,end,inputX,inputY,camera);
		end.x -= start.x;
		end.y -= start.y;
		end.z -= start.z;
		let n = Math.sqrt(end.x * end.x + end.y * end.y + end.z * end.z);
		if(n > 0.0) {
			let invN = 1.0 / n;
			end.x *= invN;
			end.y *= invN;
			end.z *= invN;
		}
		end.x *= camera.data.raw.far_plane;
		end.y *= camera.data.raw.far_plane;
		end.z *= camera.data.raw.far_plane;
		return new iron_math_Ray(start,end);
	}
	static getDirection(start,end,inputX,inputY,camera) {
		start.x = inputX / arm_App.w() * 2.0 - 1.0;
		start.y = -(inputY / arm_App.h() * 2.0 - 1.0);
		start.z = -1.0;
		end.x = start.x;
		end.y = start.y;
		end.z = 1.0;
		let _this = iron_math_RayCaster.PInv;
		let m = camera.P;
		let a00 = m.self._00;
		let a01 = m.self._01;
		let a02 = m.self._02;
		let a03 = m.self._03;
		let a10 = m.self._10;
		let a11 = m.self._11;
		let a12 = m.self._12;
		let a13 = m.self._13;
		let a20 = m.self._20;
		let a21 = m.self._21;
		let a22 = m.self._22;
		let a23 = m.self._23;
		let a30 = m.self._30;
		let a31 = m.self._31;
		let a32 = m.self._32;
		let a33 = m.self._33;
		let b00 = a00 * a11 - a01 * a10;
		let b01 = a00 * a12 - a02 * a10;
		let b02 = a00 * a13 - a03 * a10;
		let b03 = a01 * a12 - a02 * a11;
		let b04 = a01 * a13 - a03 * a11;
		let b05 = a02 * a13 - a03 * a12;
		let b06 = a20 * a31 - a21 * a30;
		let b07 = a20 * a32 - a22 * a30;
		let b08 = a20 * a33 - a23 * a30;
		let b09 = a21 * a32 - a22 * a31;
		let b10 = a21 * a33 - a23 * a31;
		let b11 = a22 * a33 - a23 * a32;
		let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
		if(det == 0.0) {
			_this.self._00 = 1.0;
			_this.self._01 = 0.0;
			_this.self._02 = 0.0;
			_this.self._03 = 0.0;
			_this.self._10 = 0.0;
			_this.self._11 = 1.0;
			_this.self._12 = 0.0;
			_this.self._13 = 0.0;
			_this.self._20 = 0.0;
			_this.self._21 = 0.0;
			_this.self._22 = 1.0;
			_this.self._23 = 0.0;
			_this.self._30 = 0.0;
			_this.self._31 = 0.0;
			_this.self._32 = 0.0;
			_this.self._33 = 1.0;
		} else {
			det = 1.0 / det;
			_this.self._00 = (a11 * b11 - a12 * b10 + a13 * b09) * det;
			_this.self._01 = (a02 * b10 - a01 * b11 - a03 * b09) * det;
			_this.self._02 = (a31 * b05 - a32 * b04 + a33 * b03) * det;
			_this.self._03 = (a22 * b04 - a21 * b05 - a23 * b03) * det;
			_this.self._10 = (a12 * b08 - a10 * b11 - a13 * b07) * det;
			_this.self._11 = (a00 * b11 - a02 * b08 + a03 * b07) * det;
			_this.self._12 = (a32 * b02 - a30 * b05 - a33 * b01) * det;
			_this.self._13 = (a20 * b05 - a22 * b02 + a23 * b01) * det;
			_this.self._20 = (a10 * b10 - a11 * b08 + a13 * b06) * det;
			_this.self._21 = (a01 * b08 - a00 * b10 - a03 * b06) * det;
			_this.self._22 = (a30 * b04 - a31 * b02 + a33 * b00) * det;
			_this.self._23 = (a21 * b02 - a20 * b04 - a23 * b00) * det;
			_this.self._30 = (a11 * b07 - a10 * b09 - a12 * b06) * det;
			_this.self._31 = (a00 * b09 - a01 * b07 + a02 * b06) * det;
			_this.self._32 = (a31 * b01 - a30 * b03 - a32 * b00) * det;
			_this.self._33 = (a20 * b03 - a21 * b01 + a22 * b00) * det;
		}
		let _this1 = iron_math_RayCaster.VInv;
		let m1 = camera.V;
		let a001 = m1.self._00;
		let a011 = m1.self._01;
		let a021 = m1.self._02;
		let a031 = m1.self._03;
		let a101 = m1.self._10;
		let a111 = m1.self._11;
		let a121 = m1.self._12;
		let a131 = m1.self._13;
		let a201 = m1.self._20;
		let a211 = m1.self._21;
		let a221 = m1.self._22;
		let a231 = m1.self._23;
		let a301 = m1.self._30;
		let a311 = m1.self._31;
		let a321 = m1.self._32;
		let a331 = m1.self._33;
		let b001 = a001 * a111 - a011 * a101;
		let b011 = a001 * a121 - a021 * a101;
		let b021 = a001 * a131 - a031 * a101;
		let b031 = a011 * a121 - a021 * a111;
		let b041 = a011 * a131 - a031 * a111;
		let b051 = a021 * a131 - a031 * a121;
		let b061 = a201 * a311 - a211 * a301;
		let b071 = a201 * a321 - a221 * a301;
		let b081 = a201 * a331 - a231 * a301;
		let b091 = a211 * a321 - a221 * a311;
		let b101 = a211 * a331 - a231 * a311;
		let b111 = a221 * a331 - a231 * a321;
		let det1 = b001 * b111 - b011 * b101 + b021 * b091 + b031 * b081 - b041 * b071 + b051 * b061;
		if(det1 == 0.0) {
			_this1.self._00 = 1.0;
			_this1.self._01 = 0.0;
			_this1.self._02 = 0.0;
			_this1.self._03 = 0.0;
			_this1.self._10 = 0.0;
			_this1.self._11 = 1.0;
			_this1.self._12 = 0.0;
			_this1.self._13 = 0.0;
			_this1.self._20 = 0.0;
			_this1.self._21 = 0.0;
			_this1.self._22 = 1.0;
			_this1.self._23 = 0.0;
			_this1.self._30 = 0.0;
			_this1.self._31 = 0.0;
			_this1.self._32 = 0.0;
			_this1.self._33 = 1.0;
		} else {
			det1 = 1.0 / det1;
			_this1.self._00 = (a111 * b111 - a121 * b101 + a131 * b091) * det1;
			_this1.self._01 = (a021 * b101 - a011 * b111 - a031 * b091) * det1;
			_this1.self._02 = (a311 * b051 - a321 * b041 + a331 * b031) * det1;
			_this1.self._03 = (a221 * b041 - a211 * b051 - a231 * b031) * det1;
			_this1.self._10 = (a121 * b081 - a101 * b111 - a131 * b071) * det1;
			_this1.self._11 = (a001 * b111 - a021 * b081 + a031 * b071) * det1;
			_this1.self._12 = (a321 * b021 - a301 * b051 - a331 * b011) * det1;
			_this1.self._13 = (a201 * b051 - a221 * b021 + a231 * b011) * det1;
			_this1.self._20 = (a101 * b101 - a111 * b081 + a131 * b061) * det1;
			_this1.self._21 = (a011 * b081 - a001 * b101 - a031 * b061) * det1;
			_this1.self._22 = (a301 * b041 - a311 * b021 + a331 * b001) * det1;
			_this1.self._23 = (a211 * b021 - a201 * b041 - a231 * b001) * det1;
			_this1.self._30 = (a111 * b071 - a101 * b091 - a121 * b061) * det1;
			_this1.self._31 = (a001 * b091 - a011 * b071 + a021 * b061) * det1;
			_this1.self._32 = (a311 * b011 - a301 * b031 - a321 * b001) * det1;
			_this1.self._33 = (a201 * b031 - a211 * b011 + a221 * b001) * det1;
		}
		let _this2 = iron_math_RayCaster.VPInv;
		let b = iron_math_RayCaster.VInv;
		let a = iron_math_RayCaster.PInv;
		let a002 = a.self._00;
		let a012 = a.self._01;
		let a022 = a.self._02;
		let a032 = a.self._03;
		let a102 = a.self._10;
		let a112 = a.self._11;
		let a122 = a.self._12;
		let a132 = a.self._13;
		let a202 = a.self._20;
		let a212 = a.self._21;
		let a222 = a.self._22;
		let a232 = a.self._23;
		let a302 = a.self._30;
		let a312 = a.self._31;
		let a322 = a.self._32;
		let a332 = a.self._33;
		let b0 = b.self._00;
		let b1 = b.self._10;
		let b2 = b.self._20;
		let b3 = b.self._30;
		_this2.self._00 = a002 * b0 + a012 * b1 + a022 * b2 + a032 * b3;
		_this2.self._10 = a102 * b0 + a112 * b1 + a122 * b2 + a132 * b3;
		_this2.self._20 = a202 * b0 + a212 * b1 + a222 * b2 + a232 * b3;
		_this2.self._30 = a302 * b0 + a312 * b1 + a322 * b2 + a332 * b3;
		b0 = b.self._01;
		b1 = b.self._11;
		b2 = b.self._21;
		b3 = b.self._31;
		_this2.self._01 = a002 * b0 + a012 * b1 + a022 * b2 + a032 * b3;
		_this2.self._11 = a102 * b0 + a112 * b1 + a122 * b2 + a132 * b3;
		_this2.self._21 = a202 * b0 + a212 * b1 + a222 * b2 + a232 * b3;
		_this2.self._31 = a302 * b0 + a312 * b1 + a322 * b2 + a332 * b3;
		b0 = b.self._02;
		b1 = b.self._12;
		b2 = b.self._22;
		b3 = b.self._32;
		_this2.self._02 = a002 * b0 + a012 * b1 + a022 * b2 + a032 * b3;
		_this2.self._12 = a102 * b0 + a112 * b1 + a122 * b2 + a132 * b3;
		_this2.self._22 = a202 * b0 + a212 * b1 + a222 * b2 + a232 * b3;
		_this2.self._32 = a302 * b0 + a312 * b1 + a322 * b2 + a332 * b3;
		b0 = b.self._03;
		b1 = b.self._13;
		b2 = b.self._23;
		b3 = b.self._33;
		_this2.self._03 = a002 * b0 + a012 * b1 + a022 * b2 + a032 * b3;
		_this2.self._13 = a102 * b0 + a112 * b1 + a122 * b2 + a132 * b3;
		_this2.self._23 = a202 * b0 + a212 * b1 + a222 * b2 + a232 * b3;
		_this2.self._33 = a302 * b0 + a312 * b1 + a322 * b2 + a332 * b3;
		let m2 = iron_math_RayCaster.VPInv;
		let x = start.x;
		let y = start.y;
		let z = start.z;
		let d = 1.0 / (m2.self._03 * x + m2.self._13 * y + m2.self._23 * z + m2.self._33);
		start.x = (m2.self._00 * x + m2.self._10 * y + m2.self._20 * z + m2.self._30) * d;
		start.y = (m2.self._01 * x + m2.self._11 * y + m2.self._21 * z + m2.self._31) * d;
		start.z = (m2.self._02 * x + m2.self._12 * y + m2.self._22 * z + m2.self._32) * d;
		let m3 = iron_math_RayCaster.VPInv;
		let x1 = end.x;
		let y1 = end.y;
		let z1 = end.z;
		let d1 = 1.0 / (m3.self._03 * x1 + m3.self._13 * y1 + m3.self._23 * z1 + m3.self._33);
		end.x = (m3.self._00 * x1 + m3.self._10 * y1 + m3.self._20 * z1 + m3.self._30) * d1;
		end.y = (m3.self._01 * x1 + m3.self._11 * y1 + m3.self._21 * z1 + m3.self._31) * d1;
		end.z = (m3.self._02 * x1 + m3.self._12 * y1 + m3.self._22 * z1 + m3.self._32) * d1;
	}
	static boxIntersect(transform,inputX,inputY,camera) {
		return iron_math_RayCaster.getRay(inputX,inputY,camera).intersectBox(new iron_math_Vec4(transform.world.self._30,transform.world.self._31,transform.world.self._32),new iron_math_Vec4(transform.dim.x,transform.dim.y,transform.dim.z));
	}
	static closestBoxIntersect(transforms,inputX,inputY,camera) {
		let intersects = [];
		let _g = 0;
		while(_g < transforms.length) {
			let t = transforms[_g];
			++_g;
			if(iron_math_RayCaster.boxIntersect(t,inputX,inputY,camera) != null) {
				intersects.push(t);
			}
		}
		if(intersects.length == 0) {
			return null;
		}
		let closest = null;
		let minDist = Infinity;
		let _g1 = 0;
		while(_g1 < intersects.length) {
			let t = intersects[_g1];
			++_g1;
			let v1 = t.loc;
			let v2 = camera.transform.loc;
			let vx = v1.x - v2.x;
			let vy = v1.y - v2.y;
			let vz = v1.z - v2.z;
			let dist = Math.sqrt(vx * vx + vy * vy + vz * vz);
			if(dist < minDist) {
				minDist = dist;
				closest = t;
			}
		}
		return closest;
	}
	static planeIntersect(normal,a,inputX,inputY,camera) {
		let ray = iron_math_RayCaster.getRay(inputX,inputY,camera);
		let plane = new iron_math_Plane();
		plane.set(normal,a);
		return ray.intersectPlane(plane);
	}
}
$hxClasses["iron.math.RayCaster"] = iron_math_RayCaster;
iron_math_RayCaster.__name__ = "iron.math.RayCaster";
class iron_math_Vec2 {
	constructor(x,y) {
		if(y == null) {
			y = 0.0;
		}
		if(x == null) {
			x = 0.0;
		}
		this.x = x;
		this.y = y;
	}
}
$hxClasses["iron.math.Vec2"] = iron_math_Vec2;
iron_math_Vec2.__name__ = "iron.math.Vec2";
Object.assign(iron_math_Vec2.prototype, {
	__class__: iron_math_Vec2
});
class iron_math_Vec3 {
	constructor(x,y,z) {
		if(z == null) {
			z = 0.0;
		}
		if(y == null) {
			y = 0.0;
		}
		if(x == null) {
			x = 0.0;
		}
		this.x = x;
		this.y = y;
		this.z = z;
	}
}
$hxClasses["iron.math.Vec3"] = iron_math_Vec3;
iron_math_Vec3.__name__ = "iron.math.Vec3";
Object.assign(iron_math_Vec3.prototype, {
	__class__: iron_math_Vec3
});
class iron_object_Animation {
	constructor() {
		if(iron_object_Animation._hx_skip_constructor) {
			return;
		}
		this._hx_constructor();
	}
	_hx_constructor() {
		this.blendFactor = 0.0;
		this.blendAction = "";
		this.blendCurrent = 0.0;
		this.blendTime = 0.0;
		this.frameTime = 0.016666666666666666;
		this.paused = false;
		this.onComplete = null;
		this.frameIndex = 0;
		this.loop = true;
		this.speed = 1.0;
		this.time = 0.0;
		this.action = "";
		iron_Scene.active.animations.push(this);
		if(iron_Scene.active.raw.frame_time != null) {
			this.frameTime = iron_Scene.active.raw.frame_time;
		}
		this.play();
	}
	play(action,onComplete,blendTime,speed,loop) {
		if(loop == null) {
			loop = true;
		}
		if(speed == null) {
			speed = 1.0;
		}
		if(blendTime == null) {
			blendTime = 0.0;
		}
		if(action == null) {
			action = "";
		}
		if(blendTime > 0) {
			this.blendTime = blendTime;
			this.blendCurrent = 0.0;
			this.blendAction = this.action;
			this.frameIndex = 0;
			this.time = 0.0;
		} else {
			this.frameIndex = -1;
		}
		this.action = action;
		this.onComplete = onComplete;
		this.speed = speed;
		this.loop = loop;
		this.paused = false;
	}
	remove() {
		HxOverrides.remove(iron_Scene.active.animations,this);
	}
	update(delta) {
		if(this.paused || this.speed == 0.0) {
			return;
		}
		this.time += delta * this.speed;
		if(this.blendTime > 0 && this.blendFactor == 0) {
			this.blendCurrent += delta;
			if(this.blendCurrent >= this.blendTime) {
				this.blendTime = 0.0;
			}
		}
	}
	rewind(track) {
		this.frameIndex = this.speed > 0 ? 0 : track.frames.length - 1;
		this.time = track.frames[this.frameIndex] * this.frameTime;
	}
}
$hxClasses["iron.object.Animation"] = iron_object_Animation;
iron_object_Animation.__name__ = "iron.object.Animation";
Object.assign(iron_object_Animation.prototype, {
	__class__: iron_object_Animation
});
class iron_object_CameraObject extends iron_object_Object {
	constructor(data) {
		iron_object_Object._hx_skip_constructor = true;
		super();
		iron_object_Object._hx_skip_constructor = false;
		this._hx_constructor(data);
	}
	_hx_constructor(data) {
		this.currentFace = 0;
		this.renderTargetCube = null;
		this.renderTarget = null;
		this.frustumPlanes = null;
		this.prevV = null;
		this.frame = 0;
		this.noJitterP = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
		super._hx_constructor();
		this.data = data;
		this.buildProjection();
		this.V = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
		this.VP = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
		if(data.raw.frustum_culling) {
			this.frustumPlanes = [];
			this.frustumPlanes.push(new iron_object_FrustumPlane());
			this.frustumPlanes.push(new iron_object_FrustumPlane());
			this.frustumPlanes.push(new iron_object_FrustumPlane());
			this.frustumPlanes.push(new iron_object_FrustumPlane());
			this.frustumPlanes.push(new iron_object_FrustumPlane());
			this.frustumPlanes.push(new iron_object_FrustumPlane());
		}
		iron_Scene.active.cameras.push(this);
	}
	buildProjection(screenAspect) {
		if(this.data.raw.ortho != null) {
			let left = this.data.raw.ortho[0];
			let right = this.data.raw.ortho[1];
			let bottom = this.data.raw.ortho[2];
			let top = this.data.raw.ortho[3];
			let near = this.data.raw.near_plane;
			let far = this.data.raw.far_plane;
			let rl = right - left;
			let tb = top - bottom;
			let fn = far - near;
			this.P = new iron_math_Mat4(2 / rl,0,0,-(right + left) / rl,0,2 / tb,0,-(top + bottom) / tb,0,0,-2 / fn,-(far + near) / fn,0,0,0,1);
		} else {
			if(screenAspect == null) {
				screenAspect = arm_App.w() / arm_App.h();
			}
			let zn = this.data.raw.near_plane;
			let zf = this.data.raw.far_plane;
			let uh = 1.0 / Math.tan(this.data.raw.fov / 2);
			this.P = new iron_math_Mat4(uh / (this.data.raw.aspect != null ? this.data.raw.aspect : screenAspect),0,0,0,0,uh,0,0,0,0,(zf + zn) / (zn - zf),2 * zf * zn / (zn - zf),0,0,-1,0);
		}
		let _this = this.noJitterP;
		let m = this.P;
		_this.self._00 = m.self._00;
		_this.self._01 = m.self._01;
		_this.self._02 = m.self._02;
		_this.self._03 = m.self._03;
		_this.self._10 = m.self._10;
		_this.self._11 = m.self._11;
		_this.self._12 = m.self._12;
		_this.self._13 = m.self._13;
		_this.self._20 = m.self._20;
		_this.self._21 = m.self._21;
		_this.self._22 = m.self._22;
		_this.self._23 = m.self._23;
		_this.self._30 = m.self._30;
		_this.self._31 = m.self._31;
		_this.self._32 = m.self._32;
		_this.self._33 = m.self._33;
	}
	remove() {
		HxOverrides.remove(iron_Scene.active.cameras,this);
		super.remove();
	}
	renderFrame(g) {
		this.projectionJitter();
		this.buildMatrix();
		iron_RenderPath.active.renderFrame(g);
		let _this = this.prevV;
		let m = this.V;
		_this.self._00 = m.self._00;
		_this.self._01 = m.self._01;
		_this.self._02 = m.self._02;
		_this.self._03 = m.self._03;
		_this.self._10 = m.self._10;
		_this.self._11 = m.self._11;
		_this.self._12 = m.self._12;
		_this.self._13 = m.self._13;
		_this.self._20 = m.self._20;
		_this.self._21 = m.self._21;
		_this.self._22 = m.self._22;
		_this.self._23 = m.self._23;
		_this.self._30 = m.self._30;
		_this.self._31 = m.self._31;
		_this.self._32 = m.self._32;
		_this.self._33 = m.self._33;
	}
	projectionJitter() {
		let _this = this.P;
		let m = this.noJitterP;
		_this.self._00 = m.self._00;
		_this.self._01 = m.self._01;
		_this.self._02 = m.self._02;
		_this.self._03 = m.self._03;
		_this.self._10 = m.self._10;
		_this.self._11 = m.self._11;
		_this.self._12 = m.self._12;
		_this.self._13 = m.self._13;
		_this.self._20 = m.self._20;
		_this.self._21 = m.self._21;
		_this.self._22 = m.self._22;
		_this.self._23 = m.self._23;
		_this.self._30 = m.self._30;
		_this.self._31 = m.self._31;
		_this.self._32 = m.self._32;
		_this.self._33 = m.self._33;
		let x = 0.0;
		let y = 0.0;
		if(this.frame % 2 == 0) {
			x = 0.25;
			y = 0.25;
		} else {
			x = -0.25;
			y = -0.25;
		}
		this.P.self._20 += x / iron_RenderPath.active.currentW;
		this.P.self._21 += y / iron_RenderPath.active.currentH;
		this.frame++;
	}
	buildMatrix() {
		this.transform.buildMatrix();
		let _this = this.transform.world;
		let x = Math.sqrt(_this.self._00 * _this.self._00 + _this.self._10 * _this.self._10 + _this.self._20 * _this.self._20);
		let y = Math.sqrt(_this.self._01 * _this.self._01 + _this.self._11 * _this.self._11 + _this.self._21 * _this.self._21);
		let z = Math.sqrt(_this.self._02 * _this.self._02 + _this.self._12 * _this.self._12 + _this.self._22 * _this.self._22);
		if(z == null) {
			z = 0.0;
		}
		if(y == null) {
			y = 0.0;
		}
		if(x == null) {
			x = 0.0;
		}
		let sc_x = x;
		let sc_y = y;
		let sc_z = z;
		if(sc_x != 1.0 || sc_y != 1.0 || sc_z != 1.0) {
			let _this = iron_object_CameraObject.temp;
			_this.x = 1.0 / sc_x;
			_this.y = 1.0 / sc_y;
			_this.z = 1.0 / sc_z;
			_this.w = 1.0;
			let _this1 = this.transform.world;
			let v = iron_object_CameraObject.temp;
			let x = v.x;
			let y = v.y;
			let z = v.z;
			_this1.self._00 *= x;
			_this1.self._01 *= x;
			_this1.self._02 *= x;
			_this1.self._03 *= x;
			_this1.self._10 *= y;
			_this1.self._11 *= y;
			_this1.self._12 *= y;
			_this1.self._13 *= y;
			_this1.self._20 *= z;
			_this1.self._21 *= z;
			_this1.self._22 *= z;
			_this1.self._23 *= z;
		}
		let _this1 = this.V;
		let m = this.transform.world;
		let a00 = m.self._00;
		let a01 = m.self._01;
		let a02 = m.self._02;
		let a03 = m.self._03;
		let a10 = m.self._10;
		let a11 = m.self._11;
		let a12 = m.self._12;
		let a13 = m.self._13;
		let a20 = m.self._20;
		let a21 = m.self._21;
		let a22 = m.self._22;
		let a23 = m.self._23;
		let a30 = m.self._30;
		let a31 = m.self._31;
		let a32 = m.self._32;
		let a33 = m.self._33;
		let b00 = a00 * a11 - a01 * a10;
		let b01 = a00 * a12 - a02 * a10;
		let b02 = a00 * a13 - a03 * a10;
		let b03 = a01 * a12 - a02 * a11;
		let b04 = a01 * a13 - a03 * a11;
		let b05 = a02 * a13 - a03 * a12;
		let b06 = a20 * a31 - a21 * a30;
		let b07 = a20 * a32 - a22 * a30;
		let b08 = a20 * a33 - a23 * a30;
		let b09 = a21 * a32 - a22 * a31;
		let b10 = a21 * a33 - a23 * a31;
		let b11 = a22 * a33 - a23 * a32;
		let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
		if(det == 0.0) {
			_this1.self._00 = 1.0;
			_this1.self._01 = 0.0;
			_this1.self._02 = 0.0;
			_this1.self._03 = 0.0;
			_this1.self._10 = 0.0;
			_this1.self._11 = 1.0;
			_this1.self._12 = 0.0;
			_this1.self._13 = 0.0;
			_this1.self._20 = 0.0;
			_this1.self._21 = 0.0;
			_this1.self._22 = 1.0;
			_this1.self._23 = 0.0;
			_this1.self._30 = 0.0;
			_this1.self._31 = 0.0;
			_this1.self._32 = 0.0;
			_this1.self._33 = 1.0;
		} else {
			det = 1.0 / det;
			_this1.self._00 = (a11 * b11 - a12 * b10 + a13 * b09) * det;
			_this1.self._01 = (a02 * b10 - a01 * b11 - a03 * b09) * det;
			_this1.self._02 = (a31 * b05 - a32 * b04 + a33 * b03) * det;
			_this1.self._03 = (a22 * b04 - a21 * b05 - a23 * b03) * det;
			_this1.self._10 = (a12 * b08 - a10 * b11 - a13 * b07) * det;
			_this1.self._11 = (a00 * b11 - a02 * b08 + a03 * b07) * det;
			_this1.self._12 = (a32 * b02 - a30 * b05 - a33 * b01) * det;
			_this1.self._13 = (a20 * b05 - a22 * b02 + a23 * b01) * det;
			_this1.self._20 = (a10 * b10 - a11 * b08 + a13 * b06) * det;
			_this1.self._21 = (a01 * b08 - a00 * b10 - a03 * b06) * det;
			_this1.self._22 = (a30 * b04 - a31 * b02 + a33 * b00) * det;
			_this1.self._23 = (a21 * b02 - a20 * b04 - a23 * b00) * det;
			_this1.self._30 = (a11 * b07 - a10 * b09 - a12 * b06) * det;
			_this1.self._31 = (a00 * b09 - a01 * b07 + a02 * b06) * det;
			_this1.self._32 = (a31 * b01 - a30 * b03 - a32 * b00) * det;
			_this1.self._33 = (a20 * b03 - a21 * b01 + a22 * b00) * det;
		}
		let _this2 = this.VP;
		let b = this.P;
		let a = this.V;
		let a001 = a.self._00;
		let a011 = a.self._01;
		let a021 = a.self._02;
		let a031 = a.self._03;
		let a101 = a.self._10;
		let a111 = a.self._11;
		let a121 = a.self._12;
		let a131 = a.self._13;
		let a201 = a.self._20;
		let a211 = a.self._21;
		let a221 = a.self._22;
		let a231 = a.self._23;
		let a301 = a.self._30;
		let a311 = a.self._31;
		let a321 = a.self._32;
		let a331 = a.self._33;
		let b0 = b.self._00;
		let b1 = b.self._10;
		let b2 = b.self._20;
		let b3 = b.self._30;
		_this2.self._00 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
		_this2.self._10 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
		_this2.self._20 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
		_this2.self._30 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
		b0 = b.self._01;
		b1 = b.self._11;
		b2 = b.self._21;
		b3 = b.self._31;
		_this2.self._01 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
		_this2.self._11 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
		_this2.self._21 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
		_this2.self._31 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
		b0 = b.self._02;
		b1 = b.self._12;
		b2 = b.self._22;
		b3 = b.self._32;
		_this2.self._02 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
		_this2.self._12 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
		_this2.self._22 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
		_this2.self._32 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
		b0 = b.self._03;
		b1 = b.self._13;
		b2 = b.self._23;
		b3 = b.self._33;
		_this2.self._03 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
		_this2.self._13 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
		_this2.self._23 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
		_this2.self._33 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
		if(this.data.raw.frustum_culling) {
			iron_object_CameraObject.buildViewFrustum(this.VP,this.frustumPlanes);
		}
		if(this.prevV == null) {
			this.prevV = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
			let _this = this.prevV;
			let m = this.V;
			_this.self._00 = m.self._00;
			_this.self._01 = m.self._01;
			_this.self._02 = m.self._02;
			_this.self._03 = m.self._03;
			_this.self._10 = m.self._10;
			_this.self._11 = m.self._11;
			_this.self._12 = m.self._12;
			_this.self._13 = m.self._13;
			_this.self._20 = m.self._20;
			_this.self._21 = m.self._21;
			_this.self._22 = m.self._22;
			_this.self._23 = m.self._23;
			_this.self._30 = m.self._30;
			_this.self._31 = m.self._31;
			_this.self._32 = m.self._32;
			_this.self._33 = m.self._33;
		}
	}
	static buildViewFrustum(VP,frustumPlanes) {
		let _this = frustumPlanes[0];
		let _this1 = _this.normal;
		_this1.x = VP.self._03 + VP.self._00;
		_this1.y = VP.self._13 + VP.self._10;
		_this1.z = VP.self._23 + VP.self._20;
		_this1.w = 1.0;
		_this.constant = VP.self._33 + VP.self._30;
		let _this2 = frustumPlanes[1];
		let _this3 = _this2.normal;
		_this3.x = VP.self._03 - VP.self._00;
		_this3.y = VP.self._13 - VP.self._10;
		_this3.z = VP.self._23 - VP.self._20;
		_this3.w = 1.0;
		_this2.constant = VP.self._33 - VP.self._30;
		let _this4 = frustumPlanes[2];
		let _this5 = _this4.normal;
		_this5.x = VP.self._03 - VP.self._01;
		_this5.y = VP.self._13 - VP.self._11;
		_this5.z = VP.self._23 - VP.self._21;
		_this5.w = 1.0;
		_this4.constant = VP.self._33 - VP.self._31;
		let _this6 = frustumPlanes[3];
		let _this7 = _this6.normal;
		_this7.x = VP.self._03 + VP.self._01;
		_this7.y = VP.self._13 + VP.self._11;
		_this7.z = VP.self._23 + VP.self._21;
		_this7.w = 1.0;
		_this6.constant = VP.self._33 + VP.self._31;
		let _this8 = frustumPlanes[4];
		let _this9 = _this8.normal;
		_this9.x = VP.self._02;
		_this9.y = VP.self._12;
		_this9.z = VP.self._22;
		_this9.w = 1.0;
		_this8.constant = VP.self._32;
		let _this10 = frustumPlanes[5];
		let _this11 = _this10.normal;
		_this11.x = VP.self._03 - VP.self._02;
		_this11.y = VP.self._13 - VP.self._12;
		_this11.z = VP.self._23 - VP.self._22;
		_this11.w = 1.0;
		_this10.constant = VP.self._33 - VP.self._32;
		let _g = 0;
		while(_g < frustumPlanes.length) frustumPlanes[_g++].normalize();
	}
	static sphereInFrustum(frustumPlanes,t,radiusScale,offsetX,offsetY,offsetZ) {
		if(offsetZ == null) {
			offsetZ = 0.0;
		}
		if(offsetY == null) {
			offsetY = 0.0;
		}
		if(offsetX == null) {
			offsetX = 0.0;
		}
		if(radiusScale == null) {
			radiusScale = 1.0;
		}
		let radius = t.radius * radiusScale;
		let _g = 0;
		while(_g < frustumPlanes.length) {
			let plane = frustumPlanes[_g++];
			let _this = iron_object_CameraObject.sphereCenter;
			_this.x = t.world.self._30 + offsetX;
			_this.y = t.world.self._31 + offsetY;
			_this.z = t.world.self._32 + offsetZ;
			_this.w = 1.0;
			if(plane.distanceToSphere(iron_object_CameraObject.sphereCenter,radius) + radius * 2 < 0) {
				return false;
			}
		}
		return true;
	}
	static setCubeFace(m,eye,face,flip) {
		if(flip == null) {
			flip = false;
		}
		let _this = iron_object_CameraObject.vcenter;
		_this.x = eye.x;
		_this.y = eye.y;
		_this.z = eye.z;
		_this.w = eye.w;
		let f = flip ? -1.0 : 1.0;
		switch(face) {
		case 0:
			let _this1 = iron_object_CameraObject.vcenter;
			_this1.x += f;
			_this1.y += 0.0;
			_this1.z += 0.0;
			let _this2 = iron_object_CameraObject.vup;
			_this2.x = 0.0;
			_this2.y = -1.0 * f;
			_this2.z = 0.0;
			_this2.w = 1.0;
			break;
		case 1:
			let _this3 = iron_object_CameraObject.vcenter;
			_this3.x += -1.0 * f;
			_this3.y += 0.0;
			_this3.z += 0.0;
			let _this4 = iron_object_CameraObject.vup;
			_this4.x = 0.0;
			_this4.y = -1.0 * f;
			_this4.z = 0.0;
			_this4.w = 1.0;
			break;
		case 2:
			let _this5 = iron_object_CameraObject.vcenter;
			_this5.x += 0.0;
			_this5.y += f;
			_this5.z += 0.0;
			let _this6 = iron_object_CameraObject.vup;
			_this6.x = 0.0;
			_this6.y = 0.0;
			_this6.z = f;
			_this6.w = 1.0;
			break;
		case 3:
			let _this7 = iron_object_CameraObject.vcenter;
			_this7.x += 0.0;
			_this7.y += -1.0 * f;
			_this7.z += 0.0;
			let _this8 = iron_object_CameraObject.vup;
			_this8.x = 0.0;
			_this8.y = 0.0;
			_this8.z = -1.0 * f;
			_this8.w = 1.0;
			break;
		case 4:
			let _this9 = iron_object_CameraObject.vcenter;
			_this9.x += 0.0;
			_this9.y += 0.0;
			_this9.z += f;
			let _this10 = iron_object_CameraObject.vup;
			_this10.x = 0.0;
			_this10.y = -1.0 * f;
			_this10.z = 0.0;
			_this10.w = 1.0;
			break;
		case 5:
			let _this11 = iron_object_CameraObject.vcenter;
			_this11.x += 0.0;
			_this11.y += 0.0;
			_this11.z += -1.0 * f;
			let _this12 = iron_object_CameraObject.vup;
			_this12.x = 0.0;
			_this12.y = -1.0 * f;
			_this12.z = 0.0;
			_this12.w = 1.0;
			break;
		}
		let center = iron_object_CameraObject.vcenter;
		let up = iron_object_CameraObject.vup;
		let f0 = center.x - eye.x;
		let f1 = center.y - eye.y;
		let f2 = center.z - eye.z;
		let n = 1.0 / Math.sqrt(f0 * f0 + f1 * f1 + f2 * f2);
		f0 *= n;
		f1 *= n;
		f2 *= n;
		let s0 = f1 * up.z - f2 * up.y;
		let s1 = f2 * up.x - f0 * up.z;
		let s2 = f0 * up.y - f1 * up.x;
		n = 1.0 / Math.sqrt(s0 * s0 + s1 * s1 + s2 * s2);
		s0 *= n;
		s1 *= n;
		s2 *= n;
		let u0 = s1 * f2 - s2 * f1;
		let u1 = s2 * f0 - s0 * f2;
		let u2 = s0 * f1 - s1 * f0;
		m.self._00 = s0;
		m.self._10 = s1;
		m.self._20 = s2;
		m.self._30 = -eye.x * s0 - eye.y * s1 - eye.z * s2;
		m.self._01 = u0;
		m.self._11 = u1;
		m.self._21 = u2;
		m.self._31 = -eye.x * u0 - eye.y * u1 - eye.z * u2;
		m.self._02 = -f0;
		m.self._12 = -f1;
		m.self._22 = -f2;
		m.self._32 = eye.x * f0 + eye.y * f1 + eye.z * f2;
		m.self._03 = 0.0;
		m.self._13 = 0.0;
		m.self._23 = 0.0;
		m.self._33 = 1.0;
	}
}
$hxClasses["iron.object.CameraObject"] = iron_object_CameraObject;
iron_object_CameraObject.__name__ = "iron.object.CameraObject";
iron_object_CameraObject.__super__ = iron_object_Object;
Object.assign(iron_object_CameraObject.prototype, {
	__class__: iron_object_CameraObject
});
class iron_object_FrustumPlane {
	constructor() {
		this.constant = 0.0;
		this.normal = new iron_math_Vec4(1.0,0.0,0.0);
	}
	normalize() {
		let _this = this.normal;
		let inverseNormalLength = 1.0 / Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z);
		let _this1 = this.normal;
		_this1.x *= inverseNormalLength;
		_this1.y *= inverseNormalLength;
		_this1.z *= inverseNormalLength;
		this.constant *= inverseNormalLength;
	}
	distanceToSphere(sphereCenter,sphereRadius) {
		let _this = this.normal;
		return _this.x * sphereCenter.x + _this.y * sphereCenter.y + _this.z * sphereCenter.z + this.constant - sphereRadius;
	}
}
$hxClasses["iron.object.FrustumPlane"] = iron_object_FrustumPlane;
iron_object_FrustumPlane.__name__ = "iron.object.FrustumPlane";
Object.assign(iron_object_FrustumPlane.prototype, {
	__class__: iron_object_FrustumPlane
});
class iron_object_Constraint {
	constructor(constr) {
		this.target = null;
		this.raw = constr;
	}
	apply(transform) {
		if(this.target == null && this.raw.target != null) {
			this.target = iron_Scene.active.getChild(this.raw.target).transform;
		}
		if(this.raw.type == "COPY_LOCATION") {
			if(this.raw.use_x) {
				transform.world.self._30 = this.target.loc.x;
				if(this.raw.use_offset) {
					transform.world.self._30 += transform.loc.x;
				}
			}
			if(this.raw.use_y) {
				transform.world.self._31 = this.target.loc.y;
				if(this.raw.use_offset) {
					transform.world.self._31 += transform.loc.y;
				}
			}
			if(this.raw.use_z) {
				transform.world.self._32 = this.target.loc.z;
				if(this.raw.use_offset) {
					transform.world.self._32 += transform.loc.z;
				}
			}
		}
	}
}
$hxClasses["iron.object.Constraint"] = iron_object_Constraint;
iron_object_Constraint.__name__ = "iron.object.Constraint";
Object.assign(iron_object_Constraint.prototype, {
	__class__: iron_object_Constraint
});
class iron_object_LightObject extends iron_object_Object {
	constructor(data) {
		iron_object_Object._hx_skip_constructor = true;
		super();
		iron_object_Object._hx_skip_constructor = false;
		this._hx_constructor(data);
	}
	_hx_constructor(data) {
		this.frustumPlanes = null;
		this.VP = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
		this.P = null;
		this.V = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
		super._hx_constructor();
		this.data = data;
		let type = data.raw.type;
		let fov = data.raw.fov;
		if(type == "sun") {
			let near = data.raw.near_plane;
			let far = data.raw.far_plane;
			let fn = far - near;
			this.P = new iron_math_Mat4(1.,0,0,0.,0,1.,0,0.,0,0,-2 / fn,-(far + near) / fn,0,0,0,1);
		} else if(type == "point" || type == "area") {
			let zn = data.raw.near_plane;
			let zf = data.raw.far_plane;
			let uh = 1.0 / Math.tan(fov / 2);
			this.P = new iron_math_Mat4(uh / 1,0,0,0,0,uh,0,0,0,0,(zf + zn) / (zn - zf),2 * zf * zn / (zn - zf),0,0,-1,0);
		} else if(type == "spot") {
			let zn = data.raw.near_plane;
			let zf = data.raw.far_plane;
			let uh = 1.0 / Math.tan(fov / 2);
			this.P = new iron_math_Mat4(uh / 1,0,0,0,0,uh,0,0,0,0,(zf + zn) / (zn - zf),2 * zf * zn / (zn - zf),0,0,-1,0);
		}
		iron_Scene.active.lights.push(this);
	}
	remove() {
		if(iron_Scene.active != null) {
			HxOverrides.remove(iron_Scene.active.lights,this);
		}
		let rp = iron_RenderPath.active;
		if(rp.light == this) {
			rp.light = null;
		}
		if(rp.point == this) {
			rp.point = null;
		} else if(rp.sun == this) {
			rp.sun = null;
		}
		super.remove();
	}
	buildMatrix(camera) {
		this.transform.buildMatrix();
		if(this.data.raw.type == "sun") {
			let _this = this.V;
			let m = this.transform.world;
			let a00 = m.self._00;
			let a01 = m.self._01;
			let a02 = m.self._02;
			let a03 = m.self._03;
			let a10 = m.self._10;
			let a11 = m.self._11;
			let a12 = m.self._12;
			let a13 = m.self._13;
			let a20 = m.self._20;
			let a21 = m.self._21;
			let a22 = m.self._22;
			let a23 = m.self._23;
			let a30 = m.self._30;
			let a31 = m.self._31;
			let a32 = m.self._32;
			let a33 = m.self._33;
			let b00 = a00 * a11 - a01 * a10;
			let b01 = a00 * a12 - a02 * a10;
			let b02 = a00 * a13 - a03 * a10;
			let b03 = a01 * a12 - a02 * a11;
			let b04 = a01 * a13 - a03 * a11;
			let b05 = a02 * a13 - a03 * a12;
			let b06 = a20 * a31 - a21 * a30;
			let b07 = a20 * a32 - a22 * a30;
			let b08 = a20 * a33 - a23 * a30;
			let b09 = a21 * a32 - a22 * a31;
			let b10 = a21 * a33 - a23 * a31;
			let b11 = a22 * a33 - a23 * a32;
			let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
			if(det == 0.0) {
				_this.self._00 = 1.0;
				_this.self._01 = 0.0;
				_this.self._02 = 0.0;
				_this.self._03 = 0.0;
				_this.self._10 = 0.0;
				_this.self._11 = 1.0;
				_this.self._12 = 0.0;
				_this.self._13 = 0.0;
				_this.self._20 = 0.0;
				_this.self._21 = 0.0;
				_this.self._22 = 1.0;
				_this.self._23 = 0.0;
				_this.self._30 = 0.0;
				_this.self._31 = 0.0;
				_this.self._32 = 0.0;
				_this.self._33 = 1.0;
			} else {
				det = 1.0 / det;
				_this.self._00 = (a11 * b11 - a12 * b10 + a13 * b09) * det;
				_this.self._01 = (a02 * b10 - a01 * b11 - a03 * b09) * det;
				_this.self._02 = (a31 * b05 - a32 * b04 + a33 * b03) * det;
				_this.self._03 = (a22 * b04 - a21 * b05 - a23 * b03) * det;
				_this.self._10 = (a12 * b08 - a10 * b11 - a13 * b07) * det;
				_this.self._11 = (a00 * b11 - a02 * b08 + a03 * b07) * det;
				_this.self._12 = (a32 * b02 - a30 * b05 - a33 * b01) * det;
				_this.self._13 = (a20 * b05 - a22 * b02 + a23 * b01) * det;
				_this.self._20 = (a10 * b10 - a11 * b08 + a13 * b06) * det;
				_this.self._21 = (a01 * b08 - a00 * b10 - a03 * b06) * det;
				_this.self._22 = (a30 * b04 - a31 * b02 + a33 * b00) * det;
				_this.self._23 = (a21 * b02 - a20 * b04 - a23 * b00) * det;
				_this.self._30 = (a11 * b07 - a10 * b09 - a12 * b06) * det;
				_this.self._31 = (a00 * b09 - a01 * b07 + a02 * b06) * det;
				_this.self._32 = (a31 * b01 - a30 * b03 - a32 * b00) * det;
				_this.self._33 = (a20 * b03 - a21 * b01 + a22 * b00) * det;
			}
			this.updateViewFrustum(camera);
		} else {
			let _this = this.V;
			let m = this.transform.world;
			let a00 = m.self._00;
			let a01 = m.self._01;
			let a02 = m.self._02;
			let a03 = m.self._03;
			let a10 = m.self._10;
			let a11 = m.self._11;
			let a12 = m.self._12;
			let a13 = m.self._13;
			let a20 = m.self._20;
			let a21 = m.self._21;
			let a22 = m.self._22;
			let a23 = m.self._23;
			let a30 = m.self._30;
			let a31 = m.self._31;
			let a32 = m.self._32;
			let a33 = m.self._33;
			let b00 = a00 * a11 - a01 * a10;
			let b01 = a00 * a12 - a02 * a10;
			let b02 = a00 * a13 - a03 * a10;
			let b03 = a01 * a12 - a02 * a11;
			let b04 = a01 * a13 - a03 * a11;
			let b05 = a02 * a13 - a03 * a12;
			let b06 = a20 * a31 - a21 * a30;
			let b07 = a20 * a32 - a22 * a30;
			let b08 = a20 * a33 - a23 * a30;
			let b09 = a21 * a32 - a22 * a31;
			let b10 = a21 * a33 - a23 * a31;
			let b11 = a22 * a33 - a23 * a32;
			let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
			if(det == 0.0) {
				_this.self._00 = 1.0;
				_this.self._01 = 0.0;
				_this.self._02 = 0.0;
				_this.self._03 = 0.0;
				_this.self._10 = 0.0;
				_this.self._11 = 1.0;
				_this.self._12 = 0.0;
				_this.self._13 = 0.0;
				_this.self._20 = 0.0;
				_this.self._21 = 0.0;
				_this.self._22 = 1.0;
				_this.self._23 = 0.0;
				_this.self._30 = 0.0;
				_this.self._31 = 0.0;
				_this.self._32 = 0.0;
				_this.self._33 = 1.0;
			} else {
				det = 1.0 / det;
				_this.self._00 = (a11 * b11 - a12 * b10 + a13 * b09) * det;
				_this.self._01 = (a02 * b10 - a01 * b11 - a03 * b09) * det;
				_this.self._02 = (a31 * b05 - a32 * b04 + a33 * b03) * det;
				_this.self._03 = (a22 * b04 - a21 * b05 - a23 * b03) * det;
				_this.self._10 = (a12 * b08 - a10 * b11 - a13 * b07) * det;
				_this.self._11 = (a00 * b11 - a02 * b08 + a03 * b07) * det;
				_this.self._12 = (a32 * b02 - a30 * b05 - a33 * b01) * det;
				_this.self._13 = (a20 * b05 - a22 * b02 + a23 * b01) * det;
				_this.self._20 = (a10 * b10 - a11 * b08 + a13 * b06) * det;
				_this.self._21 = (a01 * b08 - a00 * b10 - a03 * b06) * det;
				_this.self._22 = (a30 * b04 - a31 * b02 + a33 * b00) * det;
				_this.self._23 = (a21 * b02 - a20 * b04 - a23 * b00) * det;
				_this.self._30 = (a11 * b07 - a10 * b09 - a12 * b06) * det;
				_this.self._31 = (a00 * b09 - a01 * b07 + a02 * b06) * det;
				_this.self._32 = (a31 * b01 - a30 * b03 - a32 * b00) * det;
				_this.self._33 = (a20 * b03 - a21 * b01 + a22 * b00) * det;
			}
			this.updateViewFrustum(camera);
		}
	}
	updateViewFrustum(camera) {
		let _this = this.VP;
		let b = this.P;
		let a = this.V;
		let a00 = a.self._00;
		let a01 = a.self._01;
		let a02 = a.self._02;
		let a03 = a.self._03;
		let a10 = a.self._10;
		let a11 = a.self._11;
		let a12 = a.self._12;
		let a13 = a.self._13;
		let a20 = a.self._20;
		let a21 = a.self._21;
		let a22 = a.self._22;
		let a23 = a.self._23;
		let a30 = a.self._30;
		let a31 = a.self._31;
		let a32 = a.self._32;
		let a33 = a.self._33;
		let b0 = b.self._00;
		let b1 = b.self._10;
		let b2 = b.self._20;
		let b3 = b.self._30;
		_this.self._00 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
		_this.self._10 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
		_this.self._20 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
		_this.self._30 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
		b0 = b.self._01;
		b1 = b.self._11;
		b2 = b.self._21;
		b3 = b.self._31;
		_this.self._01 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
		_this.self._11 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
		_this.self._21 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
		_this.self._31 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
		b0 = b.self._02;
		b1 = b.self._12;
		b2 = b.self._22;
		b3 = b.self._32;
		_this.self._02 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
		_this.self._12 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
		_this.self._22 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
		_this.self._32 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
		b0 = b.self._03;
		b1 = b.self._13;
		b2 = b.self._23;
		b3 = b.self._33;
		_this.self._03 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
		_this.self._13 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
		_this.self._23 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
		_this.self._33 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
		if(camera.data.raw.frustum_culling) {
			if(this.frustumPlanes == null) {
				this.frustumPlanes = [];
				this.frustumPlanes.push(new iron_object_FrustumPlane());
				this.frustumPlanes.push(new iron_object_FrustumPlane());
				this.frustumPlanes.push(new iron_object_FrustumPlane());
				this.frustumPlanes.push(new iron_object_FrustumPlane());
				this.frustumPlanes.push(new iron_object_FrustumPlane());
				this.frustumPlanes.push(new iron_object_FrustumPlane());
			}
			iron_object_CameraObject.buildViewFrustum(this.VP,this.frustumPlanes);
		}
	}
	setCubeFace(face,camera) {
		let _this = iron_object_LightObject.eye;
		_this.x = this.transform.world.self._30;
		_this.y = this.transform.world.self._31;
		_this.z = this.transform.world.self._32;
		_this.w = 1.0;
		iron_object_CameraObject.setCubeFace(this.V,iron_object_LightObject.eye,face,face == 2 || face == 3);
		this.updateViewFrustum(camera);
	}
}
$hxClasses["iron.object.LightObject"] = iron_object_LightObject;
iron_object_LightObject.__name__ = "iron.object.LightObject";
iron_object_LightObject.__super__ = iron_object_Object;
Object.assign(iron_object_LightObject.prototype, {
	__class__: iron_object_LightObject
});
class iron_object_MeshObject extends iron_object_Object {
	constructor(data,materials) {
		iron_object_Object._hx_skip_constructor = true;
		super();
		iron_object_Object._hx_skip_constructor = false;
		this._hx_constructor(data,materials);
	}
	_hx_constructor(data,materials) {
		this.prevMatrix = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
		this.force_context = null;
		this.skip_context = null;
		this.tilesheet = null;
		this.frustumCulling = true;
		this.screenSize = 0.0;
		this.particleIndex = -1;
		this.particleOwner = null;
		this.particleChildren = null;
		this.particleSystems = null;
		this.materialIndex = 0;
		this.data = null;
		super._hx_constructor();
		this.materials = materials;
		this.setData(data);
		iron_Scene.active.meshes.push(this);
	}
	setData(data) {
		this.data = data;
		data.refcount++;
		data.geom.build();
		this.transform.scaleWorld = data.scalePos;
	}
	remove() {
		if(this.particleChildren != null) {
			let _g = 0;
			let _g1 = this.particleChildren;
			while(_g < _g1.length) _g1[_g++].remove();
			this.particleChildren = null;
		}
		if(this.particleSystems != null) {
			let _g = 0;
			let _g1 = this.particleSystems;
			while(_g < _g1.length) _g1[_g++].remove();
			this.particleSystems = null;
		}
		if(this.tilesheet != null) {
			this.tilesheet.remove();
		}
		if(iron_Scene.active != null) {
			HxOverrides.remove(iron_Scene.active.meshes,this);
		}
		this.data.refcount--;
		super.remove();
	}
	setupAnimation(oactions) {
		super.setupAnimation(oactions);
	}
	setupParticleSystem(sceneName,pref) {
		if(this.particleSystems == null) {
			this.particleSystems = [];
		}
		let psys = new iron_object_ParticleSystem(sceneName,pref);
		this.particleSystems.push(psys);
	}
	setupTilesheet(sceneName,tilesheet_ref,tilesheet_action_ref) {
		this.tilesheet = new iron_object_Tilesheet(sceneName,tilesheet_ref,tilesheet_action_ref);
	}
	setCulled(isShadow,b) {
		if(isShadow) {
			this.culledShadow = b;
		} else {
			this.culledMesh = b;
		}
		this.culled = this.culledMesh && this.culledShadow;
		return b;
	}
	cullMaterial(context) {
		if(!(this.raw != null && this.raw.lod_material != null && this.raw.lod_material == true) && !this.validContext(this.materials,context)) {
			return true;
		}
		let isShadow = context == "shadowmap";
		if(!this.visibleMesh && !isShadow) {
			return this.setCulled(isShadow,true);
		}
		if(!this.visibleShadow && isShadow) {
			return this.setCulled(isShadow,true);
		}
		if(this.skip_context == context) {
			return this.setCulled(isShadow,true);
		}
		if(this.force_context != null && this.force_context != context) {
			return this.setCulled(isShadow,true);
		}
		return this.setCulled(isShadow,false);
	}
	cullMesh(context,camera,light) {
		if(camera == null) {
			return false;
		}
		if(camera.data.raw.frustum_culling && this.frustumCulling) {
			let radiusScale = this.data.isSkinned ? 2.0 : 1.0;
			if(this.particleSystems != null || this.particleOwner != null) {
				radiusScale *= 1000;
			}
			if(context == "voxel") {
				radiusScale *= 100;
			}
			if(this.data.geom.instanced) {
				radiusScale *= 100;
			}
			let isShadow = context == "shadowmap";
			let frustumPlanes = isShadow ? light.frustumPlanes : camera.frustumPlanes;
			if(isShadow && light.data.raw.type != "sun") {
				light.transform.radius = light.data.raw.far_plane;
				if(!iron_object_CameraObject.sphereInFrustum(camera.frustumPlanes,light.transform)) {
					return this.setCulled(isShadow,true);
				}
			}
			if(!iron_object_CameraObject.sphereInFrustum(frustumPlanes,this.transform,radiusScale)) {
				return this.setCulled(isShadow,true);
			}
		}
		this.culled = false;
		return this.culled;
	}
	skipContext(context,mat) {
		if(mat.raw.skip_context != null && mat.raw.skip_context == context) {
			return true;
		}
		return false;
	}
	getContexts(context,materials,materialContexts,shaderContexts) {
		let _g = 0;
		while(_g < materials.length) {
			let mat = materials[_g];
			++_g;
			let found = false;
			let _g1 = 0;
			let _g2 = mat.raw.contexts.length;
			while(_g1 < _g2) {
				let i = _g1++;
				if(HxOverrides.substr(mat.raw.contexts[i].name,0,context.length) == context) {
					materialContexts.push(mat.contexts[i]);
					shaderContexts.push(mat.shader.getContext(context));
					found = true;
					break;
				}
			}
			if(!found) {
				materialContexts.push(null);
				shaderContexts.push(null);
			}
		}
	}
	render(g,context,bindParams) {
		if(this.data == null || !this.data.geom.ready) {
			return;
		}
		if(!this.visible) {
			return;
		}
		if(this.cullMesh(context,iron_Scene.active.camera,iron_RenderPath.active.light)) {
			return;
		}
		if(this.raw != null && this.raw.is_particle && this.particleOwner == null) {
			return;
		}
		let _gthis = this;
		if(this.particleSystems != null && (this.raw != null && context == "mesh")) {
			if(this.particleChildren == null) {
				this.particleChildren = [];
				let _g = 0;
				let _g1 = this.particleSystems;
				while(_g < _g1.length) iron_Scene.active.spawnObject(_g1[_g++].data.raw.instance_object,null,function(o) {
					if(o != null) {
						let c = o;
						_gthis.particleChildren.push(c);
						c.particleOwner = _gthis;
						c.particleIndex = _gthis.particleChildren.length - 1;
					}
				});
			}
			let _g = 0;
			let _g1 = this.particleSystems.length;
			while(_g < _g1) {
				let i = _g++;
				this.particleSystems[i].update(this.particleChildren[i],this);
			}
		}
		if(this.particleSystems != null && this.particleSystems.length > 0 && !this.raw.render_emitter) {
			return;
		}
		if(this.tilesheet != null) {
			this.tilesheet.update();
		}
		if(this.cullMaterial(context)) {
			return;
		}
		let mats = this.materials;
		let lod = this;
		if(this.raw != null && this.raw.lods != null && this.raw.lods.length > 0) {
			let tr = this.transform;
			this.screenSize = tr.dim.x * tr.dim.y * tr.dim.z * (1.0 / this.cameraDistance);
			this.screenSize = this.screenSize > 1.0 ? 1.0 : this.screenSize;
			if(this.lods == null) {
				this.lods = [];
				let _g = 0;
				let _g1 = this.raw.lods;
				while(_g < _g1.length) {
					let l = _g1[_g];
					++_g;
					if(l.object_ref == "") {
						this.lods.push(null);
					} else {
						this.lods.push(iron_Scene.active.getChild(l.object_ref));
					}
				}
			}
			if(context == "voxel") {
				lod = this.lods[this.lods.length - 1];
			} else {
				let _g = 0;
				let _g1 = this.raw.lods.length;
				while(_g < _g1) {
					let i = _g++;
					if(this.screenSize > this.raw.lods[i].screen_size) {
						break;
					}
					lod = this.lods[i];
					if(this.raw != null && this.raw.lod_material != null && this.raw.lod_material == true) {
						mats = lod.materials;
					}
				}
			}
			if(lod == null) {
				return;
			}
		}
		if(this.raw != null && this.raw.lod_material != null && this.raw.lod_material == true && !this.validContext(mats,context)) {
			return;
		}
		let materialContexts = [];
		let shaderContexts = [];
		this.getContexts(context,mats,materialContexts,shaderContexts);
		iron_object_Uniforms.posUnpack = this.data.scalePos;
		iron_object_Uniforms.texUnpack = this.data.scaleTex;
		this.transform.update();
		let ldata = lod.data;
		let _g = 0;
		let _g1 = ldata.geom.indexBuffers.length;
		while(_g < _g1) {
			let i = _g++;
			let mi = ldata.geom.materialIndices[i];
			if(shaderContexts.length <= mi || shaderContexts[mi] == null) {
				continue;
			}
			this.materialIndex = mi;
			if(this.materials.length > mi && this.skipContext(context,this.materials[mi])) {
				continue;
			}
			let scontext = shaderContexts[mi];
			if(scontext == null) {
				continue;
			}
			let elems = scontext.raw.vertex_elements;
			if(scontext.pipeState != iron_object_MeshObject.lastPipeline) {
				g.setPipeline(scontext.pipeState);
				iron_object_MeshObject.lastPipeline = scontext.pipeState;
			}
			iron_object_Uniforms.setContextConstants(g,scontext,bindParams);
			iron_object_Uniforms.setObjectConstants(g,scontext,this);
			if(materialContexts.length > mi) {
				iron_object_Uniforms.setMaterialConstants(g,scontext,materialContexts[mi]);
			}
			if(ldata.geom.instancedVB != null) {
				g.setVertexBuffers([ldata.geom.get(elems),ldata.geom.instancedVB]);
			} else {
				g.setVertexBuffer(ldata.geom.get(elems));
			}
			g.setIndexBuffer(ldata.geom.indexBuffers[i]);
			if(ldata.geom.instanced) {
				g.drawIndexedVerticesInstanced(ldata.geom.instanceCount,ldata.geom.start,ldata.geom.count);
			} else {
				g.drawIndexedVertices(ldata.geom.start,ldata.geom.count);
			}
		}
		let _this = this.prevMatrix;
		let m = this.transform.worldUnpack;
		_this.self._00 = m.self._00;
		_this.self._01 = m.self._01;
		_this.self._02 = m.self._02;
		_this.self._03 = m.self._03;
		_this.self._10 = m.self._10;
		_this.self._11 = m.self._11;
		_this.self._12 = m.self._12;
		_this.self._13 = m.self._13;
		_this.self._20 = m.self._20;
		_this.self._21 = m.self._21;
		_this.self._22 = m.self._22;
		_this.self._23 = m.self._23;
		_this.self._30 = m.self._30;
		_this.self._31 = m.self._31;
		_this.self._32 = m.self._32;
		_this.self._33 = m.self._33;
	}
	validContext(mats,context) {
		let _g = 0;
		while(_g < mats.length) if(mats[_g++].getContext(context) != null) {
			return true;
		}
		return false;
	}
}
$hxClasses["iron.object.MeshObject"] = iron_object_MeshObject;
iron_object_MeshObject.__name__ = "iron.object.MeshObject";
iron_object_MeshObject.__super__ = iron_object_Object;
Object.assign(iron_object_MeshObject.prototype, {
	__class__: iron_object_MeshObject
});
class iron_object_ObjectAnimation extends iron_object_Animation {
	constructor(object,oactions) {
		iron_object_Animation._hx_skip_constructor = true;
		super();
		iron_object_Animation._hx_skip_constructor = false;
		this._hx_constructor(object,oactions);
	}
	_hx_constructor(object,oactions) {
		this.object = object;
		this.oactions = oactions;
		this.isSkinned = false;
		super._hx_constructor();
	}
	getAction(action) {
		let _g = 0;
		let _g1 = this.oactions;
		while(_g < _g1.length) {
			let a = _g1[_g];
			++_g;
			if(a != null && a.objects[0].name == action) {
				return a.objects[0];
			}
		}
		return null;
	}
	play(action,onComplete,blendTime,speed,loop) {
		if(loop == null) {
			loop = true;
		}
		if(speed == null) {
			speed = 1.0;
		}
		if(blendTime == null) {
			blendTime = 0.0;
		}
		if(action == null) {
			action = "";
		}
		super.play(action,onComplete,blendTime,speed,loop);
		if(this.action == "" && this.oactions[0] != null) {
			this.action = this.oactions[0].objects[0].name;
		}
		this.oaction = this.getAction(this.action);
		if(this.oaction != null) {
			this.isSampled = this.oaction.sampled != null && this.oaction.sampled;
		}
	}
	update(delta) {
		if(!this.object.visible || this.object.culled || this.oaction == null) {
			return;
		}
		super.update(delta);
		if(this.paused) {
			return;
		}
		if(!this.isSkinned) {
			this.updateObjectAnim();
		}
	}
	updateObjectAnim() {
		this.updateTransformAnim(this.oaction.anim,this.object.transform);
		this.object.transform.buildMatrix();
	}
	updateTransformAnim(anim,transform) {
		if(anim == null) {
			return;
		}
		let total = anim.end * this.frameTime - anim.begin * this.frameTime;
		if(anim.has_delta) {
			if(transform.dloc == null) {
				transform.dloc = new iron_math_Vec4();
				transform.drot = new iron_math_Quat();
				transform.dscale = new iron_math_Vec4();
			}
			let _this = transform.dloc;
			_this.x = 0;
			_this.y = 0;
			_this.z = 0;
			_this.w = 1.0;
			let _this1 = transform.dscale;
			_this1.x = 0;
			_this1.y = 0;
			_this1.z = 0;
			_this1.w = 1.0;
			transform._deulerX = transform._deulerY = transform._deulerZ = 0.0;
		}
		let _g = 0;
		let _g1 = anim.tracks;
		while(_g < _g1.length) {
			let track = _g1[_g];
			++_g;
			if(this.frameIndex == -1) {
				this.rewind(track);
			}
			let sign = this.speed > 0 ? 1 : -1;
			let t = this.time + anim.begin * this.frameTime;
			while(true) {
				let frameValues = track.frames;
				if(!(this.speed > 0 ? this.frameIndex < frameValues.length - 2 && t > frameValues[this.frameIndex + 1] * this.frameTime : this.frameIndex > 1 && t > frameValues[this.frameIndex - 1] * this.frameTime)) {
					break;
				}
				this.frameIndex += sign;
			}
			if(this.frameIndex >= track.frames.length) {
				continue;
			}
			if(this.time > total) {
				if(this.onComplete != null) {
					this.onComplete();
				}
				if(this.loop) {
					this.rewind(track);
				} else {
					this.frameIndex -= sign;
					this.paused = true;
				}
				return;
			}
			let ti = this.frameIndex;
			let t1 = track.frames[ti] * this.frameTime;
			let s = (t - t1) / (track.frames[ti + sign] * this.frameTime - t1);
			let value = (1.0 - s) * track.values[ti] + s * track.values[ti + sign];
			switch(track.target) {
			case "dqwrot":
				transform.drot.w = value;
				break;
			case "dqxrot":
				transform.drot.x = value;
				break;
			case "dqyrot":
				transform.drot.y = value;
				break;
			case "dqzrot":
				transform.drot.z = value;
				break;
			case "dxloc":
				transform.dloc.x = value;
				break;
			case "dxrot":
				transform._deulerX = value;
				break;
			case "dxscl":
				transform.dscale.x = value;
				break;
			case "dyloc":
				transform.dloc.y = value;
				break;
			case "dyrot":
				transform._deulerY = value;
				break;
			case "dyscl":
				transform.dscale.y = value;
				break;
			case "dzloc":
				transform.dloc.z = value;
				break;
			case "dzrot":
				transform._deulerZ = value;
				break;
			case "dzscl":
				transform.dscale.z = value;
				break;
			case "qwrot":
				transform.rot.w = value;
				break;
			case "qxrot":
				transform.rot.x = value;
				break;
			case "qyrot":
				transform.rot.y = value;
				break;
			case "qzrot":
				transform.rot.z = value;
				break;
			case "xloc":
				transform.loc.x = value;
				break;
			case "xrot":
				transform.setRotation(value,transform._eulerY,transform._eulerZ);
				break;
			case "xscl":
				transform.scale.x = value;
				break;
			case "yloc":
				transform.loc.y = value;
				break;
			case "yrot":
				transform.setRotation(transform._eulerX,value,transform._eulerZ);
				break;
			case "yscl":
				transform.scale.y = value;
				break;
			case "zloc":
				transform.loc.z = value;
				break;
			case "zrot":
				transform.setRotation(transform._eulerX,transform._eulerY,value);
				break;
			case "zscl":
				transform.scale.z = value;
				break;
			}
		}
	}
}
$hxClasses["iron.object.ObjectAnimation"] = iron_object_ObjectAnimation;
iron_object_ObjectAnimation.__name__ = "iron.object.ObjectAnimation";
iron_object_ObjectAnimation.__super__ = iron_object_Animation;
Object.assign(iron_object_ObjectAnimation.prototype, {
	__class__: iron_object_ObjectAnimation
});
class iron_object_ParticleSystem {
	constructor(sceneName,pref) {
		this.ownerScl = new iron_math_Vec4();
		this.ownerRot = new iron_math_Quat();
		this.ownerLoc = new iron_math_Vec4();
		this.m = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
		this.lapTime = 0.0;
		this.lap = 0;
		this.count = 0;
		this.seed = 0;
		this.spawnRate = 0.0;
		this.time = 0.0;
		this.animtime = 0.0;
		this.lifetime = 0.0;
		this.frameRate = 24;
		this.speed = 1.0;
		this.seed = pref.seed;
		this.particles = [];
		this.ready = false;
		let _gthis = this;
		iron_data_Data.getParticle(sceneName,pref.particle,function(b) {
			_gthis.data = b;
			_gthis.r = _gthis.data.raw;
			if(iron_Scene.active.raw.gravity != null) {
				_gthis.gx = iron_Scene.active.raw.gravity[0] * _gthis.r.weight_gravity;
				_gthis.gy = iron_Scene.active.raw.gravity[1] * _gthis.r.weight_gravity;
				_gthis.gz = iron_Scene.active.raw.gravity[2] * _gthis.r.weight_gravity;
			} else {
				_gthis.gx = 0;
				_gthis.gy = 0;
				_gthis.gz = -9.81 * _gthis.r.weight_gravity;
			}
			_gthis.alignx = _gthis.r.object_align_factor[0] / 2;
			_gthis.aligny = _gthis.r.object_align_factor[1] / 2;
			_gthis.alignz = _gthis.r.object_align_factor[2] / 2;
			_gthis.lifetime = _gthis.r.lifetime / _gthis.frameRate;
			_gthis.animtime = (_gthis.r.frame_end - _gthis.r.frame_start) / _gthis.frameRate;
			_gthis.spawnRate = (_gthis.r.frame_end - _gthis.r.frame_start) / _gthis.r.count / _gthis.frameRate;
			let _g = 0;
			let _g1 = _gthis.r.count;
			while(_g < _g1) _gthis.particles.push(new iron_object_Particle(_g++));
			_gthis.ready = true;
		});
	}
	update(object,owner) {
		if(!this.ready || object == null || this.speed == 0.0) {
			return;
		}
		let _this = owner.transform.world;
		let loc = this.ownerLoc;
		let quat = this.ownerRot;
		let scale = this.ownerScl;
		loc.x = _this.self._30;
		loc.y = _this.self._31;
		loc.z = _this.self._32;
		let _this1 = iron_math_Mat4.helpVec;
		_this1.x = _this.self._00;
		_this1.y = _this.self._01;
		_this1.z = _this.self._02;
		_this1.w = 1.0;
		scale.x = Math.sqrt(_this1.x * _this1.x + _this1.y * _this1.y + _this1.z * _this1.z);
		let _this2 = iron_math_Mat4.helpVec;
		_this2.x = _this.self._10;
		_this2.y = _this.self._11;
		_this2.z = _this.self._12;
		_this2.w = 1.0;
		scale.y = Math.sqrt(_this2.x * _this2.x + _this2.y * _this2.y + _this2.z * _this2.z);
		let _this3 = iron_math_Mat4.helpVec;
		_this3.x = _this.self._20;
		_this3.y = _this.self._21;
		_this3.z = _this.self._22;
		_this3.w = 1.0;
		scale.z = Math.sqrt(_this3.x * _this3.x + _this3.y * _this3.y + _this3.z * _this3.z);
		let _this4 = _this.self;
		let m3 = _this4._12;
		let m4 = _this4._22;
		let m5 = _this4._32;
		let m6 = _this4._13;
		let m7 = _this4._23;
		let m8 = _this4._33;
		let m31 = _this4._12;
		let m41 = _this4._22;
		let m51 = _this4._32;
		let m61 = _this4._13;
		let m71 = _this4._23;
		let m81 = _this4._33;
		let m32 = _this4._11;
		let m42 = _this4._21;
		let m52 = _this4._31;
		let m62 = _this4._13;
		let m72 = _this4._23;
		let m82 = _this4._33;
		let m33 = _this4._11;
		let m43 = _this4._21;
		let m53 = _this4._31;
		let m63 = _this4._12;
		let m73 = _this4._22;
		let m83 = _this4._32;
		if(_this4._00 * (_this4._11 * (m4 * m8 - m5 * m7) - _this4._21 * (m3 * m8 - m5 * m6) + _this4._31 * (m3 * m7 - m4 * m6)) - _this4._01 * (_this4._10 * (m41 * m81 - m51 * m71) - _this4._20 * (m31 * m81 - m51 * m61) + _this4._30 * (m31 * m71 - m41 * m61)) + _this4._02 * (_this4._10 * (m42 * m82 - m52 * m72) - _this4._20 * (m32 * m82 - m52 * m62) + _this4._30 * (m32 * m72 - m42 * m62)) - _this4._03 * (_this4._10 * (m43 * m83 - m53 * m73) - _this4._20 * (m33 * m83 - m53 * m63) + _this4._30 * (m33 * m73 - m43 * m63)) < 0.0) {
			scale.x = -scale.x;
		}
		let invs = 1.0 / scale.x;
		iron_math_Mat4.helpMat.self._00 = _this.self._00 * invs;
		iron_math_Mat4.helpMat.self._01 = _this.self._01 * invs;
		iron_math_Mat4.helpMat.self._02 = _this.self._02 * invs;
		invs = 1.0 / scale.y;
		iron_math_Mat4.helpMat.self._10 = _this.self._10 * invs;
		iron_math_Mat4.helpMat.self._11 = _this.self._11 * invs;
		iron_math_Mat4.helpMat.self._12 = _this.self._12 * invs;
		invs = 1.0 / scale.z;
		iron_math_Mat4.helpMat.self._20 = _this.self._20 * invs;
		iron_math_Mat4.helpMat.self._21 = _this.self._21 * invs;
		iron_math_Mat4.helpMat.self._22 = _this.self._22 * invs;
		let m = iron_math_Mat4.helpMat;
		let m11 = m.self._00;
		let m12 = m.self._10;
		let m13 = m.self._20;
		let m21 = m.self._01;
		let m22 = m.self._11;
		let m23 = m.self._21;
		let m311 = m.self._02;
		let m321 = m.self._12;
		let m331 = m.self._22;
		let tr = m11 + m22 + m331;
		let s = 0.0;
		if(tr > 0) {
			s = 0.5 / Math.sqrt(tr + 1.0);
			quat.w = 0.25 / s;
			quat.x = (m321 - m23) * s;
			quat.y = (m13 - m311) * s;
			quat.z = (m21 - m12) * s;
		} else if(m11 > m22 && m11 > m331) {
			s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m331);
			quat.w = (m321 - m23) / s;
			quat.x = 0.25 * s;
			quat.y = (m12 + m21) / s;
			quat.z = (m13 + m311) / s;
		} else if(m22 > m331) {
			s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m331);
			quat.w = (m13 - m311) / s;
			quat.x = (m12 + m21) / s;
			quat.y = 0.25 * s;
			quat.z = (m23 + m321) / s;
		} else {
			s = 2.0 * Math.sqrt(1.0 + m331 - m11 - m22);
			quat.w = (m21 - m12) / s;
			quat.x = (m13 + m311) / s;
			quat.y = (m23 + m321) / s;
			quat.z = 0.25 * s;
		}
		object.transform.loc = this.ownerLoc;
		object.transform.rot = this.ownerRot;
		object.transform.scale = new iron_math_Vec4(this.r.particle_size,this.r.particle_size,this.r.particle_size,1);
		object.transform.buildMatrix();
		owner.transform.buildMatrix();
		let _this5 = object.transform.dim;
		let v = owner.transform.dim;
		_this5.x = v.x;
		_this5.y = v.y;
		_this5.z = v.z;
		_this5.w = v.w;
		this.dimx = object.transform.dim.x;
		this.dimy = object.transform.dim.y;
		if(object.tilesheet != null) {
			this.tilesx = object.tilesheet.raw.tilesx;
			this.tilesy = object.tilesheet.raw.tilesy;
			this.tilesFramerate = object.tilesheet.raw.framerate;
		}
		this.time += iron_system_Time.realDelta * this.speed;
		this.lap = this.time / this.animtime | 0;
		this.lapTime = this.time - this.lap * this.animtime;
		this.count = this.lapTime / this.spawnRate | 0;
		this.updateGpu(object,owner);
	}
	getData() {
		let hair = this.r.type == 1;
		this.m.self._00 = this.r.loop ? this.animtime : -this.animtime;
		this.m.self._01 = hair ? 1 / this.particles.length : this.spawnRate;
		this.m.self._02 = hair ? 1 : this.lifetime;
		this.m.self._03 = this.particles.length;
		this.m.self._10 = hair ? 0 : this.alignx;
		this.m.self._11 = hair ? 0 : this.aligny;
		this.m.self._12 = hair ? 0 : this.alignz;
		this.m.self._13 = hair ? 0 : this.r.factor_random;
		this.m.self._20 = hair ? 0 : this.gx * this.r.mass;
		this.m.self._21 = hair ? 0 : this.gy * this.r.mass;
		this.m.self._22 = hair ? 0 : this.gz * this.r.mass;
		this.m.self._23 = hair ? 0 : this.r.lifetime_random;
		this.m.self._30 = this.tilesx;
		this.m.self._31 = this.tilesy;
		this.m.self._32 = 1 / this.tilesFramerate;
		this.m.self._33 = hair ? 1 : this.lapTime;
		return this.m;
	}
	updateGpu(object,owner) {
		if(!object.data.geom.instanced) {
			this.setupGeomGpu(object,owner);
		}
	}
	setupGeomGpu(object,owner) {
		let instancedData = new Float32Array(this.particles.length * 3);
		let i = 0;
		if(this.r.emit_from == 0) {
			let pa = owner.data.geom.positions;
			let sc = owner.data.scalePos;
			let _g = 0;
			let _g1 = this.particles;
			while(_g < _g1.length) {
				++_g;
				let j = this.fhash(i) * (pa.values.length / pa.size) | 0;
				instancedData[i] = pa.values[j * pa.size] / 32767 * sc / this.r.particle_size;
				++i;
				instancedData[i] = pa.values[j * pa.size + 1] / 32767 * sc / this.r.particle_size;
				++i;
				instancedData[i] = pa.values[j * pa.size + 2] / 32767 * sc / this.r.particle_size;
				++i;
			}
		} else {
			let _g = 0;
			let _g1 = this.particles;
			while(_g < _g1.length) {
				++_g;
				instancedData[i] = (Math.random() * 2.0 - 1.0) * (object.transform.dim.x / 2.0);
				++i;
				instancedData[i] = (Math.random() * 2.0 - 1.0) * (object.transform.dim.y / 2.0);
				++i;
				instancedData[i] = (Math.random() * 2.0 - 1.0) * (object.transform.dim.z / 2.0);
				++i;
			}
		}
		object.data.geom.setupInstanced(instancedData,1,0);
	}
	fhash(n) {
		let s = n + 1.0;
		s *= 9301.0 % s;
		s = (s * 9301.0 + 49297.0) % 233280.0;
		return s / 233280.0;
	}
	remove() {
	}
}
$hxClasses["iron.object.ParticleSystem"] = iron_object_ParticleSystem;
iron_object_ParticleSystem.__name__ = "iron.object.ParticleSystem";
Object.assign(iron_object_ParticleSystem.prototype, {
	__class__: iron_object_ParticleSystem
});
class iron_object_Particle {
	constructor(i) {
		this.i = i;
	}
}
$hxClasses["iron.object.Particle"] = iron_object_Particle;
iron_object_Particle.__name__ = "iron.object.Particle";
Object.assign(iron_object_Particle.prototype, {
	__class__: iron_object_Particle
});
class iron_object_Tilesheet {
	constructor(sceneName,tilesheet_ref,tilesheet_action_ref) {
		this.onActionComplete = null;
		this.time = 0.0;
		this.frame = 0;
		this.paused = false;
		this.action = null;
		this.tileY = 0.0;
		this.tileX = 0.0;
		this.ready = false;
		let _gthis = this;
		iron_data_Data.getSceneRaw(sceneName,function(format) {
			let _g = 0;
			let _g1 = format.tilesheet_datas;
			while(_g < _g1.length) {
				let ts = _g1[_g];
				++_g;
				if(ts.name == tilesheet_ref) {
					_gthis.raw = ts;
					_gthis.play(tilesheet_action_ref);
					_gthis.ready = true;
					break;
				}
			}
		});
	}
	play(action_ref,onActionComplete) {
		this.onActionComplete = onActionComplete;
		let _g = 0;
		let _g1 = this.raw.actions;
		while(_g < _g1.length) {
			let a = _g1[_g];
			++_g;
			if(a.name == action_ref) {
				this.action = a;
				break;
			}
		}
		this.setFrame(this.action.start);
		this.paused = false;
	}
	remove() {
	}
	update() {
		if(!this.ready || this.paused || this.action.start >= this.action.end) {
			return;
		}
		this.time += iron_system_Time.get_delta();
		if(this.time >= 1 / this.raw.framerate) {
			this.setFrame(this.frame + 1);
		}
	}
	setFrame(f) {
		this.frame = f;
		this.time = 0;
		this.tileX = this.frame % this.raw.tilesx * (1 / this.raw.tilesx);
		this.tileY = (this.frame / this.raw.tilesx | 0) * (1 / this.raw.tilesy);
		if(this.frame >= this.action.end && this.action.start < this.action.end) {
			if(this.onActionComplete != null) {
				this.onActionComplete();
			}
			if(this.action.loop) {
				this.setFrame(this.action.start);
			} else {
				this.paused = true;
			}
		}
	}
}
$hxClasses["iron.object.Tilesheet"] = iron_object_Tilesheet;
iron_object_Tilesheet.__name__ = "iron.object.Tilesheet";
Object.assign(iron_object_Tilesheet.prototype, {
	__class__: iron_object_Tilesheet
});
class iron_object_Transform {
	constructor(object) {
		this.dscale = null;
		this.drot = null;
		this.dloc = null;
		this.boneParent = null;
		this.scaleWorld = 1.0;
		this.localOnly = false;
		this.object = object;
		this.reset();
	}
	reset() {
		this.world = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
		this.worldUnpack = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
		this.local = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
		this.loc = new iron_math_Vec4();
		this.rot = new iron_math_Quat();
		this.scale = new iron_math_Vec4(1.0,1.0,1.0);
		this.dim = new iron_math_Vec4(2.0,2.0,2.0);
		this.radius = 1.0;
		this.dirty = true;
	}
	update() {
		if(this.dirty) {
			this.buildMatrix();
		}
	}
	composeDelta() {
		let _this = this.dloc;
		let a = this.loc;
		let b = this.dloc;
		_this.x = a.x + b.x;
		_this.y = a.y + b.y;
		_this.z = a.z + b.z;
		let _this1 = this.dscale;
		let a1 = this.dscale;
		let b1 = this.scale;
		_this1.x = a1.x + b1.x;
		_this1.y = a1.y + b1.y;
		_this1.z = a1.z + b1.z;
		let _this2 = this.drot;
		let f = this._deulerX / 2;
		let c1 = Math.cos(f);
		let s1 = Math.sin(f);
		f = this._deulerY / 2;
		let c2 = Math.cos(f);
		let s2 = Math.sin(f);
		f = this._deulerZ / 2;
		let c3 = Math.cos(f);
		let s3 = Math.sin(f);
		_this2.x = s1 * c2 * c3 + c1 * s2 * s3;
		_this2.y = c1 * s2 * c3 + s1 * c2 * s3;
		_this2.z = c1 * c2 * s3 - s1 * s2 * c3;
		_this2.w = c1 * c2 * c3 - s1 * s2 * s3;
		let _this3 = this.drot;
		let q1 = this.rot;
		let q2 = this.drot;
		let q1x = q1.x;
		let q1y = q1.y;
		let q1z = q1.z;
		let q1w = q1.w;
		let q2x = q2.x;
		let q2y = q2.y;
		let q2z = q2.z;
		let q2w = q2.w;
		_this3.x = q1x * q2w + q1w * q2x + q1y * q2z - q1z * q2y;
		_this3.y = q1w * q2y - q1x * q2z + q1y * q2w + q1z * q2x;
		_this3.z = q1w * q2z + q1x * q2y - q1y * q2x + q1z * q2w;
		_this3.w = q1w * q2w - q1x * q2x - q1y * q2y - q1z * q2z;
		let _this4 = this.local;
		let loc = this.dloc;
		let quat = this.drot;
		let sc = this.dscale;
		let x = quat.x;
		let y = quat.y;
		let z = quat.z;
		let w = quat.w;
		let x2 = x + x;
		let y2 = y + y;
		let z2 = z + z;
		let xx = x * x2;
		let xy = x * y2;
		let xz = x * z2;
		let yy = y * y2;
		let yz = y * z2;
		let zz = z * z2;
		let wx = w * x2;
		let wy = w * y2;
		let wz = w * z2;
		_this4.self._00 = 1.0 - (yy + zz);
		_this4.self._10 = xy - wz;
		_this4.self._20 = xz + wy;
		_this4.self._01 = xy + wz;
		_this4.self._11 = 1.0 - (xx + zz);
		_this4.self._21 = yz - wx;
		_this4.self._02 = xz - wy;
		_this4.self._12 = yz + wx;
		_this4.self._22 = 1.0 - (xx + yy);
		_this4.self._03 = 0.0;
		_this4.self._13 = 0.0;
		_this4.self._23 = 0.0;
		_this4.self._30 = 0.0;
		_this4.self._31 = 0.0;
		_this4.self._32 = 0.0;
		_this4.self._33 = 1.0;
		let x1 = sc.x;
		let y1 = sc.y;
		let z1 = sc.z;
		_this4.self._00 *= x1;
		_this4.self._01 *= x1;
		_this4.self._02 *= x1;
		_this4.self._03 *= x1;
		_this4.self._10 *= y1;
		_this4.self._11 *= y1;
		_this4.self._12 *= y1;
		_this4.self._13 *= y1;
		_this4.self._20 *= z1;
		_this4.self._21 *= z1;
		_this4.self._22 *= z1;
		_this4.self._23 *= z1;
		_this4.self._30 = loc.x;
		_this4.self._31 = loc.y;
		_this4.self._32 = loc.z;
	}
	buildMatrix() {
		if(this.dloc == null) {
			let _this = this.local;
			let loc = this.loc;
			let quat = this.rot;
			let sc = this.scale;
			let x = quat.x;
			let y = quat.y;
			let z = quat.z;
			let w = quat.w;
			let x2 = x + x;
			let y2 = y + y;
			let z2 = z + z;
			let xx = x * x2;
			let xy = x * y2;
			let xz = x * z2;
			let yy = y * y2;
			let yz = y * z2;
			let zz = z * z2;
			let wx = w * x2;
			let wy = w * y2;
			let wz = w * z2;
			_this.self._00 = 1.0 - (yy + zz);
			_this.self._10 = xy - wz;
			_this.self._20 = xz + wy;
			_this.self._01 = xy + wz;
			_this.self._11 = 1.0 - (xx + zz);
			_this.self._21 = yz - wx;
			_this.self._02 = xz - wy;
			_this.self._12 = yz + wx;
			_this.self._22 = 1.0 - (xx + yy);
			_this.self._03 = 0.0;
			_this.self._13 = 0.0;
			_this.self._23 = 0.0;
			_this.self._30 = 0.0;
			_this.self._31 = 0.0;
			_this.self._32 = 0.0;
			_this.self._33 = 1.0;
			let x1 = sc.x;
			let y1 = sc.y;
			let z1 = sc.z;
			_this.self._00 *= x1;
			_this.self._01 *= x1;
			_this.self._02 *= x1;
			_this.self._03 *= x1;
			_this.self._10 *= y1;
			_this.self._11 *= y1;
			_this.self._12 *= y1;
			_this.self._13 *= y1;
			_this.self._20 *= z1;
			_this.self._21 *= z1;
			_this.self._22 *= z1;
			_this.self._23 *= z1;
			_this.self._30 = loc.x;
			_this.self._31 = loc.y;
			_this.self._32 = loc.z;
		} else {
			this.composeDelta();
		}
		if(this.boneParent != null) {
			let _this = this.local;
			let b = this.boneParent;
			let a = this.local;
			let a00 = a.self._00;
			let a01 = a.self._01;
			let a02 = a.self._02;
			let a03 = a.self._03;
			let a10 = a.self._10;
			let a11 = a.self._11;
			let a12 = a.self._12;
			let a13 = a.self._13;
			let a20 = a.self._20;
			let a21 = a.self._21;
			let a22 = a.self._22;
			let a23 = a.self._23;
			let a30 = a.self._30;
			let a31 = a.self._31;
			let a32 = a.self._32;
			let a33 = a.self._33;
			let b0 = b.self._00;
			let b1 = b.self._10;
			let b2 = b.self._20;
			let b3 = b.self._30;
			_this.self._00 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
			_this.self._10 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
			_this.self._20 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
			_this.self._30 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
			b0 = b.self._01;
			b1 = b.self._11;
			b2 = b.self._21;
			b3 = b.self._31;
			_this.self._01 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
			_this.self._11 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
			_this.self._21 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
			_this.self._31 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
			b0 = b.self._02;
			b1 = b.self._12;
			b2 = b.self._22;
			b3 = b.self._32;
			_this.self._02 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
			_this.self._12 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
			_this.self._22 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
			_this.self._32 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
			b0 = b.self._03;
			b1 = b.self._13;
			b2 = b.self._23;
			b3 = b.self._33;
			_this.self._03 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
			_this.self._13 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
			_this.self._23 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
			_this.self._33 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
		}
		if(this.object.parent != null && !this.localOnly) {
			let _this = this.world;
			let a = this.local;
			let b = this.object.parent.transform.world;
			let a00 = a.self._00;
			let a01 = a.self._01;
			let a02 = a.self._02;
			let a03 = a.self._03;
			let a10 = a.self._10;
			let a11 = a.self._11;
			let a12 = a.self._12;
			let a13 = a.self._13;
			let a20 = a.self._20;
			let a21 = a.self._21;
			let a22 = a.self._22;
			let a23 = a.self._23;
			let a30 = a.self._30;
			let a31 = a.self._31;
			let a32 = a.self._32;
			let a33 = a.self._33;
			let b0 = b.self._00;
			let b1 = b.self._10;
			let b2 = b.self._20;
			let b3 = b.self._30;
			_this.self._00 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
			_this.self._10 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
			_this.self._20 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
			_this.self._30 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
			b0 = b.self._01;
			b1 = b.self._11;
			b2 = b.self._21;
			b3 = b.self._31;
			_this.self._01 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
			_this.self._11 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
			_this.self._21 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
			_this.self._31 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
			b0 = b.self._02;
			b1 = b.self._12;
			b2 = b.self._22;
			b3 = b.self._32;
			_this.self._02 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
			_this.self._12 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
			_this.self._22 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
			_this.self._32 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
			_this.self._03 = 0;
			_this.self._13 = 0;
			_this.self._23 = 0;
			_this.self._33 = 1;
		} else {
			let _this = this.world;
			let m = this.local;
			_this.self._00 = m.self._00;
			_this.self._01 = m.self._01;
			_this.self._02 = m.self._02;
			_this.self._03 = m.self._03;
			_this.self._10 = m.self._10;
			_this.self._11 = m.self._11;
			_this.self._12 = m.self._12;
			_this.self._13 = m.self._13;
			_this.self._20 = m.self._20;
			_this.self._21 = m.self._21;
			_this.self._22 = m.self._22;
			_this.self._23 = m.self._23;
			_this.self._30 = m.self._30;
			_this.self._31 = m.self._31;
			_this.self._32 = m.self._32;
			_this.self._33 = m.self._33;
		}
		let _this = this.worldUnpack;
		let m = this.world;
		_this.self._00 = m.self._00;
		_this.self._01 = m.self._01;
		_this.self._02 = m.self._02;
		_this.self._03 = m.self._03;
		_this.self._10 = m.self._10;
		_this.self._11 = m.self._11;
		_this.self._12 = m.self._12;
		_this.self._13 = m.self._13;
		_this.self._20 = m.self._20;
		_this.self._21 = m.self._21;
		_this.self._22 = m.self._22;
		_this.self._23 = m.self._23;
		_this.self._30 = m.self._30;
		_this.self._31 = m.self._31;
		_this.self._32 = m.self._32;
		_this.self._33 = m.self._33;
		if(this.scaleWorld != 1.0) {
			this.worldUnpack.self._00 *= this.scaleWorld;
			this.worldUnpack.self._01 *= this.scaleWorld;
			this.worldUnpack.self._02 *= this.scaleWorld;
			this.worldUnpack.self._03 *= this.scaleWorld;
			this.worldUnpack.self._10 *= this.scaleWorld;
			this.worldUnpack.self._11 *= this.scaleWorld;
			this.worldUnpack.self._12 *= this.scaleWorld;
			this.worldUnpack.self._13 *= this.scaleWorld;
			this.worldUnpack.self._20 *= this.scaleWorld;
			this.worldUnpack.self._21 *= this.scaleWorld;
			this.worldUnpack.self._22 *= this.scaleWorld;
			this.worldUnpack.self._23 *= this.scaleWorld;
		}
		if(this.object.constraints != null) {
			let _g = 0;
			let _g1 = this.object.constraints;
			while(_g < _g1.length) _g1[_g++].apply(this);
		}
		this.computeDim();
		let _g = 0;
		let _g1 = this.object.children;
		while(_g < _g1.length) _g1[_g++].transform.buildMatrix();
		this.dirty = false;
	}
	translate(x,y,z) {
		this.loc.x += x;
		this.loc.y += y;
		this.loc.z += z;
		this.buildMatrix();
	}
	setMatrix(mat) {
		let _this = this.local;
		_this.self._00 = mat.self._00;
		_this.self._01 = mat.self._01;
		_this.self._02 = mat.self._02;
		_this.self._03 = mat.self._03;
		_this.self._10 = mat.self._10;
		_this.self._11 = mat.self._11;
		_this.self._12 = mat.self._12;
		_this.self._13 = mat.self._13;
		_this.self._20 = mat.self._20;
		_this.self._21 = mat.self._21;
		_this.self._22 = mat.self._22;
		_this.self._23 = mat.self._23;
		_this.self._30 = mat.self._30;
		_this.self._31 = mat.self._31;
		_this.self._32 = mat.self._32;
		_this.self._33 = mat.self._33;
		this.decompose();
		this.buildMatrix();
	}
	decompose() {
		let _this = this.local;
		let loc = this.loc;
		let quat = this.rot;
		let scale = this.scale;
		loc.x = _this.self._30;
		loc.y = _this.self._31;
		loc.z = _this.self._32;
		let _this1 = iron_math_Mat4.helpVec;
		_this1.x = _this.self._00;
		_this1.y = _this.self._01;
		_this1.z = _this.self._02;
		_this1.w = 1.0;
		scale.x = Math.sqrt(_this1.x * _this1.x + _this1.y * _this1.y + _this1.z * _this1.z);
		let _this2 = iron_math_Mat4.helpVec;
		_this2.x = _this.self._10;
		_this2.y = _this.self._11;
		_this2.z = _this.self._12;
		_this2.w = 1.0;
		scale.y = Math.sqrt(_this2.x * _this2.x + _this2.y * _this2.y + _this2.z * _this2.z);
		let _this3 = iron_math_Mat4.helpVec;
		_this3.x = _this.self._20;
		_this3.y = _this.self._21;
		_this3.z = _this.self._22;
		_this3.w = 1.0;
		scale.z = Math.sqrt(_this3.x * _this3.x + _this3.y * _this3.y + _this3.z * _this3.z);
		let _this4 = _this.self;
		let m3 = _this4._12;
		let m4 = _this4._22;
		let m5 = _this4._32;
		let m6 = _this4._13;
		let m7 = _this4._23;
		let m8 = _this4._33;
		let m31 = _this4._12;
		let m41 = _this4._22;
		let m51 = _this4._32;
		let m61 = _this4._13;
		let m71 = _this4._23;
		let m81 = _this4._33;
		let m32 = _this4._11;
		let m42 = _this4._21;
		let m52 = _this4._31;
		let m62 = _this4._13;
		let m72 = _this4._23;
		let m82 = _this4._33;
		let m33 = _this4._11;
		let m43 = _this4._21;
		let m53 = _this4._31;
		let m63 = _this4._12;
		let m73 = _this4._22;
		let m83 = _this4._32;
		if(_this4._00 * (_this4._11 * (m4 * m8 - m5 * m7) - _this4._21 * (m3 * m8 - m5 * m6) + _this4._31 * (m3 * m7 - m4 * m6)) - _this4._01 * (_this4._10 * (m41 * m81 - m51 * m71) - _this4._20 * (m31 * m81 - m51 * m61) + _this4._30 * (m31 * m71 - m41 * m61)) + _this4._02 * (_this4._10 * (m42 * m82 - m52 * m72) - _this4._20 * (m32 * m82 - m52 * m62) + _this4._30 * (m32 * m72 - m42 * m62)) - _this4._03 * (_this4._10 * (m43 * m83 - m53 * m73) - _this4._20 * (m33 * m83 - m53 * m63) + _this4._30 * (m33 * m73 - m43 * m63)) < 0.0) {
			scale.x = -scale.x;
		}
		let invs = 1.0 / scale.x;
		iron_math_Mat4.helpMat.self._00 = _this.self._00 * invs;
		iron_math_Mat4.helpMat.self._01 = _this.self._01 * invs;
		iron_math_Mat4.helpMat.self._02 = _this.self._02 * invs;
		invs = 1.0 / scale.y;
		iron_math_Mat4.helpMat.self._10 = _this.self._10 * invs;
		iron_math_Mat4.helpMat.self._11 = _this.self._11 * invs;
		iron_math_Mat4.helpMat.self._12 = _this.self._12 * invs;
		invs = 1.0 / scale.z;
		iron_math_Mat4.helpMat.self._20 = _this.self._20 * invs;
		iron_math_Mat4.helpMat.self._21 = _this.self._21 * invs;
		iron_math_Mat4.helpMat.self._22 = _this.self._22 * invs;
		let m = iron_math_Mat4.helpMat;
		let m11 = m.self._00;
		let m12 = m.self._10;
		let m13 = m.self._20;
		let m21 = m.self._01;
		let m22 = m.self._11;
		let m23 = m.self._21;
		let m311 = m.self._02;
		let m321 = m.self._12;
		let m331 = m.self._22;
		let tr = m11 + m22 + m331;
		let s = 0.0;
		if(tr > 0) {
			s = 0.5 / Math.sqrt(tr + 1.0);
			quat.w = 0.25 / s;
			quat.x = (m321 - m23) * s;
			quat.y = (m13 - m311) * s;
			quat.z = (m21 - m12) * s;
		} else if(m11 > m22 && m11 > m331) {
			s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m331);
			quat.w = (m321 - m23) / s;
			quat.x = 0.25 * s;
			quat.y = (m12 + m21) / s;
			quat.z = (m13 + m311) / s;
		} else if(m22 > m331) {
			s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m331);
			quat.w = (m13 - m311) / s;
			quat.x = (m12 + m21) / s;
			quat.y = 0.25 * s;
			quat.z = (m23 + m321) / s;
		} else {
			s = 2.0 * Math.sqrt(1.0 + m331 - m11 - m22);
			quat.w = (m21 - m12) / s;
			quat.x = (m13 + m311) / s;
			quat.y = (m23 + m321) / s;
			quat.z = 0.25 * s;
		}
	}
	rotate(axis,f) {
		let _this = iron_object_Transform.q;
		let s = Math.sin(f * 0.5);
		_this.x = axis.x * s;
		_this.y = axis.y * s;
		_this.z = axis.z * s;
		_this.w = Math.cos(f * 0.5);
		let l = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z + _this.w * _this.w);
		if(l == 0.0) {
			_this.x = 0;
			_this.y = 0;
			_this.z = 0;
			_this.w = 0;
		} else {
			l = 1.0 / l;
			_this.x *= l;
			_this.y *= l;
			_this.z *= l;
			_this.w *= l;
		}
		let _this1 = this.rot;
		let q1 = iron_object_Transform.q;
		let q2 = this.rot;
		let q1x = q1.x;
		let q1y = q1.y;
		let q1z = q1.z;
		let q1w = q1.w;
		let q2x = q2.x;
		let q2y = q2.y;
		let q2z = q2.z;
		let q2w = q2.w;
		_this1.x = q1x * q2w + q1w * q2x + q1y * q2z - q1z * q2y;
		_this1.y = q1w * q2y - q1x * q2z + q1y * q2w + q1z * q2x;
		_this1.z = q1w * q2z + q1x * q2y - q1y * q2x + q1z * q2w;
		_this1.w = q1w * q2w - q1x * q2x - q1y * q2y - q1z * q2z;
		this.buildMatrix();
	}
	move(axis,f) {
		if(f == null) {
			f = 1.0;
		}
		let _this = this.loc;
		_this.x += axis.x * f;
		_this.y += axis.y * f;
		_this.z += axis.z * f;
		this.buildMatrix();
	}
	setRotation(x,y,z) {
		let _this = this.rot;
		let f = x / 2;
		let c1 = Math.cos(f);
		let s1 = Math.sin(f);
		f = y / 2;
		let c2 = Math.cos(f);
		let s2 = Math.sin(f);
		f = z / 2;
		let c3 = Math.cos(f);
		let s3 = Math.sin(f);
		_this.x = s1 * c2 * c3 + c1 * s2 * s3;
		_this.y = c1 * s2 * c3 + s1 * c2 * s3;
		_this.z = c1 * c2 * s3 - s1 * s2 * c3;
		_this.w = c1 * c2 * c3 - s1 * s2 * s3;
		this._eulerX = x;
		this._eulerY = y;
		this._eulerZ = z;
		this.dirty = true;
	}
	computeRadius() {
		this.radius = Math.sqrt(this.dim.x * this.dim.x + this.dim.y * this.dim.y + this.dim.z * this.dim.z);
	}
	computeDim() {
		if(this.object.raw == null) {
			this.computeRadius();
			return;
		}
		let d = this.object.raw.dimensions;
		if(d == null) {
			let _this = this.dim;
			_this.x = 2 * this.scale.x;
			_this.y = 2 * this.scale.y;
			_this.z = 2 * this.scale.z;
			_this.w = 1.0;
		} else {
			let _this = this.dim;
			let y = d[1] * this.scale.y;
			let z = d[2] * this.scale.z;
			_this.x = d[0] * this.scale.x;
			_this.y = y;
			_this.z = z;
			_this.w = 1.0;
		}
		this.computeRadius();
	}
	applyParentInverse() {
		let pt = this.object.parent.transform;
		pt.buildMatrix();
		let _this = iron_object_Transform.temp;
		let m = pt.world;
		let a00 = m.self._00;
		let a01 = m.self._01;
		let a02 = m.self._02;
		let a03 = m.self._03;
		let a10 = m.self._10;
		let a11 = m.self._11;
		let a12 = m.self._12;
		let a13 = m.self._13;
		let a20 = m.self._20;
		let a21 = m.self._21;
		let a22 = m.self._22;
		let a23 = m.self._23;
		let a30 = m.self._30;
		let a31 = m.self._31;
		let a32 = m.self._32;
		let a33 = m.self._33;
		let b00 = a00 * a11 - a01 * a10;
		let b01 = a00 * a12 - a02 * a10;
		let b02 = a00 * a13 - a03 * a10;
		let b03 = a01 * a12 - a02 * a11;
		let b04 = a01 * a13 - a03 * a11;
		let b05 = a02 * a13 - a03 * a12;
		let b06 = a20 * a31 - a21 * a30;
		let b07 = a20 * a32 - a22 * a30;
		let b08 = a20 * a33 - a23 * a30;
		let b09 = a21 * a32 - a22 * a31;
		let b10 = a21 * a33 - a23 * a31;
		let b11 = a22 * a33 - a23 * a32;
		let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
		if(det == 0.0) {
			_this.self._00 = 1.0;
			_this.self._01 = 0.0;
			_this.self._02 = 0.0;
			_this.self._03 = 0.0;
			_this.self._10 = 0.0;
			_this.self._11 = 1.0;
			_this.self._12 = 0.0;
			_this.self._13 = 0.0;
			_this.self._20 = 0.0;
			_this.self._21 = 0.0;
			_this.self._22 = 1.0;
			_this.self._23 = 0.0;
			_this.self._30 = 0.0;
			_this.self._31 = 0.0;
			_this.self._32 = 0.0;
			_this.self._33 = 1.0;
		} else {
			det = 1.0 / det;
			_this.self._00 = (a11 * b11 - a12 * b10 + a13 * b09) * det;
			_this.self._01 = (a02 * b10 - a01 * b11 - a03 * b09) * det;
			_this.self._02 = (a31 * b05 - a32 * b04 + a33 * b03) * det;
			_this.self._03 = (a22 * b04 - a21 * b05 - a23 * b03) * det;
			_this.self._10 = (a12 * b08 - a10 * b11 - a13 * b07) * det;
			_this.self._11 = (a00 * b11 - a02 * b08 + a03 * b07) * det;
			_this.self._12 = (a32 * b02 - a30 * b05 - a33 * b01) * det;
			_this.self._13 = (a20 * b05 - a22 * b02 + a23 * b01) * det;
			_this.self._20 = (a10 * b10 - a11 * b08 + a13 * b06) * det;
			_this.self._21 = (a01 * b08 - a00 * b10 - a03 * b06) * det;
			_this.self._22 = (a30 * b04 - a31 * b02 + a33 * b00) * det;
			_this.self._23 = (a21 * b02 - a20 * b04 - a23 * b00) * det;
			_this.self._30 = (a11 * b07 - a10 * b09 - a12 * b06) * det;
			_this.self._31 = (a00 * b09 - a01 * b07 + a02 * b06) * det;
			_this.self._32 = (a31 * b01 - a30 * b03 - a32 * b00) * det;
			_this.self._33 = (a20 * b03 - a21 * b01 + a22 * b00) * det;
		}
		let _this1 = this.local;
		let m1 = iron_object_Transform.temp;
		let a001 = _this1.self._00;
		let a011 = _this1.self._01;
		let a021 = _this1.self._02;
		let a031 = _this1.self._03;
		let a101 = _this1.self._10;
		let a111 = _this1.self._11;
		let a121 = _this1.self._12;
		let a131 = _this1.self._13;
		let a201 = _this1.self._20;
		let a211 = _this1.self._21;
		let a221 = _this1.self._22;
		let a231 = _this1.self._23;
		let a301 = _this1.self._30;
		let a311 = _this1.self._31;
		let a321 = _this1.self._32;
		let a331 = _this1.self._33;
		let b0 = m1.self._00;
		let b1 = m1.self._10;
		let b2 = m1.self._20;
		let b3 = m1.self._30;
		_this1.self._00 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
		_this1.self._10 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
		_this1.self._20 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
		_this1.self._30 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
		b0 = m1.self._01;
		b1 = m1.self._11;
		b2 = m1.self._21;
		b3 = m1.self._31;
		_this1.self._01 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
		_this1.self._11 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
		_this1.self._21 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
		_this1.self._31 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
		b0 = m1.self._02;
		b1 = m1.self._12;
		b2 = m1.self._22;
		b3 = m1.self._32;
		_this1.self._02 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
		_this1.self._12 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
		_this1.self._22 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
		_this1.self._32 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
		b0 = m1.self._03;
		b1 = m1.self._13;
		b2 = m1.self._23;
		b3 = m1.self._33;
		_this1.self._03 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
		_this1.self._13 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
		_this1.self._23 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
		_this1.self._33 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
		this.decompose();
		this.buildMatrix();
	}
	applyParent() {
		let pt = this.object.parent.transform;
		pt.buildMatrix();
		let _this = this.local;
		let m = pt.world;
		let a00 = _this.self._00;
		let a01 = _this.self._01;
		let a02 = _this.self._02;
		let a03 = _this.self._03;
		let a10 = _this.self._10;
		let a11 = _this.self._11;
		let a12 = _this.self._12;
		let a13 = _this.self._13;
		let a20 = _this.self._20;
		let a21 = _this.self._21;
		let a22 = _this.self._22;
		let a23 = _this.self._23;
		let a30 = _this.self._30;
		let a31 = _this.self._31;
		let a32 = _this.self._32;
		let a33 = _this.self._33;
		let b0 = m.self._00;
		let b1 = m.self._10;
		let b2 = m.self._20;
		let b3 = m.self._30;
		_this.self._00 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
		_this.self._10 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
		_this.self._20 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
		_this.self._30 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
		b0 = m.self._01;
		b1 = m.self._11;
		b2 = m.self._21;
		b3 = m.self._31;
		_this.self._01 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
		_this.self._11 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
		_this.self._21 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
		_this.self._31 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
		b0 = m.self._02;
		b1 = m.self._12;
		b2 = m.self._22;
		b3 = m.self._32;
		_this.self._02 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
		_this.self._12 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
		_this.self._22 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
		_this.self._32 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
		b0 = m.self._03;
		b1 = m.self._13;
		b2 = m.self._23;
		b3 = m.self._33;
		_this.self._03 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
		_this.self._13 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
		_this.self._23 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
		_this.self._33 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
		this.decompose();
		this.buildMatrix();
	}
}
$hxClasses["iron.object.Transform"] = iron_object_Transform;
iron_object_Transform.__name__ = "iron.object.Transform";
Object.assign(iron_object_Transform.prototype, {
	__class__: iron_object_Transform
});
class kha_math_FastMatrix3 {
	constructor(_00,_10,_20,_01,_11,_21,_02,_12,_22) {
		this._00 = _00;
		this._10 = _10;
		this._20 = _20;
		this._01 = _01;
		this._11 = _11;
		this._21 = _21;
		this._02 = _02;
		this._12 = _12;
		this._22 = _22;
	}
}
$hxClasses["kha.math.FastMatrix3"] = kha_math_FastMatrix3;
kha_math_FastMatrix3.__name__ = "kha.math.FastMatrix3";
Object.assign(kha_math_FastMatrix3.prototype, {
	__class__: kha_math_FastMatrix3
});
class iron_object_Uniforms {
	static setContextConstants(g,context,bindParams) {
		if(context.raw.constants != null) {
			let _g = 0;
			let _g1 = context.raw.constants.length;
			while(_g < _g1) {
				let i = _g++;
				iron_object_Uniforms.setContextConstant(g,context.constants[i],context.raw.constants[i]);
			}
		}
		if(bindParams != null) {
			let _g = 0;
			let _g1 = bindParams.length / 2 | 0;
			while(_g < _g1) {
				let pos = _g++ * 2;
				let rtID = bindParams[pos];
				let attachDepth = false;
				if(rtID.charAt(0) == "_") {
					attachDepth = true;
					rtID = HxOverrides.substr(rtID,1,null);
				}
				iron_object_Uniforms.bindRenderTarget(g,attachDepth ? iron_RenderPath.active.depthToRenderTarget.h[rtID] : iron_RenderPath.active.renderTargets.h[rtID],context,bindParams[pos + 1],attachDepth);
			}
		}
		if(context.raw.texture_units != null) {
			let _g = 0;
			let _g1 = context.raw.texture_units.length;
			while(_g < _g1) {
				let j = _g++;
				let tulink = context.raw.texture_units[j].link;
				if(tulink == null) {
					continue;
				}
				if(tulink.charAt(0) == "$") {
					g.setTexture(context.textureUnits[j],iron_Scene.active.embedded.h[HxOverrides.substr(tulink,1,null)]);
					if(tulink.endsWith(".raw")) {
						g.setTexture3DParameters(context.textureUnits[j],0,0,0,1,1,0);
					} else {
						g.setTextureParameters(context.textureUnits[j],0,0,1,1,0);
					}
				} else {
					switch(tulink) {
					case "_envmap":
						let w = iron_Scene.active.world;
						if(w != null) {
							g.setTexture(context.textureUnits[j],w.envmap);
							g.setTextureParameters(context.textureUnits[j],0,0,1,1,0);
						}
						break;
					case "_envmapRadiance":
						let w1 = iron_Scene.active.world;
						if(w1 != null) {
							g.setTexture(context.textureUnits[j],w1.probe.radiance);
							g.setTextureParameters(context.textureUnits[j],0,0,1,1,2);
						}
						break;
					}
				}
			}
		}
	}
	static setObjectConstants(g,context,object) {
		if(context.raw.constants != null) {
			let _g = 0;
			let _g1 = context.raw.constants.length;
			while(_g < _g1) {
				let i = _g++;
				iron_object_Uniforms.setObjectConstant(g,object,context.constants[i],context.raw.constants[i]);
			}
		}
		if(iron_object_Uniforms.externalTextureLinks != null) {
			if(context.raw.texture_units != null) {
				let _g = 0;
				let _g1 = context.raw.texture_units.length;
				while(_g < _g1) {
					let j = _g++;
					let tu = context.raw.texture_units[j];
					if(tu.link == null) {
						continue;
					}
					let s = tu.addressing_u;
					let tuAddrU;
					if(s == null) {
						tuAddrU = 0;
					} else {
						switch(s) {
						case "clamp":
							tuAddrU = 2;
							break;
						case "mirror":
							tuAddrU = 1;
							break;
						default:
							tuAddrU = 0;
						}
					}
					let s1 = tu.addressing_v;
					let tuAddrV;
					if(s1 == null) {
						tuAddrV = 0;
					} else {
						switch(s1) {
						case "clamp":
							tuAddrV = 2;
							break;
						case "mirror":
							tuAddrV = 1;
							break;
						default:
							tuAddrV = 0;
						}
					}
					let s2 = tu.filter_min;
					let tuFilterMin;
					if(s2 == null) {
						tuFilterMin = 1;
					} else {
						switch(s2) {
						case "anisotropic":
							tuFilterMin = 2;
							break;
						case "point":
							tuFilterMin = 0;
							break;
						default:
							tuFilterMin = 1;
						}
					}
					let s3 = tu.filter_mag;
					let tuFilterMag;
					if(s3 == null) {
						tuFilterMag = 1;
					} else {
						switch(s3) {
						case "anisotropic":
							tuFilterMag = 2;
							break;
						case "point":
							tuFilterMag = 0;
							break;
						default:
							tuFilterMag = 1;
						}
					}
					let s4 = tu.mipmap_filter;
					let tuMipMapFilter;
					if(s4 == null) {
						tuMipMapFilter = 0;
					} else {
						switch(s4) {
						case "linear":
							tuMipMapFilter = 2;
							break;
						case "point":
							tuMipMapFilter = 1;
							break;
						default:
							tuMipMapFilter = 0;
						}
					}
					let _g1 = 0;
					let _g2 = iron_object_Uniforms.externalTextureLinks;
					while(_g1 < _g2.length) {
						let image = _g2[_g1++](object,iron_object_Uniforms.currentMat(object),tu.link);
						if(image != null) {
							if(tu.link.endsWith("_depth")) {
								g.setTextureDepth(context.textureUnits[j],image);
							} else {
								g.setTexture(context.textureUnits[j],image);
							}
							g.setTextureParameters(context.textureUnits[j],tuAddrU,tuAddrV,tuFilterMin,tuFilterMag,tuMipMapFilter);
							break;
						}
					}
				}
			}
		}
	}
	static bindRenderTarget(g,rt,context,samplerID,attachDepth) {
		if(rt != null) {
			let tus = context.raw.texture_units;
			let _g = 0;
			let _g1 = tus.length;
			while(_g < _g1) {
				let j = _g++;
				if(samplerID == tus[j].name) {
					let isImage = tus[j].is_image != null && tus[j].is_image;
					let paramsSet = false;
					if(rt.raw.depth > 1) {
						g.setTexture3DParameters(context.textureUnits[j],2,2,2,1,2,2);
						paramsSet = true;
					}
					if(isImage) {
						g.setImageTexture(context.textureUnits[j],rt.image);
						g.setTexture3DParameters(context.textureUnits[j],2,2,2,1,0,2);
						paramsSet = true;
					} else if(rt.isCubeMap) {
						if(attachDepth) {
							g.setCubeMapDepth(context.textureUnits[j],rt.cubeMap);
						} else {
							g.setCubeMap(context.textureUnits[j],rt.cubeMap);
						}
					} else if(attachDepth) {
						g.setTextureDepth(context.textureUnits[j],rt.image);
					} else {
						g.setTexture(context.textureUnits[j],rt.image);
					}
					if(!paramsSet && rt.raw.mipmaps != null && rt.raw.mipmaps == true && !isImage) {
						g.setTextureParameters(context.textureUnits[j],2,2,1,1,2);
						paramsSet = true;
					}
					if(!paramsSet) {
						if(samplerID.startsWith("shadowMap")) {
							if(rt.isCubeMap) {
								g.setCubeMapCompareMode(context.textureUnits[j],true);
							} else {
								g.setTextureParameters(context.textureUnits[j],2,2,1,1,0);
								g.setTextureCompareMode(context.textureUnits[j],true);
							}
							paramsSet = true;
						} else if(attachDepth) {
							g.setTextureParameters(context.textureUnits[j],2,2,0,0,0);
							paramsSet = true;
						}
					}
					if(!paramsSet) {
						let oc = context.overrideContext;
						if(oc == null || oc.shared_sampler == null || oc.shared_sampler == samplerID) {
							let addressing = oc != null && oc.addressing == "repeat" ? 0 : 2;
							let filter = oc != null && oc.filter == "point" ? 0 : iron_object_Uniforms.defaultFilter;
							g.setTextureParameters(context.textureUnits[j],addressing,addressing,filter,filter,0);
						}
						paramsSet = true;
					}
				}
			}
		}
	}
	static setContextConstant(g,location,c) {
		if(c.link == null) {
			return true;
		}
		let camera = iron_Scene.active.camera;
		let light = iron_RenderPath.active.light;
		if(c.type == "mat4") {
			let m = null;
			let _g = c.link;
			if(_g == null) {
				return false;
			} else {
				switch(_g) {
				case "_biasLightViewProjectionMatrix":
					if(light != null) {
						let _this = iron_object_Uniforms.helpMat;
						let m1 = light.VP;
						_this.self._00 = m1.self._00;
						_this.self._01 = m1.self._01;
						_this.self._02 = m1.self._02;
						_this.self._03 = m1.self._03;
						_this.self._10 = m1.self._10;
						_this.self._11 = m1.self._11;
						_this.self._12 = m1.self._12;
						_this.self._13 = m1.self._13;
						_this.self._20 = m1.self._20;
						_this.self._21 = m1.self._21;
						_this.self._22 = m1.self._22;
						_this.self._23 = m1.self._23;
						_this.self._30 = m1.self._30;
						_this.self._31 = m1.self._31;
						_this.self._32 = m1.self._32;
						_this.self._33 = m1.self._33;
						let _this1 = iron_object_Uniforms.helpMat;
						let m2 = iron_object_Uniforms.biasMat;
						let a00 = _this1.self._00;
						let a01 = _this1.self._01;
						let a02 = _this1.self._02;
						let a03 = _this1.self._03;
						let a10 = _this1.self._10;
						let a11 = _this1.self._11;
						let a12 = _this1.self._12;
						let a13 = _this1.self._13;
						let a20 = _this1.self._20;
						let a21 = _this1.self._21;
						let a22 = _this1.self._22;
						let a23 = _this1.self._23;
						let a30 = _this1.self._30;
						let a31 = _this1.self._31;
						let a32 = _this1.self._32;
						let a33 = _this1.self._33;
						let b0 = m2.self._00;
						let b1 = m2.self._10;
						let b2 = m2.self._20;
						let b3 = m2.self._30;
						_this1.self._00 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
						_this1.self._10 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
						_this1.self._20 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
						_this1.self._30 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
						b0 = m2.self._01;
						b1 = m2.self._11;
						b2 = m2.self._21;
						b3 = m2.self._31;
						_this1.self._01 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
						_this1.self._11 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
						_this1.self._21 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
						_this1.self._31 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
						b0 = m2.self._02;
						b1 = m2.self._12;
						b2 = m2.self._22;
						b3 = m2.self._32;
						_this1.self._02 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
						_this1.self._12 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
						_this1.self._22 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
						_this1.self._32 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
						b0 = m2.self._03;
						b1 = m2.self._13;
						b2 = m2.self._23;
						b3 = m2.self._33;
						_this1.self._03 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
						_this1.self._13 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
						_this1.self._23 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
						_this1.self._33 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
						m = iron_object_Uniforms.helpMat;
					}
					break;
				case "_inverseProjectionMatrix":
					let _this = iron_object_Uniforms.helpMat;
					let m1 = camera.P;
					let a00 = m1.self._00;
					let a01 = m1.self._01;
					let a02 = m1.self._02;
					let a03 = m1.self._03;
					let a10 = m1.self._10;
					let a11 = m1.self._11;
					let a12 = m1.self._12;
					let a13 = m1.self._13;
					let a20 = m1.self._20;
					let a21 = m1.self._21;
					let a22 = m1.self._22;
					let a23 = m1.self._23;
					let a30 = m1.self._30;
					let a31 = m1.self._31;
					let a32 = m1.self._32;
					let a33 = m1.self._33;
					let b00 = a00 * a11 - a01 * a10;
					let b01 = a00 * a12 - a02 * a10;
					let b02 = a00 * a13 - a03 * a10;
					let b03 = a01 * a12 - a02 * a11;
					let b04 = a01 * a13 - a03 * a11;
					let b05 = a02 * a13 - a03 * a12;
					let b06 = a20 * a31 - a21 * a30;
					let b07 = a20 * a32 - a22 * a30;
					let b08 = a20 * a33 - a23 * a30;
					let b09 = a21 * a32 - a22 * a31;
					let b10 = a21 * a33 - a23 * a31;
					let b11 = a22 * a33 - a23 * a32;
					let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
					if(det == 0.0) {
						_this.self._00 = 1.0;
						_this.self._01 = 0.0;
						_this.self._02 = 0.0;
						_this.self._03 = 0.0;
						_this.self._10 = 0.0;
						_this.self._11 = 1.0;
						_this.self._12 = 0.0;
						_this.self._13 = 0.0;
						_this.self._20 = 0.0;
						_this.self._21 = 0.0;
						_this.self._22 = 1.0;
						_this.self._23 = 0.0;
						_this.self._30 = 0.0;
						_this.self._31 = 0.0;
						_this.self._32 = 0.0;
						_this.self._33 = 1.0;
					} else {
						det = 1.0 / det;
						_this.self._00 = (a11 * b11 - a12 * b10 + a13 * b09) * det;
						_this.self._01 = (a02 * b10 - a01 * b11 - a03 * b09) * det;
						_this.self._02 = (a31 * b05 - a32 * b04 + a33 * b03) * det;
						_this.self._03 = (a22 * b04 - a21 * b05 - a23 * b03) * det;
						_this.self._10 = (a12 * b08 - a10 * b11 - a13 * b07) * det;
						_this.self._11 = (a00 * b11 - a02 * b08 + a03 * b07) * det;
						_this.self._12 = (a32 * b02 - a30 * b05 - a33 * b01) * det;
						_this.self._13 = (a20 * b05 - a22 * b02 + a23 * b01) * det;
						_this.self._20 = (a10 * b10 - a11 * b08 + a13 * b06) * det;
						_this.self._21 = (a01 * b08 - a00 * b10 - a03 * b06) * det;
						_this.self._22 = (a30 * b04 - a31 * b02 + a33 * b00) * det;
						_this.self._23 = (a21 * b02 - a20 * b04 - a23 * b00) * det;
						_this.self._30 = (a11 * b07 - a10 * b09 - a12 * b06) * det;
						_this.self._31 = (a00 * b09 - a01 * b07 + a02 * b06) * det;
						_this.self._32 = (a31 * b01 - a30 * b03 - a32 * b00) * det;
						_this.self._33 = (a20 * b03 - a21 * b01 + a22 * b00) * det;
					}
					m = iron_object_Uniforms.helpMat;
					break;
				case "_inverseViewProjectionMatrix":
					let _this1 = iron_object_Uniforms.helpMat;
					let m2 = camera.V;
					_this1.self._00 = m2.self._00;
					_this1.self._01 = m2.self._01;
					_this1.self._02 = m2.self._02;
					_this1.self._03 = m2.self._03;
					_this1.self._10 = m2.self._10;
					_this1.self._11 = m2.self._11;
					_this1.self._12 = m2.self._12;
					_this1.self._13 = m2.self._13;
					_this1.self._20 = m2.self._20;
					_this1.self._21 = m2.self._21;
					_this1.self._22 = m2.self._22;
					_this1.self._23 = m2.self._23;
					_this1.self._30 = m2.self._30;
					_this1.self._31 = m2.self._31;
					_this1.self._32 = m2.self._32;
					_this1.self._33 = m2.self._33;
					let _this2 = iron_object_Uniforms.helpMat;
					let m3 = camera.P;
					let a001 = _this2.self._00;
					let a011 = _this2.self._01;
					let a021 = _this2.self._02;
					let a031 = _this2.self._03;
					let a101 = _this2.self._10;
					let a111 = _this2.self._11;
					let a121 = _this2.self._12;
					let a131 = _this2.self._13;
					let a201 = _this2.self._20;
					let a211 = _this2.self._21;
					let a221 = _this2.self._22;
					let a231 = _this2.self._23;
					let a301 = _this2.self._30;
					let a311 = _this2.self._31;
					let a321 = _this2.self._32;
					let a331 = _this2.self._33;
					let b0 = m3.self._00;
					let b1 = m3.self._10;
					let b2 = m3.self._20;
					let b3 = m3.self._30;
					_this2.self._00 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
					_this2.self._10 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
					_this2.self._20 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
					_this2.self._30 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
					b0 = m3.self._01;
					b1 = m3.self._11;
					b2 = m3.self._21;
					b3 = m3.self._31;
					_this2.self._01 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
					_this2.self._11 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
					_this2.self._21 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
					_this2.self._31 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
					b0 = m3.self._02;
					b1 = m3.self._12;
					b2 = m3.self._22;
					b3 = m3.self._32;
					_this2.self._02 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
					_this2.self._12 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
					_this2.self._22 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
					_this2.self._32 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
					b0 = m3.self._03;
					b1 = m3.self._13;
					b2 = m3.self._23;
					b3 = m3.self._33;
					_this2.self._03 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
					_this2.self._13 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
					_this2.self._23 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
					_this2.self._33 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
					let _this3 = iron_object_Uniforms.helpMat;
					let m4 = iron_object_Uniforms.helpMat;
					let a002 = m4.self._00;
					let a012 = m4.self._01;
					let a022 = m4.self._02;
					let a032 = m4.self._03;
					let a102 = m4.self._10;
					let a112 = m4.self._11;
					let a122 = m4.self._12;
					let a132 = m4.self._13;
					let a202 = m4.self._20;
					let a212 = m4.self._21;
					let a222 = m4.self._22;
					let a232 = m4.self._23;
					let a302 = m4.self._30;
					let a312 = m4.self._31;
					let a322 = m4.self._32;
					let a332 = m4.self._33;
					let b001 = a002 * a112 - a012 * a102;
					let b011 = a002 * a122 - a022 * a102;
					let b021 = a002 * a132 - a032 * a102;
					let b031 = a012 * a122 - a022 * a112;
					let b041 = a012 * a132 - a032 * a112;
					let b051 = a022 * a132 - a032 * a122;
					let b061 = a202 * a312 - a212 * a302;
					let b071 = a202 * a322 - a222 * a302;
					let b081 = a202 * a332 - a232 * a302;
					let b091 = a212 * a322 - a222 * a312;
					let b101 = a212 * a332 - a232 * a312;
					let b111 = a222 * a332 - a232 * a322;
					let det1 = b001 * b111 - b011 * b101 + b021 * b091 + b031 * b081 - b041 * b071 + b051 * b061;
					if(det1 == 0.0) {
						_this3.self._00 = 1.0;
						_this3.self._01 = 0.0;
						_this3.self._02 = 0.0;
						_this3.self._03 = 0.0;
						_this3.self._10 = 0.0;
						_this3.self._11 = 1.0;
						_this3.self._12 = 0.0;
						_this3.self._13 = 0.0;
						_this3.self._20 = 0.0;
						_this3.self._21 = 0.0;
						_this3.self._22 = 1.0;
						_this3.self._23 = 0.0;
						_this3.self._30 = 0.0;
						_this3.self._31 = 0.0;
						_this3.self._32 = 0.0;
						_this3.self._33 = 1.0;
					} else {
						det1 = 1.0 / det1;
						_this3.self._00 = (a112 * b111 - a122 * b101 + a132 * b091) * det1;
						_this3.self._01 = (a022 * b101 - a012 * b111 - a032 * b091) * det1;
						_this3.self._02 = (a312 * b051 - a322 * b041 + a332 * b031) * det1;
						_this3.self._03 = (a222 * b041 - a212 * b051 - a232 * b031) * det1;
						_this3.self._10 = (a122 * b081 - a102 * b111 - a132 * b071) * det1;
						_this3.self._11 = (a002 * b111 - a022 * b081 + a032 * b071) * det1;
						_this3.self._12 = (a322 * b021 - a302 * b051 - a332 * b011) * det1;
						_this3.self._13 = (a202 * b051 - a222 * b021 + a232 * b011) * det1;
						_this3.self._20 = (a102 * b101 - a112 * b081 + a132 * b061) * det1;
						_this3.self._21 = (a012 * b081 - a002 * b101 - a032 * b061) * det1;
						_this3.self._22 = (a302 * b041 - a312 * b021 + a332 * b001) * det1;
						_this3.self._23 = (a212 * b021 - a202 * b041 - a232 * b001) * det1;
						_this3.self._30 = (a112 * b071 - a102 * b091 - a122 * b061) * det1;
						_this3.self._31 = (a002 * b091 - a012 * b071 + a022 * b061) * det1;
						_this3.self._32 = (a312 * b011 - a302 * b031 - a322 * b001) * det1;
						_this3.self._33 = (a202 * b031 - a212 * b011 + a222 * b001) * det1;
					}
					m = iron_object_Uniforms.helpMat;
					break;
				case "_lightViewProjectionMatrix":
					if(light != null) {
						m = light.VP;
					}
					break;
				case "_prevViewProjectionMatrix":
					let _this4 = iron_object_Uniforms.helpMat;
					let m5 = camera.prevV;
					_this4.self._00 = m5.self._00;
					_this4.self._01 = m5.self._01;
					_this4.self._02 = m5.self._02;
					_this4.self._03 = m5.self._03;
					_this4.self._10 = m5.self._10;
					_this4.self._11 = m5.self._11;
					_this4.self._12 = m5.self._12;
					_this4.self._13 = m5.self._13;
					_this4.self._20 = m5.self._20;
					_this4.self._21 = m5.self._21;
					_this4.self._22 = m5.self._22;
					_this4.self._23 = m5.self._23;
					_this4.self._30 = m5.self._30;
					_this4.self._31 = m5.self._31;
					_this4.self._32 = m5.self._32;
					_this4.self._33 = m5.self._33;
					let _this5 = iron_object_Uniforms.helpMat;
					let m6 = camera.P;
					let a003 = _this5.self._00;
					let a013 = _this5.self._01;
					let a023 = _this5.self._02;
					let a033 = _this5.self._03;
					let a103 = _this5.self._10;
					let a113 = _this5.self._11;
					let a123 = _this5.self._12;
					let a133 = _this5.self._13;
					let a203 = _this5.self._20;
					let a213 = _this5.self._21;
					let a223 = _this5.self._22;
					let a233 = _this5.self._23;
					let a303 = _this5.self._30;
					let a313 = _this5.self._31;
					let a323 = _this5.self._32;
					let a333 = _this5.self._33;
					let b010 = m6.self._00;
					let b12 = m6.self._10;
					let b21 = m6.self._20;
					let b31 = m6.self._30;
					_this5.self._00 = a003 * b010 + a013 * b12 + a023 * b21 + a033 * b31;
					_this5.self._10 = a103 * b010 + a113 * b12 + a123 * b21 + a133 * b31;
					_this5.self._20 = a203 * b010 + a213 * b12 + a223 * b21 + a233 * b31;
					_this5.self._30 = a303 * b010 + a313 * b12 + a323 * b21 + a333 * b31;
					b010 = m6.self._01;
					b12 = m6.self._11;
					b21 = m6.self._21;
					b31 = m6.self._31;
					_this5.self._01 = a003 * b010 + a013 * b12 + a023 * b21 + a033 * b31;
					_this5.self._11 = a103 * b010 + a113 * b12 + a123 * b21 + a133 * b31;
					_this5.self._21 = a203 * b010 + a213 * b12 + a223 * b21 + a233 * b31;
					_this5.self._31 = a303 * b010 + a313 * b12 + a323 * b21 + a333 * b31;
					b010 = m6.self._02;
					b12 = m6.self._12;
					b21 = m6.self._22;
					b31 = m6.self._32;
					_this5.self._02 = a003 * b010 + a013 * b12 + a023 * b21 + a033 * b31;
					_this5.self._12 = a103 * b010 + a113 * b12 + a123 * b21 + a133 * b31;
					_this5.self._22 = a203 * b010 + a213 * b12 + a223 * b21 + a233 * b31;
					_this5.self._32 = a303 * b010 + a313 * b12 + a323 * b21 + a333 * b31;
					b010 = m6.self._03;
					b12 = m6.self._13;
					b21 = m6.self._23;
					b31 = m6.self._33;
					_this5.self._03 = a003 * b010 + a013 * b12 + a023 * b21 + a033 * b31;
					_this5.self._13 = a103 * b010 + a113 * b12 + a123 * b21 + a133 * b31;
					_this5.self._23 = a203 * b010 + a213 * b12 + a223 * b21 + a233 * b31;
					_this5.self._33 = a303 * b010 + a313 * b12 + a323 * b21 + a333 * b31;
					m = iron_object_Uniforms.helpMat;
					break;
				case "_projectionMatrix":
					m = camera.P;
					break;
				case "_skydomeMatrix":
					let tr = camera.transform;
					let _this6 = iron_object_Uniforms.helpVec;
					_this6.x = tr.world.self._30;
					_this6.y = tr.world.self._31;
					_this6.z = tr.world.self._32 - 3.5;
					_this6.w = 1.0;
					let bounds = camera.data.raw.far_plane * 0.95;
					let _this7 = iron_object_Uniforms.helpVec2;
					_this7.x = bounds;
					_this7.y = bounds;
					_this7.z = bounds;
					_this7.w = 1.0;
					let _this8 = iron_object_Uniforms.helpMat;
					let loc = iron_object_Uniforms.helpVec;
					let quat = iron_object_Uniforms.helpQuat;
					let sc = iron_object_Uniforms.helpVec2;
					let x = quat.x;
					let y = quat.y;
					let z = quat.z;
					let w = quat.w;
					let x2 = x + x;
					let y2 = y + y;
					let z2 = z + z;
					let xx = x * x2;
					let xy = x * y2;
					let xz = x * z2;
					let yy = y * y2;
					let yz = y * z2;
					let zz = z * z2;
					let wx = w * x2;
					let wy = w * y2;
					let wz = w * z2;
					_this8.self._00 = 1.0 - (yy + zz);
					_this8.self._10 = xy - wz;
					_this8.self._20 = xz + wy;
					_this8.self._01 = xy + wz;
					_this8.self._11 = 1.0 - (xx + zz);
					_this8.self._21 = yz - wx;
					_this8.self._02 = xz - wy;
					_this8.self._12 = yz + wx;
					_this8.self._22 = 1.0 - (xx + yy);
					_this8.self._03 = 0.0;
					_this8.self._13 = 0.0;
					_this8.self._23 = 0.0;
					_this8.self._30 = 0.0;
					_this8.self._31 = 0.0;
					_this8.self._32 = 0.0;
					_this8.self._33 = 1.0;
					let x1 = sc.x;
					let y1 = sc.y;
					let z1 = sc.z;
					_this8.self._00 *= x1;
					_this8.self._01 *= x1;
					_this8.self._02 *= x1;
					_this8.self._03 *= x1;
					_this8.self._10 *= y1;
					_this8.self._11 *= y1;
					_this8.self._12 *= y1;
					_this8.self._13 *= y1;
					_this8.self._20 *= z1;
					_this8.self._21 *= z1;
					_this8.self._22 *= z1;
					_this8.self._23 *= z1;
					_this8.self._30 = loc.x;
					_this8.self._31 = loc.y;
					_this8.self._32 = loc.z;
					let _this9 = iron_object_Uniforms.helpMat;
					let m7 = camera.V;
					let a004 = _this9.self._00;
					let a014 = _this9.self._01;
					let a024 = _this9.self._02;
					let a034 = _this9.self._03;
					let a104 = _this9.self._10;
					let a114 = _this9.self._11;
					let a124 = _this9.self._12;
					let a134 = _this9.self._13;
					let a204 = _this9.self._20;
					let a214 = _this9.self._21;
					let a224 = _this9.self._22;
					let a234 = _this9.self._23;
					let a304 = _this9.self._30;
					let a314 = _this9.self._31;
					let a324 = _this9.self._32;
					let a334 = _this9.self._33;
					let b012 = m7.self._00;
					let b13 = m7.self._10;
					let b22 = m7.self._20;
					let b32 = m7.self._30;
					_this9.self._00 = a004 * b012 + a014 * b13 + a024 * b22 + a034 * b32;
					_this9.self._10 = a104 * b012 + a114 * b13 + a124 * b22 + a134 * b32;
					_this9.self._20 = a204 * b012 + a214 * b13 + a224 * b22 + a234 * b32;
					_this9.self._30 = a304 * b012 + a314 * b13 + a324 * b22 + a334 * b32;
					b012 = m7.self._01;
					b13 = m7.self._11;
					b22 = m7.self._21;
					b32 = m7.self._31;
					_this9.self._01 = a004 * b012 + a014 * b13 + a024 * b22 + a034 * b32;
					_this9.self._11 = a104 * b012 + a114 * b13 + a124 * b22 + a134 * b32;
					_this9.self._21 = a204 * b012 + a214 * b13 + a224 * b22 + a234 * b32;
					_this9.self._31 = a304 * b012 + a314 * b13 + a324 * b22 + a334 * b32;
					b012 = m7.self._02;
					b13 = m7.self._12;
					b22 = m7.self._22;
					b32 = m7.self._32;
					_this9.self._02 = a004 * b012 + a014 * b13 + a024 * b22 + a034 * b32;
					_this9.self._12 = a104 * b012 + a114 * b13 + a124 * b22 + a134 * b32;
					_this9.self._22 = a204 * b012 + a214 * b13 + a224 * b22 + a234 * b32;
					_this9.self._32 = a304 * b012 + a314 * b13 + a324 * b22 + a334 * b32;
					b012 = m7.self._03;
					b13 = m7.self._13;
					b22 = m7.self._23;
					b32 = m7.self._33;
					_this9.self._03 = a004 * b012 + a014 * b13 + a024 * b22 + a034 * b32;
					_this9.self._13 = a104 * b012 + a114 * b13 + a124 * b22 + a134 * b32;
					_this9.self._23 = a204 * b012 + a214 * b13 + a224 * b22 + a234 * b32;
					_this9.self._33 = a304 * b012 + a314 * b13 + a324 * b22 + a334 * b32;
					let _this10 = iron_object_Uniforms.helpMat;
					let m8 = camera.P;
					let a005 = _this10.self._00;
					let a015 = _this10.self._01;
					let a025 = _this10.self._02;
					let a035 = _this10.self._03;
					let a105 = _this10.self._10;
					let a115 = _this10.self._11;
					let a125 = _this10.self._12;
					let a135 = _this10.self._13;
					let a205 = _this10.self._20;
					let a215 = _this10.self._21;
					let a225 = _this10.self._22;
					let a235 = _this10.self._23;
					let a305 = _this10.self._30;
					let a315 = _this10.self._31;
					let a325 = _this10.self._32;
					let a335 = _this10.self._33;
					let b013 = m8.self._00;
					let b14 = m8.self._10;
					let b23 = m8.self._20;
					let b33 = m8.self._30;
					_this10.self._00 = a005 * b013 + a015 * b14 + a025 * b23 + a035 * b33;
					_this10.self._10 = a105 * b013 + a115 * b14 + a125 * b23 + a135 * b33;
					_this10.self._20 = a205 * b013 + a215 * b14 + a225 * b23 + a235 * b33;
					_this10.self._30 = a305 * b013 + a315 * b14 + a325 * b23 + a335 * b33;
					b013 = m8.self._01;
					b14 = m8.self._11;
					b23 = m8.self._21;
					b33 = m8.self._31;
					_this10.self._01 = a005 * b013 + a015 * b14 + a025 * b23 + a035 * b33;
					_this10.self._11 = a105 * b013 + a115 * b14 + a125 * b23 + a135 * b33;
					_this10.self._21 = a205 * b013 + a215 * b14 + a225 * b23 + a235 * b33;
					_this10.self._31 = a305 * b013 + a315 * b14 + a325 * b23 + a335 * b33;
					b013 = m8.self._02;
					b14 = m8.self._12;
					b23 = m8.self._22;
					b33 = m8.self._32;
					_this10.self._02 = a005 * b013 + a015 * b14 + a025 * b23 + a035 * b33;
					_this10.self._12 = a105 * b013 + a115 * b14 + a125 * b23 + a135 * b33;
					_this10.self._22 = a205 * b013 + a215 * b14 + a225 * b23 + a235 * b33;
					_this10.self._32 = a305 * b013 + a315 * b14 + a325 * b23 + a335 * b33;
					b013 = m8.self._03;
					b14 = m8.self._13;
					b23 = m8.self._23;
					b33 = m8.self._33;
					_this10.self._03 = a005 * b013 + a015 * b14 + a025 * b23 + a035 * b33;
					_this10.self._13 = a105 * b013 + a115 * b14 + a125 * b23 + a135 * b33;
					_this10.self._23 = a205 * b013 + a215 * b14 + a225 * b23 + a235 * b33;
					_this10.self._33 = a305 * b013 + a315 * b14 + a325 * b23 + a335 * b33;
					m = iron_object_Uniforms.helpMat;
					break;
				case "_transposeViewMatrix":
					let _this11 = iron_object_Uniforms.helpMat;
					let m9 = camera.V;
					_this11.self._00 = m9.self._00;
					_this11.self._01 = m9.self._01;
					_this11.self._02 = m9.self._02;
					_this11.self._03 = m9.self._03;
					_this11.self._10 = m9.self._10;
					_this11.self._11 = m9.self._11;
					_this11.self._12 = m9.self._12;
					_this11.self._13 = m9.self._13;
					_this11.self._20 = m9.self._20;
					_this11.self._21 = m9.self._21;
					_this11.self._22 = m9.self._22;
					_this11.self._23 = m9.self._23;
					_this11.self._30 = m9.self._30;
					_this11.self._31 = m9.self._31;
					_this11.self._32 = m9.self._32;
					_this11.self._33 = m9.self._33;
					let _this12 = iron_object_Uniforms.helpMat;
					let f = _this12.self._01;
					_this12.self._01 = _this12.self._10;
					_this12.self._10 = f;
					f = _this12.self._02;
					_this12.self._02 = _this12.self._20;
					_this12.self._20 = f;
					f = _this12.self._12;
					_this12.self._12 = _this12.self._21;
					_this12.self._21 = f;
					m = iron_object_Uniforms.helpMat;
					break;
				case "_viewMatrix":
					m = camera.V;
					break;
				case "_viewProjectionMatrix":
					m = camera.VP;
					break;
				default:
					return false;
				}
			}
			let matrix = m != null ? m.self : new kha_math_FastMatrix4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);
			kha_graphics4_Graphics.mat[0] = matrix._00;
			kha_graphics4_Graphics.mat[1] = matrix._01;
			kha_graphics4_Graphics.mat[2] = matrix._02;
			kha_graphics4_Graphics.mat[3] = matrix._03;
			kha_graphics4_Graphics.mat[4] = matrix._10;
			kha_graphics4_Graphics.mat[5] = matrix._11;
			kha_graphics4_Graphics.mat[6] = matrix._12;
			kha_graphics4_Graphics.mat[7] = matrix._13;
			kha_graphics4_Graphics.mat[8] = matrix._20;
			kha_graphics4_Graphics.mat[9] = matrix._21;
			kha_graphics4_Graphics.mat[10] = matrix._22;
			kha_graphics4_Graphics.mat[11] = matrix._23;
			kha_graphics4_Graphics.mat[12] = matrix._30;
			kha_graphics4_Graphics.mat[13] = matrix._31;
			kha_graphics4_Graphics.mat[14] = matrix._32;
			kha_graphics4_Graphics.mat[15] = matrix._33;
			Krom.setMatrix(location,kha_graphics4_Graphics.mat.buffer);
			return true;
		} else if(c.type == "vec4") {
			let _this = iron_object_Uniforms.helpVec;
			_this.x = 0;
			_this.y = 0;
			_this.z = 0;
			_this.w = 0;
			return false;
		} else if(c.type == "vec3") {
			let v = null;
			let _this = iron_object_Uniforms.helpVec;
			_this.x = 0;
			_this.y = 0;
			_this.z = 0;
			_this.w = 1.0;
			let _g = c.link;
			if(_g == null) {
				return false;
			} else {
				switch(_g) {
				case "_backgroundCol":
					if(camera.data.raw.clear_color != null) {
						let _this = iron_object_Uniforms.helpVec;
						let y = camera.data.raw.clear_color[1];
						let z = camera.data.raw.clear_color[2];
						_this.x = camera.data.raw.clear_color[0];
						_this.y = y;
						_this.z = z;
						_this.w = 1.0;
					}
					v = iron_object_Uniforms.helpVec;
					break;
				case "_cameraLook":
					let _this1 = new iron_math_Vec4(-camera.transform.world.self._20,-camera.transform.world.self._21,-camera.transform.world.self._22);
					let n = Math.sqrt(_this1.x * _this1.x + _this1.y * _this1.y + _this1.z * _this1.z);
					if(n > 0.0) {
						let invN = 1.0 / n;
						_this1.x *= invN;
						_this1.y *= invN;
						_this1.z *= invN;
					}
					iron_object_Uniforms.helpVec = _this1;
					v = iron_object_Uniforms.helpVec;
					break;
				case "_cameraPosition":
					let _this2 = iron_object_Uniforms.helpVec;
					_this2.x = camera.transform.world.self._30;
					_this2.y = camera.transform.world.self._31;
					_this2.z = camera.transform.world.self._32;
					_this2.w = 1.0;
					v = iron_object_Uniforms.helpVec;
					break;
				case "_cameraRight":
					let _this3 = new iron_math_Vec4(camera.transform.world.self._00,camera.transform.world.self._01,camera.transform.world.self._02);
					let n1 = Math.sqrt(_this3.x * _this3.x + _this3.y * _this3.y + _this3.z * _this3.z);
					if(n1 > 0.0) {
						let invN = 1.0 / n1;
						_this3.x *= invN;
						_this3.y *= invN;
						_this3.z *= invN;
					}
					iron_object_Uniforms.helpVec = _this3;
					v = iron_object_Uniforms.helpVec;
					break;
				case "_cameraUp":
					let _this4 = new iron_math_Vec4(camera.transform.world.self._10,camera.transform.world.self._11,camera.transform.world.self._12);
					let n2 = Math.sqrt(_this4.x * _this4.x + _this4.y * _this4.y + _this4.z * _this4.z);
					if(n2 > 0.0) {
						let invN = 1.0 / n2;
						_this4.x *= invN;
						_this4.y *= invN;
						_this4.z *= invN;
					}
					iron_object_Uniforms.helpVec = _this4;
					v = iron_object_Uniforms.helpVec;
					break;
				case "_hosekSunDirection":
					let w = iron_Scene.active.world;
					if(w != null) {
						let _this = iron_object_Uniforms.helpVec;
						let y = w.raw.sun_direction[1];
						let z = w.raw.sun_direction[2] > 0 ? w.raw.sun_direction[2] : 0;
						_this.x = w.raw.sun_direction[0];
						_this.y = y;
						_this.z = z;
						_this.w = 1.0;
						v = iron_object_Uniforms.helpVec;
					}
					break;
				case "_lightArea0":
					if(light != null && light.data.raw.size != null) {
						let _this = iron_object_Uniforms.helpVec;
						_this.x = -(light.data.raw.size * 0.5);
						_this.y = light.data.raw.size_y * 0.5;
						_this.z = 0.0;
						_this.w = 1.0;
						let _this1 = iron_object_Uniforms.helpVec;
						let m = light.transform.world;
						let x = _this1.x;
						let y = _this1.y;
						let z = _this1.z;
						_this1.x = m.self._00 * x + m.self._10 * y + m.self._20 * z + m.self._30;
						_this1.y = m.self._01 * x + m.self._11 * y + m.self._21 * z + m.self._31;
						_this1.z = m.self._02 * x + m.self._12 * y + m.self._22 * z + m.self._32;
						v = iron_object_Uniforms.helpVec;
					}
					break;
				case "_lightArea1":
					if(light != null && light.data.raw.size != null) {
						let _this = iron_object_Uniforms.helpVec;
						_this.x = light.data.raw.size * 0.5;
						_this.y = light.data.raw.size_y * 0.5;
						_this.z = 0.0;
						_this.w = 1.0;
						let _this1 = iron_object_Uniforms.helpVec;
						let m = light.transform.world;
						let x = _this1.x;
						let y = _this1.y;
						let z = _this1.z;
						_this1.x = m.self._00 * x + m.self._10 * y + m.self._20 * z + m.self._30;
						_this1.y = m.self._01 * x + m.self._11 * y + m.self._21 * z + m.self._31;
						_this1.z = m.self._02 * x + m.self._12 * y + m.self._22 * z + m.self._32;
						v = iron_object_Uniforms.helpVec;
					}
					break;
				case "_lightArea2":
					if(light != null && light.data.raw.size != null) {
						let _this = iron_object_Uniforms.helpVec;
						_this.x = light.data.raw.size * 0.5;
						_this.y = -(light.data.raw.size_y * 0.5);
						_this.z = 0.0;
						_this.w = 1.0;
						let _this1 = iron_object_Uniforms.helpVec;
						let m = light.transform.world;
						let x = _this1.x;
						let y = _this1.y;
						let z = _this1.z;
						_this1.x = m.self._00 * x + m.self._10 * y + m.self._20 * z + m.self._30;
						_this1.y = m.self._01 * x + m.self._11 * y + m.self._21 * z + m.self._31;
						_this1.z = m.self._02 * x + m.self._12 * y + m.self._22 * z + m.self._32;
						v = iron_object_Uniforms.helpVec;
					}
					break;
				case "_lightArea3":
					if(light != null && light.data.raw.size != null) {
						let _this = iron_object_Uniforms.helpVec;
						_this.x = -(light.data.raw.size * 0.5);
						_this.y = -(light.data.raw.size_y * 0.5);
						_this.z = 0.0;
						_this.w = 1.0;
						let _this1 = iron_object_Uniforms.helpVec;
						let m = light.transform.world;
						let x = _this1.x;
						let y = _this1.y;
						let z = _this1.z;
						_this1.x = m.self._00 * x + m.self._10 * y + m.self._20 * z + m.self._30;
						_this1.y = m.self._01 * x + m.self._11 * y + m.self._21 * z + m.self._31;
						_this1.z = m.self._02 * x + m.self._12 * y + m.self._22 * z + m.self._32;
						v = iron_object_Uniforms.helpVec;
					}
					break;
				case "_lightDirection":
					if(light != null) {
						let _this = new iron_math_Vec4(light.V.self._02,light.V.self._12,light.V.self._22);
						let n = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z);
						if(n > 0.0) {
							let invN = 1.0 / n;
							_this.x *= invN;
							_this.y *= invN;
							_this.z *= invN;
						}
						iron_object_Uniforms.helpVec = _this;
						v = iron_object_Uniforms.helpVec;
					}
					break;
				case "_lightPosition":
					if(light != null) {
						let _this = iron_object_Uniforms.helpVec;
						_this.x = light.transform.world.self._30;
						_this.y = light.transform.world.self._31;
						_this.z = light.transform.world.self._32;
						_this.w = 1.0;
						v = iron_object_Uniforms.helpVec;
					}
					break;
				case "_pointColor":
					let point = iron_RenderPath.active.point;
					if(point != null) {
						let str = point.visible ? point.data.raw.strength : 0.0;
						let _this = iron_object_Uniforms.helpVec;
						let y = point.data.raw.color[1] * str;
						let z = point.data.raw.color[2] * str;
						_this.x = point.data.raw.color[0] * str;
						_this.y = y;
						_this.z = z;
						_this.w = 1.0;
						v = iron_object_Uniforms.helpVec;
					}
					break;
				case "_pointPosition":
					let point1 = iron_RenderPath.active.point;
					if(point1 != null) {
						let _this = iron_object_Uniforms.helpVec;
						_this.x = point1.transform.world.self._30;
						_this.y = point1.transform.world.self._31;
						_this.z = point1.transform.world.self._32;
						_this.w = 1.0;
						v = iron_object_Uniforms.helpVec;
					}
					break;
				case "_spotDirection":
					let point2 = iron_RenderPath.active.point;
					if(point2 != null) {
						let _this = new iron_math_Vec4(point2.V.self._02,point2.V.self._12,point2.V.self._22);
						let n = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z);
						if(n > 0.0) {
							let invN = 1.0 / n;
							_this.x *= invN;
							_this.y *= invN;
							_this.z *= invN;
						}
						iron_object_Uniforms.helpVec = _this;
						v = iron_object_Uniforms.helpVec;
					}
					break;
				case "_sunColor":
					let sun = iron_RenderPath.active.sun;
					if(sun != null) {
						let str = sun.visible ? sun.data.raw.strength : 0.0;
						let _this = iron_object_Uniforms.helpVec;
						let y = sun.data.raw.color[1] * str;
						let z = sun.data.raw.color[2] * str;
						_this.x = sun.data.raw.color[0] * str;
						_this.y = y;
						_this.z = z;
						_this.w = 1.0;
						v = iron_object_Uniforms.helpVec;
					}
					break;
				case "_sunDirection":
					let sun1 = iron_RenderPath.active.sun;
					if(sun1 != null) {
						let _this = new iron_math_Vec4(sun1.V.self._02,sun1.V.self._12,sun1.V.self._22);
						let n = Math.sqrt(_this.x * _this.x + _this.y * _this.y + _this.z * _this.z);
						if(n > 0.0) {
							let invN = 1.0 / n;
							_this.x *= invN;
							_this.y *= invN;
							_this.z *= invN;
						}
						iron_object_Uniforms.helpVec = _this;
						v = iron_object_Uniforms.helpVec;
					}
					break;
				default:
					return false;
				}
			}
			if(v != null) {
				g.setFloat3(location,v.x,v.y,v.z);
			} else {
				g.setFloat3(location,0.0,0.0,0.0);
			}
			return true;
		} else if(c.type == "vec2") {
			let v = null;
			let _this = iron_object_Uniforms.helpVec;
			_this.x = 0;
			_this.y = 0;
			_this.z = 0;
			_this.w = 1.0;
			let _g = c.link;
			if(_g == null) {
				return false;
			} else {
				switch(_g) {
				case "_aspectRatio":
					v = iron_object_Uniforms.helpVec;
					v.x = iron_RenderPath.active.currentH / iron_RenderPath.active.currentW;
					v.y = iron_RenderPath.active.currentW / iron_RenderPath.active.currentH;
					v.x = v.x > 1.0 ? 1.0 : v.x;
					v.y = v.y > 1.0 ? 1.0 : v.y;
					break;
				case "_cameraPlane":
					v = iron_object_Uniforms.helpVec;
					v.x = camera.data.raw.near_plane;
					v.y = camera.data.raw.far_plane;
					break;
				case "_cameraPlaneProj":
					let near = camera.data.raw.near_plane;
					let far = camera.data.raw.far_plane;
					v = iron_object_Uniforms.helpVec;
					v.x = far / (far - near);
					v.y = -far * near / (far - near);
					break;
				case "_lightPlane":
					if(light != null) {
						v = iron_object_Uniforms.helpVec;
						v.x = light.data.raw.near_plane;
						v.y = light.data.raw.far_plane;
					}
					break;
				case "_lightPlaneProj":
					if(light != null) {
						let near = light.data.raw.near_plane;
						let far = light.data.raw.far_plane;
						let b = far - near;
						v = iron_object_Uniforms.helpVec;
						v.x = (far + near) / b;
						v.y = 2.0 * far * near / b;
					}
					break;
				case "_screenSize":
					v = iron_object_Uniforms.helpVec;
					v.x = iron_RenderPath.active.currentW;
					v.y = iron_RenderPath.active.currentH;
					break;
				case "_screenSizeInv":
					v = iron_object_Uniforms.helpVec;
					v.x = 1.0 / iron_RenderPath.active.currentW;
					v.y = 1.0 / iron_RenderPath.active.currentH;
					break;
				case "_shadowMapSize":
					if(light != null && light.data.raw.cast_shadow) {
						v = iron_object_Uniforms.helpVec;
						v.x = v.y = light.data.raw.shadowmap_size;
					}
					break;
				case "_spotData":
					let point = iron_RenderPath.active.point;
					if(point != null) {
						v = iron_object_Uniforms.helpVec;
						v.x = point.data.raw.spot_size;
						v.y = v.x - point.data.raw.spot_blend;
					}
					break;
				case "_vec2x":
					v = iron_object_Uniforms.helpVec;
					v.x = 1.0;
					v.y = 0.0;
					break;
				case "_vec2x2":
					v = iron_object_Uniforms.helpVec;
					v.x = 2.0;
					v.y = 0.0;
					break;
				case "_vec2x2Inv":
					v = iron_object_Uniforms.helpVec;
					v.x = 2.0 / iron_RenderPath.active.currentW;
					v.y = 0.0;
					break;
				case "_vec2xInv":
					v = iron_object_Uniforms.helpVec;
					v.x = 1.0 / iron_RenderPath.active.currentW;
					v.y = 0.0;
					break;
				case "_vec2y":
					v = iron_object_Uniforms.helpVec;
					v.x = 0.0;
					v.y = 1.0;
					break;
				case "_vec2y2":
					v = iron_object_Uniforms.helpVec;
					v.x = 0.0;
					v.y = 2.0;
					break;
				case "_vec2y2Inv":
					v = iron_object_Uniforms.helpVec;
					v.x = 0.0;
					v.y = 2.0 / iron_RenderPath.active.currentH;
					break;
				case "_vec2y3":
					v = iron_object_Uniforms.helpVec;
					v.x = 0.0;
					v.y = 3.0;
					break;
				case "_vec2y3Inv":
					v = iron_object_Uniforms.helpVec;
					v.x = 0.0;
					v.y = 3.0 / iron_RenderPath.active.currentH;
					break;
				case "_vec2yInv":
					v = iron_object_Uniforms.helpVec;
					v.x = 0.0;
					v.y = 1.0 / iron_RenderPath.active.currentH;
					break;
				case "_windowSize":
					v = iron_object_Uniforms.helpVec;
					v.x = arm_App.w();
					v.y = arm_App.h();
					break;
				default:
					return false;
				}
			}
			if(v != null) {
				g.setFloat2(location,v.x,v.y);
			} else {
				g.setFloat2(location,0.0,0.0);
			}
			return true;
		} else if(c.type == "float") {
			let f = null;
			let _g = c.link;
			if(_g == null) {
				return false;
			} else {
				switch(_g) {
				case "_aspectRatioF":
					f = iron_RenderPath.active.currentW / iron_RenderPath.active.currentH;
					break;
				case "_aspectRatioWindowF":
					f = arm_App.w() / arm_App.h();
					break;
				case "_envmapStrength":
					f = iron_Scene.active.world == null ? 0.0 : iron_Scene.active.world.probe.raw.strength;
					break;
				case "_fieldOfView":
					f = camera.data.raw.fov;
					break;
				case "_frameScale":
					f = iron_RenderPath.active.frameTime / iron_system_Time.get_delta();
					break;
				case "_pointShadowsBias":
					let point = iron_RenderPath.active.point;
					f = point == null ? 0.0 : point.data.raw.shadows_bias;
					break;
				case "_sunShadowsBias":
					let sun = iron_RenderPath.active.sun;
					f = sun == null ? 0.0 : sun.data.raw.shadows_bias;
					break;
				case "_time":
					f = kha_Scheduler.time();
					break;
				default:
					return false;
				}
			}
			g.setFloat(location,f != null ? f : 0);
			return true;
		} else if(c.type == "floats") {
			let fa = null;
			if(c.link == "_envmapIrradiance") {
				fa = iron_Scene.active.world == null ? iron_data_WorldData.getEmptyIrradiance() : iron_Scene.active.world.probe.irradiance;
			}
			if(fa != null) {
				g.setFloats(location,fa);
				return true;
			}
		} else if(c.type == "int") {
			let i = null;
			let _g = c.link;
			if(_g == null) {
				return false;
			} else if(_g == "_envmapNumMipmaps") {
				let w = iron_Scene.active.world;
				i = w != null ? w.probe.raw.radiance_mipmaps + 1 - 2 : 1;
			} else {
				return false;
			}
			g.setInt(location,i != null ? i : 0);
			return true;
		}
		return false;
	}
	static setObjectConstant(g,object,location,c) {
		if(c.link == null) {
			return;
		}
		let camera = iron_Scene.active.camera;
		let light = iron_RenderPath.active.light;
		if(c.type == "mat4") {
			let m = null;
			switch(c.link) {
			case "_biasLightWorldViewProjectionMatrix":
				if(light != null) {
					if(object == null) {
						let _this = iron_object_Uniforms.helpMat;
						_this.self._00 = 1.0;
						_this.self._01 = 0.0;
						_this.self._02 = 0.0;
						_this.self._03 = 0.0;
						_this.self._10 = 0.0;
						_this.self._11 = 1.0;
						_this.self._12 = 0.0;
						_this.self._13 = 0.0;
						_this.self._20 = 0.0;
						_this.self._21 = 0.0;
						_this.self._22 = 1.0;
						_this.self._23 = 0.0;
						_this.self._30 = 0.0;
						_this.self._31 = 0.0;
						_this.self._32 = 0.0;
						_this.self._33 = 1.0;
					} else {
						let _this = iron_object_Uniforms.helpMat;
						let m = object.transform.worldUnpack;
						_this.self._00 = m.self._00;
						_this.self._01 = m.self._01;
						_this.self._02 = m.self._02;
						_this.self._03 = m.self._03;
						_this.self._10 = m.self._10;
						_this.self._11 = m.self._11;
						_this.self._12 = m.self._12;
						_this.self._13 = m.self._13;
						_this.self._20 = m.self._20;
						_this.self._21 = m.self._21;
						_this.self._22 = m.self._22;
						_this.self._23 = m.self._23;
						_this.self._30 = m.self._30;
						_this.self._31 = m.self._31;
						_this.self._32 = m.self._32;
						_this.self._33 = m.self._33;
					}
					let _this = iron_object_Uniforms.helpMat;
					let m1 = light.VP;
					let a00 = _this.self._00;
					let a01 = _this.self._01;
					let a02 = _this.self._02;
					let a03 = _this.self._03;
					let a10 = _this.self._10;
					let a11 = _this.self._11;
					let a12 = _this.self._12;
					let a13 = _this.self._13;
					let a20 = _this.self._20;
					let a21 = _this.self._21;
					let a22 = _this.self._22;
					let a23 = _this.self._23;
					let a30 = _this.self._30;
					let a31 = _this.self._31;
					let a32 = _this.self._32;
					let a33 = _this.self._33;
					let b0 = m1.self._00;
					let b1 = m1.self._10;
					let b2 = m1.self._20;
					let b3 = m1.self._30;
					_this.self._00 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this.self._10 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this.self._20 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this.self._30 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					b0 = m1.self._01;
					b1 = m1.self._11;
					b2 = m1.self._21;
					b3 = m1.self._31;
					_this.self._01 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this.self._11 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this.self._21 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this.self._31 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					b0 = m1.self._02;
					b1 = m1.self._12;
					b2 = m1.self._22;
					b3 = m1.self._32;
					_this.self._02 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this.self._12 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this.self._22 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this.self._32 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					b0 = m1.self._03;
					b1 = m1.self._13;
					b2 = m1.self._23;
					b3 = m1.self._33;
					_this.self._03 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this.self._13 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this.self._23 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this.self._33 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					let _this1 = iron_object_Uniforms.helpMat;
					let m2 = iron_object_Uniforms.biasMat;
					let a001 = _this1.self._00;
					let a011 = _this1.self._01;
					let a021 = _this1.self._02;
					let a031 = _this1.self._03;
					let a101 = _this1.self._10;
					let a111 = _this1.self._11;
					let a121 = _this1.self._12;
					let a131 = _this1.self._13;
					let a201 = _this1.self._20;
					let a211 = _this1.self._21;
					let a221 = _this1.self._22;
					let a231 = _this1.self._23;
					let a301 = _this1.self._30;
					let a311 = _this1.self._31;
					let a321 = _this1.self._32;
					let a331 = _this1.self._33;
					let b01 = m2.self._00;
					let b11 = m2.self._10;
					let b21 = m2.self._20;
					let b31 = m2.self._30;
					_this1.self._00 = a001 * b01 + a011 * b11 + a021 * b21 + a031 * b31;
					_this1.self._10 = a101 * b01 + a111 * b11 + a121 * b21 + a131 * b31;
					_this1.self._20 = a201 * b01 + a211 * b11 + a221 * b21 + a231 * b31;
					_this1.self._30 = a301 * b01 + a311 * b11 + a321 * b21 + a331 * b31;
					b01 = m2.self._01;
					b11 = m2.self._11;
					b21 = m2.self._21;
					b31 = m2.self._31;
					_this1.self._01 = a001 * b01 + a011 * b11 + a021 * b21 + a031 * b31;
					_this1.self._11 = a101 * b01 + a111 * b11 + a121 * b21 + a131 * b31;
					_this1.self._21 = a201 * b01 + a211 * b11 + a221 * b21 + a231 * b31;
					_this1.self._31 = a301 * b01 + a311 * b11 + a321 * b21 + a331 * b31;
					b01 = m2.self._02;
					b11 = m2.self._12;
					b21 = m2.self._22;
					b31 = m2.self._32;
					_this1.self._02 = a001 * b01 + a011 * b11 + a021 * b21 + a031 * b31;
					_this1.self._12 = a101 * b01 + a111 * b11 + a121 * b21 + a131 * b31;
					_this1.self._22 = a201 * b01 + a211 * b11 + a221 * b21 + a231 * b31;
					_this1.self._32 = a301 * b01 + a311 * b11 + a321 * b21 + a331 * b31;
					b01 = m2.self._03;
					b11 = m2.self._13;
					b21 = m2.self._23;
					b31 = m2.self._33;
					_this1.self._03 = a001 * b01 + a011 * b11 + a021 * b21 + a031 * b31;
					_this1.self._13 = a101 * b01 + a111 * b11 + a121 * b21 + a131 * b31;
					_this1.self._23 = a201 * b01 + a211 * b11 + a221 * b21 + a231 * b31;
					_this1.self._33 = a301 * b01 + a311 * b11 + a321 * b21 + a331 * b31;
					m = iron_object_Uniforms.helpMat;
				}
				break;
			case "_biasLightWorldViewProjectionMatrixSun":
				let _g = 0;
				let _g1 = iron_Scene.active.lights;
				while(_g < _g1.length) {
					let l = _g1[_g];
					++_g;
					if(l.data.raw.type == "sun") {
						if(object == null) {
							let _this = iron_object_Uniforms.helpMat;
							_this.self._00 = 1.0;
							_this.self._01 = 0.0;
							_this.self._02 = 0.0;
							_this.self._03 = 0.0;
							_this.self._10 = 0.0;
							_this.self._11 = 1.0;
							_this.self._12 = 0.0;
							_this.self._13 = 0.0;
							_this.self._20 = 0.0;
							_this.self._21 = 0.0;
							_this.self._22 = 1.0;
							_this.self._23 = 0.0;
							_this.self._30 = 0.0;
							_this.self._31 = 0.0;
							_this.self._32 = 0.0;
							_this.self._33 = 1.0;
						} else {
							let _this = iron_object_Uniforms.helpMat;
							let m = object.transform.worldUnpack;
							_this.self._00 = m.self._00;
							_this.self._01 = m.self._01;
							_this.self._02 = m.self._02;
							_this.self._03 = m.self._03;
							_this.self._10 = m.self._10;
							_this.self._11 = m.self._11;
							_this.self._12 = m.self._12;
							_this.self._13 = m.self._13;
							_this.self._20 = m.self._20;
							_this.self._21 = m.self._21;
							_this.self._22 = m.self._22;
							_this.self._23 = m.self._23;
							_this.self._30 = m.self._30;
							_this.self._31 = m.self._31;
							_this.self._32 = m.self._32;
							_this.self._33 = m.self._33;
						}
						let _this = iron_object_Uniforms.helpMat;
						let m1 = l.VP;
						let a00 = _this.self._00;
						let a01 = _this.self._01;
						let a02 = _this.self._02;
						let a03 = _this.self._03;
						let a10 = _this.self._10;
						let a11 = _this.self._11;
						let a12 = _this.self._12;
						let a13 = _this.self._13;
						let a20 = _this.self._20;
						let a21 = _this.self._21;
						let a22 = _this.self._22;
						let a23 = _this.self._23;
						let a30 = _this.self._30;
						let a31 = _this.self._31;
						let a32 = _this.self._32;
						let a33 = _this.self._33;
						let b0 = m1.self._00;
						let b1 = m1.self._10;
						let b2 = m1.self._20;
						let b3 = m1.self._30;
						_this.self._00 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
						_this.self._10 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
						_this.self._20 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
						_this.self._30 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
						b0 = m1.self._01;
						b1 = m1.self._11;
						b2 = m1.self._21;
						b3 = m1.self._31;
						_this.self._01 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
						_this.self._11 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
						_this.self._21 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
						_this.self._31 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
						b0 = m1.self._02;
						b1 = m1.self._12;
						b2 = m1.self._22;
						b3 = m1.self._32;
						_this.self._02 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
						_this.self._12 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
						_this.self._22 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
						_this.self._32 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
						b0 = m1.self._03;
						b1 = m1.self._13;
						b2 = m1.self._23;
						b3 = m1.self._33;
						_this.self._03 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
						_this.self._13 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
						_this.self._23 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
						_this.self._33 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
						let _this1 = iron_object_Uniforms.helpMat;
						let m2 = iron_object_Uniforms.biasMat;
						let a001 = _this1.self._00;
						let a011 = _this1.self._01;
						let a021 = _this1.self._02;
						let a031 = _this1.self._03;
						let a101 = _this1.self._10;
						let a111 = _this1.self._11;
						let a121 = _this1.self._12;
						let a131 = _this1.self._13;
						let a201 = _this1.self._20;
						let a211 = _this1.self._21;
						let a221 = _this1.self._22;
						let a231 = _this1.self._23;
						let a301 = _this1.self._30;
						let a311 = _this1.self._31;
						let a321 = _this1.self._32;
						let a331 = _this1.self._33;
						let b01 = m2.self._00;
						let b11 = m2.self._10;
						let b21 = m2.self._20;
						let b31 = m2.self._30;
						_this1.self._00 = a001 * b01 + a011 * b11 + a021 * b21 + a031 * b31;
						_this1.self._10 = a101 * b01 + a111 * b11 + a121 * b21 + a131 * b31;
						_this1.self._20 = a201 * b01 + a211 * b11 + a221 * b21 + a231 * b31;
						_this1.self._30 = a301 * b01 + a311 * b11 + a321 * b21 + a331 * b31;
						b01 = m2.self._01;
						b11 = m2.self._11;
						b21 = m2.self._21;
						b31 = m2.self._31;
						_this1.self._01 = a001 * b01 + a011 * b11 + a021 * b21 + a031 * b31;
						_this1.self._11 = a101 * b01 + a111 * b11 + a121 * b21 + a131 * b31;
						_this1.self._21 = a201 * b01 + a211 * b11 + a221 * b21 + a231 * b31;
						_this1.self._31 = a301 * b01 + a311 * b11 + a321 * b21 + a331 * b31;
						b01 = m2.self._02;
						b11 = m2.self._12;
						b21 = m2.self._22;
						b31 = m2.self._32;
						_this1.self._02 = a001 * b01 + a011 * b11 + a021 * b21 + a031 * b31;
						_this1.self._12 = a101 * b01 + a111 * b11 + a121 * b21 + a131 * b31;
						_this1.self._22 = a201 * b01 + a211 * b11 + a221 * b21 + a231 * b31;
						_this1.self._32 = a301 * b01 + a311 * b11 + a321 * b21 + a331 * b31;
						b01 = m2.self._03;
						b11 = m2.self._13;
						b21 = m2.self._23;
						b31 = m2.self._33;
						_this1.self._03 = a001 * b01 + a011 * b11 + a021 * b21 + a031 * b31;
						_this1.self._13 = a101 * b01 + a111 * b11 + a121 * b21 + a131 * b31;
						_this1.self._23 = a201 * b01 + a211 * b11 + a221 * b21 + a231 * b31;
						_this1.self._33 = a301 * b01 + a311 * b11 + a321 * b21 + a331 * b31;
						m = iron_object_Uniforms.helpMat;
						break;
					}
				}
				break;
			case "_inverseWorldMatrix":
				let _this = iron_object_Uniforms.helpMat;
				let m1 = object.transform.worldUnpack;
				let a00 = m1.self._00;
				let a01 = m1.self._01;
				let a02 = m1.self._02;
				let a03 = m1.self._03;
				let a10 = m1.self._10;
				let a11 = m1.self._11;
				let a12 = m1.self._12;
				let a13 = m1.self._13;
				let a20 = m1.self._20;
				let a21 = m1.self._21;
				let a22 = m1.self._22;
				let a23 = m1.self._23;
				let a30 = m1.self._30;
				let a31 = m1.self._31;
				let a32 = m1.self._32;
				let a33 = m1.self._33;
				let b00 = a00 * a11 - a01 * a10;
				let b01 = a00 * a12 - a02 * a10;
				let b02 = a00 * a13 - a03 * a10;
				let b03 = a01 * a12 - a02 * a11;
				let b04 = a01 * a13 - a03 * a11;
				let b05 = a02 * a13 - a03 * a12;
				let b06 = a20 * a31 - a21 * a30;
				let b07 = a20 * a32 - a22 * a30;
				let b08 = a20 * a33 - a23 * a30;
				let b09 = a21 * a32 - a22 * a31;
				let b10 = a21 * a33 - a23 * a31;
				let b11 = a22 * a33 - a23 * a32;
				let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
				if(det == 0.0) {
					_this.self._00 = 1.0;
					_this.self._01 = 0.0;
					_this.self._02 = 0.0;
					_this.self._03 = 0.0;
					_this.self._10 = 0.0;
					_this.self._11 = 1.0;
					_this.self._12 = 0.0;
					_this.self._13 = 0.0;
					_this.self._20 = 0.0;
					_this.self._21 = 0.0;
					_this.self._22 = 1.0;
					_this.self._23 = 0.0;
					_this.self._30 = 0.0;
					_this.self._31 = 0.0;
					_this.self._32 = 0.0;
					_this.self._33 = 1.0;
				} else {
					det = 1.0 / det;
					_this.self._00 = (a11 * b11 - a12 * b10 + a13 * b09) * det;
					_this.self._01 = (a02 * b10 - a01 * b11 - a03 * b09) * det;
					_this.self._02 = (a31 * b05 - a32 * b04 + a33 * b03) * det;
					_this.self._03 = (a22 * b04 - a21 * b05 - a23 * b03) * det;
					_this.self._10 = (a12 * b08 - a10 * b11 - a13 * b07) * det;
					_this.self._11 = (a00 * b11 - a02 * b08 + a03 * b07) * det;
					_this.self._12 = (a32 * b02 - a30 * b05 - a33 * b01) * det;
					_this.self._13 = (a20 * b05 - a22 * b02 + a23 * b01) * det;
					_this.self._20 = (a10 * b10 - a11 * b08 + a13 * b06) * det;
					_this.self._21 = (a01 * b08 - a00 * b10 - a03 * b06) * det;
					_this.self._22 = (a30 * b04 - a31 * b02 + a33 * b00) * det;
					_this.self._23 = (a21 * b02 - a20 * b04 - a23 * b00) * det;
					_this.self._30 = (a11 * b07 - a10 * b09 - a12 * b06) * det;
					_this.self._31 = (a00 * b09 - a01 * b07 + a02 * b06) * det;
					_this.self._32 = (a31 * b01 - a30 * b03 - a32 * b00) * det;
					_this.self._33 = (a20 * b03 - a21 * b01 + a22 * b00) * det;
				}
				m = iron_object_Uniforms.helpMat;
				break;
			case "_lightWorldViewProjectionMatrix":
				if(light != null) {
					if(object == null) {
						let _this = iron_object_Uniforms.helpMat;
						_this.self._00 = 1.0;
						_this.self._01 = 0.0;
						_this.self._02 = 0.0;
						_this.self._03 = 0.0;
						_this.self._10 = 0.0;
						_this.self._11 = 1.0;
						_this.self._12 = 0.0;
						_this.self._13 = 0.0;
						_this.self._20 = 0.0;
						_this.self._21 = 0.0;
						_this.self._22 = 1.0;
						_this.self._23 = 0.0;
						_this.self._30 = 0.0;
						_this.self._31 = 0.0;
						_this.self._32 = 0.0;
						_this.self._33 = 1.0;
					} else {
						let _this = iron_object_Uniforms.helpMat;
						let m = object.transform.worldUnpack;
						_this.self._00 = m.self._00;
						_this.self._01 = m.self._01;
						_this.self._02 = m.self._02;
						_this.self._03 = m.self._03;
						_this.self._10 = m.self._10;
						_this.self._11 = m.self._11;
						_this.self._12 = m.self._12;
						_this.self._13 = m.self._13;
						_this.self._20 = m.self._20;
						_this.self._21 = m.self._21;
						_this.self._22 = m.self._22;
						_this.self._23 = m.self._23;
						_this.self._30 = m.self._30;
						_this.self._31 = m.self._31;
						_this.self._32 = m.self._32;
						_this.self._33 = m.self._33;
					}
					let _this = iron_object_Uniforms.helpMat;
					let m1 = light.VP;
					let a00 = _this.self._00;
					let a01 = _this.self._01;
					let a02 = _this.self._02;
					let a03 = _this.self._03;
					let a10 = _this.self._10;
					let a11 = _this.self._11;
					let a12 = _this.self._12;
					let a13 = _this.self._13;
					let a20 = _this.self._20;
					let a21 = _this.self._21;
					let a22 = _this.self._22;
					let a23 = _this.self._23;
					let a30 = _this.self._30;
					let a31 = _this.self._31;
					let a32 = _this.self._32;
					let a33 = _this.self._33;
					let b0 = m1.self._00;
					let b1 = m1.self._10;
					let b2 = m1.self._20;
					let b3 = m1.self._30;
					_this.self._00 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this.self._10 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this.self._20 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this.self._30 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					b0 = m1.self._01;
					b1 = m1.self._11;
					b2 = m1.self._21;
					b3 = m1.self._31;
					_this.self._01 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this.self._11 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this.self._21 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this.self._31 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					b0 = m1.self._02;
					b1 = m1.self._12;
					b2 = m1.self._22;
					b3 = m1.self._32;
					_this.self._02 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this.self._12 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this.self._22 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this.self._32 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					b0 = m1.self._03;
					b1 = m1.self._13;
					b2 = m1.self._23;
					b3 = m1.self._33;
					_this.self._03 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this.self._13 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this.self._23 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this.self._33 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					m = iron_object_Uniforms.helpMat;
				}
				break;
			case "_lightWorldViewProjectionMatrixCylinder":
				if(light != null) {
					let _this = iron_object_Uniforms.helpMat;
					let m1 = object.transform.worldUnpack;
					_this.self._00 = m1.self._00;
					_this.self._01 = m1.self._01;
					_this.self._02 = m1.self._02;
					_this.self._03 = m1.self._03;
					_this.self._10 = m1.self._10;
					_this.self._11 = m1.self._11;
					_this.self._12 = m1.self._12;
					_this.self._13 = m1.self._13;
					_this.self._20 = m1.self._20;
					_this.self._21 = m1.self._21;
					_this.self._22 = m1.self._22;
					_this.self._23 = m1.self._23;
					_this.self._30 = m1.self._30;
					_this.self._31 = m1.self._31;
					_this.self._32 = m1.self._32;
					_this.self._33 = m1.self._33;
					let _this1 = iron_object_Uniforms.helpMat;
					let m2 = camera.V;
					let a00 = _this1.self._00;
					let a01 = _this1.self._01;
					let a02 = _this1.self._02;
					let a03 = _this1.self._03;
					let a10 = _this1.self._10;
					let a11 = _this1.self._11;
					let a12 = _this1.self._12;
					let a13 = _this1.self._13;
					let a20 = _this1.self._20;
					let a21 = _this1.self._21;
					let a22 = _this1.self._22;
					let a23 = _this1.self._23;
					let a30 = _this1.self._30;
					let a31 = _this1.self._31;
					let a32 = _this1.self._32;
					let a33 = _this1.self._33;
					let b0 = m2.self._00;
					let b1 = m2.self._10;
					let b2 = m2.self._20;
					let b3 = m2.self._30;
					_this1.self._00 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this1.self._10 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this1.self._20 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this1.self._30 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					b0 = m2.self._01;
					b1 = m2.self._11;
					b2 = m2.self._21;
					b3 = m2.self._31;
					_this1.self._01 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this1.self._11 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this1.self._21 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this1.self._31 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					b0 = m2.self._02;
					b1 = m2.self._12;
					b2 = m2.self._22;
					b3 = m2.self._32;
					_this1.self._02 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this1.self._12 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this1.self._22 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this1.self._32 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					b0 = m2.self._03;
					b1 = m2.self._13;
					b2 = m2.self._23;
					b3 = m2.self._33;
					_this1.self._03 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this1.self._13 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this1.self._23 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this1.self._33 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					iron_object_Uniforms.helpMat.self._00 = 1.0;
					iron_object_Uniforms.helpMat.self._20 = 0.0;
					iron_object_Uniforms.helpMat.self._01 = 0.0;
					iron_object_Uniforms.helpMat.self._21 = 0.0;
					iron_object_Uniforms.helpMat.self._02 = 0.0;
					iron_object_Uniforms.helpMat.self._22 = 1.0;
					let _this2 = iron_object_Uniforms.helpMat2;
					let m3 = camera.V;
					let a001 = m3.self._00;
					let a011 = m3.self._01;
					let a021 = m3.self._02;
					let a031 = m3.self._03;
					let a101 = m3.self._10;
					let a111 = m3.self._11;
					let a121 = m3.self._12;
					let a131 = m3.self._13;
					let a201 = m3.self._20;
					let a211 = m3.self._21;
					let a221 = m3.self._22;
					let a231 = m3.self._23;
					let a301 = m3.self._30;
					let a311 = m3.self._31;
					let a321 = m3.self._32;
					let a331 = m3.self._33;
					let b00 = a001 * a111 - a011 * a101;
					let b01 = a001 * a121 - a021 * a101;
					let b02 = a001 * a131 - a031 * a101;
					let b03 = a011 * a121 - a021 * a111;
					let b04 = a011 * a131 - a031 * a111;
					let b05 = a021 * a131 - a031 * a121;
					let b06 = a201 * a311 - a211 * a301;
					let b07 = a201 * a321 - a221 * a301;
					let b08 = a201 * a331 - a231 * a301;
					let b09 = a211 * a321 - a221 * a311;
					let b10 = a211 * a331 - a231 * a311;
					let b11 = a221 * a331 - a231 * a321;
					let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
					if(det == 0.0) {
						_this2.self._00 = 1.0;
						_this2.self._01 = 0.0;
						_this2.self._02 = 0.0;
						_this2.self._03 = 0.0;
						_this2.self._10 = 0.0;
						_this2.self._11 = 1.0;
						_this2.self._12 = 0.0;
						_this2.self._13 = 0.0;
						_this2.self._20 = 0.0;
						_this2.self._21 = 0.0;
						_this2.self._22 = 1.0;
						_this2.self._23 = 0.0;
						_this2.self._30 = 0.0;
						_this2.self._31 = 0.0;
						_this2.self._32 = 0.0;
						_this2.self._33 = 1.0;
					} else {
						det = 1.0 / det;
						_this2.self._00 = (a111 * b11 - a121 * b10 + a131 * b09) * det;
						_this2.self._01 = (a021 * b10 - a011 * b11 - a031 * b09) * det;
						_this2.self._02 = (a311 * b05 - a321 * b04 + a331 * b03) * det;
						_this2.self._03 = (a221 * b04 - a211 * b05 - a231 * b03) * det;
						_this2.self._10 = (a121 * b08 - a101 * b11 - a131 * b07) * det;
						_this2.self._11 = (a001 * b11 - a021 * b08 + a031 * b07) * det;
						_this2.self._12 = (a321 * b02 - a301 * b05 - a331 * b01) * det;
						_this2.self._13 = (a201 * b05 - a221 * b02 + a231 * b01) * det;
						_this2.self._20 = (a101 * b10 - a111 * b08 + a131 * b06) * det;
						_this2.self._21 = (a011 * b08 - a001 * b10 - a031 * b06) * det;
						_this2.self._22 = (a301 * b04 - a311 * b02 + a331 * b00) * det;
						_this2.self._23 = (a211 * b02 - a201 * b04 - a231 * b00) * det;
						_this2.self._30 = (a111 * b07 - a101 * b09 - a121 * b06) * det;
						_this2.self._31 = (a001 * b09 - a011 * b07 + a021 * b06) * det;
						_this2.self._32 = (a311 * b01 - a301 * b03 - a321 * b00) * det;
						_this2.self._33 = (a201 * b03 - a211 * b01 + a221 * b00) * det;
					}
					let _this3 = iron_object_Uniforms.helpMat;
					let m4 = iron_object_Uniforms.helpMat2;
					let a002 = _this3.self._00;
					let a012 = _this3.self._01;
					let a022 = _this3.self._02;
					let a032 = _this3.self._03;
					let a102 = _this3.self._10;
					let a112 = _this3.self._11;
					let a122 = _this3.self._12;
					let a132 = _this3.self._13;
					let a202 = _this3.self._20;
					let a212 = _this3.self._21;
					let a222 = _this3.self._22;
					let a232 = _this3.self._23;
					let a302 = _this3.self._30;
					let a312 = _this3.self._31;
					let a322 = _this3.self._32;
					let a332 = _this3.self._33;
					let b010 = m4.self._00;
					let b12 = m4.self._10;
					let b21 = m4.self._20;
					let b31 = m4.self._30;
					_this3.self._00 = a002 * b010 + a012 * b12 + a022 * b21 + a032 * b31;
					_this3.self._10 = a102 * b010 + a112 * b12 + a122 * b21 + a132 * b31;
					_this3.self._20 = a202 * b010 + a212 * b12 + a222 * b21 + a232 * b31;
					_this3.self._30 = a302 * b010 + a312 * b12 + a322 * b21 + a332 * b31;
					b010 = m4.self._01;
					b12 = m4.self._11;
					b21 = m4.self._21;
					b31 = m4.self._31;
					_this3.self._01 = a002 * b010 + a012 * b12 + a022 * b21 + a032 * b31;
					_this3.self._11 = a102 * b010 + a112 * b12 + a122 * b21 + a132 * b31;
					_this3.self._21 = a202 * b010 + a212 * b12 + a222 * b21 + a232 * b31;
					_this3.self._31 = a302 * b010 + a312 * b12 + a322 * b21 + a332 * b31;
					b010 = m4.self._02;
					b12 = m4.self._12;
					b21 = m4.self._22;
					b31 = m4.self._32;
					_this3.self._02 = a002 * b010 + a012 * b12 + a022 * b21 + a032 * b31;
					_this3.self._12 = a102 * b010 + a112 * b12 + a122 * b21 + a132 * b31;
					_this3.self._22 = a202 * b010 + a212 * b12 + a222 * b21 + a232 * b31;
					_this3.self._32 = a302 * b010 + a312 * b12 + a322 * b21 + a332 * b31;
					b010 = m4.self._03;
					b12 = m4.self._13;
					b21 = m4.self._23;
					b31 = m4.self._33;
					_this3.self._03 = a002 * b010 + a012 * b12 + a022 * b21 + a032 * b31;
					_this3.self._13 = a102 * b010 + a112 * b12 + a122 * b21 + a132 * b31;
					_this3.self._23 = a202 * b010 + a212 * b12 + a222 * b21 + a232 * b31;
					_this3.self._33 = a302 * b010 + a312 * b12 + a322 * b21 + a332 * b31;
					let _this4 = iron_object_Uniforms.helpMat;
					let m5 = light.VP;
					let a003 = _this4.self._00;
					let a013 = _this4.self._01;
					let a023 = _this4.self._02;
					let a033 = _this4.self._03;
					let a103 = _this4.self._10;
					let a113 = _this4.self._11;
					let a123 = _this4.self._12;
					let a133 = _this4.self._13;
					let a203 = _this4.self._20;
					let a213 = _this4.self._21;
					let a223 = _this4.self._22;
					let a233 = _this4.self._23;
					let a303 = _this4.self._30;
					let a313 = _this4.self._31;
					let a323 = _this4.self._32;
					let a333 = _this4.self._33;
					let b011 = m5.self._00;
					let b13 = m5.self._10;
					let b22 = m5.self._20;
					let b32 = m5.self._30;
					_this4.self._00 = a003 * b011 + a013 * b13 + a023 * b22 + a033 * b32;
					_this4.self._10 = a103 * b011 + a113 * b13 + a123 * b22 + a133 * b32;
					_this4.self._20 = a203 * b011 + a213 * b13 + a223 * b22 + a233 * b32;
					_this4.self._30 = a303 * b011 + a313 * b13 + a323 * b22 + a333 * b32;
					b011 = m5.self._01;
					b13 = m5.self._11;
					b22 = m5.self._21;
					b32 = m5.self._31;
					_this4.self._01 = a003 * b011 + a013 * b13 + a023 * b22 + a033 * b32;
					_this4.self._11 = a103 * b011 + a113 * b13 + a123 * b22 + a133 * b32;
					_this4.self._21 = a203 * b011 + a213 * b13 + a223 * b22 + a233 * b32;
					_this4.self._31 = a303 * b011 + a313 * b13 + a323 * b22 + a333 * b32;
					b011 = m5.self._02;
					b13 = m5.self._12;
					b22 = m5.self._22;
					b32 = m5.self._32;
					_this4.self._02 = a003 * b011 + a013 * b13 + a023 * b22 + a033 * b32;
					_this4.self._12 = a103 * b011 + a113 * b13 + a123 * b22 + a133 * b32;
					_this4.self._22 = a203 * b011 + a213 * b13 + a223 * b22 + a233 * b32;
					_this4.self._32 = a303 * b011 + a313 * b13 + a323 * b22 + a333 * b32;
					b011 = m5.self._03;
					b13 = m5.self._13;
					b22 = m5.self._23;
					b32 = m5.self._33;
					_this4.self._03 = a003 * b011 + a013 * b13 + a023 * b22 + a033 * b32;
					_this4.self._13 = a103 * b011 + a113 * b13 + a123 * b22 + a133 * b32;
					_this4.self._23 = a203 * b011 + a213 * b13 + a223 * b22 + a233 * b32;
					_this4.self._33 = a303 * b011 + a313 * b13 + a323 * b22 + a333 * b32;
					m = iron_object_Uniforms.helpMat;
				}
				break;
			case "_lightWorldViewProjectionMatrixSphere":
				if(light != null) {
					let _this = iron_object_Uniforms.helpMat;
					let m1 = object.transform.worldUnpack;
					_this.self._00 = m1.self._00;
					_this.self._01 = m1.self._01;
					_this.self._02 = m1.self._02;
					_this.self._03 = m1.self._03;
					_this.self._10 = m1.self._10;
					_this.self._11 = m1.self._11;
					_this.self._12 = m1.self._12;
					_this.self._13 = m1.self._13;
					_this.self._20 = m1.self._20;
					_this.self._21 = m1.self._21;
					_this.self._22 = m1.self._22;
					_this.self._23 = m1.self._23;
					_this.self._30 = m1.self._30;
					_this.self._31 = m1.self._31;
					_this.self._32 = m1.self._32;
					_this.self._33 = m1.self._33;
					let _this1 = iron_object_Uniforms.helpMat;
					let m2 = camera.V;
					let a00 = _this1.self._00;
					let a01 = _this1.self._01;
					let a02 = _this1.self._02;
					let a03 = _this1.self._03;
					let a10 = _this1.self._10;
					let a11 = _this1.self._11;
					let a12 = _this1.self._12;
					let a13 = _this1.self._13;
					let a20 = _this1.self._20;
					let a21 = _this1.self._21;
					let a22 = _this1.self._22;
					let a23 = _this1.self._23;
					let a30 = _this1.self._30;
					let a31 = _this1.self._31;
					let a32 = _this1.self._32;
					let a33 = _this1.self._33;
					let b0 = m2.self._00;
					let b1 = m2.self._10;
					let b2 = m2.self._20;
					let b3 = m2.self._30;
					_this1.self._00 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this1.self._10 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this1.self._20 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this1.self._30 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					b0 = m2.self._01;
					b1 = m2.self._11;
					b2 = m2.self._21;
					b3 = m2.self._31;
					_this1.self._01 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this1.self._11 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this1.self._21 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this1.self._31 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					b0 = m2.self._02;
					b1 = m2.self._12;
					b2 = m2.self._22;
					b3 = m2.self._32;
					_this1.self._02 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this1.self._12 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this1.self._22 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this1.self._32 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					b0 = m2.self._03;
					b1 = m2.self._13;
					b2 = m2.self._23;
					b3 = m2.self._33;
					_this1.self._03 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
					_this1.self._13 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
					_this1.self._23 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
					_this1.self._33 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
					iron_object_Uniforms.helpMat.self._00 = 1.0;
					iron_object_Uniforms.helpMat.self._10 = 0.0;
					iron_object_Uniforms.helpMat.self._20 = 0.0;
					iron_object_Uniforms.helpMat.self._01 = 0.0;
					iron_object_Uniforms.helpMat.self._11 = 1.0;
					iron_object_Uniforms.helpMat.self._21 = 0.0;
					iron_object_Uniforms.helpMat.self._02 = 0.0;
					iron_object_Uniforms.helpMat.self._12 = 0.0;
					iron_object_Uniforms.helpMat.self._22 = 1.0;
					let _this2 = iron_object_Uniforms.helpMat2;
					let m3 = camera.V;
					let a001 = m3.self._00;
					let a011 = m3.self._01;
					let a021 = m3.self._02;
					let a031 = m3.self._03;
					let a101 = m3.self._10;
					let a111 = m3.self._11;
					let a121 = m3.self._12;
					let a131 = m3.self._13;
					let a201 = m3.self._20;
					let a211 = m3.self._21;
					let a221 = m3.self._22;
					let a231 = m3.self._23;
					let a301 = m3.self._30;
					let a311 = m3.self._31;
					let a321 = m3.self._32;
					let a331 = m3.self._33;
					let b00 = a001 * a111 - a011 * a101;
					let b01 = a001 * a121 - a021 * a101;
					let b02 = a001 * a131 - a031 * a101;
					let b03 = a011 * a121 - a021 * a111;
					let b04 = a011 * a131 - a031 * a111;
					let b05 = a021 * a131 - a031 * a121;
					let b06 = a201 * a311 - a211 * a301;
					let b07 = a201 * a321 - a221 * a301;
					let b08 = a201 * a331 - a231 * a301;
					let b09 = a211 * a321 - a221 * a311;
					let b10 = a211 * a331 - a231 * a311;
					let b11 = a221 * a331 - a231 * a321;
					let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
					if(det == 0.0) {
						_this2.self._00 = 1.0;
						_this2.self._01 = 0.0;
						_this2.self._02 = 0.0;
						_this2.self._03 = 0.0;
						_this2.self._10 = 0.0;
						_this2.self._11 = 1.0;
						_this2.self._12 = 0.0;
						_this2.self._13 = 0.0;
						_this2.self._20 = 0.0;
						_this2.self._21 = 0.0;
						_this2.self._22 = 1.0;
						_this2.self._23 = 0.0;
						_this2.self._30 = 0.0;
						_this2.self._31 = 0.0;
						_this2.self._32 = 0.0;
						_this2.self._33 = 1.0;
					} else {
						det = 1.0 / det;
						_this2.self._00 = (a111 * b11 - a121 * b10 + a131 * b09) * det;
						_this2.self._01 = (a021 * b10 - a011 * b11 - a031 * b09) * det;
						_this2.self._02 = (a311 * b05 - a321 * b04 + a331 * b03) * det;
						_this2.self._03 = (a221 * b04 - a211 * b05 - a231 * b03) * det;
						_this2.self._10 = (a121 * b08 - a101 * b11 - a131 * b07) * det;
						_this2.self._11 = (a001 * b11 - a021 * b08 + a031 * b07) * det;
						_this2.self._12 = (a321 * b02 - a301 * b05 - a331 * b01) * det;
						_this2.self._13 = (a201 * b05 - a221 * b02 + a231 * b01) * det;
						_this2.self._20 = (a101 * b10 - a111 * b08 + a131 * b06) * det;
						_this2.self._21 = (a011 * b08 - a001 * b10 - a031 * b06) * det;
						_this2.self._22 = (a301 * b04 - a311 * b02 + a331 * b00) * det;
						_this2.self._23 = (a211 * b02 - a201 * b04 - a231 * b00) * det;
						_this2.self._30 = (a111 * b07 - a101 * b09 - a121 * b06) * det;
						_this2.self._31 = (a001 * b09 - a011 * b07 + a021 * b06) * det;
						_this2.self._32 = (a311 * b01 - a301 * b03 - a321 * b00) * det;
						_this2.self._33 = (a201 * b03 - a211 * b01 + a221 * b00) * det;
					}
					let _this3 = iron_object_Uniforms.helpMat;
					let m4 = iron_object_Uniforms.helpMat2;
					let a002 = _this3.self._00;
					let a012 = _this3.self._01;
					let a022 = _this3.self._02;
					let a032 = _this3.self._03;
					let a102 = _this3.self._10;
					let a112 = _this3.self._11;
					let a122 = _this3.self._12;
					let a132 = _this3.self._13;
					let a202 = _this3.self._20;
					let a212 = _this3.self._21;
					let a222 = _this3.self._22;
					let a232 = _this3.self._23;
					let a302 = _this3.self._30;
					let a312 = _this3.self._31;
					let a322 = _this3.self._32;
					let a332 = _this3.self._33;
					let b010 = m4.self._00;
					let b12 = m4.self._10;
					let b21 = m4.self._20;
					let b31 = m4.self._30;
					_this3.self._00 = a002 * b010 + a012 * b12 + a022 * b21 + a032 * b31;
					_this3.self._10 = a102 * b010 + a112 * b12 + a122 * b21 + a132 * b31;
					_this3.self._20 = a202 * b010 + a212 * b12 + a222 * b21 + a232 * b31;
					_this3.self._30 = a302 * b010 + a312 * b12 + a322 * b21 + a332 * b31;
					b010 = m4.self._01;
					b12 = m4.self._11;
					b21 = m4.self._21;
					b31 = m4.self._31;
					_this3.self._01 = a002 * b010 + a012 * b12 + a022 * b21 + a032 * b31;
					_this3.self._11 = a102 * b010 + a112 * b12 + a122 * b21 + a132 * b31;
					_this3.self._21 = a202 * b010 + a212 * b12 + a222 * b21 + a232 * b31;
					_this3.self._31 = a302 * b010 + a312 * b12 + a322 * b21 + a332 * b31;
					b010 = m4.self._02;
					b12 = m4.self._12;
					b21 = m4.self._22;
					b31 = m4.self._32;
					_this3.self._02 = a002 * b010 + a012 * b12 + a022 * b21 + a032 * b31;
					_this3.self._12 = a102 * b010 + a112 * b12 + a122 * b21 + a132 * b31;
					_this3.self._22 = a202 * b010 + a212 * b12 + a222 * b21 + a232 * b31;
					_this3.self._32 = a302 * b010 + a312 * b12 + a322 * b21 + a332 * b31;
					b010 = m4.self._03;
					b12 = m4.self._13;
					b21 = m4.self._23;
					b31 = m4.self._33;
					_this3.self._03 = a002 * b010 + a012 * b12 + a022 * b21 + a032 * b31;
					_this3.self._13 = a102 * b010 + a112 * b12 + a122 * b21 + a132 * b31;
					_this3.self._23 = a202 * b010 + a212 * b12 + a222 * b21 + a232 * b31;
					_this3.self._33 = a302 * b010 + a312 * b12 + a322 * b21 + a332 * b31;
					let _this4 = iron_object_Uniforms.helpMat;
					let m5 = light.VP;
					let a003 = _this4.self._00;
					let a013 = _this4.self._01;
					let a023 = _this4.self._02;
					let a033 = _this4.self._03;
					let a103 = _this4.self._10;
					let a113 = _this4.self._11;
					let a123 = _this4.self._12;
					let a133 = _this4.self._13;
					let a203 = _this4.self._20;
					let a213 = _this4.self._21;
					let a223 = _this4.self._22;
					let a233 = _this4.self._23;
					let a303 = _this4.self._30;
					let a313 = _this4.self._31;
					let a323 = _this4.self._32;
					let a333 = _this4.self._33;
					let b011 = m5.self._00;
					let b13 = m5.self._10;
					let b22 = m5.self._20;
					let b32 = m5.self._30;
					_this4.self._00 = a003 * b011 + a013 * b13 + a023 * b22 + a033 * b32;
					_this4.self._10 = a103 * b011 + a113 * b13 + a123 * b22 + a133 * b32;
					_this4.self._20 = a203 * b011 + a213 * b13 + a223 * b22 + a233 * b32;
					_this4.self._30 = a303 * b011 + a313 * b13 + a323 * b22 + a333 * b32;
					b011 = m5.self._01;
					b13 = m5.self._11;
					b22 = m5.self._21;
					b32 = m5.self._31;
					_this4.self._01 = a003 * b011 + a013 * b13 + a023 * b22 + a033 * b32;
					_this4.self._11 = a103 * b011 + a113 * b13 + a123 * b22 + a133 * b32;
					_this4.self._21 = a203 * b011 + a213 * b13 + a223 * b22 + a233 * b32;
					_this4.self._31 = a303 * b011 + a313 * b13 + a323 * b22 + a333 * b32;
					b011 = m5.self._02;
					b13 = m5.self._12;
					b22 = m5.self._22;
					b32 = m5.self._32;
					_this4.self._02 = a003 * b011 + a013 * b13 + a023 * b22 + a033 * b32;
					_this4.self._12 = a103 * b011 + a113 * b13 + a123 * b22 + a133 * b32;
					_this4.self._22 = a203 * b011 + a213 * b13 + a223 * b22 + a233 * b32;
					_this4.self._32 = a303 * b011 + a313 * b13 + a323 * b22 + a333 * b32;
					b011 = m5.self._03;
					b13 = m5.self._13;
					b22 = m5.self._23;
					b32 = m5.self._33;
					_this4.self._03 = a003 * b011 + a013 * b13 + a023 * b22 + a033 * b32;
					_this4.self._13 = a103 * b011 + a113 * b13 + a123 * b22 + a133 * b32;
					_this4.self._23 = a203 * b011 + a213 * b13 + a223 * b22 + a233 * b32;
					_this4.self._33 = a303 * b011 + a313 * b13 + a323 * b22 + a333 * b32;
					m = iron_object_Uniforms.helpMat;
				}
				break;
			case "_particleData":
				let mo = js_Boot.__cast(object , iron_object_MeshObject);
				if(mo.particleOwner != null && mo.particleOwner.particleSystems != null) {
					m = mo.particleOwner.particleSystems[mo.particleIndex].getData();
				}
				break;
			case "_prevWorldMatrix":
				m = (js_Boot.__cast(object , iron_object_MeshObject)).prevMatrix;
				break;
			case "_prevWorldViewProjectionMatrix":
				let _this1 = iron_object_Uniforms.helpMat;
				let m2 = (js_Boot.__cast(object , iron_object_MeshObject)).prevMatrix;
				_this1.self._00 = m2.self._00;
				_this1.self._01 = m2.self._01;
				_this1.self._02 = m2.self._02;
				_this1.self._03 = m2.self._03;
				_this1.self._10 = m2.self._10;
				_this1.self._11 = m2.self._11;
				_this1.self._12 = m2.self._12;
				_this1.self._13 = m2.self._13;
				_this1.self._20 = m2.self._20;
				_this1.self._21 = m2.self._21;
				_this1.self._22 = m2.self._22;
				_this1.self._23 = m2.self._23;
				_this1.self._30 = m2.self._30;
				_this1.self._31 = m2.self._31;
				_this1.self._32 = m2.self._32;
				_this1.self._33 = m2.self._33;
				let _this2 = iron_object_Uniforms.helpMat;
				let m3 = camera.prevV;
				let a001 = _this2.self._00;
				let a011 = _this2.self._01;
				let a021 = _this2.self._02;
				let a031 = _this2.self._03;
				let a101 = _this2.self._10;
				let a111 = _this2.self._11;
				let a121 = _this2.self._12;
				let a131 = _this2.self._13;
				let a201 = _this2.self._20;
				let a211 = _this2.self._21;
				let a221 = _this2.self._22;
				let a231 = _this2.self._23;
				let a301 = _this2.self._30;
				let a311 = _this2.self._31;
				let a321 = _this2.self._32;
				let a331 = _this2.self._33;
				let b0 = m3.self._00;
				let b1 = m3.self._10;
				let b2 = m3.self._20;
				let b3 = m3.self._30;
				_this2.self._00 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
				_this2.self._10 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
				_this2.self._20 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
				_this2.self._30 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
				b0 = m3.self._01;
				b1 = m3.self._11;
				b2 = m3.self._21;
				b3 = m3.self._31;
				_this2.self._01 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
				_this2.self._11 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
				_this2.self._21 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
				_this2.self._31 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
				b0 = m3.self._02;
				b1 = m3.self._12;
				b2 = m3.self._22;
				b3 = m3.self._32;
				_this2.self._02 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
				_this2.self._12 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
				_this2.self._22 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
				_this2.self._32 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
				b0 = m3.self._03;
				b1 = m3.self._13;
				b2 = m3.self._23;
				b3 = m3.self._33;
				_this2.self._03 = a001 * b0 + a011 * b1 + a021 * b2 + a031 * b3;
				_this2.self._13 = a101 * b0 + a111 * b1 + a121 * b2 + a131 * b3;
				_this2.self._23 = a201 * b0 + a211 * b1 + a221 * b2 + a231 * b3;
				_this2.self._33 = a301 * b0 + a311 * b1 + a321 * b2 + a331 * b3;
				let _this3 = iron_object_Uniforms.helpMat;
				let m4 = camera.P;
				let a002 = _this3.self._00;
				let a012 = _this3.self._01;
				let a022 = _this3.self._02;
				let a032 = _this3.self._03;
				let a102 = _this3.self._10;
				let a112 = _this3.self._11;
				let a122 = _this3.self._12;
				let a132 = _this3.self._13;
				let a202 = _this3.self._20;
				let a212 = _this3.self._21;
				let a222 = _this3.self._22;
				let a232 = _this3.self._23;
				let a302 = _this3.self._30;
				let a312 = _this3.self._31;
				let a322 = _this3.self._32;
				let a332 = _this3.self._33;
				let b010 = m4.self._00;
				let b12 = m4.self._10;
				let b21 = m4.self._20;
				let b31 = m4.self._30;
				_this3.self._00 = a002 * b010 + a012 * b12 + a022 * b21 + a032 * b31;
				_this3.self._10 = a102 * b010 + a112 * b12 + a122 * b21 + a132 * b31;
				_this3.self._20 = a202 * b010 + a212 * b12 + a222 * b21 + a232 * b31;
				_this3.self._30 = a302 * b010 + a312 * b12 + a322 * b21 + a332 * b31;
				b010 = m4.self._01;
				b12 = m4.self._11;
				b21 = m4.self._21;
				b31 = m4.self._31;
				_this3.self._01 = a002 * b010 + a012 * b12 + a022 * b21 + a032 * b31;
				_this3.self._11 = a102 * b010 + a112 * b12 + a122 * b21 + a132 * b31;
				_this3.self._21 = a202 * b010 + a212 * b12 + a222 * b21 + a232 * b31;
				_this3.self._31 = a302 * b010 + a312 * b12 + a322 * b21 + a332 * b31;
				b010 = m4.self._02;
				b12 = m4.self._12;
				b21 = m4.self._22;
				b31 = m4.self._32;
				_this3.self._02 = a002 * b010 + a012 * b12 + a022 * b21 + a032 * b31;
				_this3.self._12 = a102 * b010 + a112 * b12 + a122 * b21 + a132 * b31;
				_this3.self._22 = a202 * b010 + a212 * b12 + a222 * b21 + a232 * b31;
				_this3.self._32 = a302 * b010 + a312 * b12 + a322 * b21 + a332 * b31;
				b010 = m4.self._03;
				b12 = m4.self._13;
				b21 = m4.self._23;
				b31 = m4.self._33;
				_this3.self._03 = a002 * b010 + a012 * b12 + a022 * b21 + a032 * b31;
				_this3.self._13 = a102 * b010 + a112 * b12 + a122 * b21 + a132 * b31;
				_this3.self._23 = a202 * b010 + a212 * b12 + a222 * b21 + a232 * b31;
				_this3.self._33 = a302 * b010 + a312 * b12 + a322 * b21 + a332 * b31;
				m = iron_object_Uniforms.helpMat;
				break;
			case "_worldMatrix":
				m = object.transform.worldUnpack;
				break;
			case "_worldViewMatrix":
				let _this4 = iron_object_Uniforms.helpMat;
				let m5 = object.transform.worldUnpack;
				_this4.self._00 = m5.self._00;
				_this4.self._01 = m5.self._01;
				_this4.self._02 = m5.self._02;
				_this4.self._03 = m5.self._03;
				_this4.self._10 = m5.self._10;
				_this4.self._11 = m5.self._11;
				_this4.self._12 = m5.self._12;
				_this4.self._13 = m5.self._13;
				_this4.self._20 = m5.self._20;
				_this4.self._21 = m5.self._21;
				_this4.self._22 = m5.self._22;
				_this4.self._23 = m5.self._23;
				_this4.self._30 = m5.self._30;
				_this4.self._31 = m5.self._31;
				_this4.self._32 = m5.self._32;
				_this4.self._33 = m5.self._33;
				let _this5 = iron_object_Uniforms.helpMat;
				let m6 = camera.V;
				let a003 = _this5.self._00;
				let a013 = _this5.self._01;
				let a023 = _this5.self._02;
				let a033 = _this5.self._03;
				let a103 = _this5.self._10;
				let a113 = _this5.self._11;
				let a123 = _this5.self._12;
				let a133 = _this5.self._13;
				let a203 = _this5.self._20;
				let a213 = _this5.self._21;
				let a223 = _this5.self._22;
				let a233 = _this5.self._23;
				let a303 = _this5.self._30;
				let a313 = _this5.self._31;
				let a323 = _this5.self._32;
				let a333 = _this5.self._33;
				let b011 = m6.self._00;
				let b13 = m6.self._10;
				let b22 = m6.self._20;
				let b32 = m6.self._30;
				_this5.self._00 = a003 * b011 + a013 * b13 + a023 * b22 + a033 * b32;
				_this5.self._10 = a103 * b011 + a113 * b13 + a123 * b22 + a133 * b32;
				_this5.self._20 = a203 * b011 + a213 * b13 + a223 * b22 + a233 * b32;
				_this5.self._30 = a303 * b011 + a313 * b13 + a323 * b22 + a333 * b32;
				b011 = m6.self._01;
				b13 = m6.self._11;
				b22 = m6.self._21;
				b32 = m6.self._31;
				_this5.self._01 = a003 * b011 + a013 * b13 + a023 * b22 + a033 * b32;
				_this5.self._11 = a103 * b011 + a113 * b13 + a123 * b22 + a133 * b32;
				_this5.self._21 = a203 * b011 + a213 * b13 + a223 * b22 + a233 * b32;
				_this5.self._31 = a303 * b011 + a313 * b13 + a323 * b22 + a333 * b32;
				b011 = m6.self._02;
				b13 = m6.self._12;
				b22 = m6.self._22;
				b32 = m6.self._32;
				_this5.self._02 = a003 * b011 + a013 * b13 + a023 * b22 + a033 * b32;
				_this5.self._12 = a103 * b011 + a113 * b13 + a123 * b22 + a133 * b32;
				_this5.self._22 = a203 * b011 + a213 * b13 + a223 * b22 + a233 * b32;
				_this5.self._32 = a303 * b011 + a313 * b13 + a323 * b22 + a333 * b32;
				b011 = m6.self._03;
				b13 = m6.self._13;
				b22 = m6.self._23;
				b32 = m6.self._33;
				_this5.self._03 = a003 * b011 + a013 * b13 + a023 * b22 + a033 * b32;
				_this5.self._13 = a103 * b011 + a113 * b13 + a123 * b22 + a133 * b32;
				_this5.self._23 = a203 * b011 + a213 * b13 + a223 * b22 + a233 * b32;
				_this5.self._33 = a303 * b011 + a313 * b13 + a323 * b22 + a333 * b32;
				m = iron_object_Uniforms.helpMat;
				break;
			case "_worldViewProjectionMatrix":
				let _this6 = iron_object_Uniforms.helpMat;
				let m7 = object.transform.worldUnpack;
				_this6.self._00 = m7.self._00;
				_this6.self._01 = m7.self._01;
				_this6.self._02 = m7.self._02;
				_this6.self._03 = m7.self._03;
				_this6.self._10 = m7.self._10;
				_this6.self._11 = m7.self._11;
				_this6.self._12 = m7.self._12;
				_this6.self._13 = m7.self._13;
				_this6.self._20 = m7.self._20;
				_this6.self._21 = m7.self._21;
				_this6.self._22 = m7.self._22;
				_this6.self._23 = m7.self._23;
				_this6.self._30 = m7.self._30;
				_this6.self._31 = m7.self._31;
				_this6.self._32 = m7.self._32;
				_this6.self._33 = m7.self._33;
				let _this7 = iron_object_Uniforms.helpMat;
				let m8 = camera.V;
				let a004 = _this7.self._00;
				let a014 = _this7.self._01;
				let a024 = _this7.self._02;
				let a034 = _this7.self._03;
				let a104 = _this7.self._10;
				let a114 = _this7.self._11;
				let a124 = _this7.self._12;
				let a134 = _this7.self._13;
				let a204 = _this7.self._20;
				let a214 = _this7.self._21;
				let a224 = _this7.self._22;
				let a234 = _this7.self._23;
				let a304 = _this7.self._30;
				let a314 = _this7.self._31;
				let a324 = _this7.self._32;
				let a334 = _this7.self._33;
				let b012 = m8.self._00;
				let b14 = m8.self._10;
				let b23 = m8.self._20;
				let b33 = m8.self._30;
				_this7.self._00 = a004 * b012 + a014 * b14 + a024 * b23 + a034 * b33;
				_this7.self._10 = a104 * b012 + a114 * b14 + a124 * b23 + a134 * b33;
				_this7.self._20 = a204 * b012 + a214 * b14 + a224 * b23 + a234 * b33;
				_this7.self._30 = a304 * b012 + a314 * b14 + a324 * b23 + a334 * b33;
				b012 = m8.self._01;
				b14 = m8.self._11;
				b23 = m8.self._21;
				b33 = m8.self._31;
				_this7.self._01 = a004 * b012 + a014 * b14 + a024 * b23 + a034 * b33;
				_this7.self._11 = a104 * b012 + a114 * b14 + a124 * b23 + a134 * b33;
				_this7.self._21 = a204 * b012 + a214 * b14 + a224 * b23 + a234 * b33;
				_this7.self._31 = a304 * b012 + a314 * b14 + a324 * b23 + a334 * b33;
				b012 = m8.self._02;
				b14 = m8.self._12;
				b23 = m8.self._22;
				b33 = m8.self._32;
				_this7.self._02 = a004 * b012 + a014 * b14 + a024 * b23 + a034 * b33;
				_this7.self._12 = a104 * b012 + a114 * b14 + a124 * b23 + a134 * b33;
				_this7.self._22 = a204 * b012 + a214 * b14 + a224 * b23 + a234 * b33;
				_this7.self._32 = a304 * b012 + a314 * b14 + a324 * b23 + a334 * b33;
				b012 = m8.self._03;
				b14 = m8.self._13;
				b23 = m8.self._23;
				b33 = m8.self._33;
				_this7.self._03 = a004 * b012 + a014 * b14 + a024 * b23 + a034 * b33;
				_this7.self._13 = a104 * b012 + a114 * b14 + a124 * b23 + a134 * b33;
				_this7.self._23 = a204 * b012 + a214 * b14 + a224 * b23 + a234 * b33;
				_this7.self._33 = a304 * b012 + a314 * b14 + a324 * b23 + a334 * b33;
				let _this8 = iron_object_Uniforms.helpMat;
				let m9 = camera.P;
				let a005 = _this8.self._00;
				let a015 = _this8.self._01;
				let a025 = _this8.self._02;
				let a035 = _this8.self._03;
				let a105 = _this8.self._10;
				let a115 = _this8.self._11;
				let a125 = _this8.self._12;
				let a135 = _this8.self._13;
				let a205 = _this8.self._20;
				let a215 = _this8.self._21;
				let a225 = _this8.self._22;
				let a235 = _this8.self._23;
				let a305 = _this8.self._30;
				let a315 = _this8.self._31;
				let a325 = _this8.self._32;
				let a335 = _this8.self._33;
				let b013 = m9.self._00;
				let b15 = m9.self._10;
				let b24 = m9.self._20;
				let b34 = m9.self._30;
				_this8.self._00 = a005 * b013 + a015 * b15 + a025 * b24 + a035 * b34;
				_this8.self._10 = a105 * b013 + a115 * b15 + a125 * b24 + a135 * b34;
				_this8.self._20 = a205 * b013 + a215 * b15 + a225 * b24 + a235 * b34;
				_this8.self._30 = a305 * b013 + a315 * b15 + a325 * b24 + a335 * b34;
				b013 = m9.self._01;
				b15 = m9.self._11;
				b24 = m9.self._21;
				b34 = m9.self._31;
				_this8.self._01 = a005 * b013 + a015 * b15 + a025 * b24 + a035 * b34;
				_this8.self._11 = a105 * b013 + a115 * b15 + a125 * b24 + a135 * b34;
				_this8.self._21 = a205 * b013 + a215 * b15 + a225 * b24 + a235 * b34;
				_this8.self._31 = a305 * b013 + a315 * b15 + a325 * b24 + a335 * b34;
				b013 = m9.self._02;
				b15 = m9.self._12;
				b24 = m9.self._22;
				b34 = m9.self._32;
				_this8.self._02 = a005 * b013 + a015 * b15 + a025 * b24 + a035 * b34;
				_this8.self._12 = a105 * b013 + a115 * b15 + a125 * b24 + a135 * b34;
				_this8.self._22 = a205 * b013 + a215 * b15 + a225 * b24 + a235 * b34;
				_this8.self._32 = a305 * b013 + a315 * b15 + a325 * b24 + a335 * b34;
				b013 = m9.self._03;
				b15 = m9.self._13;
				b24 = m9.self._23;
				b34 = m9.self._33;
				_this8.self._03 = a005 * b013 + a015 * b15 + a025 * b24 + a035 * b34;
				_this8.self._13 = a105 * b013 + a115 * b15 + a125 * b24 + a135 * b34;
				_this8.self._23 = a205 * b013 + a215 * b15 + a225 * b24 + a235 * b34;
				_this8.self._33 = a305 * b013 + a315 * b15 + a325 * b24 + a335 * b34;
				m = iron_object_Uniforms.helpMat;
				break;
			case "_worldViewProjectionMatrixCylinder":
				let t = object.transform;
				let _this9 = iron_object_Uniforms.helpMat;
				let m10 = t.worldUnpack;
				_this9.self._00 = m10.self._00;
				_this9.self._01 = m10.self._01;
				_this9.self._02 = m10.self._02;
				_this9.self._03 = m10.self._03;
				_this9.self._10 = m10.self._10;
				_this9.self._11 = m10.self._11;
				_this9.self._12 = m10.self._12;
				_this9.self._13 = m10.self._13;
				_this9.self._20 = m10.self._20;
				_this9.self._21 = m10.self._21;
				_this9.self._22 = m10.self._22;
				_this9.self._23 = m10.self._23;
				_this9.self._30 = m10.self._30;
				_this9.self._31 = m10.self._31;
				_this9.self._32 = m10.self._32;
				_this9.self._33 = m10.self._33;
				let _this10 = iron_object_Uniforms.helpMat;
				let m11 = camera.V;
				let a006 = _this10.self._00;
				let a016 = _this10.self._01;
				let a026 = _this10.self._02;
				let a036 = _this10.self._03;
				let a106 = _this10.self._10;
				let a116 = _this10.self._11;
				let a126 = _this10.self._12;
				let a136 = _this10.self._13;
				let a206 = _this10.self._20;
				let a216 = _this10.self._21;
				let a226 = _this10.self._22;
				let a236 = _this10.self._23;
				let a306 = _this10.self._30;
				let a316 = _this10.self._31;
				let a326 = _this10.self._32;
				let a336 = _this10.self._33;
				let b014 = m11.self._00;
				let b16 = m11.self._10;
				let b25 = m11.self._20;
				let b35 = m11.self._30;
				_this10.self._00 = a006 * b014 + a016 * b16 + a026 * b25 + a036 * b35;
				_this10.self._10 = a106 * b014 + a116 * b16 + a126 * b25 + a136 * b35;
				_this10.self._20 = a206 * b014 + a216 * b16 + a226 * b25 + a236 * b35;
				_this10.self._30 = a306 * b014 + a316 * b16 + a326 * b25 + a336 * b35;
				b014 = m11.self._01;
				b16 = m11.self._11;
				b25 = m11.self._21;
				b35 = m11.self._31;
				_this10.self._01 = a006 * b014 + a016 * b16 + a026 * b25 + a036 * b35;
				_this10.self._11 = a106 * b014 + a116 * b16 + a126 * b25 + a136 * b35;
				_this10.self._21 = a206 * b014 + a216 * b16 + a226 * b25 + a236 * b35;
				_this10.self._31 = a306 * b014 + a316 * b16 + a326 * b25 + a336 * b35;
				b014 = m11.self._02;
				b16 = m11.self._12;
				b25 = m11.self._22;
				b35 = m11.self._32;
				_this10.self._02 = a006 * b014 + a016 * b16 + a026 * b25 + a036 * b35;
				_this10.self._12 = a106 * b014 + a116 * b16 + a126 * b25 + a136 * b35;
				_this10.self._22 = a206 * b014 + a216 * b16 + a226 * b25 + a236 * b35;
				_this10.self._32 = a306 * b014 + a316 * b16 + a326 * b25 + a336 * b35;
				b014 = m11.self._03;
				b16 = m11.self._13;
				b25 = m11.self._23;
				b35 = m11.self._33;
				_this10.self._03 = a006 * b014 + a016 * b16 + a026 * b25 + a036 * b35;
				_this10.self._13 = a106 * b014 + a116 * b16 + a126 * b25 + a136 * b35;
				_this10.self._23 = a206 * b014 + a216 * b16 + a226 * b25 + a236 * b35;
				_this10.self._33 = a306 * b014 + a316 * b16 + a326 * b25 + a336 * b35;
				let x = t.scale.x;
				let y = t.scale.y;
				let z = t.scale.z;
				if(z == null) {
					z = 0.0;
				}
				if(y == null) {
					y = 0.0;
				}
				if(x == null) {
					x = 0.0;
				}
				let scl_x = x;
				let scl_y = y;
				let f = t.scaleWorld;
				scl_x *= f;
				scl_y *= f;
				iron_object_Uniforms.helpMat.self._00 = scl_x;
				iron_object_Uniforms.helpMat.self._20 = 0.0;
				iron_object_Uniforms.helpMat.self._01 = 0.0;
				iron_object_Uniforms.helpMat.self._21 = 0.0;
				iron_object_Uniforms.helpMat.self._02 = 0.0;
				iron_object_Uniforms.helpMat.self._22 = scl_y;
				let _this11 = iron_object_Uniforms.helpMat;
				let m12 = camera.P;
				let a007 = _this11.self._00;
				let a017 = _this11.self._01;
				let a027 = _this11.self._02;
				let a037 = _this11.self._03;
				let a107 = _this11.self._10;
				let a117 = _this11.self._11;
				let a127 = _this11.self._12;
				let a137 = _this11.self._13;
				let a207 = _this11.self._20;
				let a217 = _this11.self._21;
				let a227 = _this11.self._22;
				let a237 = _this11.self._23;
				let a307 = _this11.self._30;
				let a317 = _this11.self._31;
				let a327 = _this11.self._32;
				let a337 = _this11.self._33;
				let b015 = m12.self._00;
				let b17 = m12.self._10;
				let b26 = m12.self._20;
				let b36 = m12.self._30;
				_this11.self._00 = a007 * b015 + a017 * b17 + a027 * b26 + a037 * b36;
				_this11.self._10 = a107 * b015 + a117 * b17 + a127 * b26 + a137 * b36;
				_this11.self._20 = a207 * b015 + a217 * b17 + a227 * b26 + a237 * b36;
				_this11.self._30 = a307 * b015 + a317 * b17 + a327 * b26 + a337 * b36;
				b015 = m12.self._01;
				b17 = m12.self._11;
				b26 = m12.self._21;
				b36 = m12.self._31;
				_this11.self._01 = a007 * b015 + a017 * b17 + a027 * b26 + a037 * b36;
				_this11.self._11 = a107 * b015 + a117 * b17 + a127 * b26 + a137 * b36;
				_this11.self._21 = a207 * b015 + a217 * b17 + a227 * b26 + a237 * b36;
				_this11.self._31 = a307 * b015 + a317 * b17 + a327 * b26 + a337 * b36;
				b015 = m12.self._02;
				b17 = m12.self._12;
				b26 = m12.self._22;
				b36 = m12.self._32;
				_this11.self._02 = a007 * b015 + a017 * b17 + a027 * b26 + a037 * b36;
				_this11.self._12 = a107 * b015 + a117 * b17 + a127 * b26 + a137 * b36;
				_this11.self._22 = a207 * b015 + a217 * b17 + a227 * b26 + a237 * b36;
				_this11.self._32 = a307 * b015 + a317 * b17 + a327 * b26 + a337 * b36;
				b015 = m12.self._03;
				b17 = m12.self._13;
				b26 = m12.self._23;
				b36 = m12.self._33;
				_this11.self._03 = a007 * b015 + a017 * b17 + a027 * b26 + a037 * b36;
				_this11.self._13 = a107 * b015 + a117 * b17 + a127 * b26 + a137 * b36;
				_this11.self._23 = a207 * b015 + a217 * b17 + a227 * b26 + a237 * b36;
				_this11.self._33 = a307 * b015 + a317 * b17 + a327 * b26 + a337 * b36;
				m = iron_object_Uniforms.helpMat;
				break;
			case "_worldViewProjectionMatrixSphere":
				let t1 = object.transform;
				let _this12 = iron_object_Uniforms.helpMat;
				let m13 = t1.worldUnpack;
				_this12.self._00 = m13.self._00;
				_this12.self._01 = m13.self._01;
				_this12.self._02 = m13.self._02;
				_this12.self._03 = m13.self._03;
				_this12.self._10 = m13.self._10;
				_this12.self._11 = m13.self._11;
				_this12.self._12 = m13.self._12;
				_this12.self._13 = m13.self._13;
				_this12.self._20 = m13.self._20;
				_this12.self._21 = m13.self._21;
				_this12.self._22 = m13.self._22;
				_this12.self._23 = m13.self._23;
				_this12.self._30 = m13.self._30;
				_this12.self._31 = m13.self._31;
				_this12.self._32 = m13.self._32;
				_this12.self._33 = m13.self._33;
				let _this13 = iron_object_Uniforms.helpMat;
				let m14 = camera.V;
				let a008 = _this13.self._00;
				let a018 = _this13.self._01;
				let a028 = _this13.self._02;
				let a038 = _this13.self._03;
				let a108 = _this13.self._10;
				let a118 = _this13.self._11;
				let a128 = _this13.self._12;
				let a138 = _this13.self._13;
				let a208 = _this13.self._20;
				let a218 = _this13.self._21;
				let a228 = _this13.self._22;
				let a238 = _this13.self._23;
				let a308 = _this13.self._30;
				let a318 = _this13.self._31;
				let a328 = _this13.self._32;
				let a338 = _this13.self._33;
				let b016 = m14.self._00;
				let b18 = m14.self._10;
				let b27 = m14.self._20;
				let b37 = m14.self._30;
				_this13.self._00 = a008 * b016 + a018 * b18 + a028 * b27 + a038 * b37;
				_this13.self._10 = a108 * b016 + a118 * b18 + a128 * b27 + a138 * b37;
				_this13.self._20 = a208 * b016 + a218 * b18 + a228 * b27 + a238 * b37;
				_this13.self._30 = a308 * b016 + a318 * b18 + a328 * b27 + a338 * b37;
				b016 = m14.self._01;
				b18 = m14.self._11;
				b27 = m14.self._21;
				b37 = m14.self._31;
				_this13.self._01 = a008 * b016 + a018 * b18 + a028 * b27 + a038 * b37;
				_this13.self._11 = a108 * b016 + a118 * b18 + a128 * b27 + a138 * b37;
				_this13.self._21 = a208 * b016 + a218 * b18 + a228 * b27 + a238 * b37;
				_this13.self._31 = a308 * b016 + a318 * b18 + a328 * b27 + a338 * b37;
				b016 = m14.self._02;
				b18 = m14.self._12;
				b27 = m14.self._22;
				b37 = m14.self._32;
				_this13.self._02 = a008 * b016 + a018 * b18 + a028 * b27 + a038 * b37;
				_this13.self._12 = a108 * b016 + a118 * b18 + a128 * b27 + a138 * b37;
				_this13.self._22 = a208 * b016 + a218 * b18 + a228 * b27 + a238 * b37;
				_this13.self._32 = a308 * b016 + a318 * b18 + a328 * b27 + a338 * b37;
				b016 = m14.self._03;
				b18 = m14.self._13;
				b27 = m14.self._23;
				b37 = m14.self._33;
				_this13.self._03 = a008 * b016 + a018 * b18 + a028 * b27 + a038 * b37;
				_this13.self._13 = a108 * b016 + a118 * b18 + a128 * b27 + a138 * b37;
				_this13.self._23 = a208 * b016 + a218 * b18 + a228 * b27 + a238 * b37;
				_this13.self._33 = a308 * b016 + a318 * b18 + a328 * b27 + a338 * b37;
				let x1 = t1.scale.x;
				let y1 = t1.scale.y;
				let z1 = t1.scale.z;
				if(z1 == null) {
					z1 = 0.0;
				}
				if(y1 == null) {
					y1 = 0.0;
				}
				if(x1 == null) {
					x1 = 0.0;
				}
				let scl_x1 = x1;
				let scl_y1 = y1;
				let scl_z = z1;
				let f1 = t1.scaleWorld;
				scl_x1 *= f1;
				scl_y1 *= f1;
				scl_z *= f1;
				iron_object_Uniforms.helpMat.self._00 = scl_x1;
				iron_object_Uniforms.helpMat.self._10 = 0.0;
				iron_object_Uniforms.helpMat.self._20 = 0.0;
				iron_object_Uniforms.helpMat.self._01 = 0.0;
				iron_object_Uniforms.helpMat.self._11 = scl_y1;
				iron_object_Uniforms.helpMat.self._21 = 0.0;
				iron_object_Uniforms.helpMat.self._02 = 0.0;
				iron_object_Uniforms.helpMat.self._12 = 0.0;
				iron_object_Uniforms.helpMat.self._22 = scl_z;
				let _this14 = iron_object_Uniforms.helpMat;
				let m15 = camera.P;
				let a009 = _this14.self._00;
				let a019 = _this14.self._01;
				let a029 = _this14.self._02;
				let a039 = _this14.self._03;
				let a109 = _this14.self._10;
				let a119 = _this14.self._11;
				let a129 = _this14.self._12;
				let a139 = _this14.self._13;
				let a209 = _this14.self._20;
				let a219 = _this14.self._21;
				let a229 = _this14.self._22;
				let a239 = _this14.self._23;
				let a309 = _this14.self._30;
				let a319 = _this14.self._31;
				let a329 = _this14.self._32;
				let a339 = _this14.self._33;
				let b017 = m15.self._00;
				let b19 = m15.self._10;
				let b28 = m15.self._20;
				let b38 = m15.self._30;
				_this14.self._00 = a009 * b017 + a019 * b19 + a029 * b28 + a039 * b38;
				_this14.self._10 = a109 * b017 + a119 * b19 + a129 * b28 + a139 * b38;
				_this14.self._20 = a209 * b017 + a219 * b19 + a229 * b28 + a239 * b38;
				_this14.self._30 = a309 * b017 + a319 * b19 + a329 * b28 + a339 * b38;
				b017 = m15.self._01;
				b19 = m15.self._11;
				b28 = m15.self._21;
				b38 = m15.self._31;
				_this14.self._01 = a009 * b017 + a019 * b19 + a029 * b28 + a039 * b38;
				_this14.self._11 = a109 * b017 + a119 * b19 + a129 * b28 + a139 * b38;
				_this14.self._21 = a209 * b017 + a219 * b19 + a229 * b28 + a239 * b38;
				_this14.self._31 = a309 * b017 + a319 * b19 + a329 * b28 + a339 * b38;
				b017 = m15.self._02;
				b19 = m15.self._12;
				b28 = m15.self._22;
				b38 = m15.self._32;
				_this14.self._02 = a009 * b017 + a019 * b19 + a029 * b28 + a039 * b38;
				_this14.self._12 = a109 * b017 + a119 * b19 + a129 * b28 + a139 * b38;
				_this14.self._22 = a209 * b017 + a219 * b19 + a229 * b28 + a239 * b38;
				_this14.self._32 = a309 * b017 + a319 * b19 + a329 * b28 + a339 * b38;
				b017 = m15.self._03;
				b19 = m15.self._13;
				b28 = m15.self._23;
				b38 = m15.self._33;
				_this14.self._03 = a009 * b017 + a019 * b19 + a029 * b28 + a039 * b38;
				_this14.self._13 = a109 * b017 + a119 * b19 + a129 * b28 + a139 * b38;
				_this14.self._23 = a209 * b017 + a219 * b19 + a229 * b28 + a239 * b38;
				_this14.self._33 = a309 * b017 + a319 * b19 + a329 * b28 + a339 * b38;
				m = iron_object_Uniforms.helpMat;
				break;
			}
			if(m == null) {
				if(c.link.startsWith("_biasLightWorldViewProjectionMatrixSpot")) {
					let light = iron_object_Uniforms.getSpot(HxOverrides.cca(c.link,c.link.length - 1) - 48);
					if(light != null) {
						if(object == null) {
							let _this = iron_object_Uniforms.helpMat;
							_this.self._00 = 1.0;
							_this.self._01 = 0.0;
							_this.self._02 = 0.0;
							_this.self._03 = 0.0;
							_this.self._10 = 0.0;
							_this.self._11 = 1.0;
							_this.self._12 = 0.0;
							_this.self._13 = 0.0;
							_this.self._20 = 0.0;
							_this.self._21 = 0.0;
							_this.self._22 = 1.0;
							_this.self._23 = 0.0;
							_this.self._30 = 0.0;
							_this.self._31 = 0.0;
							_this.self._32 = 0.0;
							_this.self._33 = 1.0;
						} else {
							let _this = iron_object_Uniforms.helpMat;
							let m = object.transform.worldUnpack;
							_this.self._00 = m.self._00;
							_this.self._01 = m.self._01;
							_this.self._02 = m.self._02;
							_this.self._03 = m.self._03;
							_this.self._10 = m.self._10;
							_this.self._11 = m.self._11;
							_this.self._12 = m.self._12;
							_this.self._13 = m.self._13;
							_this.self._20 = m.self._20;
							_this.self._21 = m.self._21;
							_this.self._22 = m.self._22;
							_this.self._23 = m.self._23;
							_this.self._30 = m.self._30;
							_this.self._31 = m.self._31;
							_this.self._32 = m.self._32;
							_this.self._33 = m.self._33;
						}
						let _this = iron_object_Uniforms.helpMat;
						let m1 = light.VP;
						let a00 = _this.self._00;
						let a01 = _this.self._01;
						let a02 = _this.self._02;
						let a03 = _this.self._03;
						let a10 = _this.self._10;
						let a11 = _this.self._11;
						let a12 = _this.self._12;
						let a13 = _this.self._13;
						let a20 = _this.self._20;
						let a21 = _this.self._21;
						let a22 = _this.self._22;
						let a23 = _this.self._23;
						let a30 = _this.self._30;
						let a31 = _this.self._31;
						let a32 = _this.self._32;
						let a33 = _this.self._33;
						let b0 = m1.self._00;
						let b1 = m1.self._10;
						let b2 = m1.self._20;
						let b3 = m1.self._30;
						_this.self._00 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
						_this.self._10 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
						_this.self._20 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
						_this.self._30 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
						b0 = m1.self._01;
						b1 = m1.self._11;
						b2 = m1.self._21;
						b3 = m1.self._31;
						_this.self._01 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
						_this.self._11 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
						_this.self._21 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
						_this.self._31 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
						b0 = m1.self._02;
						b1 = m1.self._12;
						b2 = m1.self._22;
						b3 = m1.self._32;
						_this.self._02 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
						_this.self._12 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
						_this.self._22 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
						_this.self._32 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
						b0 = m1.self._03;
						b1 = m1.self._13;
						b2 = m1.self._23;
						b3 = m1.self._33;
						_this.self._03 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
						_this.self._13 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
						_this.self._23 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
						_this.self._33 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
						let _this1 = iron_object_Uniforms.helpMat;
						let m2 = iron_object_Uniforms.biasMat;
						let a001 = _this1.self._00;
						let a011 = _this1.self._01;
						let a021 = _this1.self._02;
						let a031 = _this1.self._03;
						let a101 = _this1.self._10;
						let a111 = _this1.self._11;
						let a121 = _this1.self._12;
						let a131 = _this1.self._13;
						let a201 = _this1.self._20;
						let a211 = _this1.self._21;
						let a221 = _this1.self._22;
						let a231 = _this1.self._23;
						let a301 = _this1.self._30;
						let a311 = _this1.self._31;
						let a321 = _this1.self._32;
						let a331 = _this1.self._33;
						let b01 = m2.self._00;
						let b11 = m2.self._10;
						let b21 = m2.self._20;
						let b31 = m2.self._30;
						_this1.self._00 = a001 * b01 + a011 * b11 + a021 * b21 + a031 * b31;
						_this1.self._10 = a101 * b01 + a111 * b11 + a121 * b21 + a131 * b31;
						_this1.self._20 = a201 * b01 + a211 * b11 + a221 * b21 + a231 * b31;
						_this1.self._30 = a301 * b01 + a311 * b11 + a321 * b21 + a331 * b31;
						b01 = m2.self._01;
						b11 = m2.self._11;
						b21 = m2.self._21;
						b31 = m2.self._31;
						_this1.self._01 = a001 * b01 + a011 * b11 + a021 * b21 + a031 * b31;
						_this1.self._11 = a101 * b01 + a111 * b11 + a121 * b21 + a131 * b31;
						_this1.self._21 = a201 * b01 + a211 * b11 + a221 * b21 + a231 * b31;
						_this1.self._31 = a301 * b01 + a311 * b11 + a321 * b21 + a331 * b31;
						b01 = m2.self._02;
						b11 = m2.self._12;
						b21 = m2.self._22;
						b31 = m2.self._32;
						_this1.self._02 = a001 * b01 + a011 * b11 + a021 * b21 + a031 * b31;
						_this1.self._12 = a101 * b01 + a111 * b11 + a121 * b21 + a131 * b31;
						_this1.self._22 = a201 * b01 + a211 * b11 + a221 * b21 + a231 * b31;
						_this1.self._32 = a301 * b01 + a311 * b11 + a321 * b21 + a331 * b31;
						b01 = m2.self._03;
						b11 = m2.self._13;
						b21 = m2.self._23;
						b31 = m2.self._33;
						_this1.self._03 = a001 * b01 + a011 * b11 + a021 * b21 + a031 * b31;
						_this1.self._13 = a101 * b01 + a111 * b11 + a121 * b21 + a131 * b31;
						_this1.self._23 = a201 * b01 + a211 * b11 + a221 * b21 + a231 * b31;
						_this1.self._33 = a301 * b01 + a311 * b11 + a321 * b21 + a331 * b31;
						m = iron_object_Uniforms.helpMat;
					}
				}
				if(c.link.startsWith("_biasLightViewProjectionMatrixSpot")) {
					let light = iron_object_Uniforms.getSpot(HxOverrides.cca(c.link,c.link.length - 1) - 48);
					if(light != null) {
						let _this = iron_object_Uniforms.helpMat;
						let m1 = light.VP;
						_this.self._00 = m1.self._00;
						_this.self._01 = m1.self._01;
						_this.self._02 = m1.self._02;
						_this.self._03 = m1.self._03;
						_this.self._10 = m1.self._10;
						_this.self._11 = m1.self._11;
						_this.self._12 = m1.self._12;
						_this.self._13 = m1.self._13;
						_this.self._20 = m1.self._20;
						_this.self._21 = m1.self._21;
						_this.self._22 = m1.self._22;
						_this.self._23 = m1.self._23;
						_this.self._30 = m1.self._30;
						_this.self._31 = m1.self._31;
						_this.self._32 = m1.self._32;
						_this.self._33 = m1.self._33;
						let _this1 = iron_object_Uniforms.helpMat;
						let m2 = iron_object_Uniforms.biasMat;
						let a00 = _this1.self._00;
						let a01 = _this1.self._01;
						let a02 = _this1.self._02;
						let a03 = _this1.self._03;
						let a10 = _this1.self._10;
						let a11 = _this1.self._11;
						let a12 = _this1.self._12;
						let a13 = _this1.self._13;
						let a20 = _this1.self._20;
						let a21 = _this1.self._21;
						let a22 = _this1.self._22;
						let a23 = _this1.self._23;
						let a30 = _this1.self._30;
						let a31 = _this1.self._31;
						let a32 = _this1.self._32;
						let a33 = _this1.self._33;
						let b0 = m2.self._00;
						let b1 = m2.self._10;
						let b2 = m2.self._20;
						let b3 = m2.self._30;
						_this1.self._00 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
						_this1.self._10 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
						_this1.self._20 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
						_this1.self._30 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
						b0 = m2.self._01;
						b1 = m2.self._11;
						b2 = m2.self._21;
						b3 = m2.self._31;
						_this1.self._01 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
						_this1.self._11 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
						_this1.self._21 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
						_this1.self._31 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
						b0 = m2.self._02;
						b1 = m2.self._12;
						b2 = m2.self._22;
						b3 = m2.self._32;
						_this1.self._02 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
						_this1.self._12 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
						_this1.self._22 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
						_this1.self._32 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
						b0 = m2.self._03;
						b1 = m2.self._13;
						b2 = m2.self._23;
						b3 = m2.self._33;
						_this1.self._03 = a00 * b0 + a01 * b1 + a02 * b2 + a03 * b3;
						_this1.self._13 = a10 * b0 + a11 * b1 + a12 * b2 + a13 * b3;
						_this1.self._23 = a20 * b0 + a21 * b1 + a22 * b2 + a23 * b3;
						_this1.self._33 = a30 * b0 + a31 * b1 + a32 * b2 + a33 * b3;
						m = iron_object_Uniforms.helpMat;
					}
				}
			}
			if(m == null && iron_object_Uniforms.externalMat4Links != null) {
				let _g = 0;
				let _g1 = iron_object_Uniforms.externalMat4Links;
				while(_g < _g1.length) {
					m = _g1[_g++](object,iron_object_Uniforms.currentMat(object),c.link);
					if(m != null) {
						break;
					}
				}
			}
			if(m == null) {
				return;
			}
			let matrix = m.self;
			kha_graphics4_Graphics.mat[0] = matrix._00;
			kha_graphics4_Graphics.mat[1] = matrix._01;
			kha_graphics4_Graphics.mat[2] = matrix._02;
			kha_graphics4_Graphics.mat[3] = matrix._03;
			kha_graphics4_Graphics.mat[4] = matrix._10;
			kha_graphics4_Graphics.mat[5] = matrix._11;
			kha_graphics4_Graphics.mat[6] = matrix._12;
			kha_graphics4_Graphics.mat[7] = matrix._13;
			kha_graphics4_Graphics.mat[8] = matrix._20;
			kha_graphics4_Graphics.mat[9] = matrix._21;
			kha_graphics4_Graphics.mat[10] = matrix._22;
			kha_graphics4_Graphics.mat[11] = matrix._23;
			kha_graphics4_Graphics.mat[12] = matrix._30;
			kha_graphics4_Graphics.mat[13] = matrix._31;
			kha_graphics4_Graphics.mat[14] = matrix._32;
			kha_graphics4_Graphics.mat[15] = matrix._33;
			Krom.setMatrix(location,kha_graphics4_Graphics.mat.buffer);
		} else if(c.type == "mat3") {
			let m = null;
			switch(c.link) {
			case "_normalMatrix":
				let _this = iron_object_Uniforms.helpMat;
				let m1 = object.transform.world;
				let a00 = m1.self._00;
				let a01 = m1.self._01;
				let a02 = m1.self._02;
				let a03 = m1.self._03;
				let a10 = m1.self._10;
				let a11 = m1.self._11;
				let a12 = m1.self._12;
				let a13 = m1.self._13;
				let a20 = m1.self._20;
				let a21 = m1.self._21;
				let a22 = m1.self._22;
				let a23 = m1.self._23;
				let a30 = m1.self._30;
				let a31 = m1.self._31;
				let a32 = m1.self._32;
				let a33 = m1.self._33;
				let b00 = a00 * a11 - a01 * a10;
				let b01 = a00 * a12 - a02 * a10;
				let b02 = a00 * a13 - a03 * a10;
				let b03 = a01 * a12 - a02 * a11;
				let b04 = a01 * a13 - a03 * a11;
				let b05 = a02 * a13 - a03 * a12;
				let b06 = a20 * a31 - a21 * a30;
				let b07 = a20 * a32 - a22 * a30;
				let b08 = a20 * a33 - a23 * a30;
				let b09 = a21 * a32 - a22 * a31;
				let b10 = a21 * a33 - a23 * a31;
				let b11 = a22 * a33 - a23 * a32;
				let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
				if(det == 0.0) {
					_this.self._00 = 1.0;
					_this.self._01 = 0.0;
					_this.self._02 = 0.0;
					_this.self._03 = 0.0;
					_this.self._10 = 0.0;
					_this.self._11 = 1.0;
					_this.self._12 = 0.0;
					_this.self._13 = 0.0;
					_this.self._20 = 0.0;
					_this.self._21 = 0.0;
					_this.self._22 = 1.0;
					_this.self._23 = 0.0;
					_this.self._30 = 0.0;
					_this.self._31 = 0.0;
					_this.self._32 = 0.0;
					_this.self._33 = 1.0;
				} else {
					det = 1.0 / det;
					_this.self._00 = (a11 * b11 - a12 * b10 + a13 * b09) * det;
					_this.self._01 = (a02 * b10 - a01 * b11 - a03 * b09) * det;
					_this.self._02 = (a31 * b05 - a32 * b04 + a33 * b03) * det;
					_this.self._03 = (a22 * b04 - a21 * b05 - a23 * b03) * det;
					_this.self._10 = (a12 * b08 - a10 * b11 - a13 * b07) * det;
					_this.self._11 = (a00 * b11 - a02 * b08 + a03 * b07) * det;
					_this.self._12 = (a32 * b02 - a30 * b05 - a33 * b01) * det;
					_this.self._13 = (a20 * b05 - a22 * b02 + a23 * b01) * det;
					_this.self._20 = (a10 * b10 - a11 * b08 + a13 * b06) * det;
					_this.self._21 = (a01 * b08 - a00 * b10 - a03 * b06) * det;
					_this.self._22 = (a30 * b04 - a31 * b02 + a33 * b00) * det;
					_this.self._23 = (a21 * b02 - a20 * b04 - a23 * b00) * det;
					_this.self._30 = (a11 * b07 - a10 * b09 - a12 * b06) * det;
					_this.self._31 = (a00 * b09 - a01 * b07 + a02 * b06) * det;
					_this.self._32 = (a31 * b01 - a30 * b03 - a32 * b00) * det;
					_this.self._33 = (a20 * b03 - a21 * b01 + a22 * b00) * det;
				}
				let _this1 = iron_object_Uniforms.helpMat;
				let f = _this1.self._01;
				_this1.self._01 = _this1.self._10;
				_this1.self._10 = f;
				f = _this1.self._02;
				_this1.self._02 = _this1.self._20;
				_this1.self._20 = f;
				f = _this1.self._12;
				_this1.self._12 = _this1.self._21;
				_this1.self._21 = f;
				let _this2 = iron_object_Uniforms.helpMat3;
				let m2 = iron_object_Uniforms.helpMat;
				_this2.self._00 = m2.self._00;
				_this2.self._01 = m2.self._01;
				_this2.self._02 = m2.self._02;
				_this2.self._10 = m2.self._10;
				_this2.self._11 = m2.self._11;
				_this2.self._12 = m2.self._12;
				_this2.self._20 = m2.self._20;
				_this2.self._21 = m2.self._21;
				_this2.self._22 = m2.self._22;
				m = iron_object_Uniforms.helpMat3;
				break;
			case "_viewMatrix3":
				let _this3 = iron_object_Uniforms.helpMat3;
				let m3 = camera.V;
				_this3.self._00 = m3.self._00;
				_this3.self._01 = m3.self._01;
				_this3.self._02 = m3.self._02;
				_this3.self._10 = m3.self._10;
				_this3.self._11 = m3.self._11;
				_this3.self._12 = m3.self._12;
				_this3.self._20 = m3.self._20;
				_this3.self._21 = m3.self._21;
				_this3.self._22 = m3.self._22;
				m = iron_object_Uniforms.helpMat3;
				break;
			}
			if(m == null) {
				return;
			}
			let matrix = m.self;
			kha_graphics4_Graphics.mat[0] = matrix._00;
			kha_graphics4_Graphics.mat[1] = matrix._01;
			kha_graphics4_Graphics.mat[2] = matrix._02;
			kha_graphics4_Graphics.mat[3] = matrix._10;
			kha_graphics4_Graphics.mat[4] = matrix._11;
			kha_graphics4_Graphics.mat[5] = matrix._12;
			kha_graphics4_Graphics.mat[6] = matrix._20;
			kha_graphics4_Graphics.mat[7] = matrix._21;
			kha_graphics4_Graphics.mat[8] = matrix._22;
			Krom.setMatrix3(location,kha_graphics4_Graphics.mat.buffer);
		} else if(c.type == "vec4") {
			let v = null;
			let _this = iron_object_Uniforms.helpVec;
			_this.x = 0;
			_this.y = 0;
			_this.z = 0;
			_this.w = 1.0;
			if(iron_object_Uniforms.externalVec4Links != null) {
				let _g = 0;
				let _g1 = iron_object_Uniforms.externalVec4Links;
				while(_g < _g1.length) {
					v = _g1[_g++](object,iron_object_Uniforms.currentMat(object),c.link);
					if(v != null) {
						break;
					}
				}
			}
			if(v == null) {
				return;
			}
			g.setFloat4(location,v.x,v.y,v.z,v.w);
		} else if(c.type == "vec3") {
			let v = null;
			let _this = iron_object_Uniforms.helpVec;
			_this.x = 0;
			_this.y = 0;
			_this.z = 0;
			_this.w = 1.0;
			switch(c.link) {
			case "_dim":
				let d = object.transform.dim;
				let s = object.transform.scale;
				let _this1 = iron_object_Uniforms.helpVec;
				_this1.x = d.x / s.x;
				_this1.y = d.y / s.y;
				_this1.z = d.z / s.z;
				_this1.w = 1.0;
				v = iron_object_Uniforms.helpVec;
				break;
			case "_halfDim":
				let d1 = object.transform.dim;
				let s1 = object.transform.scale;
				let _this2 = iron_object_Uniforms.helpVec;
				_this2.x = d1.x / s1.x / 2;
				_this2.y = d1.y / s1.y / 2;
				_this2.z = d1.z / s1.z / 2;
				_this2.w = 1.0;
				v = iron_object_Uniforms.helpVec;
				break;
			}
			if(v == null && iron_object_Uniforms.externalVec3Links != null) {
				let _g = 0;
				let _g1 = iron_object_Uniforms.externalVec3Links;
				while(_g < _g1.length) {
					v = _g1[_g++](object,iron_object_Uniforms.currentMat(object),c.link);
					if(v != null) {
						break;
					}
				}
			}
			if(v == null) {
				return;
			}
			g.setFloat3(location,v.x,v.y,v.z);
		} else if(c.type == "vec2") {
			let vx = null;
			let vy = null;
			if(c.link == "_tilesheetOffset") {
				let ts = (js_Boot.__cast(object , iron_object_MeshObject)).tilesheet;
				vx = ts.tileX;
				vy = ts.tileY;
			}
			if(vx == null && iron_object_Uniforms.externalVec2Links != null) {
				let _g = 0;
				let _g1 = iron_object_Uniforms.externalVec2Links;
				while(_g < _g1.length) {
					let v = _g1[_g++](object,iron_object_Uniforms.currentMat(object),c.link);
					if(v != null) {
						vx = v.x;
						vy = v.y;
						break;
					}
				}
			}
			if(vx == null) {
				return;
			}
			g.setFloat2(location,vx,vy);
		} else if(c.type == "float") {
			let f = null;
			switch(c.link) {
			case "_objectInfoIndex":
				f = object.uid;
				break;
			case "_objectInfoMaterialIndex":
				f = iron_object_Uniforms.currentMat(object).uid;
				break;
			case "_objectInfoRandom":
				f = object.urandom;
				break;
			case "_posUnpack":
				f = iron_object_Uniforms.posUnpack != null ? iron_object_Uniforms.posUnpack : 1.0;
				break;
			case "_texUnpack":
				f = iron_object_Uniforms.texUnpack != null ? iron_object_Uniforms.texUnpack : 1.0;
				break;
			}
			if(f == null && iron_object_Uniforms.externalFloatLinks != null) {
				let _g = 0;
				let _g1 = iron_object_Uniforms.externalFloatLinks;
				while(_g < _g1.length) {
					let res = _g1[_g++](object,iron_object_Uniforms.currentMat(object),c.link);
					if(res != null) {
						f = res;
						break;
					}
				}
			}
			if(f == null) {
				return;
			}
			g.setFloat(location,f);
		} else if(c.type == "floats") {
			let fa = null;
			if(iron_object_Uniforms.externalFloatsLinks != null) {
				let _g = 0;
				let _g1 = iron_object_Uniforms.externalFloatsLinks;
				while(_g < _g1.length) {
					fa = _g1[_g++](object,iron_object_Uniforms.currentMat(object),c.link);
					if(fa != null) {
						break;
					}
				}
			}
			if(fa == null) {
				return;
			}
			g.setFloats(location,fa);
		} else if(c.type == "int") {
			let i = null;
			if(c.link == "_uid") {
				i = object.uid;
			}
			if(i == null && iron_object_Uniforms.externalIntLinks != null) {
				let _g = 0;
				let _g1 = iron_object_Uniforms.externalIntLinks;
				while(_g < _g1.length) {
					let res = _g1[_g++](object,iron_object_Uniforms.currentMat(object),c.link);
					if(res != null) {
						i = res;
						break;
					}
				}
			}
			if(i == null) {
				return;
			}
			g.setInt(location,i);
		}
	}
	static setMaterialConstants(g,context,materialContext) {
		if(materialContext.raw.bind_constants != null) {
			let _g = 0;
			let _g1 = materialContext.raw.bind_constants.length;
			while(_g < _g1) {
				let matc = materialContext.raw.bind_constants[_g++];
				let pos = -1;
				let _g1 = 0;
				let _g2 = context.raw.constants.length;
				while(_g1 < _g2) {
					let i = _g1++;
					if(context.raw.constants[i].name == matc.name) {
						pos = i;
						break;
					}
				}
				if(pos == -1) {
					continue;
				}
				iron_object_Uniforms.setMaterialConstant(g,context.constants[pos],context.raw.constants[pos],matc);
			}
		}
		if(materialContext.textures != null) {
			let _g = 0;
			let _g1 = materialContext.textures.length;
			while(_g < _g1) {
				let i = _g++;
				let mname = materialContext.raw.bind_textures[i].name;
				let _g1 = 0;
				let _g2 = context.textureUnits.length;
				while(_g1 < _g2) {
					let j = _g1++;
					if(mname == context.raw.texture_units[j].name) {
						g.setTexture(context.textureUnits[j],materialContext.textures[i]);
						materialContext.setTextureParameters(g,i,context,j);
						break;
					}
				}
			}
		}
	}
	static getSpot(index) {
		let i = 0;
		let _g = 0;
		let _g1 = iron_Scene.active.lights;
		while(_g < _g1.length) {
			let l = _g1[_g];
			++_g;
			if(l.data.raw.type != "spot" && l.data.raw.type != "area") {
				continue;
			}
			if(i == index) {
				return l;
			}
			++i;
		}
		return null;
	}
	static currentMat(object) {
		if(object != null && ((object) instanceof iron_object_MeshObject)) {
			let mo = js_Boot.__cast(object , iron_object_MeshObject);
			return mo.materials[mo.materialIndex];
		}
		return null;
	}
	static setMaterialConstant(g,location,c,matc) {
		switch(c.type) {
		case "bool":
			g.setBool(location,matc.bool);
			break;
		case "float":
			g.setFloat(location,matc.float);
			break;
		case "int":
			g.setInt(location,matc.int);
			break;
		case "vec2":
			g.setFloat2(location,matc.vec2[0],matc.vec2[1]);
			break;
		case "vec3":
			g.setFloat3(location,matc.vec3[0],matc.vec3[1],matc.vec3[2]);
			break;
		case "vec4":
			g.setFloat4(location,matc.vec4[0],matc.vec4[1],matc.vec4[2],matc.vec4[3]);
			break;
		}
	}
}
$hxClasses["iron.object.Uniforms"] = iron_object_Uniforms;
iron_object_Uniforms.__name__ = "iron.object.Uniforms";
class iron_system_VirtualButton {
	constructor() {
		this.down = false;
		this.released = false;
		this.started = false;
	}
}
$hxClasses["iron.system.VirtualButton"] = iron_system_VirtualButton;
iron_system_VirtualButton.__name__ = "iron.system.VirtualButton";
Object.assign(iron_system_VirtualButton.prototype, {
	__class__: iron_system_VirtualButton
});
class iron_system_VirtualInput {
	constructor() {
		if(iron_system_VirtualInput._hx_skip_constructor) {
			return;
		}
		this._hx_constructor();
	}
	_hx_constructor() {
		this.virtualButtons = null;
	}
	downVirtual(button) {
		if(this.virtualButtons != null) {
			let vb = this.virtualButtons.h[button];
			if(vb != null) {
				vb.down = true;
				vb.started = true;
			}
		}
	}
	upVirtual(button) {
		if(this.virtualButtons != null) {
			let vb = this.virtualButtons.h[button];
			if(vb != null) {
				vb.down = false;
				vb.released = true;
			}
		}
	}
}
$hxClasses["iron.system.VirtualInput"] = iron_system_VirtualInput;
iron_system_VirtualInput.__name__ = "iron.system.VirtualInput";
Object.assign(iron_system_VirtualInput.prototype, {
	__class__: iron_system_VirtualInput
});
class iron_system_Mouse extends iron_system_VirtualInput {
	constructor() {
		iron_system_VirtualInput._hx_skip_constructor = true;
		super();
		iron_system_VirtualInput._hx_skip_constructor = false;
		this._hx_constructor();
	}
	_hx_constructor() {
		this.lastY = -1.0;
		this.lastX = -1.0;
		this.hidden = false;
		this.locked = false;
		this.wheelDelta = 0;
		this.movementY = 0.0;
		this.movementX = 0.0;
		this.moved = false;
		this.y = 0.0;
		this.x = 0.0;
		this.buttonsReleased = [false,false,false];
		this.buttonsStarted = [false,false,false];
		this.buttonsDown = [false,false,false];
		super._hx_constructor();
		kha_input_Mouse.get().notify($bind(this,this.downListener),$bind(this,this.upListener),$bind(this,this.moveListener),$bind(this,this.wheelListener));
	}
	endFrame() {
		this.buttonsStarted[1] = this.buttonsStarted[2] = false;
		this.buttonsStarted[0] = false;
		this.buttonsReleased[1] = this.buttonsReleased[2] = false;
		this.buttonsReleased[0] = false;
		this.moved = false;
		this.movementX = 0;
		this.movementY = 0;
		this.wheelDelta = 0;
	}
	reset() {
		this.buttonsDown[1] = this.buttonsDown[2] = false;
		this.buttonsDown[0] = false;
		this.endFrame();
	}
	buttonIndex(button) {
		if(button == "left") {
			return 0;
		} else if(button == "right") {
			return 1;
		} else {
			return 2;
		}
	}
	down(button) {
		if(button == null) {
			button = "left";
		}
		return this.buttonsDown[this.buttonIndex(button)];
	}
	started(button) {
		if(button == null) {
			button = "left";
		}
		return this.buttonsStarted[this.buttonIndex(button)];
	}
	released(button) {
		if(button == null) {
			button = "left";
		}
		return this.buttonsReleased[this.buttonIndex(button)];
	}
	lock() {
		if(kha_input_Mouse.get().canLock()) {
			kha_input_Mouse.get().lock();
			this.locked = true;
			this.hidden = true;
		}
	}
	unlock() {
		if(kha_input_Mouse.get().canLock()) {
			kha_input_Mouse.get().unlock();
			this.locked = false;
			this.hidden = false;
		}
	}
	downListener(index,x,y) {
		this.buttonsDown[index] = true;
		this.buttonsStarted[index] = true;
		this.x = x;
		this.y = y;
		this.downVirtual(iron_system_Mouse.buttons[index]);
	}
	upListener(index,x,y) {
		this.buttonsDown[index] = false;
		this.buttonsReleased[index] = true;
		this.x = x;
		this.y = y;
		this.upVirtual(iron_system_Mouse.buttons[index]);
	}
	moveListener(x,y,movementX,movementY) {
		if(this.lastX == -1.0 && this.lastY == -1.0) {
			this.lastX = x;
			this.lastY = y;
		}
		if(this.locked) {
			this.movementX += movementX;
			this.movementY += movementY;
		} else {
			this.movementX += x - this.lastX;
			this.movementY += y - this.lastY;
		}
		this.lastX = x;
		this.lastY = y;
		this.x = x;
		this.y = y;
		this.moved = true;
	}
	wheelListener(delta) {
		this.wheelDelta = delta;
	}
}
$hxClasses["iron.system.Mouse"] = iron_system_Mouse;
iron_system_Mouse.__name__ = "iron.system.Mouse";
iron_system_Mouse.__super__ = iron_system_VirtualInput;
Object.assign(iron_system_Mouse.prototype, {
	__class__: iron_system_Mouse
});
class iron_system_Pen extends iron_system_VirtualInput {
	constructor() {
		iron_system_VirtualInput._hx_skip_constructor = true;
		super();
		iron_system_VirtualInput._hx_skip_constructor = false;
		this._hx_constructor();
	}
	_hx_constructor() {
		this.lastY = -1.0;
		this.lastX = -1.0;
		this.connected = false;
		this.pressure = 0.0;
		this.movementY = 0.0;
		this.movementX = 0.0;
		this.moved = false;
		this.y = 0.0;
		this.x = 0.0;
		this.buttonsReleased = [false];
		this.buttonsStarted = [false];
		this.buttonsDown = [false];
		super._hx_constructor();
		kha_input_Pen.get().notify($bind(this,this.downListener),$bind(this,this.upListener),$bind(this,this.moveListener));
	}
	endFrame() {
		this.buttonsStarted[0] = false;
		this.buttonsReleased[0] = false;
		this.moved = false;
		this.movementX = 0;
		this.movementY = 0;
	}
	reset() {
		this.buttonsDown[0] = false;
		this.endFrame();
	}
	buttonIndex(button) {
		return 0;
	}
	down(button) {
		if(button == null) {
			button = "tip";
		}
		return this.buttonsDown[this.buttonIndex(button)];
	}
	started(button) {
		if(button == null) {
			button = "tip";
		}
		return this.buttonsStarted[this.buttonIndex(button)];
	}
	downListener(x,y,pressure) {
		this.buttonsDown[0] = true;
		this.buttonsStarted[0] = true;
		this.x = x;
		this.y = y;
		this.pressure = pressure;
	}
	upListener(x,y,pressure) {
		this.buttonsDown[0] = false;
		this.buttonsReleased[0] = true;
		this.x = x;
		this.y = y;
		this.pressure = pressure;
	}
	moveListener(x,y,pressure) {
		if(this.lastX == -1.0 && this.lastY == -1.0) {
			this.lastX = x;
			this.lastY = y;
		}
		this.movementX = x - this.lastX;
		this.movementY = y - this.lastY;
		this.lastX = x;
		this.lastY = y;
		this.x = x;
		this.y = y;
		this.moved = true;
		this.pressure = pressure;
		this.connected = true;
	}
}
$hxClasses["iron.system.Pen"] = iron_system_Pen;
iron_system_Pen.__name__ = "iron.system.Pen";
iron_system_Pen.__super__ = iron_system_VirtualInput;
Object.assign(iron_system_Pen.prototype, {
	__class__: iron_system_Pen
});
class iron_system_Keyboard extends iron_system_VirtualInput {
	constructor() {
		iron_system_VirtualInput._hx_skip_constructor = true;
		super();
		iron_system_VirtualInput._hx_skip_constructor = false;
		this._hx_constructor();
	}
	_hx_constructor() {
		this.repeatTime = 0.0;
		this.repeatKey = false;
		this.keysFrame = [];
		this.keysReleased = new haxe_ds_StringMap();
		this.keysStarted = new haxe_ds_StringMap();
		this.keysDown = new haxe_ds_StringMap();
		super._hx_constructor();
		this.reset();
		kha_input_Keyboard.get().notify($bind(this,this.downListener),$bind(this,this.upListener),$bind(this,this.pressListener));
	}
	endFrame() {
		if(this.keysFrame.length > 0) {
			let _g = 0;
			let _g1 = this.keysFrame;
			while(_g < _g1.length) {
				let s = _g1[_g];
				++_g;
				this.keysStarted.h[s] = false;
				this.keysReleased.h[s] = false;
			}
			this.keysFrame.splice(0,this.keysFrame.length);
		}
		if(kha_Scheduler.time() - this.repeatTime > 0.05) {
			this.repeatTime = kha_Scheduler.time();
			this.repeatKey = true;
		} else {
			this.repeatKey = false;
		}
	}
	reset() {
		let _g = 0;
		let _g1 = iron_system_Keyboard.keys;
		while(_g < _g1.length) {
			let s = _g1[_g];
			++_g;
			this.keysDown.h[s] = false;
			this.keysStarted.h[s] = false;
			this.keysReleased.h[s] = false;
		}
		this.endFrame();
	}
	down(key) {
		return this.keysDown.h[key];
	}
	started(key) {
		return this.keysStarted.h[key];
	}
	released(key) {
		return this.keysReleased.h[key];
	}
	repeat(key) {
		if(!this.keysStarted.h[key]) {
			if(this.repeatKey) {
				return this.keysDown.h[key];
			} else {
				return false;
			}
		} else {
			return true;
		}
	}
	downListener(code) {
		let s = iron_system_Keyboard.keyCode(code);
		this.keysFrame.push(s);
		this.keysStarted.h[s] = true;
		this.keysDown.h[s] = true;
		this.repeatTime = kha_Scheduler.time() + 0.4;
		this.downVirtual(s);
	}
	upListener(code) {
		let s = iron_system_Keyboard.keyCode(code);
		this.keysFrame.push(s);
		this.keysReleased.h[s] = true;
		this.keysDown.h[s] = false;
		this.upVirtual(s);
	}
	pressListener(char) {
	}
	static keyCode(key) {
		switch(key) {
		case 1:
			return "back";
		case 8:
			return "backspace";
		case 9:
			return "tab";
		case 13:
			return "enter";
		case 16:
			return "shift";
		case 17:
			return "control";
		case 18:
			return "alt";
		case 27:
			return "escape";
		case 32:
			return "space";
		case 37:
			return "left";
		case 38:
			return "up";
		case 39:
			return "right";
		case 40:
			return "down";
		case 46:
			return "delete";
		case 48:
			return "0";
		case 49:
			return "1";
		case 50:
			return "2";
		case 51:
			return "3";
		case 52:
			return "4";
		case 53:
			return "5";
		case 54:
			return "6";
		case 55:
			return "7";
		case 56:
			return "8";
		case 57:
			return "9";
		case 58:
			return ":";
		case 59:
			return ";";
		case 60:
			return "<";
		case 61:
			return "=";
		case 62:
			return ">";
		case 63:
			return "?";
		case 64:
			return "@";
		case 91:
			return "win";
		case 96:
			return "0";
		case 97:
			return "1";
		case 98:
			return "2";
		case 99:
			return "3";
		case 100:
			return "4";
		case 101:
			return "5";
		case 102:
			return "6";
		case 103:
			return "7";
		case 104:
			return "8";
		case 105:
			return "9";
		case 106:
			return "*";
		case 107:
			return "+";
		case 109:
			return "-";
		case 110:
			return ".";
		case 111:
			return "/";
		case 112:
			return "f1";
		case 113:
			return "f2";
		case 114:
			return "f3";
		case 115:
			return "f4";
		case 116:
			return "f5";
		case 117:
			return "f6";
		case 118:
			return "f7";
		case 119:
			return "f8";
		case 120:
			return "f9";
		case 121:
			return "f10";
		case 122:
			return "f11";
		case 123:
			return "f12";
		case 161:
			return "!";
		case 162:
			return "\"";
		case 163:
			return "#";
		case 164:
			return "$";
		case 165:
			return "%";
		case 166:
			return "&";
		case 167:
			return "_";
		case 168:
			return "(";
		case 169:
			return ")";
		case 170:
			return "*";
		case 171:
			return "+";
		case 172:
			return "|";
		case 173:
			return "-";
		case 174:
			return "{";
		case 175:
			return "}";
		case 176:
			return "~";
		case 188:
			return ",";
		case 190:
			return ".";
		case 191:
			return "/";
		case 192:
			return "`";
		case 219:
			return "[";
		case 220:
			return "\\";
		case 221:
			return "]";
		default:
			return String.fromCodePoint(key).toLowerCase();
		}
	}
}
$hxClasses["iron.system.Keyboard"] = iron_system_Keyboard;
iron_system_Keyboard.__name__ = "iron.system.Keyboard";
iron_system_Keyboard.__super__ = iron_system_VirtualInput;
Object.assign(iron_system_Keyboard.prototype, {
	__class__: iron_system_Keyboard
});
class iron_system_GamepadStick {
	constructor() {
		this.movementY = 0.0;
		this.movementX = 0.0;
		this.moved = false;
		this.lastY = 0.0;
		this.lastX = 0.0;
		this.y = 0.0;
		this.x = 0.0;
	}
}
$hxClasses["iron.system.GamepadStick"] = iron_system_GamepadStick;
iron_system_GamepadStick.__name__ = "iron.system.GamepadStick";
Object.assign(iron_system_GamepadStick.prototype, {
	__class__: iron_system_GamepadStick
});
class iron_system_Gamepad extends iron_system_VirtualInput {
	constructor(i,virtual) {
		iron_system_VirtualInput._hx_skip_constructor = true;
		super();
		iron_system_VirtualInput._hx_skip_constructor = false;
		this._hx_constructor(i,virtual);
	}
	_hx_constructor(i,virtual) {
		if(virtual == null) {
			virtual = false;
		}
		this.num = 0;
		this.connected = false;
		this.rightStick = new iron_system_GamepadStick();
		this.leftStick = new iron_system_GamepadStick();
		this.buttonsFrame = [];
		this.buttonsReleased = [];
		this.buttonsStarted = [];
		this.buttonsDown = [];
		super._hx_constructor();
		let _g = 0;
		let _g1 = iron_system_Gamepad.buttons;
		while(_g < _g1.length) {
			++_g;
			this.buttonsDown.push(0.0);
			this.buttonsStarted.push(false);
			this.buttonsReleased.push(false);
		}
		this.num = i;
		this.reset();
		if(virtual) {
			this.connected = true;
		} else {
			this.connect();
		}
	}
	connect() {
		let gamepad = kha_input_Gamepad.get(this.num);
		if(gamepad == null) {
			return;
		}
		this.connected = true;
		gamepad.notify($bind(this,this.axisListener),$bind(this,this.buttonListener));
	}
	endFrame() {
		if(this.buttonsFrame.length > 0) {
			let _g = 0;
			let _g1 = this.buttonsFrame;
			while(_g < _g1.length) {
				let i = _g1[_g];
				++_g;
				this.buttonsStarted[i] = false;
				this.buttonsReleased[i] = false;
			}
			this.buttonsFrame.splice(0,this.buttonsFrame.length);
		}
		this.leftStick.moved = false;
		this.leftStick.movementX = 0;
		this.leftStick.movementY = 0;
		this.rightStick.moved = false;
		this.rightStick.movementX = 0;
		this.rightStick.movementY = 0;
	}
	reset() {
		let _g = 0;
		let _g1 = this.buttonsDown.length;
		while(_g < _g1) {
			let i = _g++;
			this.buttonsDown[i] = 0.0;
			this.buttonsStarted[i] = false;
			this.buttonsReleased[i] = false;
		}
		this.endFrame();
	}
	axisListener(axis,value) {
		let stick = axis <= 1 ? this.leftStick : this.rightStick;
		if(axis == 0 || axis == 2) {
			stick.lastX = stick.x;
			stick.x = value;
			stick.movementX = stick.x - stick.lastX;
		} else if(axis == 1 || axis == 3) {
			stick.lastY = stick.y;
			stick.y = value;
			stick.movementY = stick.y - stick.lastY;
		}
		stick.moved = true;
	}
	buttonListener(button,value) {
		this.buttonsFrame.push(button);
		this.buttonsDown[button] = value;
		if(value > 0) {
			this.buttonsStarted[button] = true;
		} else {
			this.buttonsReleased[button] = true;
		}
		if(value == 0.0) {
			this.upVirtual(iron_system_Gamepad.buttons[button]);
		} else if(value == 1.0) {
			this.downVirtual(iron_system_Gamepad.buttons[button]);
		}
	}
}
$hxClasses["iron.system.Gamepad"] = iron_system_Gamepad;
iron_system_Gamepad.__name__ = "iron.system.Gamepad";
iron_system_Gamepad.__super__ = iron_system_VirtualInput;
Object.assign(iron_system_Gamepad.prototype, {
	__class__: iron_system_Gamepad
});
class iron_system_Lz4 {
	static encode(b) {
		let this1 = new Uint8Array(b.b.bufferValue);
		let iBuf = this1;
		let iLen = iBuf.length;
		if(iLen >= 2113929216) {
			haxe_Log.trace("LZ4 range error",{ fileName : "Sources/iron/system/Lz4.hx", lineNumber : 52, className : "iron.system.Lz4", methodName : "encode"});
			return null;
		}
		let lastMatchPos = iLen - 12;
		let lastLiteralPos = iLen - 5;
		if(iron_system_Lz4.hashTable == null) {
			let this1 = new Int32Array(65536);
			iron_system_Lz4.hashTable = this1;
		}
		let _g = 0;
		let _g1 = iron_system_Lz4.hashTable.length;
		while(_g < _g1) {
			let i = _g++;
			iron_system_Lz4.hashTable[i] = -65536;
		}
		let oLen = iLen > 2113929216 ? 0 : iLen + (iLen / 255 | 0) + 16;
		let this2 = new Uint8Array(oLen);
		let oBuf = this2;
		let iPos = 0;
		let oPos = 0;
		let anchorPos = 0;
		while(true) {
			let refPos = 0;
			let mOffset = 0;
			let sequence = iBuf[iPos] << 8 | iBuf[iPos + 1] << 16 | iBuf[iPos + 2] << 24;
			while(iPos <= lastMatchPos) {
				sequence = sequence >>> 8 | iBuf[iPos + 3] << 24;
				let hash = (sequence * 40503 & 65535) + (sequence * 31153 >>> 16) & 65535;
				refPos = iron_system_Lz4.hashTable[hash];
				iron_system_Lz4.hashTable[hash] = iPos;
				mOffset = iPos - refPos;
				if(mOffset < 65536 && iBuf[refPos] == (sequence & 255) && iBuf[refPos + 1] == (sequence >>> 8 & 255) && iBuf[refPos + 2] == (sequence >>> 16 & 255) && iBuf[refPos + 3] == (sequence >>> 24 & 255)) {
					break;
				}
				++iPos;
			}
			if(iPos > lastMatchPos) {
				break;
			}
			let lLen = iPos - anchorPos;
			let mLen = iPos;
			iPos += 4;
			refPos += 4;
			while(iPos < lastLiteralPos && iBuf[iPos] == iBuf[refPos]) {
				++iPos;
				++refPos;
			}
			mLen = iPos - mLen;
			let token = mLen < 19 ? mLen - 4 : 15;
			if(lLen >= 15) {
				oBuf[oPos++] = 240 | token;
				let l = lLen - 15;
				while(l >= 255) {
					oBuf[oPos++] = 255;
					l -= 255;
				}
				oBuf[oPos++] = l;
			} else {
				oBuf[oPos++] = lLen << 4 | token;
			}
			while(lLen-- > 0) oBuf[oPos++] = iBuf[anchorPos++];
			if(mLen == 0) {
				break;
			}
			oBuf[oPos] = mOffset;
			oBuf[oPos + 1] = mOffset >>> 8;
			oPos += 2;
			if(mLen >= 19) {
				let l = mLen - 19;
				while(l >= 255) {
					oBuf[oPos++] = 255;
					l -= 255;
				}
				oBuf[oPos++] = l;
			}
			anchorPos = iPos;
		}
		let lLen = iLen - anchorPos;
		if(lLen >= 15) {
			oBuf[oPos++] = 240;
			let l = lLen - 15;
			while(l >= 255) {
				oBuf[oPos++] = 255;
				l -= 255;
			}
			oBuf[oPos++] = l;
		} else {
			oBuf[oPos++] = lLen << 4;
		}
		while(lLen-- > 0) oBuf[oPos++] = iBuf[anchorPos++];
		return haxe_io_Bytes.ofData(oBuf.buffer.slice(0,oPos));
	}
	static decode(b,oLen) {
		let this1 = new Uint8Array(b.b.bufferValue);
		let iBuf = this1;
		let iLen = iBuf.length;
		let this2 = new Uint8Array(oLen);
		let oBuf = this2;
		let iPos = 0;
		let oPos = 0;
		while(iPos < iLen) {
			let token = iBuf[iPos++];
			let clen = token >>> 4;
			if(clen != 0) {
				if(clen == 15) {
					let l = 0;
					while(true) {
						l = iBuf[iPos++];
						if(l != 255) {
							break;
						}
						clen += 255;
					}
					clen += l;
				}
				let end = iPos + clen;
				while(iPos < end) oBuf[oPos++] = iBuf[iPos++];
				if(iPos == iLen) {
					break;
				}
			}
			let mOffset = iBuf[iPos] | iBuf[iPos + 1] << 8;
			if(mOffset == 0 || mOffset > oPos) {
				return null;
			}
			iPos += 2;
			clen = (token & 15) + 4;
			if(clen == 19) {
				let l = 0;
				while(true) {
					l = iBuf[iPos++];
					if(l != 255) {
						break;
					}
					clen += 255;
				}
				clen += l;
			}
			let mPos = oPos - mOffset;
			let end = oPos + clen;
			while(oPos < end) oBuf[oPos++] = oBuf[mPos++];
		}
		return haxe_io_Bytes.ofData(oBuf.buffer);
	}
}
$hxClasses["iron.system.Lz4"] = iron_system_Lz4;
iron_system_Lz4.__name__ = "iron.system.Lz4";
class kha_Assets {
	static loadImageFromPath(path,readable,done) {
		let image = Krom.loadImage(path,readable);
		if(image != null) {
			done(kha_Image._fromTexture(image));
		}
	}
	static loadBlobFromPath(path,done) {
		done(new kha_Blob(haxe_io_Bytes.ofData(Krom.loadBlob(path))));
	}
	static loadFontFromPath(path,done) {
		kha_Assets.loadBlobFromPath(path,function(blob) {
			done(new kha_Font(blob));
		});
	}
}
$hxClasses["kha.Assets"] = kha_Assets;
kha_Assets.__name__ = "kha.Assets";
class kha_Display {
	constructor(num,isPrimary) {
		this.num = num;
		this.isPrimary = isPrimary;
	}
	get_width() {
		return Krom.displayWidth(this.num);
	}
	get_height() {
		return Krom.displayHeight(this.num);
	}
	get_frequency() {
		return Krom.displayFrequency(this.num);
	}
	static init() {
		if(kha_Display.displays.length > 0) {
			return;
		}
		let _g = 0;
		let _g1 = Krom.displayCount();
		while(_g < _g1) {
			let i = _g++;
			kha_Display.displays.push(new kha_Display(i,Krom.displayIsPrimary(i)));
		}
	}
	static get_primary() {
		kha_Display.init();
		let _g = 0;
		let _g1 = kha_Display.displays;
		while(_g < _g1.length) {
			let display = _g1[_g];
			++_g;
			if(display.isPrimary) {
				return display;
			}
		}
		return null;
	}
}
$hxClasses["kha.Display"] = kha_Display;
kha_Display.__name__ = "kha.Display";
kha_Display.__properties__ = {get_primary: "get_primary"};
Object.assign(kha_Display.prototype, {
	__class__: kha_Display
	,__properties__: {get_frequency: "get_frequency",get_height: "get_height",get_width: "get_width"}
});
class kha_AlignedQuad {
	constructor() {
	}
}
$hxClasses["kha.AlignedQuad"] = kha_AlignedQuad;
kha_AlignedQuad.__name__ = "kha.AlignedQuad";
Object.assign(kha_AlignedQuad.prototype, {
	__class__: kha_AlignedQuad
});
class kha_KravurImage {
	constructor(size,ascent,descent,lineGap,width,height,chars,pixels) {
		this.mySize = size;
		this.width = width;
		this.height = height;
		this.chars = chars;
		this.baseline = ascent;
		let _g = 0;
		while(_g < chars.length) chars[_g++].yoff += this.baseline;
		this.texture = kha_Image.fromBytes(pixels.toBytes(),width,height,1);
	}
	getTexture() {
		return this.texture;
	}
	getBakedQuad(q,char_index,xpos,ypos) {
		if(char_index >= this.chars.length) {
			return null;
		}
		let ipw = 1.0 / this.width;
		let iph = 1.0 / this.height;
		let b = this.chars[char_index];
		if(b == null) {
			return null;
		}
		let round_x = Math.round(xpos + b.xoff);
		let round_y = Math.round(ypos + b.yoff);
		q.x0 = round_x;
		q.y0 = round_y;
		q.x1 = round_x + b.x1 - b.x0;
		q.y1 = round_y + b.y1 - b.y0;
		q.s0 = b.x0 * ipw;
		q.t0 = b.y0 * iph;
		q.s1 = b.x1 * ipw;
		q.t1 = b.y1 * iph;
		q.xadvance = b.xadvance;
		return q;
	}
	getCharWidth(charIndex) {
		if(this.chars.length == 0) {
			return 0;
		}
		let offset = kha_KravurImage.charBlocks[0];
		if(charIndex < offset) {
			return this.chars[0].xadvance;
		}
		let _g = 1;
		let _g1 = kha_KravurImage.charBlocks.length / 2 | 0;
		while(_g < _g1) {
			let i = _g++;
			let start = kha_KravurImage.charBlocks[i * 2];
			if(charIndex > start - 1) {
				offset += start - 1 - kha_KravurImage.charBlocks[i * 2 - 1];
			}
		}
		if(charIndex - offset >= this.chars.length) {
			return this.chars[0].xadvance;
		}
		return this.chars[charIndex - offset].xadvance;
	}
	getHeight() {
		return this.mySize;
	}
	stringWidth(str) {
		let width = 0;
		let _g = 0;
		let _g1 = str.length;
		while(_g < _g1) width += this.getCharWidth(HxOverrides.cca(str,_g++));
		return width;
	}
}
$hxClasses["kha.KravurImage"] = kha_KravurImage;
kha_KravurImage.__name__ = "kha.KravurImage";
Object.assign(kha_KravurImage.prototype, {
	__class__: kha_KravurImage
});
class kha_Font {
	constructor(blob,fontIndex) {
		if(fontIndex == null) {
			fontIndex = 0;
		}
		this.images = new haxe_ds_IntMap();
		this.blob = blob;
		this.fontIndex = fontIndex;
	}
	_get(fontSize) {
		let glyphs = kha_graphics2_Graphics.fontGlyphs;
		if(glyphs != this.oldGlyphs) {
			this.oldGlyphs = glyphs;
			kha_KravurImage.charBlocks = [glyphs[0]];
			let nextChar = kha_KravurImage.charBlocks[0] + 1;
			let _g = 1;
			let _g1 = glyphs.length;
			while(_g < _g1) {
				let i = _g++;
				if(glyphs[i] != nextChar) {
					kha_KravurImage.charBlocks.push(glyphs[i - 1]);
					kha_KravurImage.charBlocks.push(glyphs[i]);
					nextChar = glyphs[i] + 1;
				} else {
					++nextChar;
				}
			}
			kha_KravurImage.charBlocks.push(glyphs[glyphs.length - 1]);
		}
		let imageIndex = this.fontIndex * 10000000 + fontSize * 10000 + glyphs.length;
		if(!this.images.h.hasOwnProperty(imageIndex)) {
			let width = 64;
			let height = 32;
			let baked = new Array(glyphs.length);
			let _g = 0;
			let _g1 = baked.length;
			while(_g < _g1) baked[_g++] = new kha_graphics2_truetype_Stbtt_$bakedchar();
			let pixels = null;
			let offset = kha_graphics2_truetype_StbTruetype.stbtt_GetFontOffsetForIndex(this.blob,this.fontIndex);
			if(offset == -1) {
				offset = kha_graphics2_truetype_StbTruetype.stbtt_GetFontOffsetForIndex(this.blob,0);
			}
			let status = -1;
			while(status <= 0) {
				if(height < width) {
					height *= 2;
				} else {
					width *= 2;
				}
				pixels = kha_Blob.alloc(width * height);
				status = kha_graphics2_truetype_StbTruetype.stbtt_BakeFontBitmap(this.blob,offset,fontSize,pixels,width,height,glyphs,baked);
			}
			let info = new kha_graphics2_truetype_Stbtt_$fontinfo();
			kha_graphics2_truetype_StbTruetype.stbtt_InitFont(info,this.blob,offset);
			let metrics = kha_graphics2_truetype_StbTruetype.stbtt_GetFontVMetrics(info);
			let scale = kha_graphics2_truetype_StbTruetype.stbtt_ScaleForPixelHeight(info,fontSize);
			let image = new kha_KravurImage(fontSize | 0,Math.round(metrics.ascent * scale),Math.round(metrics.descent * scale),Math.round(metrics.lineGap * scale),width,height,baked,pixels);
			this.images.h[imageIndex] = image;
			return image;
		}
		return this.images.h[imageIndex];
	}
	height(fontSize) {
		return this._get(fontSize).getHeight();
	}
	width(fontSize,str) {
		return this._get(fontSize).stringWidth(str);
	}
	setFontIndex(fontIndex) {
		this.fontIndex = fontIndex;
	}
	getFontNames() {
		let info = new kha_graphics2_truetype_Stbtt_$fontinfo();
		info.data = this.blob;
		let count = kha_graphics2_truetype_StbTruetype.stbtt_GetNumberOfFonts(this.blob);
		let fontNames = new Array(count);
		let _g = 0;
		while(_g < count) {
			let i = _g++;
			info.fontstart = kha_graphics2_truetype_StbTruetype.stbtt_GetFontOffsetForIndex(this.blob,i);
			let fontName = kha_graphics2_truetype_StbTruetype.stbtt_GetFontNameString(info,1,0,0,4);
			if(fontName == null) {
				fontName = kha_graphics2_truetype_StbTruetype.stbtt_GetFontNameString(info,3,1,1033,4);
			}
			fontNames[i] = fontName;
		}
		return fontNames;
	}
	clone() {
		return new kha_Font(this.blob,this.fontIndex);
	}
	unload() {
		this.blob = null;
		this.images = null;
	}
}
$hxClasses["kha.Font"] = kha_Font;
kha_Font.__name__ = "kha.Font";
Object.assign(kha_Font.prototype, {
	__class__: kha_Font
});
class kha_Framebuffer {
	constructor($window,g2,g4) {
		this.window = $window;
		this.graphics2 = g2;
		this.graphics4 = g4;
	}
	init(g2,g4) {
		this.graphics2 = g2;
		this.graphics4 = g4;
	}
	get_g2() {
		return this.graphics2;
	}
	get_g4() {
		return this.graphics4;
	}
	get_width() {
		return kha_System.windowWidth(this.window);
	}
	get_height() {
		return kha_System.windowHeight(this.window);
	}
}
$hxClasses["kha.Framebuffer"] = kha_Framebuffer;
kha_Framebuffer.__name__ = "kha.Framebuffer";
kha_Framebuffer.__interfaces__ = [kha_Canvas];
Object.assign(kha_Framebuffer.prototype, {
	__class__: kha_Framebuffer
	,__properties__: {get_height: "get_height",get_width: "get_width",get_g4: "get_g4",get_g2: "get_g2"}
});
class kha_FramebufferOptions {
	constructor(frequency,verticalSync,colorBufferBits,depthBufferBits,stencilBufferBits,samplesPerPixel) {
		if(samplesPerPixel == null) {
			samplesPerPixel = 1;
		}
		if(stencilBufferBits == null) {
			stencilBufferBits = 8;
		}
		if(depthBufferBits == null) {
			depthBufferBits = 16;
		}
		if(colorBufferBits == null) {
			colorBufferBits = 32;
		}
		if(verticalSync == null) {
			verticalSync = true;
		}
		if(frequency == null) {
			frequency = 60;
		}
		this.samplesPerPixel = 1;
		this.colorBufferBits = 32;
		this.verticalSync = true;
		this.frequency = 60;
		this.frequency = frequency;
		this.verticalSync = verticalSync;
		this.colorBufferBits = colorBufferBits;
		this.samplesPerPixel = samplesPerPixel;
	}
}
$hxClasses["kha.FramebufferOptions"] = kha_FramebufferOptions;
kha_FramebufferOptions.__name__ = "kha.FramebufferOptions";
Object.assign(kha_FramebufferOptions.prototype, {
	__class__: kha_FramebufferOptions
});
class kha_TimeTask {
	constructor() {
	}
}
$hxClasses["kha.TimeTask"] = kha_TimeTask;
kha_TimeTask.__name__ = "kha.TimeTask";
Object.assign(kha_TimeTask.prototype, {
	__class__: kha_TimeTask
});
class kha_FrameTask {
	constructor(task,priority,id) {
		this.task = task;
		this.priority = priority;
		this.id = id;
		this.active = true;
		this.paused = false;
	}
}
$hxClasses["kha.FrameTask"] = kha_FrameTask;
kha_FrameTask.__name__ = "kha.FrameTask";
Object.assign(kha_FrameTask.prototype, {
	__class__: kha_FrameTask
});
class kha_Shaders {
	static getBlob(name) {
		return kha_Blob.fromBytes(haxe_io_Bytes.ofData(Krom.loadBlob("data/" + name + kha_Shaders.ext)));
	}
	static getVertex(name) {
		let shader = kha_Shaders.vertexShaders.h[name];
		if(shader == null) {
			shader = new kha_graphics4_VertexShader([kha_Shaders.getBlob(name)],[name]);
			kha_Shaders.vertexShaders.h[name] = shader;
		}
		return shader;
	}
	static getFragment(name) {
		let shader = kha_Shaders.fragmentShaders.h[name];
		if(shader == null) {
			shader = new kha_graphics4_FragmentShader([kha_Shaders.getBlob(name)],[name]);
			kha_Shaders.fragmentShaders.h[name] = shader;
		}
		return shader;
	}
}
$hxClasses["kha.Shaders"] = kha_Shaders;
kha_Shaders.__name__ = "kha.Shaders";
class kha_SystemOptions {
	constructor(title,width,height,$window,framebuffer) {
		if(height == null) {
			height = -1;
		}
		if(width == null) {
			width = -1;
		}
		if(title == null) {
			title = "Kha";
		}
		this.framebuffer = null;
		this.window = null;
		this.height = -1;
		this.width = -1;
		this.title = "Kha";
		this.title = title;
		this.window = $window == null ? new kha_WindowOptions(null,-1,-1,800,600,-1,true,null,0) : $window;
		if(width > 0) {
			this.window.width = width;
			this.width = width;
		} else {
			this.width = this.window.width;
		}
		if(height > 0) {
			this.window.height = height;
			this.height = height;
		} else {
			this.height = this.window.height;
		}
		if(this.window.title == null) {
			this.window.title = title;
		}
		this.framebuffer = framebuffer == null ? new kha_FramebufferOptions(60,true,32,16,8,1) : framebuffer;
	}
}
$hxClasses["kha.SystemOptions"] = kha_SystemOptions;
kha_SystemOptions.__name__ = "kha.SystemOptions";
Object.assign(kha_SystemOptions.prototype, {
	__class__: kha_SystemOptions
});
class kha_System {
	static start(options,callback) {
		Krom.init(options.title,options.width,options.height,options.framebuffer.samplesPerPixel,options.framebuffer.verticalSync,options.window.mode,options.window.windowFeatures,6,options.window.x,options.window.y,options.framebuffer.frequency);
		kha_System.startTime = Krom.getTime();
		haxe_Log.trace = function(v,infos) {
			Krom.log(haxe_Log.formatOutput(v,infos));
		};
		new kha_Window(0);
		kha_Scheduler.init();
		let g4 = new kha_graphics4_Graphics();
		kha_System.framebuffer = new kha_Framebuffer(0,null,g4);
		kha_System.framebuffer.init(new kha_graphics2_Graphics(kha_System.framebuffer),g4);
		Krom.setCallback(kha_System.renderCallback);
		Krom.setDropFilesCallback(kha_System.dropFilesCallback);
		Krom.setCutCopyPasteCallback(kha_System.cutCallback,kha_System.copyCallback,kha_System.pasteCallback);
		Krom.setApplicationStateCallback(kha_System.foregroundCallback,kha_System.resumeCallback,kha_System.pauseCallback,kha_System.backgroundCallback,kha_System.shutdownCallback);
		kha_System.keyboard = new kha_input_Keyboard();
		kha_System.mouse = new kha_input_Mouse();
		kha_System.surface = new kha_input_Surface();
		kha_System.pen = new kha_input_Pen();
		kha_System.gamepads = [];
		let _g = 0;
		let _g1 = kha_System.maxGamepads;
		while(_g < _g1) {
			let i = _g++;
			kha_System.gamepads[i] = new kha_input_Gamepad(i);
		}
		Krom.setKeyboardDownCallback(kha_System.keyboardDownCallback);
		Krom.setKeyboardUpCallback(kha_System.keyboardUpCallback);
		Krom.setKeyboardPressCallback(kha_System.keyboardPressCallback);
		Krom.setMouseDownCallback(kha_System.mouseDownCallback);
		Krom.setMouseUpCallback(kha_System.mouseUpCallback);
		Krom.setMouseMoveCallback(kha_System.mouseMoveCallback);
		Krom.setMouseWheelCallback(kha_System.mouseWheelCallback);
		Krom.setTouchDownCallback(kha_System.touchDownCallback);
		Krom.setTouchUpCallback(kha_System.touchUpCallback);
		Krom.setTouchMoveCallback(kha_System.touchMoveCallback);
		Krom.setPenDownCallback(kha_System.penDownCallback);
		Krom.setPenUpCallback(kha_System.penUpCallback);
		Krom.setPenMoveCallback(kha_System.penMoveCallback);
		Krom.setGamepadAxisCallback(kha_System.gamepadAxisCallback);
		Krom.setGamepadButtonCallback(kha_System.gamepadButtonCallback);
		kha_Scheduler.start();
		callback(kha_Window.get(0));
	}
	static notifyOnFrames(listener) {
		kha_System.renderListeners.push(listener);
	}
	static notifyOnApplicationState(foregroundListener,resumeListener,pauseListener,backgroundListener,shutdownListener) {
		if(foregroundListener != null) {
			kha_System.foregroundListeners.push(foregroundListener);
		}
		if(resumeListener != null) {
			kha_System.resumeListeners.push(resumeListener);
		}
		if(pauseListener != null) {
			kha_System.pauseListeners.push(pauseListener);
		}
		if(backgroundListener != null) {
			kha_System.backgroundListeners.push(backgroundListener);
		}
		if(shutdownListener != null) {
			kha_System.shutdownListeners.push(shutdownListener);
		}
	}
	static notifyOnDropFiles(dropFilesListener) {
		kha_System.dropFilesListeners.push(dropFilesListener);
	}
	static notifyOnCutCopyPaste(cutListener,copyListener,pasteListener) {
		kha_System.cutListener = cutListener;
		kha_System.copyListener = copyListener;
		kha_System.pasteListener = pasteListener;
	}
	static render(framebuffers) {
		let _g = 0;
		let _g1 = kha_System.renderListeners;
		while(_g < _g1.length) _g1[_g++](framebuffers);
	}
	static foreground() {
		let _g = 0;
		let _g1 = kha_System.foregroundListeners;
		while(_g < _g1.length) _g1[_g++]();
	}
	static resume() {
		let _g = 0;
		let _g1 = kha_System.resumeListeners;
		while(_g < _g1.length) _g1[_g++]();
	}
	static pause() {
		let _g = 0;
		let _g1 = kha_System.pauseListeners;
		while(_g < _g1.length) _g1[_g++]();
	}
	static background() {
		let _g = 0;
		let _g1 = kha_System.backgroundListeners;
		while(_g < _g1.length) _g1[_g++]();
	}
	static shutdown() {
		let _g = 0;
		let _g1 = kha_System.shutdownListeners;
		while(_g < _g1.length) _g1[_g++]();
	}
	static dropFiles(filePath) {
		let _g = 0;
		let _g1 = kha_System.dropFilesListeners;
		while(_g < _g1.length) _g1[_g++](filePath);
	}
	static get_time() {
		return Krom.getTime() - kha_System.startTime;
	}
	static windowWidth($window) {
		if($window == null) {
			$window = 0;
		}
		return kha_Window.get($window).get_width();
	}
	static windowHeight($window) {
		if($window == null) {
			$window = 0;
		}
		return kha_Window.get_all()[$window].get_height();
	}
	static get_systemId() {
		return Krom.systemId();
	}
	static stop() {
		Krom.requestShutdown();
		return true;
	}
	static renderCallback() {
		kha_Scheduler.executeFrame();
		kha_System.render([kha_System.framebuffer]);
	}
	static dropFilesCallback(filePath) {
		kha_System.dropFiles(filePath);
	}
	static copyCallback() {
		if(kha_System.copyListener != null) {
			return kha_System.copyListener();
		} else {
			return null;
		}
	}
	static cutCallback() {
		if(kha_System.cutListener != null) {
			return kha_System.cutListener();
		} else {
			return null;
		}
	}
	static pasteCallback(data) {
		if(kha_System.pasteListener != null) {
			kha_System.pasteListener(data);
		}
	}
	static foregroundCallback() {
		kha_System.foreground();
	}
	static resumeCallback() {
		kha_System.resume();
	}
	static pauseCallback() {
		kha_System.pause();
	}
	static backgroundCallback() {
		kha_System.background();
	}
	static shutdownCallback() {
		kha_System.shutdown();
	}
	static keyboardDownCallback(code) {
		kha_System.keyboard.sendDownEvent(code);
	}
	static keyboardUpCallback(code) {
		kha_System.keyboard.sendUpEvent(code);
	}
	static keyboardPressCallback(charCode) {
		kha_System.keyboard.sendPressEvent(String.fromCodePoint(charCode));
	}
	static mouseDownCallback(button,x,y) {
		kha_System.mouse.sendDownEvent(0,button,x,y);
	}
	static mouseUpCallback(button,x,y) {
		kha_System.mouse.sendUpEvent(0,button,x,y);
	}
	static mouseMoveCallback(x,y,mx,my) {
		kha_System.mouse.sendMoveEvent(0,x,y,mx,my);
	}
	static mouseWheelCallback(delta) {
		kha_System.mouse.sendWheelEvent(0,delta);
	}
	static touchDownCallback(index,x,y) {
		kha_System.surface.sendTouchStartEvent(index,x,y);
	}
	static touchUpCallback(index,x,y) {
		kha_System.surface.sendTouchEndEvent(index,x,y);
	}
	static touchMoveCallback(index,x,y) {
		kha_System.surface.sendMoveEvent(index,x,y);
	}
	static penDownCallback(x,y,pressure) {
		kha_System.pen.sendDownEvent(0,x,y,pressure);
	}
	static penUpCallback(x,y,pressure) {
		kha_System.pen.sendUpEvent(0,x,y,pressure);
	}
	static penMoveCallback(x,y,pressure) {
		kha_System.pen.sendMoveEvent(0,x,y,pressure);
	}
	static gamepadAxisCallback(gamepad,axis,value) {
		kha_System.gamepads[gamepad].sendAxisEvent(axis,value);
	}
	static gamepadButtonCallback(gamepad,button,value) {
		kha_System.gamepads[gamepad].sendButtonEvent(button,value);
	}
	static getMouse(num) {
		return kha_System.mouse;
	}
	static getPen(num) {
		return kha_System.pen;
	}
	static getKeyboard(num) {
		return kha_System.keyboard;
	}
	static showKeyboard() {
		Krom.showKeyboard(true);
	}
	static hideKeyboard() {
		Krom.showKeyboard(false);
	}
	static lockMouse() {
		if(!kha_System.isMouseLocked()) {
			Krom.lockMouse();
			let _g = 0;
			let _g1 = kha_System.mouseLockListeners;
			while(_g < _g1.length) _g1[_g++]();
		}
	}
	static unlockMouse() {
		if(kha_System.isMouseLocked()) {
			Krom.unlockMouse();
			let _g = 0;
			let _g1 = kha_System.mouseLockListeners;
			while(_g < _g1.length) _g1[_g++]();
		}
	}
	static canLockMouse() {
		return Krom.canLockMouse();
	}
	static isMouseLocked() {
		return Krom.isMouseLocked();
	}
	static notifyOfMouseLockChange(func,error) {
		if(kha_System.canLockMouse() && func != null) {
			kha_System.mouseLockListeners.push(func);
		}
	}
	static removeFromMouseLockChange(func,error) {
		if(kha_System.canLockMouse() && func != null) {
			HxOverrides.remove(kha_System.mouseLockListeners,func);
		}
	}
	static hideSystemCursor() {
		Krom.showMouse(false);
	}
	static showSystemCursor() {
		Krom.showMouse(true);
	}
	static getGamepadId(index) {
		return "unkown";
	}
}
$hxClasses["kha.System"] = kha_System;
kha_System.__name__ = "kha.System";
kha_System.__properties__ = {get_systemId: "get_systemId",get_time: "get_time"};
class kha_Window {
	constructor(num) {
		this.num = num;
		kha_Window.windows.push(this);
	}
	resize(width,height) {
		Krom.resizeWindow(this.num,width,height);
	}
	move(x,y) {
		Krom.moveWindow(this.num,x,y);
	}
	get_x() {
		return Krom.windowX(this.num);
	}
	get_y() {
		return Krom.windowY(this.num);
	}
	get_width() {
		return Krom.windowWidth(this.num);
	}
	get_height() {
		return Krom.windowHeight(this.num);
	}
	get_mode() {
		return Krom.getWindowMode(this.num);
	}
	set_mode(mode) {
		Krom.setWindowMode(this.num,mode);
		return mode;
	}
	set_title(value) {
		Krom.setWindowTitle(this.num,value);
		this.windowTitle = value;
		return this.windowTitle;
	}
	get_vSynced() {
		return true;
	}
	static get(index) {
		return kha_Window.windows[index];
	}
	static get_all() {
		return kha_Window.windows;
	}
}
$hxClasses["kha.Window"] = kha_Window;
kha_Window.__name__ = "kha.Window";
kha_Window.__properties__ = {get_all: "get_all"};
Object.assign(kha_Window.prototype, {
	__class__: kha_Window
	,__properties__: {get_vSynced: "get_vSynced",set_title: "set_title",set_mode: "set_mode",get_mode: "get_mode",get_height: "get_height",get_width: "get_width",get_y: "get_y",get_x: "get_x"}
});
class kha_WindowOptions {
	constructor(title,x,y,width,height,display,visible,windowFeatures,mode) {
		if(mode == null) {
			mode = 0;
		}
		if(visible == null) {
			visible = true;
		}
		if(display == null) {
			display = -1;
		}
		if(height == null) {
			height = 600;
		}
		if(width == null) {
			width = 800;
		}
		if(y == null) {
			y = -1;
		}
		if(x == null) {
			x = -1;
		}
		this.mode = 0;
		this.windowFeatures = 1 | 4 | 2;
		this.visible = true;
		this.display = -1;
		this.height = 600;
		this.width = 800;
		this.y = -1;
		this.x = -1;
		this.title = null;
		this.title = title;
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
		this.display = display;
		this.visible = visible;
		this.windowFeatures = windowFeatures == null ? 1 | 4 | 2 : windowFeatures;
		this.mode = mode;
	}
}
$hxClasses["kha.WindowOptions"] = kha_WindowOptions;
kha_WindowOptions.__name__ = "kha.WindowOptions";
Object.assign(kha_WindowOptions.prototype, {
	__class__: kha_WindowOptions
});
class kha_arrays_ByteArray {
	static _new(buffer,byteOffset,byteLength) {
		return new DataView(buffer,byteOffset,byteLength);
	}
}
class kha_graphics2_InternalPipeline {
	constructor(pipeline,projectionLocation,textureLocation) {
		this.pipeline = pipeline;
		this.projectionLocation = projectionLocation;
		this.textureLocation = textureLocation;
	}
}
$hxClasses["kha.graphics2.InternalPipeline"] = kha_graphics2_InternalPipeline;
kha_graphics2_InternalPipeline.__name__ = "kha.graphics2.InternalPipeline";
Object.assign(kha_graphics2_InternalPipeline.prototype, {
	__class__: kha_graphics2_InternalPipeline
});
class kha_graphics2_PipelineCache {
}
$hxClasses["kha.graphics2.PipelineCache"] = kha_graphics2_PipelineCache;
kha_graphics2_PipelineCache.__name__ = "kha.graphics2.PipelineCache";
kha_graphics2_PipelineCache.__isInterface__ = true;
Object.assign(kha_graphics2_PipelineCache.prototype, {
	__class__: kha_graphics2_PipelineCache
});
class kha_graphics2_SimplePipelineCache {
	constructor(pipeline,texture) {
		let projectionLocation = null;
		try {
			projectionLocation = pipeline.getConstantLocation("projectionMatrix");
		} catch( _g ) {
			haxe_Log.trace(haxe_Exception.caught(_g).unwrap(),{ fileName : "kha/graphics2/Graphics.hx", lineNumber : 55, className : "kha.graphics2.SimplePipelineCache", methodName : "new"});
		}
		let textureLocation = null;
		if(texture) {
			try {
				textureLocation = pipeline.getTextureUnit("tex");
			} catch( _g ) {
				haxe_Log.trace(haxe_Exception.caught(_g).unwrap(),{ fileName : "kha/graphics2/Graphics.hx", lineNumber : 64, className : "kha.graphics2.SimplePipelineCache", methodName : "new"});
			}
		}
		this.pipeline = new kha_graphics2_InternalPipeline(pipeline,projectionLocation,textureLocation);
	}
	get(colorFormats,depthStencilFormat) {
		return this.pipeline;
	}
}
$hxClasses["kha.graphics2.SimplePipelineCache"] = kha_graphics2_SimplePipelineCache;
kha_graphics2_SimplePipelineCache.__name__ = "kha.graphics2.SimplePipelineCache";
kha_graphics2_SimplePipelineCache.__interfaces__ = [kha_graphics2_PipelineCache];
Object.assign(kha_graphics2_SimplePipelineCache.prototype, {
	__class__: kha_graphics2_SimplePipelineCache
});
class kha_graphics2_PerFramebufferPipelineCache {
	constructor(pipeline,texture) {
		this.pipelines = [];
		pipeline.compile();
		let projectionLocation = null;
		try {
			projectionLocation = pipeline.getConstantLocation("projectionMatrix");
		} catch( _g ) {
			haxe_Log.trace(haxe_Exception.caught(_g).unwrap(),{ fileName : "kha/graphics2/Graphics.hx", lineNumber : 87, className : "kha.graphics2.PerFramebufferPipelineCache", methodName : "new"});
		}
		let textureLocation = null;
		if(texture) {
			try {
				textureLocation = pipeline.getTextureUnit("tex");
			} catch( _g ) {
				haxe_Log.trace(haxe_Exception.caught(_g).unwrap(),{ fileName : "kha/graphics2/Graphics.hx", lineNumber : 96, className : "kha.graphics2.PerFramebufferPipelineCache", methodName : "new"});
			}
		}
		this.pipelines.push(new kha_graphics2_InternalPipeline(pipeline,projectionLocation,textureLocation));
	}
	get(colorFormats,depthStencilFormat) {
		return this.pipelines[this.hash(colorFormats,depthStencilFormat)];
	}
	hash(colorFormats,depthStencilFormat) {
		return 0;
	}
}
$hxClasses["kha.graphics2.PerFramebufferPipelineCache"] = kha_graphics2_PerFramebufferPipelineCache;
kha_graphics2_PerFramebufferPipelineCache.__name__ = "kha.graphics2.PerFramebufferPipelineCache";
kha_graphics2_PerFramebufferPipelineCache.__interfaces__ = [kha_graphics2_PipelineCache];
Object.assign(kha_graphics2_PerFramebufferPipelineCache.prototype, {
	__class__: kha_graphics2_PerFramebufferPipelineCache
});
class kha_graphics2_ImageShaderPainter {
	constructor(g4) {
		this.myPipeline = null;
		this.bilinearMipmaps = false;
		this.bilinear = false;
		this.g = g4;
		kha_graphics2_ImageShaderPainter.bufferStart = 0;
		kha_graphics2_ImageShaderPainter.bufferIndex = 0;
		kha_graphics2_ImageShaderPainter.initShaders();
		this.myPipeline = kha_graphics2_ImageShaderPainter.standardImagePipeline;
		this.initBuffers();
	}
	set_pipeline(pipe) {
		this.myPipeline = pipe != null ? pipe : kha_graphics2_ImageShaderPainter.standardImagePipeline;
		return this.myPipeline;
	}
	setProjection(projectionMatrix) {
		this.projectionMatrix = projectionMatrix;
	}
	initBuffers() {
		if(kha_graphics2_ImageShaderPainter.rectVertexBuffer == null) {
			kha_graphics2_ImageShaderPainter.rectVertexBuffer = new kha_graphics4_VertexBuffer(6000,kha_graphics2_ImageShaderPainter.structure,1);
			kha_graphics2_ImageShaderPainter.rectVertices = kha_graphics2_ImageShaderPainter.rectVertexBuffer.lock();
			kha_graphics2_ImageShaderPainter.indexBuffer = new kha_graphics4_IndexBuffer(9000,0);
			let indices = kha_graphics2_ImageShaderPainter.indexBuffer.lock();
			let _g = 0;
			while(_g < 1500) {
				let i = _g++;
				indices[i * 3 * 2] = i * 4;
				indices[i * 3 * 2 + 1] = i * 4 + 1;
				indices[i * 3 * 2 + 2] = i * 4 + 2;
				indices[i * 3 * 2 + 3] = i * 4;
				indices[i * 3 * 2 + 4] = i * 4 + 2;
				indices[i * 3 * 2 + 5] = i * 4 + 3;
			}
			kha_graphics2_ImageShaderPainter.indexBuffer.unlock();
		}
	}
	drawBuffer(end) {
		if(kha_graphics2_ImageShaderPainter.bufferIndex - kha_graphics2_ImageShaderPainter.bufferStart == 0) {
			return;
		}
		kha_graphics2_ImageShaderPainter.rectVertexBuffer.unlock((kha_graphics2_ImageShaderPainter.bufferIndex - kha_graphics2_ImageShaderPainter.bufferStart) * 4);
		let pipeline = this.myPipeline.get(null,3);
		this.g.setPipeline(pipeline.pipeline);
		this.g.setVertexBuffer(kha_graphics2_ImageShaderPainter.rectVertexBuffer);
		this.g.setIndexBuffer(kha_graphics2_ImageShaderPainter.indexBuffer);
		this.g.setTexture(pipeline.textureLocation,kha_graphics2_ImageShaderPainter.lastTexture);
		this.g.setTextureParameters(pipeline.textureLocation,2,2,this.bilinear ? 1 : 0,this.bilinear ? 1 : 0,this.bilinearMipmaps ? 2 : 0);
		let matrix = this.projectionMatrix;
		kha_graphics4_Graphics.mat[0] = matrix._00;
		kha_graphics4_Graphics.mat[1] = matrix._01;
		kha_graphics4_Graphics.mat[2] = matrix._02;
		kha_graphics4_Graphics.mat[3] = matrix._03;
		kha_graphics4_Graphics.mat[4] = matrix._10;
		kha_graphics4_Graphics.mat[5] = matrix._11;
		kha_graphics4_Graphics.mat[6] = matrix._12;
		kha_graphics4_Graphics.mat[7] = matrix._13;
		kha_graphics4_Graphics.mat[8] = matrix._20;
		kha_graphics4_Graphics.mat[9] = matrix._21;
		kha_graphics4_Graphics.mat[10] = matrix._22;
		kha_graphics4_Graphics.mat[11] = matrix._23;
		kha_graphics4_Graphics.mat[12] = matrix._30;
		kha_graphics4_Graphics.mat[13] = matrix._31;
		kha_graphics4_Graphics.mat[14] = matrix._32;
		kha_graphics4_Graphics.mat[15] = matrix._33;
		Krom.setMatrix(pipeline.projectionLocation,kha_graphics4_Graphics.mat.buffer);
		this.g.drawIndexedVertices(kha_graphics2_ImageShaderPainter.bufferStart * 2 * 3,(kha_graphics2_ImageShaderPainter.bufferIndex - kha_graphics2_ImageShaderPainter.bufferStart) * 2 * 3);
		this.g.setTexture(pipeline.textureLocation,null);
		if(end || (kha_graphics2_ImageShaderPainter.bufferStart + kha_graphics2_ImageShaderPainter.bufferIndex + 1) * 4 >= 1500) {
			kha_graphics2_ImageShaderPainter.bufferStart = 0;
			kha_graphics2_ImageShaderPainter.bufferIndex = 0;
			kha_graphics2_ImageShaderPainter.rectVertices = kha_graphics2_ImageShaderPainter.rectVertexBuffer.lock(0);
		} else {
			kha_graphics2_ImageShaderPainter.bufferStart = kha_graphics2_ImageShaderPainter.bufferIndex;
			kha_graphics2_ImageShaderPainter.rectVertices = kha_graphics2_ImageShaderPainter.rectVertexBuffer.lock(kha_graphics2_ImageShaderPainter.bufferStart * 4);
		}
	}
	setBilinearFilter(bilinear) {
		this.drawBuffer(false);
		kha_graphics2_ImageShaderPainter.lastTexture = null;
		this.bilinear = bilinear;
	}
	end() {
		if(kha_graphics2_ImageShaderPainter.bufferIndex > 0) {
			this.drawBuffer(true);
		}
		kha_graphics2_ImageShaderPainter.lastTexture = null;
	}
	static initShaders() {
		if(kha_graphics2_ImageShaderPainter.structure == null) {
			kha_graphics2_ImageShaderPainter.structure = kha_graphics2_Graphics.createImageVertexStructure();
		}
		if(kha_graphics2_ImageShaderPainter.standardImagePipeline == null) {
			kha_graphics2_ImageShaderPainter.standardImagePipeline = new kha_graphics2_PerFramebufferPipelineCache(kha_graphics2_Graphics.createImagePipeline(kha_graphics2_ImageShaderPainter.structure),true);
		}
	}
}
$hxClasses["kha.graphics2.ImageShaderPainter"] = kha_graphics2_ImageShaderPainter;
kha_graphics2_ImageShaderPainter.__name__ = "kha.graphics2.ImageShaderPainter";
Object.assign(kha_graphics2_ImageShaderPainter.prototype, {
	__class__: kha_graphics2_ImageShaderPainter
	,__properties__: {set_pipeline: "set_pipeline"}
});
class kha_graphics2_ColoredShaderPainter {
	constructor(g4) {
		this.myPipeline = null;
		this.g = g4;
		kha_graphics2_ColoredShaderPainter.bufferIndex = 0;
		kha_graphics2_ColoredShaderPainter.triangleBufferIndex = 0;
		kha_graphics2_ColoredShaderPainter.initShaders();
		this.myPipeline = kha_graphics2_ColoredShaderPainter.standardColorPipeline;
		this.initBuffers();
	}
	set_pipeline(pipe) {
		this.myPipeline = pipe != null ? pipe : kha_graphics2_ColoredShaderPainter.standardColorPipeline;
		return this.myPipeline;
	}
	setProjection(projectionMatrix) {
		this.projectionMatrix = projectionMatrix;
	}
	initBuffers() {
		if(kha_graphics2_ColoredShaderPainter.rectVertexBuffer == null) {
			kha_graphics2_ColoredShaderPainter.rectVertexBuffer = new kha_graphics4_VertexBuffer(4000,kha_graphics2_ColoredShaderPainter.structure,1);
			kha_graphics2_ColoredShaderPainter.rectVertices = kha_graphics2_ColoredShaderPainter.rectVertexBuffer.lock();
			kha_graphics2_ColoredShaderPainter.indexBuffer = new kha_graphics4_IndexBuffer(6000,0);
			let indices = kha_graphics2_ColoredShaderPainter.indexBuffer.lock();
			let _g = 0;
			while(_g < 1000) {
				let i = _g++;
				indices[i * 3 * 2] = i * 4;
				indices[i * 3 * 2 + 1] = i * 4 + 1;
				indices[i * 3 * 2 + 2] = i * 4 + 2;
				indices[i * 3 * 2 + 3] = i * 4;
				indices[i * 3 * 2 + 4] = i * 4 + 2;
				indices[i * 3 * 2 + 5] = i * 4 + 3;
			}
			kha_graphics2_ColoredShaderPainter.indexBuffer.unlock();
			kha_graphics2_ColoredShaderPainter.triangleVertexBuffer = new kha_graphics4_VertexBuffer(3000,kha_graphics2_ColoredShaderPainter.structure,1);
			kha_graphics2_ColoredShaderPainter.triangleVertices = kha_graphics2_ColoredShaderPainter.triangleVertexBuffer.lock();
			kha_graphics2_ColoredShaderPainter.triangleIndexBuffer = new kha_graphics4_IndexBuffer(3000,0);
			let triIndices = kha_graphics2_ColoredShaderPainter.triangleIndexBuffer.lock();
			let _g1 = 0;
			while(_g1 < 1000) {
				let i = _g1++;
				triIndices[i * 3] = i * 3;
				triIndices[i * 3 + 1] = i * 3 + 1;
				triIndices[i * 3 + 2] = i * 3 + 2;
			}
			kha_graphics2_ColoredShaderPainter.triangleIndexBuffer.unlock();
		}
	}
	setRectVertices(bottomleftx,bottomlefty,topleftx,toplefty,toprightx,toprighty,bottomrightx,bottomrighty) {
		let baseIndex = kha_graphics2_ColoredShaderPainter.bufferIndex * 4 * 4;
		kha_graphics2_ColoredShaderPainter.rectVertices.setFloat32(baseIndex * 4,bottomleftx,true);
		kha_graphics2_ColoredShaderPainter.rectVertices.setFloat32((baseIndex + 1) * 4,bottomlefty,true);
		kha_graphics2_ColoredShaderPainter.rectVertices.setFloat32((baseIndex + 2) * 4,-5.0,true);
		kha_graphics2_ColoredShaderPainter.rectVertices.setFloat32((baseIndex + 4) * 4,topleftx,true);
		kha_graphics2_ColoredShaderPainter.rectVertices.setFloat32((baseIndex + 5) * 4,toplefty,true);
		kha_graphics2_ColoredShaderPainter.rectVertices.setFloat32((baseIndex + 6) * 4,-5.0,true);
		kha_graphics2_ColoredShaderPainter.rectVertices.setFloat32((baseIndex + 8) * 4,toprightx,true);
		kha_graphics2_ColoredShaderPainter.rectVertices.setFloat32((baseIndex + 9) * 4,toprighty,true);
		kha_graphics2_ColoredShaderPainter.rectVertices.setFloat32((baseIndex + 10) * 4,-5.0,true);
		kha_graphics2_ColoredShaderPainter.rectVertices.setFloat32((baseIndex + 12) * 4,bottomrightx,true);
		kha_graphics2_ColoredShaderPainter.rectVertices.setFloat32((baseIndex + 13) * 4,bottomrighty,true);
		kha_graphics2_ColoredShaderPainter.rectVertices.setFloat32((baseIndex + 14) * 4,-5.0,true);
	}
	setRectColors(opacity,color) {
		let baseIndex = kha_graphics2_ColoredShaderPainter.bufferIndex * 4 * 4 * 4;
		let a = opacity * ((color >>> 24) * 0.00392156862745098);
		let r = a * (((color & 16711680) >>> 16) * 0.00392156862745098);
		let g = a * (((color & 65280) >>> 8) * 0.00392156862745098);
		let b = a * ((color & 255) * 0.00392156862745098);
		kha_graphics2_ColoredShaderPainter.rectVertices.setUint8(baseIndex + 12,r * 255 | 0);
		kha_graphics2_ColoredShaderPainter.rectVertices.setUint8(baseIndex + 12 + 1,g * 255 | 0);
		kha_graphics2_ColoredShaderPainter.rectVertices.setUint8(baseIndex + 12 + 2,b * 255 | 0);
		kha_graphics2_ColoredShaderPainter.rectVertices.setUint8(baseIndex + 12 + 3,a * 255 | 0);
		kha_graphics2_ColoredShaderPainter.rectVertices.setUint8(baseIndex + 28,r * 255 | 0);
		kha_graphics2_ColoredShaderPainter.rectVertices.setUint8(baseIndex + 28 + 1,g * 255 | 0);
		kha_graphics2_ColoredShaderPainter.rectVertices.setUint8(baseIndex + 28 + 2,b * 255 | 0);
		kha_graphics2_ColoredShaderPainter.rectVertices.setUint8(baseIndex + 28 + 3,a * 255 | 0);
		kha_graphics2_ColoredShaderPainter.rectVertices.setUint8(baseIndex + 44,r * 255 | 0);
		kha_graphics2_ColoredShaderPainter.rectVertices.setUint8(baseIndex + 44 + 1,g * 255 | 0);
		kha_graphics2_ColoredShaderPainter.rectVertices.setUint8(baseIndex + 44 + 2,b * 255 | 0);
		kha_graphics2_ColoredShaderPainter.rectVertices.setUint8(baseIndex + 44 + 3,a * 255 | 0);
		kha_graphics2_ColoredShaderPainter.rectVertices.setUint8(baseIndex + 60,r * 255 | 0);
		kha_graphics2_ColoredShaderPainter.rectVertices.setUint8(baseIndex + 60 + 1,g * 255 | 0);
		kha_graphics2_ColoredShaderPainter.rectVertices.setUint8(baseIndex + 60 + 2,b * 255 | 0);
		kha_graphics2_ColoredShaderPainter.rectVertices.setUint8(baseIndex + 60 + 3,a * 255 | 0);
	}
	setTriVertices(x1,y1,x2,y2,x3,y3) {
		let baseIndex = kha_graphics2_ColoredShaderPainter.triangleBufferIndex * 4 * 3;
		kha_graphics2_ColoredShaderPainter.triangleVertices.setFloat32(baseIndex * 4,x1,true);
		kha_graphics2_ColoredShaderPainter.triangleVertices.setFloat32((baseIndex + 1) * 4,y1,true);
		kha_graphics2_ColoredShaderPainter.triangleVertices.setFloat32((baseIndex + 2) * 4,-5.0,true);
		kha_graphics2_ColoredShaderPainter.triangleVertices.setFloat32((baseIndex + 4) * 4,x2,true);
		kha_graphics2_ColoredShaderPainter.triangleVertices.setFloat32((baseIndex + 5) * 4,y2,true);
		kha_graphics2_ColoredShaderPainter.triangleVertices.setFloat32((baseIndex + 6) * 4,-5.0,true);
		kha_graphics2_ColoredShaderPainter.triangleVertices.setFloat32((baseIndex + 8) * 4,x3,true);
		kha_graphics2_ColoredShaderPainter.triangleVertices.setFloat32((baseIndex + 9) * 4,y3,true);
		kha_graphics2_ColoredShaderPainter.triangleVertices.setFloat32((baseIndex + 10) * 4,-5.0,true);
	}
	setTriColors(opacity,color) {
		let baseIndex = kha_graphics2_ColoredShaderPainter.triangleBufferIndex * 4 * 4 * 3;
		let a = opacity * ((color >>> 24) * 0.00392156862745098);
		let r = a * (((color & 16711680) >>> 16) * 0.00392156862745098);
		let g = a * (((color & 65280) >>> 8) * 0.00392156862745098);
		let b = a * ((color & 255) * 0.00392156862745098);
		kha_graphics2_ColoredShaderPainter.triangleVertices.setUint8(baseIndex + 12,r * 255 | 0);
		kha_graphics2_ColoredShaderPainter.triangleVertices.setUint8(baseIndex + 12 + 1,g * 255 | 0);
		kha_graphics2_ColoredShaderPainter.triangleVertices.setUint8(baseIndex + 12 + 2,b * 255 | 0);
		kha_graphics2_ColoredShaderPainter.triangleVertices.setUint8(baseIndex + 12 + 3,a * 255 | 0);
		kha_graphics2_ColoredShaderPainter.triangleVertices.setUint8(baseIndex + 28,r * 255 | 0);
		kha_graphics2_ColoredShaderPainter.triangleVertices.setUint8(baseIndex + 28 + 1,g * 255 | 0);
		kha_graphics2_ColoredShaderPainter.triangleVertices.setUint8(baseIndex + 28 + 2,b * 255 | 0);
		kha_graphics2_ColoredShaderPainter.triangleVertices.setUint8(baseIndex + 28 + 3,a * 255 | 0);
		kha_graphics2_ColoredShaderPainter.triangleVertices.setUint8(baseIndex + 44,r * 255 | 0);
		kha_graphics2_ColoredShaderPainter.triangleVertices.setUint8(baseIndex + 44 + 1,g * 255 | 0);
		kha_graphics2_ColoredShaderPainter.triangleVertices.setUint8(baseIndex + 44 + 2,b * 255 | 0);
		kha_graphics2_ColoredShaderPainter.triangleVertices.setUint8(baseIndex + 44 + 3,a * 255 | 0);
	}
	drawBuffer(trisDone) {
		if(kha_graphics2_ColoredShaderPainter.bufferIndex == 0) {
			return;
		}
		if(!trisDone) {
			if(kha_graphics2_ColoredShaderPainter.triangleBufferIndex > 0) {
				this.drawTriBuffer(true);
			}
		}
		kha_graphics2_ColoredShaderPainter.rectVertexBuffer.unlock(kha_graphics2_ColoredShaderPainter.bufferIndex * 4);
		let pipeline = this.myPipeline.get(null,3);
		this.g.setPipeline(pipeline.pipeline);
		this.g.setVertexBuffer(kha_graphics2_ColoredShaderPainter.rectVertexBuffer);
		this.g.setIndexBuffer(kha_graphics2_ColoredShaderPainter.indexBuffer);
		let matrix = this.projectionMatrix;
		kha_graphics4_Graphics.mat[0] = matrix._00;
		kha_graphics4_Graphics.mat[1] = matrix._01;
		kha_graphics4_Graphics.mat[2] = matrix._02;
		kha_graphics4_Graphics.mat[3] = matrix._03;
		kha_graphics4_Graphics.mat[4] = matrix._10;
		kha_graphics4_Graphics.mat[5] = matrix._11;
		kha_graphics4_Graphics.mat[6] = matrix._12;
		kha_graphics4_Graphics.mat[7] = matrix._13;
		kha_graphics4_Graphics.mat[8] = matrix._20;
		kha_graphics4_Graphics.mat[9] = matrix._21;
		kha_graphics4_Graphics.mat[10] = matrix._22;
		kha_graphics4_Graphics.mat[11] = matrix._23;
		kha_graphics4_Graphics.mat[12] = matrix._30;
		kha_graphics4_Graphics.mat[13] = matrix._31;
		kha_graphics4_Graphics.mat[14] = matrix._32;
		kha_graphics4_Graphics.mat[15] = matrix._33;
		Krom.setMatrix(pipeline.projectionLocation,kha_graphics4_Graphics.mat.buffer);
		this.g.drawIndexedVertices(0,kha_graphics2_ColoredShaderPainter.bufferIndex * 2 * 3);
		kha_graphics2_ColoredShaderPainter.bufferIndex = 0;
		kha_graphics2_ColoredShaderPainter.rectVertices = kha_graphics2_ColoredShaderPainter.rectVertexBuffer.lock();
	}
	drawTriBuffer(rectsDone) {
		if(!rectsDone) {
			if(kha_graphics2_ColoredShaderPainter.bufferIndex > 0) {
				this.drawBuffer(true);
			}
		}
		kha_graphics2_ColoredShaderPainter.triangleVertexBuffer.unlock(kha_graphics2_ColoredShaderPainter.triangleBufferIndex * 3);
		let pipeline = this.myPipeline.get(null,3);
		this.g.setPipeline(pipeline.pipeline);
		this.g.setVertexBuffer(kha_graphics2_ColoredShaderPainter.triangleVertexBuffer);
		this.g.setIndexBuffer(kha_graphics2_ColoredShaderPainter.triangleIndexBuffer);
		let matrix = this.projectionMatrix;
		kha_graphics4_Graphics.mat[0] = matrix._00;
		kha_graphics4_Graphics.mat[1] = matrix._01;
		kha_graphics4_Graphics.mat[2] = matrix._02;
		kha_graphics4_Graphics.mat[3] = matrix._03;
		kha_graphics4_Graphics.mat[4] = matrix._10;
		kha_graphics4_Graphics.mat[5] = matrix._11;
		kha_graphics4_Graphics.mat[6] = matrix._12;
		kha_graphics4_Graphics.mat[7] = matrix._13;
		kha_graphics4_Graphics.mat[8] = matrix._20;
		kha_graphics4_Graphics.mat[9] = matrix._21;
		kha_graphics4_Graphics.mat[10] = matrix._22;
		kha_graphics4_Graphics.mat[11] = matrix._23;
		kha_graphics4_Graphics.mat[12] = matrix._30;
		kha_graphics4_Graphics.mat[13] = matrix._31;
		kha_graphics4_Graphics.mat[14] = matrix._32;
		kha_graphics4_Graphics.mat[15] = matrix._33;
		Krom.setMatrix(pipeline.projectionLocation,kha_graphics4_Graphics.mat.buffer);
		this.g.drawIndexedVertices(0,kha_graphics2_ColoredShaderPainter.triangleBufferIndex * 3);
		kha_graphics2_ColoredShaderPainter.triangleBufferIndex = 0;
		kha_graphics2_ColoredShaderPainter.triangleVertices = kha_graphics2_ColoredShaderPainter.triangleVertexBuffer.lock();
	}
	fillRect(opacity,color,bottomleftx,bottomlefty,topleftx,toplefty,toprightx,toprighty,bottomrightx,bottomrighty) {
		if(kha_graphics2_ColoredShaderPainter.triangleBufferIndex > 0) {
			this.drawTriBuffer(true);
		}
		if(kha_graphics2_ColoredShaderPainter.bufferIndex + 1 >= 1000) {
			this.drawBuffer(false);
		}
		this.setRectColors(opacity,color);
		this.setRectVertices(bottomleftx,bottomlefty,topleftx,toplefty,toprightx,toprighty,bottomrightx,bottomrighty);
		++kha_graphics2_ColoredShaderPainter.bufferIndex;
	}
	fillTriangle(opacity,color,x1,y1,x2,y2,x3,y3) {
		if(kha_graphics2_ColoredShaderPainter.bufferIndex > 0) {
			this.drawBuffer(true);
		}
		if(kha_graphics2_ColoredShaderPainter.triangleBufferIndex + 1 >= 1000) {
			this.drawTriBuffer(false);
		}
		this.setTriColors(opacity,color);
		this.setTriVertices(x1,y1,x2,y2,x3,y3);
		++kha_graphics2_ColoredShaderPainter.triangleBufferIndex;
	}
	static initShaders() {
		if(kha_graphics2_ColoredShaderPainter.structure == null) {
			kha_graphics2_ColoredShaderPainter.structure = kha_graphics2_Graphics.createColoredVertexStructure();
		}
		if(kha_graphics2_ColoredShaderPainter.standardColorPipeline == null) {
			kha_graphics2_ColoredShaderPainter.standardColorPipeline = new kha_graphics2_PerFramebufferPipelineCache(kha_graphics2_Graphics.createColoredPipeline(kha_graphics2_ColoredShaderPainter.structure),false);
		}
	}
}
$hxClasses["kha.graphics2.ColoredShaderPainter"] = kha_graphics2_ColoredShaderPainter;
kha_graphics2_ColoredShaderPainter.__name__ = "kha.graphics2.ColoredShaderPainter";
Object.assign(kha_graphics2_ColoredShaderPainter.prototype, {
	__class__: kha_graphics2_ColoredShaderPainter
	,__properties__: {set_pipeline: "set_pipeline"}
});
class kha_graphics2_TextShaderPainter {
	constructor(g4) {
		this.bakedQuadCache = new kha_AlignedQuad();
		this.bilinear = false;
		this.myPipeline = null;
		this.g = g4;
		kha_graphics2_TextShaderPainter.bufferIndex = 0;
		kha_graphics2_TextShaderPainter.initShaders();
		this.myPipeline = kha_graphics2_TextShaderPainter.standardTextPipeline;
		this.initBuffers();
	}
	set_pipeline(pipe) {
		this.myPipeline = pipe != null ? pipe : kha_graphics2_TextShaderPainter.standardTextPipeline;
		return this.myPipeline;
	}
	setProjection(projectionMatrix) {
		this.projectionMatrix = projectionMatrix;
	}
	initBuffers() {
		if(kha_graphics2_TextShaderPainter.rectVertexBuffer == null) {
			kha_graphics2_TextShaderPainter.rectVertexBuffer = new kha_graphics4_VertexBuffer(4000,kha_graphics2_TextShaderPainter.structure,1);
			kha_graphics2_TextShaderPainter.rectVertices = kha_graphics2_TextShaderPainter.rectVertexBuffer.lock();
			kha_graphics2_TextShaderPainter.indexBuffer = new kha_graphics4_IndexBuffer(6000,0);
			let indices = kha_graphics2_TextShaderPainter.indexBuffer.lock();
			let _g = 0;
			while(_g < 1000) {
				let i = _g++;
				indices[i * 3 * 2] = i * 4;
				indices[i * 3 * 2 + 1] = i * 4 + 1;
				indices[i * 3 * 2 + 2] = i * 4 + 2;
				indices[i * 3 * 2 + 3] = i * 4;
				indices[i * 3 * 2 + 4] = i * 4 + 2;
				indices[i * 3 * 2 + 5] = i * 4 + 3;
			}
			kha_graphics2_TextShaderPainter.indexBuffer.unlock();
		}
	}
	setRectVertices(bottomleftx,bottomlefty,topleftx,toplefty,toprightx,toprighty,bottomrightx,bottomrighty) {
		let baseIndex = kha_graphics2_TextShaderPainter.bufferIndex * 9 * 4;
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32(baseIndex * 4,bottomleftx,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 1) * 4,bottomlefty,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 2) * 4,-5.0,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 9) * 4,topleftx,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 10) * 4,toplefty,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 11) * 4,-5.0,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 18) * 4,toprightx,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 19) * 4,toprighty,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 20) * 4,-5.0,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 27) * 4,bottomrightx,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 28) * 4,bottomrighty,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 29) * 4,-5.0,true);
	}
	setRectTexCoords(left,top,right,bottom) {
		let baseIndex = kha_graphics2_TextShaderPainter.bufferIndex * 9 * 4;
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 3) * 4,left,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 4) * 4,bottom,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 12) * 4,left,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 13) * 4,top,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 21) * 4,right,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 22) * 4,top,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 30) * 4,right,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 31) * 4,bottom,true);
	}
	setRectColors(opacity,color) {
		let baseIndex = kha_graphics2_TextShaderPainter.bufferIndex * 9 * 4;
		let a = opacity * ((color >>> 24) * 0.00392156862745098);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 5) * 4,((color & 16711680) >>> 16) * 0.00392156862745098,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 6) * 4,((color & 65280) >>> 8) * 0.00392156862745098,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 7) * 4,(color & 255) * 0.00392156862745098,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 8) * 4,a,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 14) * 4,((color & 16711680) >>> 16) * 0.00392156862745098,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 15) * 4,((color & 65280) >>> 8) * 0.00392156862745098,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 16) * 4,(color & 255) * 0.00392156862745098,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 17) * 4,a,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 23) * 4,((color & 16711680) >>> 16) * 0.00392156862745098,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 24) * 4,((color & 65280) >>> 8) * 0.00392156862745098,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 25) * 4,(color & 255) * 0.00392156862745098,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 26) * 4,a,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 32) * 4,((color & 16711680) >>> 16) * 0.00392156862745098,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 33) * 4,((color & 65280) >>> 8) * 0.00392156862745098,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 34) * 4,(color & 255) * 0.00392156862745098,true);
		kha_graphics2_TextShaderPainter.rectVertices.setFloat32((baseIndex + 35) * 4,a,true);
	}
	drawBuffer() {
		if(kha_graphics2_TextShaderPainter.bufferIndex == 0) {
			return;
		}
		kha_graphics2_TextShaderPainter.rectVertexBuffer.unlock(kha_graphics2_TextShaderPainter.bufferIndex * 4);
		let pipeline = this.myPipeline.get(null,3);
		this.g.setPipeline(pipeline.pipeline);
		this.g.setVertexBuffer(kha_graphics2_TextShaderPainter.rectVertexBuffer);
		this.g.setIndexBuffer(kha_graphics2_TextShaderPainter.indexBuffer);
		let matrix = this.projectionMatrix;
		kha_graphics4_Graphics.mat[0] = matrix._00;
		kha_graphics4_Graphics.mat[1] = matrix._01;
		kha_graphics4_Graphics.mat[2] = matrix._02;
		kha_graphics4_Graphics.mat[3] = matrix._03;
		kha_graphics4_Graphics.mat[4] = matrix._10;
		kha_graphics4_Graphics.mat[5] = matrix._11;
		kha_graphics4_Graphics.mat[6] = matrix._12;
		kha_graphics4_Graphics.mat[7] = matrix._13;
		kha_graphics4_Graphics.mat[8] = matrix._20;
		kha_graphics4_Graphics.mat[9] = matrix._21;
		kha_graphics4_Graphics.mat[10] = matrix._22;
		kha_graphics4_Graphics.mat[11] = matrix._23;
		kha_graphics4_Graphics.mat[12] = matrix._30;
		kha_graphics4_Graphics.mat[13] = matrix._31;
		kha_graphics4_Graphics.mat[14] = matrix._32;
		kha_graphics4_Graphics.mat[15] = matrix._33;
		Krom.setMatrix(pipeline.projectionLocation,kha_graphics4_Graphics.mat.buffer);
		this.g.setTexture(pipeline.textureLocation,kha_graphics2_TextShaderPainter.lastTexture);
		this.g.setTextureParameters(pipeline.textureLocation,2,2,this.bilinear ? 1 : 0,this.bilinear ? 1 : 0,0);
		this.g.drawIndexedVertices(0,kha_graphics2_TextShaderPainter.bufferIndex * 2 * 3);
		this.g.setTexture(pipeline.textureLocation,null);
		kha_graphics2_TextShaderPainter.bufferIndex = 0;
		kha_graphics2_TextShaderPainter.rectVertices = kha_graphics2_TextShaderPainter.rectVertexBuffer.lock();
	}
	setBilinearFilter(bilinear) {
		this.end();
		this.bilinear = bilinear;
	}
	setFont(font) {
		this.font = font;
	}
	drawString(text,opacity,color,x,y,transformation) {
		let font = this.font._get(this.fontSize);
		let tex = font.getTexture();
		if(kha_graphics2_TextShaderPainter.lastTexture != null && tex != kha_graphics2_TextShaderPainter.lastTexture) {
			this.drawBuffer();
		}
		kha_graphics2_TextShaderPainter.lastTexture = tex;
		let xpos = x;
		let _g = 0;
		let _g1 = text.length;
		while(_g < _g1) {
			let charCode = text.charCodeAt(_g++);
			let q = font.getBakedQuad(this.bakedQuadCache,kha_graphics2_TextShaderPainter.findIndex(charCode),xpos,y);
			if(q != null) {
				if(kha_graphics2_TextShaderPainter.bufferIndex + 1 >= 1000) {
					this.drawBuffer();
				}
				this.setRectColors(opacity,color);
				this.setRectTexCoords(q.s0,q.t0,q.s1,q.t1);
				let x = q.x0;
				let y = q.y1;
				if(y == null) {
					y = 0;
				}
				if(x == null) {
					x = 0;
				}
				let value_x = x;
				let value_y = y;
				let w = transformation._02 * value_x + transformation._12 * value_y + transformation._22;
				let x1 = (transformation._00 * value_x + transformation._10 * value_y + transformation._20) / w;
				let y1 = (transformation._01 * value_x + transformation._11 * value_y + transformation._21) / w;
				let x2 = x1;
				let y2 = y1;
				if(y1 == null) {
					y2 = 0;
				}
				if(x1 == null) {
					x2 = 0;
				}
				let x3 = q.x0;
				let y3 = q.y0;
				if(y3 == null) {
					y3 = 0;
				}
				if(x3 == null) {
					x3 = 0;
				}
				let value_x1 = x3;
				let value_y1 = y3;
				let w1 = transformation._02 * value_x1 + transformation._12 * value_y1 + transformation._22;
				let x4 = (transformation._00 * value_x1 + transformation._10 * value_y1 + transformation._20) / w1;
				let y4 = (transformation._01 * value_x1 + transformation._11 * value_y1 + transformation._21) / w1;
				let x5 = x4;
				let y5 = y4;
				if(y4 == null) {
					y5 = 0;
				}
				if(x4 == null) {
					x5 = 0;
				}
				let x6 = q.x1;
				let y6 = q.y0;
				if(y6 == null) {
					y6 = 0;
				}
				if(x6 == null) {
					x6 = 0;
				}
				let value_x2 = x6;
				let value_y2 = y6;
				let w2 = transformation._02 * value_x2 + transformation._12 * value_y2 + transformation._22;
				let x7 = (transformation._00 * value_x2 + transformation._10 * value_y2 + transformation._20) / w2;
				let y7 = (transformation._01 * value_x2 + transformation._11 * value_y2 + transformation._21) / w2;
				let x8 = x7;
				let y8 = y7;
				if(y7 == null) {
					y8 = 0;
				}
				if(x7 == null) {
					x8 = 0;
				}
				let x9 = q.x1;
				let y9 = q.y1;
				if(y9 == null) {
					y9 = 0;
				}
				if(x9 == null) {
					x9 = 0;
				}
				let value_x3 = x9;
				let value_y3 = y9;
				let w3 = transformation._02 * value_x3 + transformation._12 * value_y3 + transformation._22;
				let x10 = (transformation._00 * value_x3 + transformation._10 * value_y3 + transformation._20) / w3;
				let y10 = (transformation._01 * value_x3 + transformation._11 * value_y3 + transformation._21) / w3;
				let x11 = x10;
				let y11 = y10;
				if(y10 == null) {
					y11 = 0;
				}
				if(x10 == null) {
					x11 = 0;
				}
				this.setRectVertices(x2,y2,x5,y5,x8,y8,x11,y11);
				xpos += q.xadvance;
				++kha_graphics2_TextShaderPainter.bufferIndex;
			}
		}
	}
	end() {
		if(kha_graphics2_TextShaderPainter.bufferIndex > 0) {
			this.drawBuffer();
		}
		kha_graphics2_TextShaderPainter.lastTexture = null;
	}
	static initShaders() {
		if(kha_graphics2_TextShaderPainter.structure == null) {
			kha_graphics2_TextShaderPainter.structure = kha_graphics2_Graphics.createTextVertexStructure();
		}
		if(kha_graphics2_TextShaderPainter.standardTextPipeline == null) {
			kha_graphics2_TextShaderPainter.standardTextPipeline = new kha_graphics2_PerFramebufferPipelineCache(kha_graphics2_Graphics.createTextPipeline(kha_graphics2_TextShaderPainter.structure),true);
		}
	}
	static findIndex(charCode) {
		let blocks = kha_KravurImage.charBlocks;
		let offset = 0;
		let _g = 0;
		let _g1 = blocks.length / 2 | 0;
		while(_g < _g1) {
			let i = _g++;
			let start = blocks[i * 2];
			let end = blocks[i * 2 + 1];
			if(charCode >= start && charCode <= end) {
				return offset + charCode - start;
			}
			offset += end - start + 1;
		}
		return 0;
	}
}
$hxClasses["kha.graphics2.TextShaderPainter"] = kha_graphics2_TextShaderPainter;
kha_graphics2_TextShaderPainter.__name__ = "kha.graphics2.TextShaderPainter";
Object.assign(kha_graphics2_TextShaderPainter.prototype, {
	__class__: kha_graphics2_TextShaderPainter
	,__properties__: {set_pipeline: "set_pipeline"}
});
class kha_graphics2_Graphics {
	constructor(canvas) {
		this.scissorH = -1;
		this.scissorW = -1;
		this.scissorY = -1;
		this.scissorX = -1;
		this.scissorEnabled = false;
		this.lastPipeline = null;
		this.pipelineCache = new haxe_ds_ObjectMap();
		this.myImageScaleQuality = kha_graphics2_ImageScaleQuality.Low;
		this.transformations = [new kha_math_FastMatrix3(1,0,0,0,1,0,0,0,1)];
		this.transformationIndex = 0;
		this.opacities = [1];
		this.myFontSize = 12;
		this.pipe = null;
		this.set_color(-1);
		this.canvas = canvas;
		this.g = canvas.get_g4();
		this.imagePainter = new kha_graphics2_ImageShaderPainter(this.g);
		this.coloredPainter = new kha_graphics2_ColoredShaderPainter(this.g);
		this.textPainter = new kha_graphics2_TextShaderPainter(this.g);
		this.textPainter.fontSize = this.get_fontSize();
		this.projectionMatrix = new kha_math_FastMatrix4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);
		this.setProjection();
		if(kha_graphics2_Graphics.videoPipeline == null) {
			kha_graphics2_Graphics.videoPipeline = kha_graphics2_Graphics.createImagePipeline(kha_graphics2_Graphics.createImageVertexStructure());
			kha_graphics2_Graphics.videoPipeline.fragmentShader = kha_Shaders.getFragment("painter-video.frag");
			kha_graphics2_Graphics.videoPipeline.vertexShader = kha_Shaders.getVertex("painter-video.vert");
			kha_graphics2_Graphics.videoPipeline.compile();
		}
	}
	popTransformation() {
		this.transformationIndex--;
		this.setTransformation(this.transformations[this.transformationIndex]);
		return this.transformations[this.transformationIndex + 1];
	}
	setTransformation(transformation) {
	}
	setOpacity(opacity) {
	}
	pushRotation(angle,centerx,centery) {
		let _this__00 = 1;
		let _this__10 = 0;
		let _this__01 = 0;
		let _this__11 = 1;
		let _this__02 = 0;
		let _this__12 = 0;
		let _this__22 = 1;
		let _00 = Math.cos(angle);
		let _10 = -Math.sin(angle);
		let _01 = Math.sin(angle);
		let _11 = Math.cos(angle);
		let m__20 = 0;
		let m__21 = 0;
		let m__02 = 0;
		let m__12 = 0;
		let m__22 = 1;
		let _001 = _this__00 * _00 + _this__10 * _01 + centerx * m__02;
		let _101 = _this__00 * _10 + _this__10 * _11 + centerx * m__12;
		let _20 = _this__00 * m__20 + _this__10 * m__21 + centerx * m__22;
		let _011 = _this__01 * _00 + _this__11 * _01 + centery * m__02;
		let _111 = _this__01 * _10 + _this__11 * _11 + centery * m__12;
		let _21 = _this__01 * m__20 + _this__11 * m__21 + centery * m__22;
		let _02 = _this__02 * _00 + _this__12 * _01 + _this__22 * m__02;
		let _12 = _this__02 * _10 + _this__12 * _11 + _this__22 * m__12;
		let _22 = _this__02 * m__20 + _this__12 * m__21 + _this__22 * m__22;
		let m__00 = 1;
		let m__10 = 0;
		let m__201 = -centerx;
		let m__01 = 0;
		let m__11 = 1;
		let m__211 = -centery;
		let m__021 = 0;
		let m__121 = 0;
		let m__221 = 1;
		let _002 = _001 * m__00 + _101 * m__01 + _20 * m__021;
		let _102 = _001 * m__10 + _101 * m__11 + _20 * m__121;
		let _201 = _001 * m__201 + _101 * m__211 + _20 * m__221;
		let _012 = _011 * m__00 + _111 * m__01 + _21 * m__021;
		let _112 = _011 * m__10 + _111 * m__11 + _21 * m__121;
		let _211 = _011 * m__201 + _111 * m__211 + _21 * m__221;
		let _021 = _02 * m__00 + _12 * m__01 + _22 * m__021;
		let _121 = _02 * m__10 + _12 * m__11 + _22 * m__121;
		let _221 = _02 * m__201 + _12 * m__211 + _22 * m__221;
		let m = this.transformations[this.transformationIndex];
		let _003 = _002 * m._00 + _102 * m._01 + _201 * m._02;
		let _103 = _002 * m._10 + _102 * m._11 + _201 * m._12;
		let _202 = _002 * m._20 + _102 * m._21 + _201 * m._22;
		let _013 = _012 * m._00 + _112 * m._01 + _211 * m._02;
		let _113 = _012 * m._10 + _112 * m._11 + _211 * m._12;
		let _212 = _012 * m._20 + _112 * m._21 + _211 * m._22;
		let _022 = _021 * m._00 + _121 * m._01 + _221 * m._02;
		let _122 = _021 * m._10 + _121 * m._11 + _221 * m._12;
		let _222 = _021 * m._20 + _121 * m._21 + _221 * m._22;
		this.transformationIndex++;
		if(this.transformationIndex == this.transformations.length) {
			this.transformations.push(new kha_math_FastMatrix3(1,0,0,0,1,0,0,0,1));
		}
		let _this = this.transformations[this.transformationIndex];
		_this._00 = _003;
		_this._10 = _103;
		_this._20 = _202;
		_this._01 = _013;
		_this._11 = _113;
		_this._21 = _212;
		_this._02 = _022;
		_this._12 = _122;
		_this._22 = _222;
		this.setTransformation(this.transformations[this.transformationIndex]);
	}
	get_opacity() {
		return this.opacities[this.opacities.length - 1];
	}
	set_opacity(opacity) {
		this.setOpacity(opacity);
		return this.opacities[this.opacities.length - 1] = opacity;
	}
	set_pipeline(pipeline) {
		this.setPipeline(pipeline);
		return this.pipe = pipeline;
	}
	setProjection() {
		let width = this.canvas.get_width();
		let height = this.canvas.get_height();
		if(((this.canvas) instanceof kha_Framebuffer)) {
			let _this = this.projectionMatrix;
			_this._00 = 2 / width;
			_this._10 = 0;
			_this._20 = 0;
			_this._30 = -width / width;
			_this._01 = 0;
			_this._11 = 2.0 / (0 - height);
			_this._21 = 0;
			_this._31 = -height / (0 - height);
			_this._02 = 0;
			_this._12 = 0;
			_this._22 = -0.002000200020002;
			_this._32 = -1.0002000200020003;
			_this._03 = 0;
			_this._13 = 0;
			_this._23 = 0;
			_this._33 = 1;
		} else {
			if(!kha_Image.get_nonPow2Supported()) {
				width = kha_graphics2_Graphics.upperPowerOfTwo(width);
				height = kha_graphics2_Graphics.upperPowerOfTwo(height);
			}
			if(kha_Image.renderTargetsInvertedY()) {
				let _this = this.projectionMatrix;
				_this._00 = 2 / width;
				_this._10 = 0;
				_this._20 = 0;
				_this._30 = -width / width;
				_this._01 = 0;
				_this._11 = 2.0 / height;
				_this._21 = 0;
				_this._31 = -height / height;
				_this._02 = 0;
				_this._12 = 0;
				_this._22 = -0.002000200020002;
				_this._32 = -1.0002000200020003;
				_this._03 = 0;
				_this._13 = 0;
				_this._23 = 0;
				_this._33 = 1;
			} else {
				let _this = this.projectionMatrix;
				_this._00 = 2 / width;
				_this._10 = 0;
				_this._20 = 0;
				_this._30 = -width / width;
				_this._01 = 0;
				_this._11 = 2.0 / (0 - height);
				_this._21 = 0;
				_this._31 = -height / (0 - height);
				_this._02 = 0;
				_this._12 = 0;
				_this._22 = -0.002000200020002;
				_this._32 = -1.0002000200020003;
				_this._03 = 0;
				_this._13 = 0;
				_this._23 = 0;
				_this._33 = 1;
			}
		}
		this.imagePainter.setProjection(this.projectionMatrix);
		this.coloredPainter.setProjection(this.projectionMatrix);
		this.textPainter.setProjection(this.projectionMatrix);
	}
	drawImage(img,x,y) {
		let _this = this.coloredPainter;
		if(kha_graphics2_ColoredShaderPainter.triangleBufferIndex > 0) {
			_this.drawTriBuffer(false);
		}
		if(kha_graphics2_ColoredShaderPainter.bufferIndex > 0) {
			_this.drawBuffer(false);
		}
		this.textPainter.end();
		let xw = x + img.get_width();
		let yh = y + img.get_height();
		let _this1 = this.transformations[this.transformationIndex];
		let x1 = x;
		let y1 = yh;
		if(yh == null) {
			y1 = 0;
		}
		if(x == null) {
			x1 = 0;
		}
		let value_x = x1;
		let value_y = y1;
		let w = _this1._02 * value_x + _this1._12 * value_y + _this1._22;
		let x2 = (_this1._00 * value_x + _this1._10 * value_y + _this1._20) / w;
		let y2 = (_this1._01 * value_x + _this1._11 * value_y + _this1._21) / w;
		let x3 = x2;
		let y3 = y2;
		if(y2 == null) {
			y3 = 0;
		}
		if(x2 == null) {
			x3 = 0;
		}
		let _this2 = this.transformations[this.transformationIndex];
		let x4 = x;
		let y4 = y;
		if(y == null) {
			y4 = 0;
		}
		if(x == null) {
			x4 = 0;
		}
		let value_x1 = x4;
		let value_y1 = y4;
		let w1 = _this2._02 * value_x1 + _this2._12 * value_y1 + _this2._22;
		let x5 = (_this2._00 * value_x1 + _this2._10 * value_y1 + _this2._20) / w1;
		let y5 = (_this2._01 * value_x1 + _this2._11 * value_y1 + _this2._21) / w1;
		let x6 = x5;
		let y6 = y5;
		if(y5 == null) {
			y6 = 0;
		}
		if(x5 == null) {
			x6 = 0;
		}
		let _this3 = this.transformations[this.transformationIndex];
		let x7 = xw;
		let y7 = y;
		if(y == null) {
			y7 = 0;
		}
		if(xw == null) {
			x7 = 0;
		}
		let value_x2 = x7;
		let value_y2 = y7;
		let w2 = _this3._02 * value_x2 + _this3._12 * value_y2 + _this3._22;
		let x8 = (_this3._00 * value_x2 + _this3._10 * value_y2 + _this3._20) / w2;
		let y8 = (_this3._01 * value_x2 + _this3._11 * value_y2 + _this3._21) / w2;
		let x9 = x8;
		let y9 = y8;
		if(y8 == null) {
			y9 = 0;
		}
		if(x8 == null) {
			x9 = 0;
		}
		let _this4 = this.transformations[this.transformationIndex];
		let x10 = xw;
		let y10 = yh;
		if(yh == null) {
			y10 = 0;
		}
		if(xw == null) {
			x10 = 0;
		}
		let value_x3 = x10;
		let value_y3 = y10;
		let w3 = _this4._02 * value_x3 + _this4._12 * value_y3 + _this4._22;
		let x11 = (_this4._00 * value_x3 + _this4._10 * value_y3 + _this4._20) / w3;
		let y11 = (_this4._01 * value_x3 + _this4._11 * value_y3 + _this4._21) / w3;
		let x12 = x11;
		let y12 = y11;
		if(y11 == null) {
			y12 = 0;
		}
		if(x11 == null) {
			x12 = 0;
		}
		let _this5 = this.imagePainter;
		let opacity = this.get_opacity();
		let color = this.get_color();
		if(kha_graphics2_ImageShaderPainter.bufferStart + kha_graphics2_ImageShaderPainter.bufferIndex + 1 >= 1500 || kha_graphics2_ImageShaderPainter.lastTexture != null && img != kha_graphics2_ImageShaderPainter.lastTexture) {
			_this5.drawBuffer(false);
		}
		let r = ((color & 16711680) >>> 16) * 0.00392156862745098;
		let g = ((color & 65280) >>> 8) * 0.00392156862745098;
		let b = (color & 255) * 0.00392156862745098;
		let a = (color >>> 24) * 0.00392156862745098 * opacity;
		let baseIndex = (kha_graphics2_ImageShaderPainter.bufferIndex - kha_graphics2_ImageShaderPainter.bufferStart) * 6 * 4 * 4;
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex + 20,r * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex + 20 + 1,g * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex + 20 + 2,b * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex + 20 + 3,a * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex + 44,r * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex + 44 + 1,g * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex + 44 + 2,b * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex + 44 + 3,a * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex + 68,r * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex + 68 + 1,g * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex + 68 + 2,b * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex + 68 + 3,a * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex + 92,r * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex + 92 + 1,g * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex + 92 + 2,b * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex + 92 + 3,a * 255 | 0);
		let baseIndex1 = (kha_graphics2_ImageShaderPainter.bufferIndex - kha_graphics2_ImageShaderPainter.bufferStart) * 6 * 4;
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex1 + 3) * 4,0,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex1 + 4) * 4,1,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex1 + 9) * 4,0,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex1 + 10) * 4,0,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex1 + 15) * 4,1,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex1 + 16) * 4,0,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex1 + 21) * 4,1,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex1 + 22) * 4,1,true);
		let baseIndex2 = (kha_graphics2_ImageShaderPainter.bufferIndex - kha_graphics2_ImageShaderPainter.bufferStart) * 6 * 4;
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32(baseIndex2 * 4,x3,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 1) * 4,y3,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 2) * 4,-5.0,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 6) * 4,x6,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 7) * 4,y6,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 8) * 4,-5.0,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 12) * 4,x9,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 13) * 4,y9,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 14) * 4,-5.0,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 18) * 4,x12,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 19) * 4,y12,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 20) * 4,-5.0,true);
		++kha_graphics2_ImageShaderPainter.bufferIndex;
		kha_graphics2_ImageShaderPainter.lastTexture = img;
	}
	drawScaledSubImage(img,sx,sy,sw,sh,dx,dy,dw,dh) {
		let _this = this.coloredPainter;
		if(kha_graphics2_ColoredShaderPainter.triangleBufferIndex > 0) {
			_this.drawTriBuffer(false);
		}
		if(kha_graphics2_ColoredShaderPainter.bufferIndex > 0) {
			_this.drawBuffer(false);
		}
		this.textPainter.end();
		let _this1 = this.transformations[this.transformationIndex];
		let x = dx;
		let y = dy + dh;
		if(y == null) {
			y = 0;
		}
		if(dx == null) {
			x = 0;
		}
		let value_x = x;
		let value_y = y;
		let w = _this1._02 * value_x + _this1._12 * value_y + _this1._22;
		let x1 = (_this1._00 * value_x + _this1._10 * value_y + _this1._20) / w;
		let y1 = (_this1._01 * value_x + _this1._11 * value_y + _this1._21) / w;
		let x2 = x1;
		let y2 = y1;
		if(y1 == null) {
			y2 = 0;
		}
		if(x1 == null) {
			x2 = 0;
		}
		let _this2 = this.transformations[this.transformationIndex];
		let x3 = dx;
		let y3 = dy;
		if(dy == null) {
			y3 = 0;
		}
		if(dx == null) {
			x3 = 0;
		}
		let value_x1 = x3;
		let value_y1 = y3;
		let w1 = _this2._02 * value_x1 + _this2._12 * value_y1 + _this2._22;
		let x4 = (_this2._00 * value_x1 + _this2._10 * value_y1 + _this2._20) / w1;
		let y4 = (_this2._01 * value_x1 + _this2._11 * value_y1 + _this2._21) / w1;
		let x5 = x4;
		let y5 = y4;
		if(y4 == null) {
			y5 = 0;
		}
		if(x4 == null) {
			x5 = 0;
		}
		let _this3 = this.transformations[this.transformationIndex];
		let x6 = dx + dw;
		let y6 = dy;
		if(dy == null) {
			y6 = 0;
		}
		if(x6 == null) {
			x6 = 0;
		}
		let value_x2 = x6;
		let value_y2 = y6;
		let w2 = _this3._02 * value_x2 + _this3._12 * value_y2 + _this3._22;
		let x7 = (_this3._00 * value_x2 + _this3._10 * value_y2 + _this3._20) / w2;
		let y7 = (_this3._01 * value_x2 + _this3._11 * value_y2 + _this3._21) / w2;
		let x8 = x7;
		let y8 = y7;
		if(y7 == null) {
			y8 = 0;
		}
		if(x7 == null) {
			x8 = 0;
		}
		let _this4 = this.transformations[this.transformationIndex];
		let x9 = dx + dw;
		let y9 = dy + dh;
		if(y9 == null) {
			y9 = 0;
		}
		if(x9 == null) {
			x9 = 0;
		}
		let value_x3 = x9;
		let value_y3 = y9;
		let w3 = _this4._02 * value_x3 + _this4._12 * value_y3 + _this4._22;
		let x10 = (_this4._00 * value_x3 + _this4._10 * value_y3 + _this4._20) / w3;
		let y10 = (_this4._01 * value_x3 + _this4._11 * value_y3 + _this4._21) / w3;
		let x11 = x10;
		let y11 = y10;
		if(y10 == null) {
			y11 = 0;
		}
		if(x10 == null) {
			x11 = 0;
		}
		let _this5 = this.imagePainter;
		let opacity = this.get_opacity();
		let color = this.get_color();
		if(kha_graphics2_ImageShaderPainter.bufferStart + kha_graphics2_ImageShaderPainter.bufferIndex + 1 >= 1500 || kha_graphics2_ImageShaderPainter.lastTexture != null && img != kha_graphics2_ImageShaderPainter.lastTexture) {
			_this5.drawBuffer(false);
		}
		let left = sx / img.get_width();
		let top = sy / img.get_height();
		let right = (sx + sw) / img.get_width();
		let bottom = (sy + sh) / img.get_height();
		let baseIndex = (kha_graphics2_ImageShaderPainter.bufferIndex - kha_graphics2_ImageShaderPainter.bufferStart) * 6 * 4;
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex + 3) * 4,left,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex + 4) * 4,bottom,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex + 9) * 4,left,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex + 10) * 4,top,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex + 15) * 4,right,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex + 16) * 4,top,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex + 21) * 4,right,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex + 22) * 4,bottom,true);
		let r = ((color & 16711680) >>> 16) * 0.00392156862745098;
		let g = ((color & 65280) >>> 8) * 0.00392156862745098;
		let b = (color & 255) * 0.00392156862745098;
		let a = (color >>> 24) * 0.00392156862745098 * opacity;
		let baseIndex1 = (kha_graphics2_ImageShaderPainter.bufferIndex - kha_graphics2_ImageShaderPainter.bufferStart) * 6 * 4 * 4;
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex1 + 20,r * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex1 + 20 + 1,g * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex1 + 20 + 2,b * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex1 + 20 + 3,a * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex1 + 44,r * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex1 + 44 + 1,g * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex1 + 44 + 2,b * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex1 + 44 + 3,a * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex1 + 68,r * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex1 + 68 + 1,g * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex1 + 68 + 2,b * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex1 + 68 + 3,a * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex1 + 92,r * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex1 + 92 + 1,g * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex1 + 92 + 2,b * 255 | 0);
		kha_graphics2_ImageShaderPainter.rectVertices.setUint8(baseIndex1 + 92 + 3,a * 255 | 0);
		let baseIndex2 = (kha_graphics2_ImageShaderPainter.bufferIndex - kha_graphics2_ImageShaderPainter.bufferStart) * 6 * 4;
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32(baseIndex2 * 4,x2,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 1) * 4,y2,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 2) * 4,-5.0,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 6) * 4,x5,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 7) * 4,y5,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 8) * 4,-5.0,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 12) * 4,x8,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 13) * 4,y8,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 14) * 4,-5.0,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 18) * 4,x11,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 19) * 4,y11,true);
		kha_graphics2_ImageShaderPainter.rectVertices.setFloat32((baseIndex2 + 20) * 4,-5.0,true);
		++kha_graphics2_ImageShaderPainter.bufferIndex;
		kha_graphics2_ImageShaderPainter.lastTexture = img;
	}
	get_color() {
		return this.myColor;
	}
	set_color(color) {
		return this.myColor = color;
	}
	drawRect(x,y,width,height,strength) {
		if(strength == null) {
			strength = 1.0;
		}
		this.imagePainter.end();
		this.textPainter.end();
		let _this = this.transformations[this.transformationIndex];
		let x1 = x - strength / 2;
		let y1 = y + strength / 2;
		if(y1 == null) {
			y1 = 0;
		}
		if(x1 == null) {
			x1 = 0;
		}
		let value_x = x1;
		let value_y = y1;
		let w = _this._02 * value_x + _this._12 * value_y + _this._22;
		let x2 = (_this._00 * value_x + _this._10 * value_y + _this._20) / w;
		let y2 = (_this._01 * value_x + _this._11 * value_y + _this._21) / w;
		let x3 = x2;
		let y3 = y2;
		if(y2 == null) {
			y3 = 0;
		}
		if(x2 == null) {
			x3 = 0;
		}
		let p1_x = x3;
		let p1_y = y3;
		let _this1 = this.transformations[this.transformationIndex];
		let x4 = x - strength / 2;
		let y4 = y - strength / 2;
		if(y4 == null) {
			y4 = 0;
		}
		if(x4 == null) {
			x4 = 0;
		}
		let value_x1 = x4;
		let value_y1 = y4;
		let w1 = _this1._02 * value_x1 + _this1._12 * value_y1 + _this1._22;
		let x5 = (_this1._00 * value_x1 + _this1._10 * value_y1 + _this1._20) / w1;
		let y5 = (_this1._01 * value_x1 + _this1._11 * value_y1 + _this1._21) / w1;
		let x6 = x5;
		let y6 = y5;
		if(y5 == null) {
			y6 = 0;
		}
		if(x5 == null) {
			x6 = 0;
		}
		let p2_x = x6;
		let p2_y = y6;
		let _this2 = this.transformations[this.transformationIndex];
		let x7 = x + width + strength / 2;
		let y7 = y - strength / 2;
		if(y7 == null) {
			y7 = 0;
		}
		if(x7 == null) {
			x7 = 0;
		}
		let value_x2 = x7;
		let value_y2 = y7;
		let w2 = _this2._02 * value_x2 + _this2._12 * value_y2 + _this2._22;
		let x8 = (_this2._00 * value_x2 + _this2._10 * value_y2 + _this2._20) / w2;
		let y8 = (_this2._01 * value_x2 + _this2._11 * value_y2 + _this2._21) / w2;
		let x9 = x8;
		let y9 = y8;
		if(y8 == null) {
			y9 = 0;
		}
		if(x8 == null) {
			x9 = 0;
		}
		let p3_x = x9;
		let p3_y = y9;
		let _this3 = this.transformations[this.transformationIndex];
		let x10 = x + width + strength / 2;
		let y10 = y + strength / 2;
		if(y10 == null) {
			y10 = 0;
		}
		if(x10 == null) {
			x10 = 0;
		}
		let value_x3 = x10;
		let value_y3 = y10;
		let w3 = _this3._02 * value_x3 + _this3._12 * value_y3 + _this3._22;
		let x11 = (_this3._00 * value_x3 + _this3._10 * value_y3 + _this3._20) / w3;
		let y11 = (_this3._01 * value_x3 + _this3._11 * value_y3 + _this3._21) / w3;
		let x12 = x11;
		let y12 = y11;
		if(y11 == null) {
			y12 = 0;
		}
		if(x11 == null) {
			x12 = 0;
		}
		let p4_x = x12;
		let p4_y = y12;
		this.coloredPainter.fillRect(this.get_opacity(),this.get_color(),p1_x,p1_y,p2_x,p2_y,p3_x,p3_y,p4_x,p4_y);
		let _this4 = this.transformations[this.transformationIndex];
		let x13 = x - strength / 2;
		let y13 = y + height - strength / 2;
		if(y13 == null) {
			y13 = 0;
		}
		if(x13 == null) {
			x13 = 0;
		}
		let value_x4 = x13;
		let value_y4 = y13;
		let w4 = _this4._02 * value_x4 + _this4._12 * value_y4 + _this4._22;
		let x14 = (_this4._00 * value_x4 + _this4._10 * value_y4 + _this4._20) / w4;
		let y14 = (_this4._01 * value_x4 + _this4._11 * value_y4 + _this4._21) / w4;
		let x15 = x14;
		let y15 = y14;
		if(y14 == null) {
			y15 = 0;
		}
		if(x14 == null) {
			x15 = 0;
		}
		p1_x = x15;
		p1_y = y15;
		let _this5 = this.transformations[this.transformationIndex];
		let x16 = x - strength / 2;
		let y16 = y + strength / 2;
		if(y16 == null) {
			y16 = 0;
		}
		if(x16 == null) {
			x16 = 0;
		}
		let value_x5 = x16;
		let value_y5 = y16;
		let w5 = _this5._02 * value_x5 + _this5._12 * value_y5 + _this5._22;
		let x17 = (_this5._00 * value_x5 + _this5._10 * value_y5 + _this5._20) / w5;
		let y17 = (_this5._01 * value_x5 + _this5._11 * value_y5 + _this5._21) / w5;
		let x18 = x17;
		let y18 = y17;
		if(y17 == null) {
			y18 = 0;
		}
		if(x17 == null) {
			x18 = 0;
		}
		p2_x = x18;
		p2_y = y18;
		let _this6 = this.transformations[this.transformationIndex];
		let x19 = x + strength / 2;
		let y19 = y + strength / 2;
		if(y19 == null) {
			y19 = 0;
		}
		if(x19 == null) {
			x19 = 0;
		}
		let value_x6 = x19;
		let value_y6 = y19;
		let w6 = _this6._02 * value_x6 + _this6._12 * value_y6 + _this6._22;
		let x20 = (_this6._00 * value_x6 + _this6._10 * value_y6 + _this6._20) / w6;
		let y20 = (_this6._01 * value_x6 + _this6._11 * value_y6 + _this6._21) / w6;
		let x21 = x20;
		let y21 = y20;
		if(y20 == null) {
			y21 = 0;
		}
		if(x20 == null) {
			x21 = 0;
		}
		p3_x = x21;
		p3_y = y21;
		let _this7 = this.transformations[this.transformationIndex];
		let x22 = x + strength / 2;
		let y22 = y + height - strength / 2;
		if(y22 == null) {
			y22 = 0;
		}
		if(x22 == null) {
			x22 = 0;
		}
		let value_x7 = x22;
		let value_y7 = y22;
		let w7 = _this7._02 * value_x7 + _this7._12 * value_y7 + _this7._22;
		let x23 = (_this7._00 * value_x7 + _this7._10 * value_y7 + _this7._20) / w7;
		let y23 = (_this7._01 * value_x7 + _this7._11 * value_y7 + _this7._21) / w7;
		let x24 = x23;
		let y24 = y23;
		if(y23 == null) {
			y24 = 0;
		}
		if(x23 == null) {
			x24 = 0;
		}
		p4_x = x24;
		p4_y = y24;
		this.coloredPainter.fillRect(this.get_opacity(),this.get_color(),p1_x,p1_y,p2_x,p2_y,p3_x,p3_y,p4_x,p4_y);
		let _this8 = this.transformations[this.transformationIndex];
		let x25 = x - strength / 2;
		let y25 = y + height + strength / 2;
		if(y25 == null) {
			y25 = 0;
		}
		if(x25 == null) {
			x25 = 0;
		}
		let value_x8 = x25;
		let value_y8 = y25;
		let w8 = _this8._02 * value_x8 + _this8._12 * value_y8 + _this8._22;
		let x26 = (_this8._00 * value_x8 + _this8._10 * value_y8 + _this8._20) / w8;
		let y26 = (_this8._01 * value_x8 + _this8._11 * value_y8 + _this8._21) / w8;
		let x27 = x26;
		let y27 = y26;
		if(y26 == null) {
			y27 = 0;
		}
		if(x26 == null) {
			x27 = 0;
		}
		p1_x = x27;
		p1_y = y27;
		let _this9 = this.transformations[this.transformationIndex];
		let x28 = x - strength / 2;
		let y28 = y + height - strength / 2;
		if(y28 == null) {
			y28 = 0;
		}
		if(x28 == null) {
			x28 = 0;
		}
		let value_x9 = x28;
		let value_y9 = y28;
		let w9 = _this9._02 * value_x9 + _this9._12 * value_y9 + _this9._22;
		let x29 = (_this9._00 * value_x9 + _this9._10 * value_y9 + _this9._20) / w9;
		let y29 = (_this9._01 * value_x9 + _this9._11 * value_y9 + _this9._21) / w9;
		let x30 = x29;
		let y30 = y29;
		if(y29 == null) {
			y30 = 0;
		}
		if(x29 == null) {
			x30 = 0;
		}
		p2_x = x30;
		p2_y = y30;
		let _this10 = this.transformations[this.transformationIndex];
		let x31 = x + width + strength / 2;
		let y31 = y + height - strength / 2;
		if(y31 == null) {
			y31 = 0;
		}
		if(x31 == null) {
			x31 = 0;
		}
		let value_x10 = x31;
		let value_y10 = y31;
		let w10 = _this10._02 * value_x10 + _this10._12 * value_y10 + _this10._22;
		let x32 = (_this10._00 * value_x10 + _this10._10 * value_y10 + _this10._20) / w10;
		let y32 = (_this10._01 * value_x10 + _this10._11 * value_y10 + _this10._21) / w10;
		let x33 = x32;
		let y33 = y32;
		if(y32 == null) {
			y33 = 0;
		}
		if(x32 == null) {
			x33 = 0;
		}
		p3_x = x33;
		p3_y = y33;
		let _this11 = this.transformations[this.transformationIndex];
		let x34 = x + width + strength / 2;
		let y34 = y + height + strength / 2;
		if(y34 == null) {
			y34 = 0;
		}
		if(x34 == null) {
			x34 = 0;
		}
		let value_x11 = x34;
		let value_y11 = y34;
		let w11 = _this11._02 * value_x11 + _this11._12 * value_y11 + _this11._22;
		let x35 = (_this11._00 * value_x11 + _this11._10 * value_y11 + _this11._20) / w11;
		let y35 = (_this11._01 * value_x11 + _this11._11 * value_y11 + _this11._21) / w11;
		let x36 = x35;
		let y36 = y35;
		if(y35 == null) {
			y36 = 0;
		}
		if(x35 == null) {
			x36 = 0;
		}
		p4_x = x36;
		p4_y = y36;
		this.coloredPainter.fillRect(this.get_opacity(),this.get_color(),p1_x,p1_y,p2_x,p2_y,p3_x,p3_y,p4_x,p4_y);
		let _this12 = this.transformations[this.transformationIndex];
		let x37 = x + width - strength / 2;
		let y37 = y + height - strength / 2;
		if(y37 == null) {
			y37 = 0;
		}
		if(x37 == null) {
			x37 = 0;
		}
		let value_x12 = x37;
		let value_y12 = y37;
		let w12 = _this12._02 * value_x12 + _this12._12 * value_y12 + _this12._22;
		let x38 = (_this12._00 * value_x12 + _this12._10 * value_y12 + _this12._20) / w12;
		let y38 = (_this12._01 * value_x12 + _this12._11 * value_y12 + _this12._21) / w12;
		let x39 = x38;
		let y39 = y38;
		if(y38 == null) {
			y39 = 0;
		}
		if(x38 == null) {
			x39 = 0;
		}
		p1_x = x39;
		p1_y = y39;
		let _this13 = this.transformations[this.transformationIndex];
		let x40 = x + width - strength / 2;
		let y40 = y + strength / 2;
		if(y40 == null) {
			y40 = 0;
		}
		if(x40 == null) {
			x40 = 0;
		}
		let value_x13 = x40;
		let value_y13 = y40;
		let w13 = _this13._02 * value_x13 + _this13._12 * value_y13 + _this13._22;
		let x41 = (_this13._00 * value_x13 + _this13._10 * value_y13 + _this13._20) / w13;
		let y41 = (_this13._01 * value_x13 + _this13._11 * value_y13 + _this13._21) / w13;
		let x42 = x41;
		let y42 = y41;
		if(y41 == null) {
			y42 = 0;
		}
		if(x41 == null) {
			x42 = 0;
		}
		p2_x = x42;
		p2_y = y42;
		let _this14 = this.transformations[this.transformationIndex];
		let x43 = x + width + strength / 2;
		let y43 = y + strength / 2;
		if(y43 == null) {
			y43 = 0;
		}
		if(x43 == null) {
			x43 = 0;
		}
		let value_x14 = x43;
		let value_y14 = y43;
		let w14 = _this14._02 * value_x14 + _this14._12 * value_y14 + _this14._22;
		let x44 = (_this14._00 * value_x14 + _this14._10 * value_y14 + _this14._20) / w14;
		let y44 = (_this14._01 * value_x14 + _this14._11 * value_y14 + _this14._21) / w14;
		let x45 = x44;
		let y45 = y44;
		if(y44 == null) {
			y45 = 0;
		}
		if(x44 == null) {
			x45 = 0;
		}
		p3_x = x45;
		p3_y = y45;
		let _this15 = this.transformations[this.transformationIndex];
		let x46 = x + width + strength / 2;
		let y46 = y + height - strength / 2;
		if(y46 == null) {
			y46 = 0;
		}
		if(x46 == null) {
			x46 = 0;
		}
		let value_x15 = x46;
		let value_y15 = y46;
		let w15 = _this15._02 * value_x15 + _this15._12 * value_y15 + _this15._22;
		let x47 = (_this15._00 * value_x15 + _this15._10 * value_y15 + _this15._20) / w15;
		let y47 = (_this15._01 * value_x15 + _this15._11 * value_y15 + _this15._21) / w15;
		let x48 = x47;
		let y48 = y47;
		if(y47 == null) {
			y48 = 0;
		}
		if(x47 == null) {
			x48 = 0;
		}
		p4_x = x48;
		p4_y = y48;
		this.coloredPainter.fillRect(this.get_opacity(),this.get_color(),p1_x,p1_y,p2_x,p2_y,p3_x,p3_y,p4_x,p4_y);
	}
	fillRect(x,y,width,height) {
		this.imagePainter.end();
		this.textPainter.end();
		let _this = this.transformations[this.transformationIndex];
		let x1 = x;
		let y1 = y + height;
		if(y1 == null) {
			y1 = 0;
		}
		if(x == null) {
			x1 = 0;
		}
		let value_x = x1;
		let value_y = y1;
		let w = _this._02 * value_x + _this._12 * value_y + _this._22;
		let x2 = (_this._00 * value_x + _this._10 * value_y + _this._20) / w;
		let y2 = (_this._01 * value_x + _this._11 * value_y + _this._21) / w;
		let x3 = x2;
		let y3 = y2;
		if(y2 == null) {
			y3 = 0;
		}
		if(x2 == null) {
			x3 = 0;
		}
		let _this1 = this.transformations[this.transformationIndex];
		let x4 = x;
		let y4 = y;
		if(y == null) {
			y4 = 0;
		}
		if(x == null) {
			x4 = 0;
		}
		let value_x1 = x4;
		let value_y1 = y4;
		let w1 = _this1._02 * value_x1 + _this1._12 * value_y1 + _this1._22;
		let x5 = (_this1._00 * value_x1 + _this1._10 * value_y1 + _this1._20) / w1;
		let y5 = (_this1._01 * value_x1 + _this1._11 * value_y1 + _this1._21) / w1;
		let x6 = x5;
		let y6 = y5;
		if(y5 == null) {
			y6 = 0;
		}
		if(x5 == null) {
			x6 = 0;
		}
		let _this2 = this.transformations[this.transformationIndex];
		let x7 = x + width;
		let y7 = y;
		if(y == null) {
			y7 = 0;
		}
		if(x7 == null) {
			x7 = 0;
		}
		let value_x2 = x7;
		let value_y2 = y7;
		let w2 = _this2._02 * value_x2 + _this2._12 * value_y2 + _this2._22;
		let x8 = (_this2._00 * value_x2 + _this2._10 * value_y2 + _this2._20) / w2;
		let y8 = (_this2._01 * value_x2 + _this2._11 * value_y2 + _this2._21) / w2;
		let x9 = x8;
		let y9 = y8;
		if(y8 == null) {
			y9 = 0;
		}
		if(x8 == null) {
			x9 = 0;
		}
		let _this3 = this.transformations[this.transformationIndex];
		let x10 = x + width;
		let y10 = y + height;
		if(y10 == null) {
			y10 = 0;
		}
		if(x10 == null) {
			x10 = 0;
		}
		let value_x3 = x10;
		let value_y3 = y10;
		let w3 = _this3._02 * value_x3 + _this3._12 * value_y3 + _this3._22;
		let x11 = (_this3._00 * value_x3 + _this3._10 * value_y3 + _this3._20) / w3;
		let y11 = (_this3._01 * value_x3 + _this3._11 * value_y3 + _this3._21) / w3;
		let x12 = x11;
		let y12 = y11;
		if(y11 == null) {
			y12 = 0;
		}
		if(x11 == null) {
			x12 = 0;
		}
		this.coloredPainter.fillRect(this.get_opacity(),this.get_color(),x3,y3,x6,y6,x9,y9,x12,y12);
	}
	drawString(text,x,y) {
		this.imagePainter.end();
		let _this = this.coloredPainter;
		if(kha_graphics2_ColoredShaderPainter.triangleBufferIndex > 0) {
			_this.drawTriBuffer(false);
		}
		if(kha_graphics2_ColoredShaderPainter.bufferIndex > 0) {
			_this.drawBuffer(false);
		}
		this.textPainter.drawString(text,this.get_opacity(),this.get_color(),x,y,this.transformations[this.transformationIndex]);
	}
	get_font() {
		return this.myFont;
	}
	set_font(font) {
		this.textPainter.setFont(font);
		return this.myFont = font;
	}
	get_fontSize() {
		return this.myFontSize;
	}
	set_fontSize(value) {
		return this.myFontSize = this.textPainter.fontSize = value;
	}
	drawLine(x1,y1,x2,y2,strength) {
		if(strength == null) {
			strength = 1.0;
		}
		this.imagePainter.end();
		this.textPainter.end();
		let vec_x = 0;
		let vec_y = 0;
		if(y2 == y1) {
			vec_x = 0;
			vec_y = -1;
		} else {
			let y = -(x2 - x1) / (y2 - y1);
			if(y == null) {
				y = 0;
			}
			vec_x = 1;
			vec_y = y;
		}
		let currentLength = Math.sqrt(vec_x * vec_x + vec_y * vec_y);
		if(currentLength != 0) {
			let mul = strength / currentLength;
			vec_x *= mul;
			vec_y *= mul;
		}
		let x = x1 + 0.5 * vec_x;
		let y = y1 + 0.5 * vec_y;
		if(y == null) {
			y = 0;
		}
		if(x == null) {
			x = 0;
		}
		let p1_x = x;
		let p1_y = y;
		let x3 = x2 + 0.5 * vec_x;
		let y3 = y2 + 0.5 * vec_y;
		if(y3 == null) {
			y3 = 0;
		}
		if(x3 == null) {
			x3 = 0;
		}
		let p2_x = x3;
		let p2_y = y3;
		let x4 = p1_x - vec_x;
		let y4 = p1_y - vec_y;
		if(y4 == null) {
			y4 = 0;
		}
		if(x4 == null) {
			x4 = 0;
		}
		let p3_x = x4;
		let p3_y = y4;
		let x5 = p2_x - vec_x;
		let y5 = p2_y - vec_y;
		if(y5 == null) {
			y5 = 0;
		}
		if(x5 == null) {
			x5 = 0;
		}
		let p4_x = x5;
		let p4_y = y5;
		let _this = this.transformations[this.transformationIndex];
		let w = _this._02 * p1_x + _this._12 * p1_y + _this._22;
		let x6 = (_this._00 * p1_x + _this._10 * p1_y + _this._20) / w;
		let y6 = (_this._01 * p1_x + _this._11 * p1_y + _this._21) / w;
		let x7 = x6;
		let y7 = y6;
		if(y6 == null) {
			y7 = 0;
		}
		if(x6 == null) {
			x7 = 0;
		}
		p1_x = x7;
		p1_y = y7;
		let _this1 = this.transformations[this.transformationIndex];
		let w1 = _this1._02 * p2_x + _this1._12 * p2_y + _this1._22;
		let x8 = (_this1._00 * p2_x + _this1._10 * p2_y + _this1._20) / w1;
		let y8 = (_this1._01 * p2_x + _this1._11 * p2_y + _this1._21) / w1;
		let x9 = x8;
		let y9 = y8;
		if(y8 == null) {
			y9 = 0;
		}
		if(x8 == null) {
			x9 = 0;
		}
		p2_x = x9;
		p2_y = y9;
		let _this2 = this.transformations[this.transformationIndex];
		let w2 = _this2._02 * p3_x + _this2._12 * p3_y + _this2._22;
		let x10 = (_this2._00 * p3_x + _this2._10 * p3_y + _this2._20) / w2;
		let y10 = (_this2._01 * p3_x + _this2._11 * p3_y + _this2._21) / w2;
		let x11 = x10;
		let y11 = y10;
		if(y10 == null) {
			y11 = 0;
		}
		if(x10 == null) {
			x11 = 0;
		}
		p3_x = x11;
		p3_y = y11;
		let _this3 = this.transformations[this.transformationIndex];
		let w3 = _this3._02 * p4_x + _this3._12 * p4_y + _this3._22;
		let x12 = (_this3._00 * p4_x + _this3._10 * p4_y + _this3._20) / w3;
		let y12 = (_this3._01 * p4_x + _this3._11 * p4_y + _this3._21) / w3;
		let x13 = x12;
		let y13 = y12;
		if(y12 == null) {
			y13 = 0;
		}
		if(x12 == null) {
			x13 = 0;
		}
		p4_x = x13;
		p4_y = y13;
		this.coloredPainter.fillTriangle(this.get_opacity(),this.get_color(),p1_x,p1_y,p2_x,p2_y,p3_x,p3_y);
		this.coloredPainter.fillTriangle(this.get_opacity(),this.get_color(),p3_x,p3_y,p2_x,p2_y,p4_x,p4_y);
	}
	fillTriangle(x1,y1,x2,y2,x3,y3) {
		this.imagePainter.end();
		this.textPainter.end();
		let _this = this.transformations[this.transformationIndex];
		let x = x1;
		let y = y1;
		if(y1 == null) {
			y = 0;
		}
		if(x1 == null) {
			x = 0;
		}
		let value_x = x;
		let value_y = y;
		let w = _this._02 * value_x + _this._12 * value_y + _this._22;
		let x4 = (_this._00 * value_x + _this._10 * value_y + _this._20) / w;
		let y4 = (_this._01 * value_x + _this._11 * value_y + _this._21) / w;
		let x5 = x4;
		let y5 = y4;
		if(y4 == null) {
			y5 = 0;
		}
		if(x4 == null) {
			x5 = 0;
		}
		let _this1 = this.transformations[this.transformationIndex];
		let x6 = x2;
		let y6 = y2;
		if(y2 == null) {
			y6 = 0;
		}
		if(x2 == null) {
			x6 = 0;
		}
		let value_x1 = x6;
		let value_y1 = y6;
		let w1 = _this1._02 * value_x1 + _this1._12 * value_y1 + _this1._22;
		let x7 = (_this1._00 * value_x1 + _this1._10 * value_y1 + _this1._20) / w1;
		let y7 = (_this1._01 * value_x1 + _this1._11 * value_y1 + _this1._21) / w1;
		let x8 = x7;
		let y8 = y7;
		if(y7 == null) {
			y8 = 0;
		}
		if(x7 == null) {
			x8 = 0;
		}
		let _this2 = this.transformations[this.transformationIndex];
		let x9 = x3;
		let y9 = y3;
		if(y3 == null) {
			y9 = 0;
		}
		if(x3 == null) {
			x9 = 0;
		}
		let value_x2 = x9;
		let value_y2 = y9;
		let w2 = _this2._02 * value_x2 + _this2._12 * value_y2 + _this2._22;
		let x10 = (_this2._00 * value_x2 + _this2._10 * value_y2 + _this2._20) / w2;
		let y10 = (_this2._01 * value_x2 + _this2._11 * value_y2 + _this2._21) / w2;
		let x11 = x10;
		let y11 = y10;
		if(y10 == null) {
			y11 = 0;
		}
		if(x10 == null) {
			x11 = 0;
		}
		this.coloredPainter.fillTriangle(this.get_opacity(),this.get_color(),x5,y5,x8,y8,x11,y11);
	}
	set_imageScaleQuality(value) {
		if(value == this.myImageScaleQuality) {
			return value;
		}
		this.imagePainter.setBilinearFilter(value == kha_graphics2_ImageScaleQuality.High);
		this.textPainter.setBilinearFilter(value == kha_graphics2_ImageScaleQuality.High);
		return this.myImageScaleQuality = value;
	}
	setPipeline(pipeline) {
		if(pipeline == this.lastPipeline) {
			return;
		}
		this.lastPipeline = pipeline;
		this.flush();
		if(pipeline == null) {
			this.imagePainter.set_pipeline(null);
			this.coloredPainter.set_pipeline(null);
			this.textPainter.set_pipeline(null);
		} else {
			let cache = this.pipelineCache.h[pipeline.__id__];
			if(cache == null) {
				cache = new kha_graphics2_SimplePipelineCache(pipeline,true);
				this.pipelineCache.set(pipeline,cache);
			}
			this.imagePainter.set_pipeline(cache);
			this.coloredPainter.set_pipeline(cache);
			this.textPainter.set_pipeline(cache);
		}
	}
	scissor(x,y,width,height) {
		this.scissorEnabled = true;
		this.scissorX = x;
		this.scissorY = y;
		this.scissorW = width;
		this.scissorH = height;
		this.flush();
		this.g.scissor(x,y,width,height);
	}
	disableScissor() {
		this.scissorEnabled = false;
		this.flush();
		this.g.disableScissor();
	}
	begin(clear,clearColor) {
		if(clear == null) {
			clear = true;
		}
		if(kha_graphics2_Graphics.current == null) {
			kha_graphics2_Graphics.current = this;
		} else if(!kha_graphics2_Graphics.thrown) {
			kha_graphics2_Graphics.thrown = true;
			throw haxe_Exception.thrown("End before you begin");
		}
		this.g.begin();
		if(clear) {
			this.clear(clearColor);
		}
		this.setProjection();
	}
	clear(color) {
		this.flush();
		this.g.clear(color == null ? -16777216 : color);
	}
	flush() {
		this.imagePainter.end();
		this.textPainter.end();
		let _this = this.coloredPainter;
		if(kha_graphics2_ColoredShaderPainter.triangleBufferIndex > 0) {
			_this.drawTriBuffer(false);
		}
		if(kha_graphics2_ColoredShaderPainter.bufferIndex > 0) {
			_this.drawBuffer(false);
		}
	}
	end() {
		this.flush();
		this.g.end();
		if(kha_graphics2_Graphics.current == this) {
			kha_graphics2_Graphics.current = null;
		} else if(!kha_graphics2_Graphics.thrown) {
			kha_graphics2_Graphics.thrown = true;
			throw haxe_Exception.thrown("Begin before you end");
		}
	}
	drawScaledImage(img,dx,dy,dw,dh) {
		this.drawScaledSubImage(img,0,0,img.get_width(),img.get_height(),dx,dy,dw,dh);
	}
	static upperPowerOfTwo(v) {
		--v;
		v |= v >>> 1;
		v |= v >>> 2;
		v |= v >>> 4;
		v |= v >>> 8;
		v |= v >>> 16;
		return ++v;
	}
	static createImageVertexStructure() {
		let structure = new kha_graphics4_VertexStructure();
		structure.add("vertexPosition",2);
		structure.add("vertexUV",1);
		structure.add("vertexColor",16);
		return structure;
	}
	static createImagePipeline(structure) {
		let shaderPipeline = new kha_graphics4_PipelineState();
		shaderPipeline.fragmentShader = kha_Shaders.getFragment("painter-image.frag");
		shaderPipeline.vertexShader = kha_Shaders.getVertex("painter-image.vert");
		shaderPipeline.inputLayout = [structure];
		shaderPipeline.blendSource = 1;
		shaderPipeline.blendDestination = 5;
		shaderPipeline.alphaBlendSource = 1;
		shaderPipeline.alphaBlendDestination = 5;
		return shaderPipeline;
	}
	static createColoredVertexStructure() {
		let structure = new kha_graphics4_VertexStructure();
		structure.add("vertexPosition",2);
		structure.add("vertexColor",16);
		return structure;
	}
	static createColoredPipeline(structure) {
		let shaderPipeline = new kha_graphics4_PipelineState();
		shaderPipeline.fragmentShader = kha_Shaders.getFragment("painter-colored.frag");
		shaderPipeline.vertexShader = kha_Shaders.getVertex("painter-colored.vert");
		shaderPipeline.inputLayout = [structure];
		shaderPipeline.blendSource = 1;
		shaderPipeline.blendDestination = 5;
		shaderPipeline.alphaBlendSource = 1;
		shaderPipeline.alphaBlendDestination = 5;
		return shaderPipeline;
	}
	static createTextVertexStructure() {
		let structure = new kha_graphics4_VertexStructure();
		structure.add("vertexPosition",2);
		structure.add("vertexUV",1);
		structure.add("vertexColor",3);
		return structure;
	}
	static createTextPipeline(structure) {
		let shaderPipeline = new kha_graphics4_PipelineState();
		shaderPipeline.fragmentShader = kha_Shaders.getFragment("painter-text.frag");
		shaderPipeline.vertexShader = kha_Shaders.getVertex("painter-text.vert");
		shaderPipeline.inputLayout = [structure];
		shaderPipeline.blendSource = 3;
		shaderPipeline.blendDestination = 5;
		shaderPipeline.alphaBlendSource = 3;
		shaderPipeline.alphaBlendDestination = 5;
		return shaderPipeline;
	}
}
$hxClasses["kha.graphics2.Graphics"] = kha_graphics2_Graphics;
kha_graphics2_Graphics.__name__ = "kha.graphics2.Graphics";
Object.assign(kha_graphics2_Graphics.prototype, {
	__class__: kha_graphics2_Graphics
	,__properties__: {set_imageScaleQuality: "set_imageScaleQuality",set_pipeline: "set_pipeline",set_opacity: "set_opacity",get_opacity: "get_opacity",set_fontSize: "set_fontSize",get_fontSize: "get_fontSize",set_font: "set_font",get_font: "get_font",set_color: "set_color",get_color: "get_color"}
});
class kha_graphics2_GraphicsExtension {
	static fillCircle(g2,cx,cy,radius,segments) {
		if(segments == null) {
			segments = 0;
		}
		if(segments <= 0) {
			segments = Math.floor(10 * Math.sqrt(radius));
		}
		let theta = 2 * Math.PI / segments;
		let c = Math.cos(theta);
		let s = Math.sin(theta);
		let x = radius;
		let y = 0.0;
		let _g = 0;
		let _g1 = segments;
		while(_g < _g1) {
			++_g;
			let px = x + cx;
			let py = y + cy;
			let t = x;
			x = c * x - s * y;
			y = c * y + s * t;
			g2.fillTriangle(px,py,x + cx,y + cy,cx,cy);
		}
	}
	static drawCubicBezier(g2,x,y,segments,strength) {
		if(strength == null) {
			strength = 1.0;
		}
		if(segments == null) {
			segments = 20;
		}
		let t;
		let q0 = kha_graphics2_GraphicsExtension.calculateCubicBezierPoint(0,x,y);
		let q1;
		let _g = 1;
		let _g1 = segments + 1;
		while(_g < _g1) {
			t = _g++ / segments;
			q1 = kha_graphics2_GraphicsExtension.calculateCubicBezierPoint(t,x,y);
			g2.drawLine(q0[0],q0[1],q1[0],q1[1],strength);
			q0 = q1;
		}
	}
	static calculateCubicBezierPoint(t,x,y) {
		let u = 1 - t;
		let tt = t * t;
		let uu = u * u;
		let uuu = uu * u;
		let ttt = tt * t;
		let p = [uuu * x[0],uuu * y[0]];
		p[0] += 3 * uu * t * x[1];
		p[1] += 3 * uu * t * y[1];
		p[0] += 3 * u * tt * x[2];
		p[1] += 3 * u * tt * y[2];
		p[0] += ttt * x[3];
		p[1] += ttt * y[3];
		return p;
	}
}
$hxClasses["kha.graphics2.GraphicsExtension"] = kha_graphics2_GraphicsExtension;
kha_graphics2_GraphicsExtension.__name__ = "kha.graphics2.GraphicsExtension";
var kha_graphics2_ImageScaleQuality = $hxEnums["kha.graphics2.ImageScaleQuality"] = { __ename__:true,__constructs__:null
	,Low: {_hx_name:"Low",_hx_index:0,__enum__:"kha.graphics2.ImageScaleQuality",toString:$estr}
	,High: {_hx_name:"High",_hx_index:1,__enum__:"kha.graphics2.ImageScaleQuality",toString:$estr}
};
kha_graphics2_ImageScaleQuality.__constructs__ = [kha_graphics2_ImageScaleQuality.Low,kha_graphics2_ImageScaleQuality.High];
class kha_graphics2_truetype_VectorOfIntPointer {
	constructor() {
	}
}
$hxClasses["kha.graphics2.truetype.VectorOfIntPointer"] = kha_graphics2_truetype_VectorOfIntPointer;
kha_graphics2_truetype_VectorOfIntPointer.__name__ = "kha.graphics2.truetype.VectorOfIntPointer";
Object.assign(kha_graphics2_truetype_VectorOfIntPointer.prototype, {
	__class__: kha_graphics2_truetype_VectorOfIntPointer
});
class kha_graphics2_truetype_Stbtt_$temp_$rect {
	constructor() {
	}
}
$hxClasses["kha.graphics2.truetype.Stbtt_temp_rect"] = kha_graphics2_truetype_Stbtt_$temp_$rect;
kha_graphics2_truetype_Stbtt_$temp_$rect.__name__ = "kha.graphics2.truetype.Stbtt_temp_rect";
Object.assign(kha_graphics2_truetype_Stbtt_$temp_$rect.prototype, {
	__class__: kha_graphics2_truetype_Stbtt_$temp_$rect
});
class kha_graphics2_truetype_Stbtt_$temp_$glyph_$h_$metrics {
	constructor() {
	}
}
$hxClasses["kha.graphics2.truetype.Stbtt_temp_glyph_h_metrics"] = kha_graphics2_truetype_Stbtt_$temp_$glyph_$h_$metrics;
kha_graphics2_truetype_Stbtt_$temp_$glyph_$h_$metrics.__name__ = "kha.graphics2.truetype.Stbtt_temp_glyph_h_metrics";
Object.assign(kha_graphics2_truetype_Stbtt_$temp_$glyph_$h_$metrics.prototype, {
	__class__: kha_graphics2_truetype_Stbtt_$temp_$glyph_$h_$metrics
});
class kha_graphics2_truetype_Stbtt_$temp_$font_$v_$metrics {
	constructor() {
	}
}
$hxClasses["kha.graphics2.truetype.Stbtt_temp_font_v_metrics"] = kha_graphics2_truetype_Stbtt_$temp_$font_$v_$metrics;
kha_graphics2_truetype_Stbtt_$temp_$font_$v_$metrics.__name__ = "kha.graphics2.truetype.Stbtt_temp_font_v_metrics";
Object.assign(kha_graphics2_truetype_Stbtt_$temp_$font_$v_$metrics.prototype, {
	__class__: kha_graphics2_truetype_Stbtt_$temp_$font_$v_$metrics
});
class kha_graphics2_truetype_Stbtt_$_$buf {
	constructor() {
	}
}
$hxClasses["kha.graphics2.truetype.Stbtt__buf"] = kha_graphics2_truetype_Stbtt_$_$buf;
kha_graphics2_truetype_Stbtt_$_$buf.__name__ = "kha.graphics2.truetype.Stbtt__buf";
Object.assign(kha_graphics2_truetype_Stbtt_$_$buf.prototype, {
	__class__: kha_graphics2_truetype_Stbtt_$_$buf
});
class kha_graphics2_truetype_Stbtt_$bakedchar {
	constructor() {
	}
}
$hxClasses["kha.graphics2.truetype.Stbtt_bakedchar"] = kha_graphics2_truetype_Stbtt_$bakedchar;
kha_graphics2_truetype_Stbtt_$bakedchar.__name__ = "kha.graphics2.truetype.Stbtt_bakedchar";
Object.assign(kha_graphics2_truetype_Stbtt_$bakedchar.prototype, {
	__class__: kha_graphics2_truetype_Stbtt_$bakedchar
});
class kha_graphics2_truetype_Stbtt_$fontinfo {
	constructor() {
	}
}
$hxClasses["kha.graphics2.truetype.Stbtt_fontinfo"] = kha_graphics2_truetype_Stbtt_$fontinfo;
kha_graphics2_truetype_Stbtt_$fontinfo.__name__ = "kha.graphics2.truetype.Stbtt_fontinfo";
Object.assign(kha_graphics2_truetype_Stbtt_$fontinfo.prototype, {
	__class__: kha_graphics2_truetype_Stbtt_$fontinfo
});
class kha_graphics2_truetype_Stbtt_$vertex {
	constructor() {
	}
}
$hxClasses["kha.graphics2.truetype.Stbtt_vertex"] = kha_graphics2_truetype_Stbtt_$vertex;
kha_graphics2_truetype_Stbtt_$vertex.__name__ = "kha.graphics2.truetype.Stbtt_vertex";
Object.assign(kha_graphics2_truetype_Stbtt_$vertex.prototype, {
	__class__: kha_graphics2_truetype_Stbtt_$vertex
});
class kha_graphics2_truetype_Stbtt_$_$bitmap {
	constructor() {
	}
}
$hxClasses["kha.graphics2.truetype.Stbtt__bitmap"] = kha_graphics2_truetype_Stbtt_$_$bitmap;
kha_graphics2_truetype_Stbtt_$_$bitmap.__name__ = "kha.graphics2.truetype.Stbtt__bitmap";
Object.assign(kha_graphics2_truetype_Stbtt_$_$bitmap.prototype, {
	__class__: kha_graphics2_truetype_Stbtt_$_$bitmap
});
class kha_graphics2_truetype_Stbtt_$_$edge {
	constructor() {
	}
}
$hxClasses["kha.graphics2.truetype.Stbtt__edge"] = kha_graphics2_truetype_Stbtt_$_$edge;
kha_graphics2_truetype_Stbtt_$_$edge.__name__ = "kha.graphics2.truetype.Stbtt__edge";
Object.assign(kha_graphics2_truetype_Stbtt_$_$edge.prototype, {
	__class__: kha_graphics2_truetype_Stbtt_$_$edge
});
class kha_graphics2_truetype_Stbtt_$_$active_$edge {
	constructor() {
	}
}
$hxClasses["kha.graphics2.truetype.Stbtt__active_edge"] = kha_graphics2_truetype_Stbtt_$_$active_$edge;
kha_graphics2_truetype_Stbtt_$_$active_$edge.__name__ = "kha.graphics2.truetype.Stbtt__active_edge";
Object.assign(kha_graphics2_truetype_Stbtt_$_$active_$edge.prototype, {
	__class__: kha_graphics2_truetype_Stbtt_$_$active_$edge
});
class kha_graphics2_truetype_Stbtt_$_$point {
	constructor() {
	}
}
$hxClasses["kha.graphics2.truetype.Stbtt__point"] = kha_graphics2_truetype_Stbtt_$_$point;
kha_graphics2_truetype_Stbtt_$_$point.__name__ = "kha.graphics2.truetype.Stbtt__point";
Object.assign(kha_graphics2_truetype_Stbtt_$_$point.prototype, {
	__class__: kha_graphics2_truetype_Stbtt_$_$point
});
class kha_graphics2_truetype_Stbtt_$_$csctx {
	constructor() {
	}
}
$hxClasses["kha.graphics2.truetype.Stbtt__csctx"] = kha_graphics2_truetype_Stbtt_$_$csctx;
kha_graphics2_truetype_Stbtt_$_$csctx.__name__ = "kha.graphics2.truetype.Stbtt__csctx";
Object.assign(kha_graphics2_truetype_Stbtt_$_$csctx.prototype, {
	__class__: kha_graphics2_truetype_Stbtt_$_$csctx
});
class kha_graphics2_truetype_StbTruetype {
	static stbtt__buf_get(b,n) {
		let v = 0;
		if(!(n >= 1 && n <= 4)) {
			throw haxe_Exception.thrown("Error");
		}
		let _g = 0;
		while(_g < n) {
			++_g;
			let v1;
			if(b.cursor >= b.data.get_length()) {
				v1 = 0;
			} else {
				let pos = b.cursor++;
				if(pos == null) {
					pos = 0;
				}
				v1 = b.data.readU8(pos);
			}
			v = v << 8 | v1;
		}
		return v;
	}
	static stbtt__new_buf(p,size) {
		let r = new kha_graphics2_truetype_Stbtt_$_$buf();
		if(size >= 1073741824) {
			throw haxe_Exception.thrown("Error");
		}
		r.data = p;
		r.cursor = 0;
		return r;
	}
	static stbtt__buf_range(b,o,s) {
		let r = kha_graphics2_truetype_StbTruetype.stbtt__new_buf(null,0);
		if(o < 0 || s < 0 || o > b.data.get_length() || s > b.data.get_length() - o) {
			return r;
		}
		r.data = b.data.sub(o,s);
		return r;
	}
	static stbtt__cff_get_index(b) {
		let start = b.cursor;
		let count = kha_graphics2_truetype_StbTruetype.stbtt__buf_get(b,2);
		if(count > 0) {
			let offsize;
			if(b.cursor >= b.data.get_length()) {
				offsize = 0;
			} else {
				let pos = b.cursor++;
				if(pos == null) {
					pos = 0;
				}
				offsize = b.data.readU8(pos);
			}
			if(!(offsize >= 1 && offsize <= 4)) {
				throw haxe_Exception.thrown("Error");
			}
			let o = b.cursor + offsize * count;
			if(o > b.data.get_length() || o < 0) {
				throw haxe_Exception.thrown("Error");
			}
			b.cursor = o > b.data.get_length() || o < 0 ? b.data.get_length() : o;
			let o1 = kha_graphics2_truetype_StbTruetype.stbtt__buf_get(b,offsize) - 1;
			let o2 = b.cursor + o1;
			if(o2 > b.data.get_length() || o2 < 0) {
				throw haxe_Exception.thrown("Error");
			}
			b.cursor = o2 > b.data.get_length() || o2 < 0 ? b.data.get_length() : o2;
			return kha_graphics2_truetype_StbTruetype.stbtt__buf_range(b,start,b.cursor - start);
		}
		return b;
	}
	static stbtt__cff_int(b) {
		let b0;
		if(b.cursor >= b.data.get_length()) {
			b0 = 0;
		} else {
			let pos = b.cursor++;
			if(pos == null) {
				pos = 0;
			}
			b0 = b.data.readU8(pos);
		}
		if(b0 >= 32 && b0 <= 246) {
			return b0 - 139;
		} else if(b0 >= 247 && b0 <= 250) {
			let tmp;
			if(b.cursor >= b.data.get_length()) {
				tmp = 0;
			} else {
				let pos = b.cursor++;
				if(pos == null) {
					pos = 0;
				}
				tmp = b.data.readU8(pos);
			}
			return (b0 - 247) * 256 + tmp + 108;
		} else if(b0 >= 251 && b0 <= 254) {
			let tmp;
			if(b.cursor >= b.data.get_length()) {
				tmp = 0;
			} else {
				let pos = b.cursor++;
				if(pos == null) {
					pos = 0;
				}
				tmp = b.data.readU8(pos);
			}
			return -(b0 - 251) * 256 - tmp - 108;
		} else if(b0 == 28) {
			return kha_graphics2_truetype_StbTruetype.stbtt__buf_get(b,2);
		} else if(b0 == 29) {
			return kha_graphics2_truetype_StbTruetype.stbtt__buf_get(b,4);
		} else {
			throw haxe_Exception.thrown("Error");
		}
	}
	static stbtt__dict_get_ints(b,key,outcount,out) {
		let i = 0;
		if(0 > b.data.get_length()) {
			throw haxe_Exception.thrown("Error");
		}
		b.cursor = 0 > b.data.get_length() ? b.data.get_length() : 0;
		let ret = null;
		while(b.cursor < b.data.get_length()) {
			let start = b.cursor;
			let op;
			while(true) {
				let tmp;
				if(b.cursor >= b.data.get_length()) {
					tmp = 0;
				} else {
					let pos = b.cursor;
					if(pos == null) {
						pos = 0;
					}
					tmp = b.data.readU8(pos);
				}
				if(!(tmp >= 28)) {
					break;
				}
				let v;
				let b0;
				if(b.cursor >= b.data.get_length()) {
					b0 = 0;
				} else {
					let pos = b.cursor;
					if(pos == null) {
						pos = 0;
					}
					b0 = b.data.readU8(pos);
				}
				if(b0 < 28) {
					throw haxe_Exception.thrown("Error");
				}
				if(b0 == 30) {
					let o = b.cursor + 1;
					if(o > b.data.get_length() || o < 0) {
						throw haxe_Exception.thrown("Error");
					}
					b.cursor = o > b.data.get_length() || o < 0 ? b.data.get_length() : o;
					while(b.cursor < b.data.get_length()) {
						if(b.cursor >= b.data.get_length()) {
							v = 0;
						} else {
							let pos = b.cursor++;
							if(pos == null) {
								pos = 0;
							}
							v = b.data.readU8(pos);
						}
						if((v & 15) == 15 || v >> 4 == 15) {
							break;
						}
					}
				} else {
					kha_graphics2_truetype_StbTruetype.stbtt__cff_int(b);
				}
			}
			let end = b.cursor;
			if(b.cursor >= b.data.get_length()) {
				op = 0;
			} else {
				let pos = b.cursor++;
				if(pos == null) {
					pos = 0;
				}
				op = b.data.readU8(pos);
			}
			if(op == 12) {
				let op1;
				if(b.cursor >= b.data.get_length()) {
					op1 = 0;
				} else {
					let pos = b.cursor++;
					if(pos == null) {
						pos = 0;
					}
					op1 = b.data.readU8(pos);
				}
				op = op1 | 256;
			}
			if(op == key) {
				ret = kha_graphics2_truetype_StbTruetype.stbtt__buf_range(b,start,end - start);
				break;
			}
		}
		let operands = ret != null ? ret : kha_graphics2_truetype_StbTruetype.stbtt__buf_range(b,0,0);
		while(i < outcount && operands.cursor < operands.data.get_length()) {
			out[i] = kha_graphics2_truetype_StbTruetype.stbtt__cff_int(operands);
			++i;
		}
	}
	static stbtt__cff_index_get(b,i) {
		if(0 > b.data.get_length()) {
			throw haxe_Exception.thrown("Error");
		}
		b.cursor = 0 > b.data.get_length() ? b.data.get_length() : 0;
		let count = kha_graphics2_truetype_StbTruetype.stbtt__buf_get(b,2);
		let offsize;
		if(b.cursor >= b.data.get_length()) {
			offsize = 0;
		} else {
			let pos = b.cursor++;
			if(pos == null) {
				pos = 0;
			}
			offsize = b.data.readU8(pos);
		}
		if(!(i >= 0 && i < count)) {
			throw haxe_Exception.thrown("Error");
		}
		if(!(offsize >= 1 && offsize <= 4)) {
			throw haxe_Exception.thrown("Error");
		}
		let o = b.cursor + i * offsize;
		if(o > b.data.get_length() || o < 0) {
			throw haxe_Exception.thrown("Error");
		}
		b.cursor = o > b.data.get_length() || o < 0 ? b.data.get_length() : o;
		let start = kha_graphics2_truetype_StbTruetype.stbtt__buf_get(b,offsize);
		return kha_graphics2_truetype_StbTruetype.stbtt__buf_range(b,2 + (count + 1) * offsize + start,kha_graphics2_truetype_StbTruetype.stbtt__buf_get(b,offsize) - start);
	}
	static ttCHAR(p,pos) {
		if(pos == null) {
			pos = 0;
		}
		let n = p.readU8(pos);
		if(n >= 128) {
			return n - 256;
		}
		return n;
	}
	static ttUSHORT(p,pos) {
		if(pos == null) {
			pos = 0;
		}
		let ch1 = p.readU8(pos);
		return p.readU8(pos + 1) | ch1 << 8;
	}
	static ttSHORT(p,pos) {
		if(pos == null) {
			pos = 0;
		}
		let ch1 = p.readU8(pos);
		let n = p.readU8(pos + 1) | ch1 << 8;
		if((n & 32768) != 0) {
			return n - 65536;
		}
		return n;
	}
	static ttLONG(p,pos) {
		if(pos == null) {
			pos = 0;
		}
		let ch1 = p.readU8(pos);
		let ch2 = p.readU8(pos + 1);
		let ch3 = p.readU8(pos + 2);
		return p.readU8(pos + 3) | ch3 << 8 | ch2 << 16 | ch1 << 24;
	}
	static stbtt__isfont(font) {
		let c0 = HxOverrides.cca("1",0);
		if(font.readU8(0) == c0 && font.readU8(1) == 0 && font.readU8(2) == 0 && font.readU8(3) == 0) {
			return true;
		}
		let c01 = HxOverrides.cca("typ1",0);
		let c1 = HxOverrides.cca("typ1",1);
		let c2 = HxOverrides.cca("typ1",2);
		let c3 = HxOverrides.cca("typ1",3);
		if(font.readU8(0) == c01 && font.readU8(1) == c1 && font.readU8(2) == c2 && font.readU8(3) == c3) {
			return true;
		}
		let c02 = HxOverrides.cca("OTTO",0);
		let c11 = HxOverrides.cca("OTTO",1);
		let c21 = HxOverrides.cca("OTTO",2);
		let c31 = HxOverrides.cca("OTTO",3);
		if(font.readU8(0) == c02 && font.readU8(1) == c11 && font.readU8(2) == c21 && font.readU8(3) == c31) {
			return true;
		}
		if(font.readU8(0) == 0 && font.readU8(1) == 1 && font.readU8(2) == 0 && font.readU8(3) == 0) {
			return true;
		}
		let c03 = HxOverrides.cca("true",0);
		let c12 = HxOverrides.cca("true",1);
		let c22 = HxOverrides.cca("true",2);
		let c32 = HxOverrides.cca("true",3);
		if(font.readU8(0) == c03 && font.readU8(1) == c12 && font.readU8(2) == c22 && font.readU8(3) == c32) {
			return true;
		}
		return false;
	}
	static stbtt__find_table(data,fontstart,tag) {
		let num_tables = kha_graphics2_truetype_StbTruetype.ttUSHORT(data,fontstart + 4);
		let tabledir = fontstart + 12;
		let _g = 0;
		while(_g < num_tables) {
			let loc = tabledir + 16 * _g++;
			let c0 = HxOverrides.cca(tag,0);
			let c1 = HxOverrides.cca(tag,1);
			let c2 = HxOverrides.cca(tag,2);
			let c3 = HxOverrides.cca(tag,3);
			if(data.readU8(loc) == c0 && data.readU8(loc + 1) == c1 && data.readU8(loc + 2) == c2 && data.readU8(loc + 3) == c3) {
				let pos = loc + 8;
				if(pos == null) {
					pos = 0;
				}
				return kha_graphics2_truetype_StbTruetype.ttLONG(data,pos);
			}
		}
		return 0;
	}
	static stbtt_GetFontOffsetForIndex(font_collection,index) {
		if(kha_graphics2_truetype_StbTruetype.stbtt__isfont(font_collection)) {
			if(index == 0) {
				return 0;
			} else {
				return -1;
			}
		}
		let c0 = HxOverrides.cca("ttcf",0);
		let c1 = HxOverrides.cca("ttcf",1);
		let c2 = HxOverrides.cca("ttcf",2);
		let c3 = HxOverrides.cca("ttcf",3);
		if(font_collection.readU8(0) == c0 && font_collection.readU8(1) == c1 && font_collection.readU8(2) == c2 && font_collection.readU8(3) == c3) {
			if(kha_graphics2_truetype_StbTruetype.ttLONG(font_collection,4) == 65536 || kha_graphics2_truetype_StbTruetype.ttLONG(font_collection,4) == 131072) {
				if(index >= kha_graphics2_truetype_StbTruetype.ttLONG(font_collection,8)) {
					return -1;
				}
				let pos = 12 + index * 4;
				if(pos == null) {
					pos = 0;
				}
				return kha_graphics2_truetype_StbTruetype.ttLONG(font_collection,pos);
			}
		}
		return -1;
	}
	static stbtt_GetNumberOfFonts(font_collection) {
		if(kha_graphics2_truetype_StbTruetype.stbtt__isfont(font_collection)) {
			return 1;
		}
		let c0 = HxOverrides.cca("ttcf",0);
		let c1 = HxOverrides.cca("ttcf",1);
		let c2 = HxOverrides.cca("ttcf",2);
		let c3 = HxOverrides.cca("ttcf",3);
		if(font_collection.readU8(0) == c0 && font_collection.readU8(1) == c1 && font_collection.readU8(2) == c2 && font_collection.readU8(3) == c3) {
			if(kha_graphics2_truetype_StbTruetype.ttLONG(font_collection,4) == 65536 || kha_graphics2_truetype_StbTruetype.ttLONG(font_collection,4) == 131072) {
				return kha_graphics2_truetype_StbTruetype.ttLONG(font_collection,8);
			}
		}
		return 0;
	}
	static stbtt__get_subrs(cff,fontdict) {
		let subrsoff = [0];
		let private_loc = [0,0];
		kha_graphics2_truetype_StbTruetype.stbtt__dict_get_ints(fontdict,18,2,private_loc);
		if(private_loc[1] == 0 || private_loc[0] == 0) {
			return kha_graphics2_truetype_StbTruetype.stbtt__new_buf(null,0);
		}
		kha_graphics2_truetype_StbTruetype.stbtt__dict_get_ints(kha_graphics2_truetype_StbTruetype.stbtt__buf_range(cff,private_loc[1],private_loc[0]),19,1,subrsoff);
		if(subrsoff[0] == 0) {
			return kha_graphics2_truetype_StbTruetype.stbtt__new_buf(null,0);
		}
		let o = private_loc[1] + subrsoff[0];
		if(o > cff.data.get_length() || o < 0) {
			throw haxe_Exception.thrown("Error");
		}
		cff.cursor = o > cff.data.get_length() || o < 0 ? cff.data.get_length() : o;
		return kha_graphics2_truetype_StbTruetype.stbtt__cff_get_index(cff);
	}
	static stbtt_InitFont(info,data,fontstart) {
		info.data = data;
		info.fontstart = fontstart;
		info.cff = kha_graphics2_truetype_StbTruetype.stbtt__new_buf(null,0);
		let cmap = kha_graphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"cmap");
		info.loca = kha_graphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"loca");
		info.head = kha_graphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"head");
		info.glyf = kha_graphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"glyf");
		info.hhea = kha_graphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"hhea");
		info.hmtx = kha_graphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"hmtx");
		info.kern = kha_graphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"kern");
		info.gpos = kha_graphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"GPOS");
		if(cmap == 0 || info.head == 0 || info.hhea == 0 || info.hmtx == 0) {
			return false;
		}
		if(info.glyf != 0) {
			if(info.loca == 0) {
				return false;
			}
		} else {
			let cstype = [2];
			let charstrings = [0];
			let fdarrayoff = [0];
			let fdselectoff = [0];
			let cff = kha_graphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"CFF ");
			if(cff == 0) {
				return false;
			}
			info.fontdicts = kha_graphics2_truetype_StbTruetype.stbtt__new_buf(null,0);
			info.fdselect = kha_graphics2_truetype_StbTruetype.stbtt__new_buf(null,0);
			let cff_data = data.sub(cff,data.get_length() - cff);
			info.cff = kha_graphics2_truetype_StbTruetype.stbtt__new_buf(cff_data,cff_data.get_length());
			let b = info.cff;
			let o = b.cursor + 2;
			if(o > b.data.get_length() || o < 0) {
				throw haxe_Exception.thrown("Error");
			}
			b.cursor = o > b.data.get_length() || o < 0 ? b.data.get_length() : o;
			let o1;
			if(b.cursor >= b.data.get_length()) {
				o1 = 0;
			} else {
				let pos = b.cursor++;
				if(pos == null) {
					pos = 0;
				}
				o1 = b.data.readU8(pos);
			}
			if(o1 > b.data.get_length() || o1 < 0) {
				throw haxe_Exception.thrown("Error");
			}
			b.cursor = o1 > b.data.get_length() || o1 < 0 ? b.data.get_length() : o1;
			kha_graphics2_truetype_StbTruetype.stbtt__cff_get_index(b);
			let topdict = kha_graphics2_truetype_StbTruetype.stbtt__cff_index_get(kha_graphics2_truetype_StbTruetype.stbtt__cff_get_index(b),0);
			kha_graphics2_truetype_StbTruetype.stbtt__cff_get_index(b);
			info.gsubrs = kha_graphics2_truetype_StbTruetype.stbtt__cff_get_index(b);
			kha_graphics2_truetype_StbTruetype.stbtt__dict_get_ints(topdict,17,1,charstrings);
			kha_graphics2_truetype_StbTruetype.stbtt__dict_get_ints(topdict,262,1,cstype);
			kha_graphics2_truetype_StbTruetype.stbtt__dict_get_ints(topdict,292,1,fdarrayoff);
			kha_graphics2_truetype_StbTruetype.stbtt__dict_get_ints(topdict,293,1,fdselectoff);
			info.subrs = kha_graphics2_truetype_StbTruetype.stbtt__get_subrs(b,topdict);
			if(cstype[0] != 2) {
				return false;
			}
			if(charstrings[0] == 0) {
				return false;
			}
			if(fdarrayoff[0] != 0) {
				if(fdselectoff[0] == 0) {
					return false;
				}
				let o = fdarrayoff[0];
				if(o > b.data.get_length() || o < 0) {
					throw haxe_Exception.thrown("Error");
				}
				b.cursor = o > b.data.get_length() || o < 0 ? b.data.get_length() : o;
				info.fontdicts = kha_graphics2_truetype_StbTruetype.stbtt__cff_get_index(b);
				info.fdselect = kha_graphics2_truetype_StbTruetype.stbtt__buf_range(b,fdselectoff[0],b.data.get_length() - fdselectoff[0]);
			}
			let o2 = charstrings[0];
			if(o2 > b.data.get_length() || o2 < 0) {
				throw haxe_Exception.thrown("Error");
			}
			b.cursor = o2 > b.data.get_length() || o2 < 0 ? b.data.get_length() : o2;
			info.charstrings = kha_graphics2_truetype_StbTruetype.stbtt__cff_get_index(b);
		}
		let t = kha_graphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"maxp");
		if(t != 0) {
			info.numGlyphs = kha_graphics2_truetype_StbTruetype.ttUSHORT(data,t + 4);
		} else {
			info.numGlyphs = 65535;
		}
		let numTables = kha_graphics2_truetype_StbTruetype.ttUSHORT(data,cmap + 2);
		info.index_map = 0;
		let _g = 0;
		while(_g < numTables) {
			let encoding_record = cmap + 4 + 8 * _g++;
			switch(kha_graphics2_truetype_StbTruetype.ttUSHORT(data,encoding_record)) {
			case 0:
				let pos = encoding_record + 4;
				if(pos == null) {
					pos = 0;
				}
				info.index_map = cmap + kha_graphics2_truetype_StbTruetype.ttLONG(data,pos);
				break;
			case 3:
				switch(kha_graphics2_truetype_StbTruetype.ttUSHORT(data,encoding_record + 2)) {
				case 1:case 10:
					let pos1 = encoding_record + 4;
					if(pos1 == null) {
						pos1 = 0;
					}
					info.index_map = cmap + kha_graphics2_truetype_StbTruetype.ttLONG(data,pos1);
					break;
				}
				break;
			}
		}
		if(info.index_map == 0) {
			return false;
		}
		info.indexToLocFormat = kha_graphics2_truetype_StbTruetype.ttUSHORT(data,info.head + 50);
		return true;
	}
	static stbtt_FindGlyphIndex(info,unicode_codepoint) {
		let data = info.data;
		let index_map = info.index_map;
		let format = kha_graphics2_truetype_StbTruetype.ttUSHORT(data,index_map);
		if(format == 0) {
			if(unicode_codepoint < kha_graphics2_truetype_StbTruetype.ttUSHORT(data,index_map + 2) - 6) {
				let pos = index_map + 6 + unicode_codepoint;
				if(pos == null) {
					pos = 0;
				}
				return data.readU8(pos);
			}
			return 0;
		} else if(format == 6) {
			let first = kha_graphics2_truetype_StbTruetype.ttUSHORT(data,index_map + 6);
			let count = kha_graphics2_truetype_StbTruetype.ttUSHORT(data,index_map + 8);
			if(unicode_codepoint >= first && unicode_codepoint < first + count) {
				return kha_graphics2_truetype_StbTruetype.ttUSHORT(data,index_map + 10 + (unicode_codepoint - first) * 2);
			}
			return 0;
		} else if(format == 2) {
			throw haxe_Exception.thrown("Error");
		} else if(format == 4) {
			let segcount = kha_graphics2_truetype_StbTruetype.ttUSHORT(data,index_map + 6) >> 1;
			let searchRange = kha_graphics2_truetype_StbTruetype.ttUSHORT(data,index_map + 8) >> 1;
			let entrySelector = kha_graphics2_truetype_StbTruetype.ttUSHORT(data,index_map + 10);
			let rangeShift = kha_graphics2_truetype_StbTruetype.ttUSHORT(data,index_map + 12) >> 1;
			let endCount = index_map + 14;
			let search = endCount;
			if(unicode_codepoint > 65535) {
				return 0;
			}
			if(unicode_codepoint >= kha_graphics2_truetype_StbTruetype.ttUSHORT(data,endCount + rangeShift * 2)) {
				search = endCount + rangeShift * 2;
			}
			search -= 2;
			while(entrySelector != 0) {
				searchRange >>= 1;
				if(unicode_codepoint > kha_graphics2_truetype_StbTruetype.ttUSHORT(data,search + searchRange * 2)) {
					search += searchRange * 2;
				}
				--entrySelector;
			}
			search += 2;
			let item = search - endCount >> 1 & 65535;
			if(unicode_codepoint > kha_graphics2_truetype_StbTruetype.ttUSHORT(data,endCount + 2 * item)) {
				throw haxe_Exception.thrown("Error");
			}
			let start = kha_graphics2_truetype_StbTruetype.ttUSHORT(data,index_map + 14 + segcount * 2 + 2 + 2 * item);
			if(unicode_codepoint < start) {
				return 0;
			}
			let offset = kha_graphics2_truetype_StbTruetype.ttUSHORT(data,index_map + 14 + segcount * 6 + 2 + 2 * item);
			if(offset == 0) {
				return unicode_codepoint + kha_graphics2_truetype_StbTruetype.ttSHORT(data,index_map + 14 + segcount * 4 + 2 + 2 * item) & 65535;
			}
			return kha_graphics2_truetype_StbTruetype.ttUSHORT(data,offset + (unicode_codepoint - start) * 2 + index_map + 14 + segcount * 6 + 2 + 2 * item);
		} else if(format == 12 || format == 13) {
			let pos = index_map + 12;
			if(pos == null) {
				pos = 0;
			}
			let low = 0;
			let high = kha_graphics2_truetype_StbTruetype.ttLONG(data,pos);
			while(low < high) {
				let mid = low + (high - low >> 1);
				let pos = index_map + 16 + mid * 12;
				if(pos == null) {
					pos = 0;
				}
				let start_char = kha_graphics2_truetype_StbTruetype.ttLONG(data,pos);
				let pos1 = index_map + 16 + mid * 12 + 4;
				if(pos1 == null) {
					pos1 = 0;
				}
				let end_char = kha_graphics2_truetype_StbTruetype.ttLONG(data,pos1);
				if(unicode_codepoint < start_char) {
					high = mid;
				} else if(unicode_codepoint > end_char) {
					low = mid + 1;
				} else {
					let pos = index_map + 16 + mid * 12 + 8;
					if(pos == null) {
						pos = 0;
					}
					let start_glyph = kha_graphics2_truetype_StbTruetype.ttLONG(data,pos);
					if(format == 12) {
						return start_glyph + unicode_codepoint - start_char;
					} else {
						return start_glyph;
					}
				}
			}
			return 0;
		}
		throw haxe_Exception.thrown("Error");
	}
	static stbtt_setvertex(v,type,x,y,cx,cy) {
		v.type = type;
		v.x = x;
		v.y = y;
		v.cx = cx;
		v.cy = cy;
	}
	static stbtt__GetGlyfOffset(info,glyph_index) {
		let g1;
		let g2;
		if(!(info.cff.data == null || info.cff.data.get_length() == 0)) {
			throw haxe_Exception.thrown("Error");
		}
		if(glyph_index >= info.numGlyphs) {
			return -1;
		}
		if(info.indexToLocFormat >= 2) {
			return -1;
		}
		if(info.indexToLocFormat == 0) {
			g1 = info.glyf + kha_graphics2_truetype_StbTruetype.ttUSHORT(info.data,info.loca + glyph_index * 2) * 2;
			g2 = info.glyf + kha_graphics2_truetype_StbTruetype.ttUSHORT(info.data,info.loca + glyph_index * 2 + 2) * 2;
		} else {
			let pos = info.loca + glyph_index * 4;
			if(pos == null) {
				pos = 0;
			}
			g1 = info.glyf + kha_graphics2_truetype_StbTruetype.ttLONG(info.data,pos);
			let pos1 = info.loca + glyph_index * 4 + 4;
			if(pos1 == null) {
				pos1 = 0;
			}
			g2 = info.glyf + kha_graphics2_truetype_StbTruetype.ttLONG(info.data,pos1);
		}
		if(g1 == g2) {
			return -1;
		} else {
			return g1;
		}
	}
	static stbtt_GetGlyphBox(info,glyph_index,rect) {
		if(info.cff.data != null && info.cff.data.get_length() > 0) {
			kha_graphics2_truetype_StbTruetype.stbtt__GetGlyphInfoT2(info,glyph_index,rect);
		} else {
			let g = kha_graphics2_truetype_StbTruetype.stbtt__GetGlyfOffset(info,glyph_index);
			if(g < 0) {
				return false;
			}
			rect.x0 = kha_graphics2_truetype_StbTruetype.ttSHORT(info.data,g + 2);
			rect.y0 = kha_graphics2_truetype_StbTruetype.ttSHORT(info.data,g + 4);
			rect.x1 = kha_graphics2_truetype_StbTruetype.ttSHORT(info.data,g + 6);
			rect.y1 = kha_graphics2_truetype_StbTruetype.ttSHORT(info.data,g + 8);
		}
		return true;
	}
	static stbtt__close_shape(vertices,num_vertices,was_off,start_off,sx,sy,scx,scy,cx,cy) {
		if(start_off) {
			if(was_off) {
				kha_graphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],3,cx + scx >> 1,cy + scy >> 1,cx,cy);
			}
			kha_graphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],3,sx,sy,scx,scy);
		} else if(was_off) {
			kha_graphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],3,sx,sy,cx,cy);
		} else {
			kha_graphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],2,sx,sy,0,0);
		}
		return num_vertices;
	}
	static copyVertices(from,to,offset,count) {
		let _g = 0;
		while(_g < count) {
			let i = _g++;
			to[offset + i] = from[i];
		}
	}
	static stbtt__GetGlyphShapeTT(info,glyph_index) {
		let data = info.data;
		let vertices = null;
		let num_vertices = 0;
		let g = kha_graphics2_truetype_StbTruetype.stbtt__GetGlyfOffset(info,glyph_index);
		if(g < 0) {
			return null;
		}
		let numberOfContours = kha_graphics2_truetype_StbTruetype.ttSHORT(data,g);
		if(numberOfContours > 0) {
			let flags = 0;
			let j = 0;
			let next_move = 0;
			let off = 0;
			let was_off = false;
			let start_off = false;
			let endPtsOfContoursOffset = g + 10;
			let pointsIndex = endPtsOfContoursOffset + numberOfContours * 2 + 2 + kha_graphics2_truetype_StbTruetype.ttUSHORT(data,endPtsOfContoursOffset + numberOfContours * 2);
			let n = 1 + kha_graphics2_truetype_StbTruetype.ttUSHORT(data,endPtsOfContoursOffset + numberOfContours * 2 - 2);
			let m = n + 2 * numberOfContours;
			vertices = new Array(m);
			if(vertices == null) {
				return null;
			} else {
				let _g = 0;
				let _g1 = vertices.length;
				while(_g < _g1) vertices[_g++] = new kha_graphics2_truetype_Stbtt_$vertex();
			}
			next_move = 0;
			let flagcount = 0;
			off = m - n;
			let _g = 0;
			while(_g < n) {
				let i = _g++;
				if(flagcount == 0) {
					flags = data.readU8(pointsIndex++);
					if((flags & 8) != 0) {
						flagcount = data.readU8(pointsIndex++);
					}
				} else {
					--flagcount;
				}
				vertices[off + i].type = flags;
			}
			let x = 0;
			let _g1 = 0;
			while(_g1 < n) {
				let i = _g1++;
				flags = vertices[off + i].type;
				if((flags & 2) != 0) {
					let dx = data.readU8(pointsIndex++);
					x += (flags & 16) != 0 ? dx : -dx;
				} else if((flags & 16) == 0) {
					let value;
					let ch1 = data.readU8(pointsIndex);
					let n = data.readU8(pointsIndex + 1) | ch1 << 8;
					if((n & 32768) != 0) {
						value = n - 65536;
					} else {
						value = n;
					}
					x += value;
					pointsIndex += 2;
				}
				vertices[off + i].x = x;
			}
			let y = 0;
			let _g2 = 0;
			while(_g2 < n) {
				let i = _g2++;
				flags = vertices[off + i].type;
				if((flags & 4) != 0) {
					let dy = data.readU8(pointsIndex++);
					y += (flags & 32) != 0 ? dy : -dy;
				} else if((flags & 32) == 0) {
					let value;
					let ch1 = data.readU8(pointsIndex);
					let n = data.readU8(pointsIndex + 1) | ch1 << 8;
					if((n & 32768) != 0) {
						value = n - 65536;
					} else {
						value = n;
					}
					y += value;
					pointsIndex += 2;
				}
				vertices[off + i].y = y;
			}
			num_vertices = 0;
			let scy = 0;
			let scx = 0;
			let cy = 0;
			let cx = 0;
			let sy = 0;
			let sx = 0;
			let i = 0;
			while(i < n) {
				flags = vertices[off + i].type;
				x = vertices[off + i].x;
				y = vertices[off + i].y;
				if(next_move == i) {
					if(i != 0) {
						num_vertices = kha_graphics2_truetype_StbTruetype.stbtt__close_shape(vertices,num_vertices,was_off,start_off,sx,sy,scx,scy,cx,cy);
					}
					start_off = (flags & 1) == 0;
					if(start_off) {
						scx = x;
						scy = y;
						if((vertices[off + i + 1].type & 1) == 0) {
							sx = x + vertices[off + i + 1].x >> 1;
							sy = y + vertices[off + i + 1].y >> 1;
						} else {
							sx = vertices[off + i + 1].x;
							sy = vertices[off + i + 1].y;
							++i;
						}
					} else {
						sx = x;
						sy = y;
					}
					kha_graphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],1,sx,sy,0,0);
					was_off = false;
					next_move = 1 + kha_graphics2_truetype_StbTruetype.ttUSHORT(data,endPtsOfContoursOffset + j * 2);
					++j;
				} else if((flags & 1) == 0) {
					if(was_off) {
						kha_graphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],3,cx + x >> 1,cy + y >> 1,cx,cy);
					}
					cx = x;
					cy = y;
					was_off = true;
				} else {
					if(was_off) {
						kha_graphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],3,x,y,cx,cy);
					} else {
						kha_graphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],2,x,y,0,0);
					}
					was_off = false;
				}
				++i;
			}
			num_vertices = kha_graphics2_truetype_StbTruetype.stbtt__close_shape(vertices,num_vertices,was_off,start_off,sx,sy,scx,scy,cx,cy);
		} else if(numberOfContours < 0) {
			let more = 1;
			let compIndex = g + 10;
			num_vertices = 0;
			vertices = null;
			while(more != 0) {
				let comp_num_verts = 0;
				let comp_verts = null;
				let tmp = null;
				let mtx0 = 1;
				let mtx1 = 0;
				let mtx2 = 0;
				let mtx3 = 1;
				let mtx4 = 0;
				let mtx5 = 0;
				let flags = kha_graphics2_truetype_StbTruetype.ttSHORT(data,compIndex);
				compIndex += 2;
				let gidx = kha_graphics2_truetype_StbTruetype.ttSHORT(data,compIndex);
				compIndex += 2;
				if((flags & 2) != 0) {
					if((flags & 1) != 0) {
						mtx4 = kha_graphics2_truetype_StbTruetype.ttSHORT(data,compIndex);
						compIndex += 2;
						mtx5 = kha_graphics2_truetype_StbTruetype.ttSHORT(data,compIndex);
						compIndex += 2;
					} else {
						mtx4 = kha_graphics2_truetype_StbTruetype.ttCHAR(data,compIndex);
						++compIndex;
						mtx5 = kha_graphics2_truetype_StbTruetype.ttCHAR(data,compIndex);
						++compIndex;
					}
				} else {
					throw haxe_Exception.thrown("Error");
				}
				if((flags & 8) != 0) {
					mtx3 = kha_graphics2_truetype_StbTruetype.ttSHORT(data,compIndex) / 16384.0;
					mtx0 = mtx3;
					compIndex += 2;
					mtx2 = 0;
					mtx1 = mtx2;
				} else if((flags & 64) != 0) {
					mtx0 = kha_graphics2_truetype_StbTruetype.ttSHORT(data,compIndex) / 16384.0;
					compIndex += 2;
					mtx2 = 0;
					mtx1 = mtx2;
					mtx3 = kha_graphics2_truetype_StbTruetype.ttSHORT(data,compIndex) / 16384.0;
					compIndex += 2;
				} else if((flags & 128) != 0) {
					mtx0 = kha_graphics2_truetype_StbTruetype.ttSHORT(data,compIndex) / 16384.0;
					compIndex += 2;
					mtx1 = kha_graphics2_truetype_StbTruetype.ttSHORT(data,compIndex) / 16384.0;
					compIndex += 2;
					mtx2 = kha_graphics2_truetype_StbTruetype.ttSHORT(data,compIndex) / 16384.0;
					compIndex += 2;
					mtx3 = kha_graphics2_truetype_StbTruetype.ttSHORT(data,compIndex) / 16384.0;
					compIndex += 2;
				}
				let m = Math.sqrt(mtx0 * mtx0 + mtx1 * mtx1);
				let n = Math.sqrt(mtx2 * mtx2 + mtx3 * mtx3);
				comp_verts = kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphShape(info,gidx);
				comp_num_verts = comp_verts == null ? 0 : comp_verts.length;
				if(comp_num_verts > 0) {
					let _g = 0;
					let _g1 = comp_num_verts;
					while(_g < _g1) {
						let v = comp_verts[_g++];
						let x = v.x;
						let y = v.y;
						v.x = m * (mtx0 * x + mtx2 * y + mtx4) | 0;
						v.y = n * (mtx1 * x + mtx3 * y + mtx5) | 0;
						x = v.cx;
						y = v.cy;
						v.cx = m * (mtx0 * x + mtx2 * y + mtx4) | 0;
						v.cy = n * (mtx1 * x + mtx3 * y + mtx5) | 0;
					}
					tmp = new Array(num_vertices + comp_num_verts);
					if(tmp == null) {
						return null;
					}
					if(num_vertices > 0) {
						kha_graphics2_truetype_StbTruetype.copyVertices(vertices,tmp,0,num_vertices);
					}
					kha_graphics2_truetype_StbTruetype.copyVertices(comp_verts,tmp,num_vertices,comp_num_verts);
					vertices = tmp;
					num_vertices += comp_num_verts;
				}
				more = flags & 32;
			}
		}
		if(vertices == null) {
			return null;
		}
		if(vertices.length < num_vertices) {
			throw haxe_Exception.thrown("Error");
		}
		if(num_vertices < vertices.length) {
			let tmp = new Array(num_vertices);
			kha_graphics2_truetype_StbTruetype.copyVertices(vertices,tmp,0,num_vertices);
			return tmp;
		} else {
			return vertices;
		}
	}
	static STBTT__CSCTX_INIT(bounds) {
		let tmp = new kha_graphics2_truetype_Stbtt_$_$csctx();
		tmp.bounds = bounds;
		tmp.started = false;
		tmp.first_x = 0;
		tmp.first_y = 0;
		tmp.x = 0;
		tmp.y = 0;
		tmp.min_x = 0;
		tmp.min_y = 0;
		tmp.max_x = 0;
		tmp.max_y = 0;
		tmp.pvertices = null;
		tmp.num_vertices = 0;
		return tmp;
	}
	static stbtt__track_vertex(c,x,y) {
		if(x > c.max_x || !c.started) {
			c.max_x = x;
		}
		if(y > c.max_y || !c.started) {
			c.max_y = y;
		}
		if(x < c.min_x || !c.started) {
			c.min_x = x;
		}
		if(y < c.min_y || !c.started) {
			c.min_y = y;
		}
		c.started = true;
	}
	static stbtt__csctx_v(c,type,x,y,cx,cy,cx1,cy1) {
		if(c.bounds) {
			kha_graphics2_truetype_StbTruetype.stbtt__track_vertex(c,x,y);
			if(type == 4) {
				kha_graphics2_truetype_StbTruetype.stbtt__track_vertex(c,cx,cy);
				kha_graphics2_truetype_StbTruetype.stbtt__track_vertex(c,cx1,cy1);
			}
		} else {
			kha_graphics2_truetype_StbTruetype.stbtt_setvertex(c.pvertices[c.num_vertices],type,x,y,cx,cy);
			c.pvertices[c.num_vertices].cx1 = js_Boot.__cast(cx1 , Int);
			c.pvertices[c.num_vertices].cy1 = js_Boot.__cast(cy1 , Int);
		}
		c.num_vertices++;
	}
	static stbtt__csctx_close_shape(ctx) {
		if(ctx.first_x != ctx.x || ctx.first_y != ctx.y) {
			kha_graphics2_truetype_StbTruetype.stbtt__csctx_v(ctx,2,ctx.first_x | 0,ctx.first_y | 0,0,0,0,0);
		}
	}
	static stbtt__csctx_rmove_to(ctx,dx,dy) {
		kha_graphics2_truetype_StbTruetype.stbtt__csctx_close_shape(ctx);
		ctx.first_x = ctx.x = ctx.x + dx;
		ctx.first_y = ctx.y = ctx.y + dy;
		kha_graphics2_truetype_StbTruetype.stbtt__csctx_v(ctx,1,ctx.x | 0,ctx.y | 0,0,0,0,0);
	}
	static stbtt__csctx_rline_to(ctx,dx,dy) {
		ctx.x += dx;
		ctx.y += dy;
		kha_graphics2_truetype_StbTruetype.stbtt__csctx_v(ctx,2,ctx.x | 0,ctx.y | 0,0,0,0,0);
	}
	static stbtt__csctx_rccurve_to(ctx,dx1,dy1,dx2,dy2,dx3,dy3) {
		let cx1 = ctx.x + dx1;
		let cy1 = ctx.y + dy1;
		let cx2 = cx1 + dx2;
		let cy2 = cy1 + dy2;
		ctx.x = cx2 + dx3;
		ctx.y = cy2 + dy3;
		kha_graphics2_truetype_StbTruetype.stbtt__csctx_v(ctx,4,ctx.x | 0,ctx.y | 0,cx1 | 0,cy1 | 0,cx2 | 0,cy2 | 0);
	}
	static stbtt__get_subr(idx,n) {
		if(0 > idx.data.get_length()) {
			throw haxe_Exception.thrown("Error");
		}
		idx.cursor = 0 > idx.data.get_length() ? idx.data.get_length() : 0;
		let count = kha_graphics2_truetype_StbTruetype.stbtt__buf_get(idx,2);
		let bias = 107;
		if(count >= 33900) {
			bias = 32768;
		} else if(count >= 1240) {
			bias = 1131;
		}
		n += bias;
		if(n < 0 || n >= count) {
			return kha_graphics2_truetype_StbTruetype.stbtt__new_buf(null,0);
		}
		return kha_graphics2_truetype_StbTruetype.stbtt__cff_index_get(idx,n);
	}
	static stbtt__run_charstring(info,glyph_index,c) {
		let in_header = true;
		let maskbits = 0;
		let subr_stack_height = 0;
		let sp = 0;
		let v;
		let i;
		let b0;
		let has_subrs = false;
		let clear_stack;
		let _g = [];
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		_g.push(0);
		let _g1 = [];
		_g1.push(new kha_graphics2_truetype_Stbtt_$_$buf());
		_g1.push(new kha_graphics2_truetype_Stbtt_$_$buf());
		_g1.push(new kha_graphics2_truetype_Stbtt_$_$buf());
		_g1.push(new kha_graphics2_truetype_Stbtt_$_$buf());
		_g1.push(new kha_graphics2_truetype_Stbtt_$_$buf());
		_g1.push(new kha_graphics2_truetype_Stbtt_$_$buf());
		_g1.push(new kha_graphics2_truetype_Stbtt_$_$buf());
		_g1.push(new kha_graphics2_truetype_Stbtt_$_$buf());
		_g1.push(new kha_graphics2_truetype_Stbtt_$_$buf());
		_g1.push(new kha_graphics2_truetype_Stbtt_$_$buf());
		let subrs = info.subrs;
		let f;
		let b = kha_graphics2_truetype_StbTruetype.stbtt__cff_index_get(info.charstrings,glyph_index);
		while(b.cursor < b.data.get_length()) {
			i = 0;
			clear_stack = true;
			if(b.cursor >= b.data.get_length()) {
				b0 = 0;
			} else {
				let pos = b.cursor++;
				if(pos == null) {
					pos = 0;
				}
				b0 = b.data.readU8(pos);
			}
			switch(b0) {
			case 1:case 3:case 18:case 23:
				maskbits += sp / 2 | 0;
				break;
			case 4:
				in_header = false;
				if(sp < 1) {
					return false;
				}
				kha_graphics2_truetype_StbTruetype.stbtt__csctx_rmove_to(c,0,_g[sp - 1]);
				break;
			case 5:
				if(sp < 2) {
					return false;
				}
				while(i + 1 < sp) {
					kha_graphics2_truetype_StbTruetype.stbtt__csctx_rline_to(c,_g[i],_g[i + 1]);
					i += 2;
				}
				break;
			case 6:
				if(sp < 1) {
					return false;
				}
				while(i < sp) {
					kha_graphics2_truetype_StbTruetype.stbtt__csctx_rline_to(c,_g[i],0);
					++i;
					if(i >= sp) {
						break;
					}
					kha_graphics2_truetype_StbTruetype.stbtt__csctx_rline_to(c,0,_g[i]);
					++i;
				}
				break;
			case 7:
				if(sp < 1) {
					return false;
				}
				while(i < sp) {
					kha_graphics2_truetype_StbTruetype.stbtt__csctx_rline_to(c,0,_g[i]);
					++i;
					if(i >= sp) {
						break;
					}
					kha_graphics2_truetype_StbTruetype.stbtt__csctx_rline_to(c,_g[i],0);
					++i;
				}
				break;
			case 8:
				if(sp < 6) {
					return false;
				}
				while(i + 5 < sp) {
					kha_graphics2_truetype_StbTruetype.stbtt__csctx_rccurve_to(c,_g[i],_g[i + 1],_g[i + 2],_g[i + 3],_g[i + 4],_g[i + 5]);
					i += 6;
				}
				break;
			case 11:
				if(subr_stack_height <= 0) {
					return false;
				}
				b = _g1[--subr_stack_height];
				clear_stack = false;
				break;
			case 12:
				let dx1;
				let dx2;
				let dx3;
				let dx4;
				let dx5;
				let dx6;
				let dy1;
				let dy2;
				let dy3;
				let dy4;
				let dy5;
				let dy6;
				let dx;
				let dy;
				let b1;
				if(b.cursor >= b.data.get_length()) {
					b1 = 0;
				} else {
					let pos = b.cursor++;
					if(pos == null) {
						pos = 0;
					}
					b1 = b.data.readU8(pos);
				}
				switch(b1) {
				case 34:
					if(sp < 7) {
						return false;
					}
					dx1 = _g[0];
					dx2 = _g[1];
					dy2 = _g[2];
					dx3 = _g[3];
					dx4 = _g[4];
					dx5 = _g[5];
					dx6 = _g[6];
					kha_graphics2_truetype_StbTruetype.stbtt__csctx_rccurve_to(c,dx1,0,dx2,dy2,dx3,0);
					kha_graphics2_truetype_StbTruetype.stbtt__csctx_rccurve_to(c,dx4,0,dx5,-dy2,dx6,0);
					break;
				case 35:
					if(sp < 13) {
						return false;
					}
					dx1 = _g[0];
					dy1 = _g[1];
					dx2 = _g[2];
					dy2 = _g[3];
					dx3 = _g[4];
					dy3 = _g[5];
					dx4 = _g[6];
					dy4 = _g[7];
					dx5 = _g[8];
					dy5 = _g[9];
					dx6 = _g[10];
					dy6 = _g[11];
					kha_graphics2_truetype_StbTruetype.stbtt__csctx_rccurve_to(c,dx1,dy1,dx2,dy2,dx3,dy3);
					kha_graphics2_truetype_StbTruetype.stbtt__csctx_rccurve_to(c,dx4,dy4,dx5,dy5,dx6,dy6);
					break;
				case 36:
					if(sp < 9) {
						return false;
					}
					dx1 = _g[0];
					dy1 = _g[1];
					dx2 = _g[2];
					dy2 = _g[3];
					dx3 = _g[4];
					dx4 = _g[5];
					dx5 = _g[6];
					dy5 = _g[7];
					dx6 = _g[8];
					kha_graphics2_truetype_StbTruetype.stbtt__csctx_rccurve_to(c,dx1,dy1,dx2,dy2,dx3,0);
					kha_graphics2_truetype_StbTruetype.stbtt__csctx_rccurve_to(c,dx4,0,dx5,dy5,dx6,-(dy1 + dy2 + dy5));
					break;
				case 37:
					if(sp < 11) {
						return false;
					}
					dx1 = _g[0];
					dy1 = _g[1];
					dx2 = _g[2];
					dy2 = _g[3];
					dx3 = _g[4];
					dy3 = _g[5];
					dx4 = _g[6];
					dy4 = _g[7];
					dx5 = _g[8];
					dy5 = _g[9];
					dy6 = _g[10];
					dx6 = dy6;
					dx = dx1 + dx2 + dx3 + dx4 + dx5;
					dy = dy1 + dy2 + dy3 + dy4 + dy5;
					if(Math.abs(dx) > Math.abs(dy)) {
						dy6 = -dy;
					} else {
						dx6 = -dx;
					}
					kha_graphics2_truetype_StbTruetype.stbtt__csctx_rccurve_to(c,dx1,dy1,dx2,dy2,dx3,dy3);
					kha_graphics2_truetype_StbTruetype.stbtt__csctx_rccurve_to(c,dx4,dy4,dx5,dy5,dx6,dy6);
					break;
				default:
					return false;
				}
				break;
			case 14:
				kha_graphics2_truetype_StbTruetype.stbtt__csctx_close_shape(c);
				return true;
			case 19:case 20:
				if(in_header) {
					maskbits += sp / 2 | 0;
				}
				in_header = false;
				let o = b.cursor + ((maskbits + 7) / 8 | 0);
				if(o > b.data.get_length() || o < 0) {
					throw haxe_Exception.thrown("Error");
				}
				b.cursor = o > b.data.get_length() || o < 0 ? b.data.get_length() : o;
				break;
			case 21:
				in_header = false;
				if(sp < 2) {
					return false;
				}
				kha_graphics2_truetype_StbTruetype.stbtt__csctx_rmove_to(c,_g[sp - 2],_g[sp - 1]);
				break;
			case 22:
				in_header = false;
				if(sp < 1) {
					return false;
				}
				kha_graphics2_truetype_StbTruetype.stbtt__csctx_rmove_to(c,_g[sp - 1],0);
				break;
			case 24:
				if(sp < 8) {
					return false;
				}
				while(i + 5 < sp - 2) {
					kha_graphics2_truetype_StbTruetype.stbtt__csctx_rccurve_to(c,_g[i],_g[i + 1],_g[i + 2],_g[i + 3],_g[i + 4],_g[i + 5]);
					i += 6;
				}
				if(i + 1 >= sp) {
					return false;
				}
				kha_graphics2_truetype_StbTruetype.stbtt__csctx_rline_to(c,_g[i],_g[i + 1]);
				break;
			case 25:
				if(sp < 8) {
					return false;
				}
				while(i + 1 < sp - 6) {
					kha_graphics2_truetype_StbTruetype.stbtt__csctx_rline_to(c,_g[i],_g[i + 1]);
					i += 2;
				}
				if(i + 5 >= sp) {
					return false;
				}
				kha_graphics2_truetype_StbTruetype.stbtt__csctx_rccurve_to(c,_g[i],_g[i + 1],_g[i + 2],_g[i + 3],_g[i + 4],_g[i + 5]);
				break;
			case 26:case 27:
				if(sp < 4) {
					return false;
				}
				f = 0.0;
				if((sp & 1) != 0) {
					f = _g[0];
					i = 1;
				}
				while(i + 3 < sp) {
					if(b0 == 27) {
						kha_graphics2_truetype_StbTruetype.stbtt__csctx_rccurve_to(c,_g[i],f,_g[i + 1],_g[i + 2],_g[i + 3],0.0);
					} else {
						kha_graphics2_truetype_StbTruetype.stbtt__csctx_rccurve_to(c,f,_g[i],_g[i + 1],_g[i + 2],0.0,_g[i + 3]);
					}
					f = 0.0;
					i += 4;
				}
				break;
			case 10:case 29:
				if(b0 == 10) {
					if(!has_subrs) {
						if(info.fdselect.data.get_length() != 0) {
							let fdselect = info.fdselect;
							let nranges;
							let start;
							let end;
							let v;
							let fmt;
							let fdselector = -1;
							if(0 > fdselect.data.get_length()) {
								throw haxe_Exception.thrown("Error");
							}
							fdselect.cursor = 0 > fdselect.data.get_length() ? fdselect.data.get_length() : 0;
							if(fdselect.cursor >= fdselect.data.get_length()) {
								fmt = 0;
							} else {
								let pos = fdselect.cursor++;
								if(pos == null) {
									pos = 0;
								}
								fmt = fdselect.data.readU8(pos);
							}
							if(fmt == 0) {
								let o = fdselect.cursor + glyph_index;
								if(o > fdselect.data.get_length() || o < 0) {
									throw haxe_Exception.thrown("Error");
								}
								fdselect.cursor = o > fdselect.data.get_length() || o < 0 ? fdselect.data.get_length() : o;
								if(fdselect.cursor >= fdselect.data.get_length()) {
									fdselector = 0;
								} else {
									let pos = fdselect.cursor++;
									if(pos == null) {
										pos = 0;
									}
									fdselector = fdselect.data.readU8(pos);
								}
							} else if(fmt == 3) {
								nranges = kha_graphics2_truetype_StbTruetype.stbtt__buf_get(fdselect,2);
								start = kha_graphics2_truetype_StbTruetype.stbtt__buf_get(fdselect,2);
								let _g = 0;
								while(_g < nranges) {
									++_g;
									if(fdselect.cursor >= fdselect.data.get_length()) {
										v = 0;
									} else {
										let pos = fdselect.cursor++;
										if(pos == null) {
											pos = 0;
										}
										v = fdselect.data.readU8(pos);
									}
									end = kha_graphics2_truetype_StbTruetype.stbtt__buf_get(fdselect,2);
									if(glyph_index >= start && glyph_index < end) {
										fdselector = v;
										break;
									}
									start = end;
								}
							}
							if(fdselector == -1) {
								kha_graphics2_truetype_StbTruetype.stbtt__new_buf(null,0);
							}
							subrs = kha_graphics2_truetype_StbTruetype.stbtt__get_subrs(info.cff,kha_graphics2_truetype_StbTruetype.stbtt__cff_index_get(info.fontdicts,fdselector));
						}
						has_subrs = true;
					}
				}
				if(sp < 1) {
					return false;
				}
				v = _g[--sp] | 0;
				if(subr_stack_height >= 10) {
					return false;
				}
				_g1[subr_stack_height++] = b;
				b = kha_graphics2_truetype_StbTruetype.stbtt__get_subr(b0 == 10 ? subrs : info.gsubrs,v);
				if(b.data.get_length() == 0) {
					return false;
				}
				b.cursor = 0;
				clear_stack = false;
				break;
			case 30:
				if(sp < 4) {
					return false;
				}
				while(i + 3 < sp) {
					kha_graphics2_truetype_StbTruetype.stbtt__csctx_rccurve_to(c,0,_g[i],_g[i + 1],_g[i + 2],_g[i + 3],sp - i == 5 ? _g[i + 4] : 0);
					i += 4;
					if(i + 3 >= sp) {
						break;
					}
					kha_graphics2_truetype_StbTruetype.stbtt__csctx_rccurve_to(c,_g[i],0,_g[i + 1],_g[i + 2],sp - i == 5 ? _g[i + 4] : 0,_g[i + 3]);
					i += 4;
				}
				break;
			case 31:
				if(sp < 4) {
					return false;
				}
				while(i + 3 < sp) {
					kha_graphics2_truetype_StbTruetype.stbtt__csctx_rccurve_to(c,_g[i],0,_g[i + 1],_g[i + 2],sp - i == 5 ? _g[i + 4] : 0,_g[i + 3]);
					i += 4;
					if(i + 3 >= sp) {
						break;
					}
					kha_graphics2_truetype_StbTruetype.stbtt__csctx_rccurve_to(c,0,_g[i],_g[i + 1],_g[i + 2],_g[i + 3],sp - i == 5 ? _g[i + 4] : 0);
					i += 4;
				}
				break;
			default:
				if(b0 != 255 && b0 != 28 && (b0 < 32 || b0 > 254)) {
					return false;
				}
				if(b0 == 255) {
					f = kha_graphics2_truetype_StbTruetype.stbtt__buf_get(b,4) / 65536;
				} else {
					let o = b.cursor + (-1);
					if(o > b.data.get_length() || o < 0) {
						throw haxe_Exception.thrown("Error");
					}
					b.cursor = o > b.data.get_length() || o < 0 ? b.data.get_length() : o;
					f = kha_graphics2_truetype_StbTruetype.stbtt__cff_int(b);
				}
				if(sp >= 48) {
					return false;
				}
				_g[sp++] = f;
				clear_stack = false;
			}
			if(clear_stack) {
				sp = 0;
			}
		}
		return false;
	}
	static stbtt__GetGlyphShapeT2(info,glyph_index) {
		let count_ctx = kha_graphics2_truetype_StbTruetype.STBTT__CSCTX_INIT(true);
		let output_ctx = kha_graphics2_truetype_StbTruetype.STBTT__CSCTX_INIT(false);
		if(kha_graphics2_truetype_StbTruetype.stbtt__run_charstring(info,glyph_index,count_ctx)) {
			output_ctx.pvertices = new Array(count_ctx.num_vertices);
			let _g = 0;
			let _g1 = count_ctx.num_vertices;
			while(_g < _g1) output_ctx.pvertices[_g++] = new kha_graphics2_truetype_Stbtt_$vertex();
			if(kha_graphics2_truetype_StbTruetype.stbtt__run_charstring(info,glyph_index,output_ctx)) {
				if(output_ctx.num_vertices != count_ctx.num_vertices) {
					throw haxe_Exception.thrown("Error");
				}
				return output_ctx.pvertices;
			}
		}
		return null;
	}
	static stbtt__GetGlyphInfoT2(info,glyph_index,rect) {
		let c = kha_graphics2_truetype_StbTruetype.STBTT__CSCTX_INIT(true);
		let r = kha_graphics2_truetype_StbTruetype.stbtt__run_charstring(info,glyph_index,c);
		if(rect != null) {
			rect.x0 = r ? c.min_x : 0;
			rect.y0 = r ? c.min_y : 0;
			rect.x1 = r ? c.max_x : 0;
			rect.y1 = r ? c.max_y : 0;
		}
		if(r) {
			return c.num_vertices;
		} else {
			return 0;
		}
	}
	static stbtt_GetGlyphShape(info,glyph_index) {
		if(info.cff.data == null || info.cff.data.get_length() == 0) {
			return kha_graphics2_truetype_StbTruetype.stbtt__GetGlyphShapeTT(info,glyph_index);
		} else {
			return kha_graphics2_truetype_StbTruetype.stbtt__GetGlyphShapeT2(info,glyph_index);
		}
	}
	static stbtt_GetGlyphHMetrics(info,glyph_index) {
		let numOfLongHorMetrics = kha_graphics2_truetype_StbTruetype.ttUSHORT(info.data,info.hhea + 34);
		let metrics = new kha_graphics2_truetype_Stbtt_$temp_$glyph_$h_$metrics();
		if(glyph_index < numOfLongHorMetrics) {
			metrics.advanceWidth = kha_graphics2_truetype_StbTruetype.ttSHORT(info.data,info.hmtx + 4 * glyph_index);
			metrics.leftSideBearing = kha_graphics2_truetype_StbTruetype.ttSHORT(info.data,info.hmtx + 4 * glyph_index + 2);
		} else {
			metrics.advanceWidth = kha_graphics2_truetype_StbTruetype.ttSHORT(info.data,info.hmtx + 4 * (numOfLongHorMetrics - 1));
			metrics.leftSideBearing = kha_graphics2_truetype_StbTruetype.ttSHORT(info.data,info.hmtx + 4 * numOfLongHorMetrics + 2 * (glyph_index - numOfLongHorMetrics));
		}
		return metrics;
	}
	static stbtt_GetFontVMetrics(info) {
		let metrics = new kha_graphics2_truetype_Stbtt_$temp_$font_$v_$metrics();
		metrics.ascent = kha_graphics2_truetype_StbTruetype.ttSHORT(info.data,info.hhea + 4);
		metrics.descent = kha_graphics2_truetype_StbTruetype.ttSHORT(info.data,info.hhea + 6);
		metrics.lineGap = kha_graphics2_truetype_StbTruetype.ttSHORT(info.data,info.hhea + 8);
		return metrics;
	}
	static stbtt_ScaleForPixelHeight(info,height) {
		return height / (kha_graphics2_truetype_StbTruetype.ttSHORT(info.data,info.hhea + 4) - kha_graphics2_truetype_StbTruetype.ttSHORT(info.data,info.hhea + 6));
	}
	static stbtt_GetGlyphBitmapBoxSubpixel(font,glyph,scale_x,scale_y,shift_x,shift_y) {
		let rect = new kha_graphics2_truetype_Stbtt_$temp_$rect();
		if(!kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphBox(font,glyph,rect)) {
			rect.x0 = 0;
			rect.y0 = 0;
			rect.x1 = 0;
			rect.y1 = 0;
		} else {
			let y0 = rect.y0;
			rect.x0 = Math.floor(rect.x0 * scale_x + shift_x);
			rect.y0 = Math.floor(-rect.y1 * scale_y + shift_y);
			rect.x1 = Math.ceil(rect.x1 * scale_x + shift_x);
			rect.y1 = Math.ceil(-y0 * scale_y + shift_y);
		}
		return rect;
	}
	static stbtt_GetGlyphBitmapBox(font,glyph,scale_x,scale_y) {
		return kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphBitmapBoxSubpixel(font,glyph,scale_x,scale_y,0.0,0.0);
	}
	static stbtt__new_active(e,eIndex,off_x,start_point) {
		let z = new kha_graphics2_truetype_Stbtt_$_$active_$edge();
		let dxdy = (e[eIndex].x1 - e[eIndex].x0) / (e[eIndex].y1 - e[eIndex].y0);
		if(z == null) {
			throw haxe_Exception.thrown("Error");
		}
		if(z == null) {
			return z;
		}
		z.fdx = dxdy;
		z.fdy = dxdy != 0.0 ? 1.0 / dxdy : 0.0;
		z.fx = e[eIndex].x0 + dxdy * (start_point - e[eIndex].y0);
		z.fx -= off_x;
		z.direction = e[eIndex].invert ? 1.0 : -1.0;
		z.sy = e[eIndex].y0;
		z.ey = e[eIndex].y1;
		z.next = null;
		return z;
	}
	static stbtt__handle_clipped_edge(scanline,scanlineIndex,x,e,x0,y0,x1,y1) {
		if(y0 == y1) {
			return;
		}
		if(!(y0 < y1)) {
			throw haxe_Exception.thrown("Error");
		}
		if(!(e.sy <= e.ey)) {
			throw haxe_Exception.thrown("Error");
		}
		if(y0 > e.ey) {
			return;
		}
		if(y1 < e.sy) {
			return;
		}
		if(y0 < e.sy) {
			x0 += (x1 - x0) * (e.sy - y0) / (y1 - y0);
			y0 = e.sy;
		}
		if(y1 > e.ey) {
			x1 += (x1 - x0) * (e.ey - y1) / (y1 - y0);
			y1 = e.ey;
		}
		if(x0 == x) {
			if(!(x1 <= x + 1)) {
				throw haxe_Exception.thrown("Error");
			}
		} else if(x0 == x + 1) {
			if(!(x1 >= x)) {
				throw haxe_Exception.thrown("Error");
			}
		} else if(x0 <= x) {
			if(!(x1 <= x)) {
				throw haxe_Exception.thrown("Error");
			}
		} else if(x0 >= x + 1) {
			if(!(x1 >= x + 1)) {
				throw haxe_Exception.thrown("Error");
			}
		} else if(!(x1 >= x && x1 <= x + 1)) {
			throw haxe_Exception.thrown("Error");
		}
		if(x0 <= x && x1 <= x) {
			scanline[scanlineIndex + x] += e.direction * (y1 - y0);
		} else if(!(x0 >= x + 1 && x1 >= x + 1)) {
			if(!(x0 >= x && x0 <= x + 1 && x1 >= x && x1 <= x + 1)) {
				throw haxe_Exception.thrown("Error");
			}
			scanline[scanlineIndex + x] += e.direction * (y1 - y0) * (1 - (x0 - x + (x1 - x)) / 2);
		}
	}
	static stbtt__fill_active_edges_new(scanline,scanline_fill,scanline_fillIndex,len,e,y_top) {
		let y_bottom = y_top + 1;
		while(e != null) {
			if(!(e.ey >= y_top)) {
				throw haxe_Exception.thrown("Error");
			}
			if(e.fdx == 0) {
				let x0 = e.fx;
				if(x0 < len) {
					if(x0 >= 0) {
						kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x0 | 0,e,x0,y_top,x0,y_bottom);
						kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline_fill,scanline_fillIndex - 1,x0 + 1 | 0,e,x0,y_top,x0,y_bottom);
					} else {
						kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline_fill,scanline_fillIndex - 1,0,e,x0,y_top,x0,y_bottom);
					}
				}
			} else {
				let x0 = e.fx;
				let dx = e.fdx;
				let xb = x0 + dx;
				let x_top;
				let x_bottom;
				let sy0;
				let sy1;
				let dy = e.fdy;
				if(!(e.sy <= y_bottom && e.ey >= y_top)) {
					throw haxe_Exception.thrown("Error");
				}
				if(e.sy > y_top) {
					x_top = x0 + dx * (e.sy - y_top);
					sy0 = e.sy;
				} else {
					x_top = x0;
					sy0 = y_top;
				}
				if(e.ey < y_bottom) {
					x_bottom = x0 + dx * (e.ey - y_top);
					sy1 = e.ey;
				} else {
					x_bottom = xb;
					sy1 = y_bottom;
				}
				if(x_top >= 0 && x_bottom >= 0 && x_top < len && x_bottom < len) {
					if((x_top | 0) == (x_bottom | 0)) {
						let x = x_top | 0;
						let height = sy1 - sy0;
						if(!(x >= 0 && x < len)) {
							throw haxe_Exception.thrown("Error");
						}
						scanline[x] += e.direction * (1 - (x_top - x + (x_bottom - x)) / 2) * height;
						scanline_fill[scanline_fillIndex + x] += e.direction * height;
					} else {
						if(x_top > x_bottom) {
							sy0 = y_bottom - (sy0 - y_top);
							sy1 = y_bottom - (sy1 - y_top);
							let t = sy0;
							sy0 = sy1;
							sy1 = t;
							t = x_bottom;
							x_bottom = x_top;
							x_top = t;
							dx = -dx;
							dy = -dy;
							t = x0;
							x0 = xb;
							xb = t;
						}
						let x1 = x_top | 0;
						let x2 = x_bottom | 0;
						let y_crossing = (x1 + 1 - x0) * dy + y_top;
						let sign = e.direction;
						let area = sign * (y_crossing - sy0);
						scanline[x1] += area * (1 - (x_top - x1 + (x1 + 1 - x1)) / 2);
						let step = sign * dy;
						let _g = x1 + 1;
						while(_g < x2) {
							scanline[_g++] += area + step / 2;
							area += step;
						}
						y_crossing += dy * (x2 - (x1 + 1));
						if(!(Math.abs(area) <= 1.01)) {
							throw haxe_Exception.thrown("Error");
						}
						scanline[x2] += area + sign * (1 - (x2 - x2 + (x_bottom - x2)) / 2) * (sy1 - y_crossing);
						scanline_fill[scanline_fillIndex + x2] += sign * (sy1 - sy0);
					}
				} else {
					let _g = 0;
					while(_g < len) {
						let x = _g++;
						let x1 = x;
						let x2 = x + 1;
						let x3 = xb;
						let y1 = (x - x0) / dx + y_top;
						let y2 = (x + 1 - x0) / dx + y_top;
						if(x0 < x1 && x3 > x2) {
							kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x,e,x0,y_top,x1,y1);
							kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x,e,x1,y1,x2,y2);
							kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x,e,x2,y2,x3,y_bottom);
						} else if(x3 < x1 && x0 > x2) {
							kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x,e,x0,y_top,x2,y2);
							kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x,e,x2,y2,x1,y1);
							kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x,e,x1,y1,x3,y_bottom);
						} else if(x0 < x1 && x3 > x1) {
							kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x,e,x0,y_top,x1,y1);
							kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x,e,x1,y1,x3,y_bottom);
						} else if(x3 < x1 && x0 > x1) {
							kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x,e,x0,y_top,x1,y1);
							kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x,e,x1,y1,x3,y_bottom);
						} else if(x0 < x2 && x3 > x2) {
							kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x,e,x0,y_top,x2,y2);
							kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x,e,x2,y2,x3,y_bottom);
						} else if(x3 < x2 && x0 > x2) {
							kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x,e,x0,y_top,x2,y2);
							kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x,e,x2,y2,x3,y_bottom);
						} else {
							kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x,e,x0,y_top,x3,y_bottom);
						}
					}
				}
			}
			e = e.next;
		}
	}
	static stbtt__rasterize_sorted_edges(result,e,n,vsubsample,off_x,off_y) {
		let active = null;
		let j = 0;
		let scanline;
		let scanline2Index = 0;
		let eIndex = 0;
		if(result.w > 64) {
			scanline = new Array(result.w * 2 + 1);
		} else {
			scanline = new Array(129);
		}
		let scanline2 = scanline;
		scanline2Index = result.w;
		let y = off_y;
		e[n].y0 = off_y + result.h + 1;
		while(j < result.h) {
			let scan_y_top = y + 0.0;
			let scan_y_bottom = y + 1.0;
			let step_value = active;
			let step_parent = null;
			let _g = 0;
			let _g1 = result.w;
			while(_g < _g1) scanline[_g++] = 0;
			let _g2 = 0;
			let _g3 = result.w + 1;
			while(_g2 < _g3) scanline2[scanline2Index + _g2++] = 0;
			while(step_value != null) {
				let z = step_value;
				if(z.ey <= scan_y_top) {
					if(step_parent == null) {
						active = z.next;
						step_value = z.next;
					} else {
						step_parent.next = z.next;
						step_value = z.next;
					}
					if(z.direction == 0) {
						throw haxe_Exception.thrown("Error");
					}
					z.direction = 0;
				} else {
					step_parent = step_value;
					step_value = step_value.next;
				}
			}
			while(e[eIndex].y0 <= scan_y_bottom) {
				if(e[eIndex].y0 != e[eIndex].y1) {
					let z = kha_graphics2_truetype_StbTruetype.stbtt__new_active(e,eIndex,off_x,scan_y_top);
					if(!(z.ey >= scan_y_top)) {
						throw haxe_Exception.thrown("Error");
					}
					if(z != null) {
						if(j == 0 && off_y != 0) {
							if(z.ey < scan_y_top) {
								z.ey = scan_y_top;
							}
						}
						if(!(z.ey >= scan_y_top)) {
							throw haxe_Exception.thrown("Error");
						}
					}
					z.next = active;
					active = z;
				}
				++eIndex;
			}
			if(active != null) {
				kha_graphics2_truetype_StbTruetype.stbtt__fill_active_edges_new(scanline,scanline2,scanline2Index + 1,result.w,active,scan_y_top);
			}
			let sum = 0;
			let _g4 = 0;
			let _g5 = result.w;
			while(_g4 < _g5) {
				let i = _g4++;
				sum += scanline2[scanline2Index + i];
				let k = scanline[i] + sum;
				k = Math.abs(k) * 255.0 + 0.5;
				let m = k | 0;
				if(m > 255) {
					m = 255;
				}
				result.pixels.writeU8(result.pixels_offset + j * result.stride + i,m);
			}
			step_parent = null;
			step_value = active;
			while(step_value != null) {
				let z = step_value;
				z.fx += z.fdx;
				step_parent = step_value;
				step_value = step_value.next;
			}
			++y;
			++j;
		}
	}
	static STBTT__COMPARE(a,b) {
		return a.y0 < b.y0;
	}
	static stbtt__sort_edges_ins_sort(p,n) {
		let j;
		let _g = 1;
		while(_g < n) {
			let i = _g++;
			let t = p[i];
			j = i;
			while(j > 0) {
				if(!kha_graphics2_truetype_StbTruetype.STBTT__COMPARE(t,p[j - 1])) {
					break;
				}
				p[j] = p[j - 1];
				--j;
			}
			if(i != j) {
				p[j] = t;
			}
		}
	}
	static stbtt__sort_edges_quicksort(p,pIndex,n) {
		while(n > 12) {
			let t;
			let c;
			let m = n >> 1;
			let c12 = kha_graphics2_truetype_StbTruetype.STBTT__COMPARE(p[pIndex + m],p[pIndex + n - 1]);
			if(kha_graphics2_truetype_StbTruetype.STBTT__COMPARE(p[pIndex],p[pIndex + m]) != c12) {
				c = kha_graphics2_truetype_StbTruetype.STBTT__COMPARE(p[pIndex],p[pIndex + n - 1]);
				let z = c == c12 ? 0 : n - 1;
				t = p[pIndex + z];
				p[pIndex + z] = p[pIndex + m];
				p[pIndex + m] = t;
			}
			t = p[pIndex];
			p[pIndex] = p[pIndex + m];
			p[pIndex + m] = t;
			let i = 1;
			let j = n - 1;
			while(true) {
				while(kha_graphics2_truetype_StbTruetype.STBTT__COMPARE(p[pIndex + i],p[pIndex])) ++i;
				while(kha_graphics2_truetype_StbTruetype.STBTT__COMPARE(p[pIndex],p[pIndex + j])) --j;
				if(i >= j) {
					break;
				}
				t = p[pIndex + i];
				p[pIndex + i] = p[pIndex + j];
				p[pIndex + j] = t;
				++i;
				--j;
			}
			if(j < n - i) {
				kha_graphics2_truetype_StbTruetype.stbtt__sort_edges_quicksort(p,pIndex,j);
				pIndex += i;
				n -= i;
			} else {
				kha_graphics2_truetype_StbTruetype.stbtt__sort_edges_quicksort(p,pIndex + i,n - i);
				n = j;
			}
		}
	}
	static stbtt__sort_edges(p,n) {
		kha_graphics2_truetype_StbTruetype.stbtt__sort_edges_quicksort(p,0,n);
		kha_graphics2_truetype_StbTruetype.stbtt__sort_edges_ins_sort(p,n);
	}
	static stbtt__rasterize(result,pts,wcount,windings,scale_x,scale_y,shift_x,shift_y,off_x,off_y,invert) {
		let y_scale_inv = invert ? -scale_y : scale_y;
		let j;
		let n = 0;
		let _g = 0;
		while(_g < windings) n += wcount[_g++];
		let e = new Array(n + 1);
		if(e == null) {
			return;
		} else {
			let _g = 0;
			let _g1 = e.length;
			while(_g < _g1) e[_g++] = new kha_graphics2_truetype_Stbtt_$_$edge();
		}
		n = 0;
		let m = 0;
		let _g1 = 0;
		while(_g1 < windings) {
			let i = _g1++;
			let pIndex = m;
			m += wcount[i];
			j = wcount[i] - 1;
			let _g = 0;
			let _g2 = wcount[i];
			while(_g < _g2) {
				let k = _g++;
				let a = k;
				let b = j;
				if(pts[pIndex + j].y == pts[pIndex + k].y) {
					j = k;
					continue;
				}
				e[n].invert = false;
				if(invert ? pts[pIndex + j].y > pts[pIndex + k].y : pts[pIndex + j].y < pts[pIndex + k].y) {
					e[n].invert = true;
					a = j;
					b = k;
				}
				e[n].x0 = pts[pIndex + a].x * scale_x + shift_x;
				e[n].y0 = pts[pIndex + a].y * y_scale_inv + shift_y;
				e[n].x1 = pts[pIndex + b].x * scale_x + shift_x;
				e[n].y1 = pts[pIndex + b].y * y_scale_inv + shift_y;
				++n;
				j = k;
			}
		}
		kha_graphics2_truetype_StbTruetype.stbtt__sort_edges(e,n);
		kha_graphics2_truetype_StbTruetype.stbtt__rasterize_sorted_edges(result,e,n,1,off_x,off_y);
	}
	static stbtt__add_point(points,n,x,y) {
		if(points == null) {
			return;
		}
		points[n].x = x;
		points[n].y = y;
	}
	static stbtt__tesselate_curve(points,num_points,x0,y0,x1,y1,x2,y2,objspace_flatness_squared,n) {
		let mx = (x0 + 2 * x1 + x2) / 4;
		let my = (y0 + 2 * y1 + y2) / 4;
		let dx = (x0 + x2) / 2 - mx;
		let dy = (y0 + y2) / 2 - my;
		if(n > 16) {
			return 1;
		}
		if(dx * dx + dy * dy > objspace_flatness_squared) {
			kha_graphics2_truetype_StbTruetype.stbtt__tesselate_curve(points,num_points,x0,y0,(x0 + x1) / 2.0,(y0 + y1) / 2.0,mx,my,objspace_flatness_squared,n + 1);
			kha_graphics2_truetype_StbTruetype.stbtt__tesselate_curve(points,num_points,mx,my,(x1 + x2) / 2.0,(y1 + y2) / 2.0,x2,y2,objspace_flatness_squared,n + 1);
		} else {
			kha_graphics2_truetype_StbTruetype.stbtt__add_point(points,num_points.value,x2,y2);
			num_points.value += 1;
		}
		return 1;
	}
	static stbtt__tesselate_cubic(points,num_points,x0,y0,x1,y1,x2,y2,x3,y3,objspace_flatness_squared,n) {
		while(true) {
			let dx0 = x1 - x0;
			let dy0 = y1 - y0;
			let dx1 = x2 - x1;
			let dy1 = y2 - y1;
			let dx2 = x3 - x2;
			let dy2 = y3 - y2;
			let dx = x3 - x0;
			let dy = y3 - y0;
			let longlen = Math.sqrt(dx0 * dx0 + dy0 * dy0) + Math.sqrt(dx1 * dx1 + dy1 * dy1) + Math.sqrt(dx2 * dx2 + dy2 * dy2);
			let shortlen = Math.sqrt(dx * dx + dy * dy);
			if(n > 16) {
				return;
			}
			if(longlen * longlen - shortlen * shortlen > objspace_flatness_squared) {
				let x01 = (x0 + x1) / 2;
				let y01 = (y0 + y1) / 2;
				let x12 = (x1 + x2) / 2;
				let y12 = (y1 + y2) / 2;
				let x23 = (x2 + x3) / 2;
				let y23 = (y2 + y3) / 2;
				let xa = (x01 + x12) / 2;
				let ya = (y01 + y12) / 2;
				let xb = (x12 + x23) / 2;
				let yb = (y12 + y23) / 2;
				let mx = (xa + xb) / 2;
				let my = (ya + yb) / 2;
				kha_graphics2_truetype_StbTruetype.stbtt__tesselate_cubic(points,num_points,x0,y0,x01,y01,xa,ya,mx,my,objspace_flatness_squared,n + 1);
				x0 = mx;
				y0 = my;
				x1 = xb;
				y1 = yb;
				x2 = x23;
				y2 = y23;
				n += 1;
				continue;
			} else {
				kha_graphics2_truetype_StbTruetype.stbtt__add_point(points,num_points.value,x3,y3);
				num_points.value += 1;
			}
			return;
		}
	}
	static stbtt_FlattenCurves(vertices,num_verts,objspace_flatness,contour_lengths,num_contours) {
		let points = null;
		let num_points = 0;
		let objspace_flatness_squared = objspace_flatness * objspace_flatness;
		let n = 0;
		let start = 0;
		let _g = 0;
		while(_g < num_verts) if(vertices[_g++].type == 1) {
			++n;
		}
		num_contours.value = n;
		if(n == 0) {
			return null;
		}
		contour_lengths.value = new Array(n);
		if(contour_lengths.value == null) {
			num_contours.value = 0;
			return null;
		}
		let _g1 = 0;
		while(_g1 < 2) {
			let x = 0;
			let y = 0;
			if(_g1++ == 1) {
				points = new Array(num_points);
				if(points == null) {
					contour_lengths.value = null;
					num_contours.value = 0;
					return null;
				} else {
					let _g = 0;
					let _g1 = points.length;
					while(_g < _g1) points[_g++] = new kha_graphics2_truetype_Stbtt_$_$point();
				}
			}
			num_points = 0;
			n = -1;
			let _g = 0;
			while(_g < num_verts) {
				let i = _g++;
				switch(vertices[i].type) {
				case 1:
					if(n >= 0) {
						contour_lengths.value[n] = num_points - start;
					}
					++n;
					start = num_points;
					x = vertices[i].x;
					y = vertices[i].y;
					kha_graphics2_truetype_StbTruetype.stbtt__add_point(points,num_points++,x,y);
					break;
				case 2:
					x = vertices[i].x;
					y = vertices[i].y;
					kha_graphics2_truetype_StbTruetype.stbtt__add_point(points,num_points++,x,y);
					break;
				case 3:
					let num_points_reference = { value : num_points};
					kha_graphics2_truetype_StbTruetype.stbtt__tesselate_curve(points,num_points_reference,x,y,vertices[i].cx,vertices[i].cy,vertices[i].x,vertices[i].y,objspace_flatness_squared,0);
					num_points = num_points_reference.value;
					x = vertices[i].x;
					y = vertices[i].y;
					break;
				case 4:
					let num_points_reference1 = { value : num_points};
					kha_graphics2_truetype_StbTruetype.stbtt__tesselate_cubic(points,num_points_reference1,x,y,vertices[i].cx,vertices[i].cy,vertices[i].cx1,vertices[i].cy1,vertices[i].x,vertices[i].y,objspace_flatness_squared,0);
					num_points = num_points_reference1.value;
					x = vertices[i].x;
					y = vertices[i].y;
					break;
				}
			}
			contour_lengths.value[n] = num_points - start;
		}
		return points;
	}
	static stbtt_Rasterize(result,flatness_in_pixels,vertices,num_verts,scale_x,scale_y,shift_x,shift_y,x_off,y_off,invert) {
		let winding_count = 0;
		let winding_lengths = null;
		let winding_count_reference = { value : 0};
		let winding_lengths_reference = new kha_graphics2_truetype_VectorOfIntPointer();
		let windings = kha_graphics2_truetype_StbTruetype.stbtt_FlattenCurves(vertices,num_verts,flatness_in_pixels / (scale_x > scale_y ? scale_y : scale_x),winding_lengths_reference,winding_count_reference);
		winding_count = winding_count_reference.value;
		winding_lengths = winding_lengths_reference.value;
		if(windings != null) {
			kha_graphics2_truetype_StbTruetype.stbtt__rasterize(result,windings,winding_lengths,winding_count,scale_x,scale_y,shift_x,shift_y,x_off,y_off,invert);
		}
	}
	static stbtt_MakeGlyphBitmapSubpixel(info,output,output_offset,out_w,out_h,out_stride,scale_x,scale_y,shift_x,shift_y,glyph) {
		let ix0 = 0;
		let iy0 = 0;
		let vertices = kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphShape(info,glyph);
		let num_verts = vertices == null ? 0 : vertices.length;
		let gbm = new kha_graphics2_truetype_Stbtt_$_$bitmap();
		let rect = kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphBitmapBoxSubpixel(info,glyph,scale_x,scale_y,shift_x,shift_y);
		ix0 = rect.x0;
		iy0 = rect.y0;
		gbm.pixels = output;
		gbm.pixels_offset = output_offset;
		gbm.w = out_w;
		gbm.h = out_h;
		gbm.stride = out_stride;
		if(gbm.w != 0 && gbm.h != 0) {
			kha_graphics2_truetype_StbTruetype.stbtt_Rasterize(gbm,0.35,vertices,num_verts,scale_x,scale_y,shift_x,shift_y,ix0,iy0,true);
		}
	}
	static stbtt_MakeGlyphBitmap(info,output,output_offset,out_w,out_h,out_stride,scale_x,scale_y,glyph) {
		kha_graphics2_truetype_StbTruetype.stbtt_MakeGlyphBitmapSubpixel(info,output,output_offset,out_w,out_h,out_stride,scale_x,scale_y,0.0,0.0,glyph);
	}
	static stbtt_BakeFontBitmap(data,offset,pixel_height,pixels,pw,ph,chars,chardata) {
		let f = new kha_graphics2_truetype_Stbtt_$fontinfo();
		if(!kha_graphics2_truetype_StbTruetype.stbtt_InitFont(f,data,offset)) {
			return -1;
		}
		let y = 1;
		let x = 1;
		let bottom_y = 1;
		let scale = kha_graphics2_truetype_StbTruetype.stbtt_ScaleForPixelHeight(f,pixel_height);
		let i = 0;
		let _g = 0;
		while(_g < chars.length) {
			let g = kha_graphics2_truetype_StbTruetype.stbtt_FindGlyphIndex(f,chars[_g++]);
			let advance = kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphHMetrics(f,g).advanceWidth;
			let rect = kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphBitmapBox(f,g,scale,scale);
			let x0 = rect.x0;
			let y0 = rect.y0;
			let gw = rect.x1 - x0;
			let gh = rect.y1 - y0;
			if(x + gw + 1 >= pw) {
				y = bottom_y;
				x = 1;
			}
			if(y + gh + 1 >= ph) {
				return -i;
			}
			if(x + gw >= pw) {
				throw haxe_Exception.thrown("Error");
			}
			if(y + gh >= ph) {
				throw haxe_Exception.thrown("Error");
			}
			chardata[i].x0 = x;
			chardata[i].y0 = y;
			chardata[i].x1 = x + gw;
			chardata[i].y1 = y + gh;
			chardata[i].xadvance = scale * advance;
			chardata[i].xoff = x0;
			chardata[i].yoff = y0;
			x = x + gw + 1;
			if(y + gh + 1 > bottom_y) {
				bottom_y = y + gh + 1;
			}
			++i;
		}
		let _g1 = 0;
		let _g2 = pw * ph;
		while(_g1 < _g2) pixels.writeU8(_g1++,0);
		i = 0;
		let ch;
		let _g3 = 0;
		while(_g3 < chars.length) {
			let g = kha_graphics2_truetype_StbTruetype.stbtt_FindGlyphIndex(f,chars[_g3++]);
			ch = chardata[i];
			kha_graphics2_truetype_StbTruetype.stbtt_MakeGlyphBitmap(f,pixels,ch.x0 + ch.y0 * pw,ch.x1 - ch.x0,ch.y1 - ch.y0,pw,scale,scale,g);
			++i;
		}
		return bottom_y;
	}
	static UTF16BEtoString(data,length) {
		let name = "";
		let pos = 0;
		while(pos < length) {
			let ch = data.readU16BE(pos);
			if(ch < 128) {
				name += String.fromCodePoint(ch);
			} else if(ch < 2048) {
				name += String.fromCodePoint((192 + (ch >> 6)));
				name += String.fromCodePoint((128 + (ch & 63)));
			} else if(ch >= 55296 && ch < 56320) {
				let c = data.readU32BE(pos);
				name += String.fromCodePoint((240 + (c >> 18)));
				name += String.fromCodePoint((128 + (c >> 12)));
				name += String.fromCodePoint((128 + (c >> 6)));
				name += String.fromCodePoint((128 + c));
				pos += 2;
			} else if(ch >= 57344) {
				name += String.fromCodePoint((224 + (ch >> 12)));
				name += String.fromCodePoint((128 + (ch >> 6)));
				name += String.fromCodePoint((128 + ch));
			}
			pos += 2;
		}
		return name;
	}
	static stbtt_GetFontNameString(font,platformID,encodingID,languageID,nameID) {
		let fc = font.data;
		let nm = kha_graphics2_truetype_StbTruetype.stbtt__find_table(fc,font.fontstart,"name");
		if(nm == 0) {
			return null;
		}
		let count = kha_graphics2_truetype_StbTruetype.ttUSHORT(fc,nm + 2);
		let stringOffset = nm + kha_graphics2_truetype_StbTruetype.ttUSHORT(fc,nm + 4);
		let _g = 0;
		while(_g < count) {
			let loc = nm + 6 + 12 * _g++;
			if(platformID == kha_graphics2_truetype_StbTruetype.ttUSHORT(fc,loc) && encodingID == kha_graphics2_truetype_StbTruetype.ttUSHORT(fc,loc + 2) && languageID == kha_graphics2_truetype_StbTruetype.ttUSHORT(fc,loc + 4) && nameID == kha_graphics2_truetype_StbTruetype.ttUSHORT(fc,loc + 6)) {
				let length = kha_graphics2_truetype_StbTruetype.ttUSHORT(fc,loc + 8);
				let nameBytes = fc.sub(stringOffset + kha_graphics2_truetype_StbTruetype.ttUSHORT(fc,loc + 10),length);
				if(platformID == 3 && (encodingID == 1 || encodingID == 10) || platformID == 0) {
					return kha_graphics2_truetype_StbTruetype.UTF16BEtoString(nameBytes,length);
				} else {
					return nameBytes.toString();
				}
			}
		}
		return null;
	}
}
$hxClasses["kha.graphics2.truetype.StbTruetype"] = kha_graphics2_truetype_StbTruetype;
kha_graphics2_truetype_StbTruetype.__name__ = "kha.graphics2.truetype.StbTruetype";
class kha_graphics4_ConstantLocation {
}
$hxClasses["kha.graphics4.ConstantLocation"] = kha_graphics4_ConstantLocation;
kha_graphics4_ConstantLocation.__name__ = "kha.graphics4.ConstantLocation";
kha_graphics4_ConstantLocation.__isInterface__ = true;
class kha_graphics4_CubeMap {
	constructor(texture) {
		this.texture_ = texture;
	}
	unload() {
	}
	get_width() {
		if(this.texture_ == null) {
			return this.renderTarget_.width;
		} else {
			return this.texture_.width;
		}
	}
	get_height() {
		if(this.texture_ == null) {
			return this.renderTarget_.height;
		} else {
			return this.texture_.height;
		}
	}
	get_g4() {
		if(this.graphics4 == null) {
			this.graphics4 = new kha_graphics4_Graphics(this);
		}
		return this.graphics4;
	}
	static getRenderTargetFormat(format) {
		switch(format) {
		case 0:
			return 0;
		case 2:
			return 3;
		case 3:
			return 4;
		case 4:
			return 1;
		default:
			return 0;
		}
	}
	static getDepthBufferBits(depthAndStencil) {
		switch(depthAndStencil) {
		case 0:
			return -1;
		case 1:
			return 24;
		case 2:
			return 24;
		case 3:
			return 24;
		case 4:
			return 32;
		case 5:
			return 16;
		}
	}
	static getStencilBufferBits(depthAndStencil) {
		switch(depthAndStencil) {
		case 0:
			return -1;
		case 1:
			return -1;
		case 2:
			return 8;
		case 3:
			return 8;
		case 4:
			return 8;
		case 5:
			return 0;
		}
	}
	static createRenderTarget(size,format,depthStencil,contextId) {
		if(contextId == null) {
			contextId = 0;
		}
		if(depthStencil == null) {
			depthStencil = 0;
		}
		if(format == null) {
			format = 0;
		}
		let cubeMap = new kha_graphics4_CubeMap(null);
		cubeMap.format = format;
		cubeMap.renderTarget_ = Krom.createRenderTargetCubeMap(size,kha_graphics4_CubeMap.getDepthBufferBits(depthStencil),kha_graphics4_CubeMap.getRenderTargetFormat(format),kha_graphics4_CubeMap.getStencilBufferBits(depthStencil),contextId);
		return cubeMap;
	}
}
$hxClasses["kha.graphics4.CubeMap"] = kha_graphics4_CubeMap;
kha_graphics4_CubeMap.__name__ = "kha.graphics4.CubeMap";
kha_graphics4_CubeMap.__interfaces__ = [kha_Canvas];
Object.assign(kha_graphics4_CubeMap.prototype, {
	__class__: kha_graphics4_CubeMap
	,__properties__: {get_g4: "get_g4",get_height: "get_height",get_width: "get_width"}
});
class kha_graphics4_FragmentShader {
	constructor(sources,names) {
		if(sources != null) {
			this.shader = Krom.createFragmentShader(sources[0].bytes.b.bufferValue,names[0]);
		}
	}
	delete() {
		Krom.deleteShader(this.shader);
		this.shader = null;
	}
	static fromSource(source) {
		let shader = new kha_graphics4_FragmentShader(null,null);
		shader.shader = Krom.createFragmentShaderFromSource(source);
		return shader;
	}
}
$hxClasses["kha.graphics4.FragmentShader"] = kha_graphics4_FragmentShader;
kha_graphics4_FragmentShader.__name__ = "kha.graphics4.FragmentShader";
Object.assign(kha_graphics4_FragmentShader.prototype, {
	__class__: kha_graphics4_FragmentShader
});
class kha_graphics4_GeometryShader {
	constructor(sources,names) {
		this.shader = Krom.createGeometryShader(sources[0].bytes.b.bufferValue,names[0]);
	}
	delete() {
		Krom.deleteShader(this.shader);
		this.shader = null;
	}
}
$hxClasses["kha.graphics4.GeometryShader"] = kha_graphics4_GeometryShader;
kha_graphics4_GeometryShader.__name__ = "kha.graphics4.GeometryShader";
Object.assign(kha_graphics4_GeometryShader.prototype, {
	__class__: kha_graphics4_GeometryShader
});
class kha_graphics4_Graphics {
	constructor(renderTarget) {
		this.renderTarget = renderTarget;
	}
	begin(additionalRenderTargets) {
		Krom.begin(this.renderTarget,additionalRenderTargets);
	}
	beginFace(face) {
		Krom.beginFace(this.renderTarget,face);
	}
	end() {
		Krom.end();
	}
	clear(color,depth,stencil) {
		let flags = 0;
		if(color != null) {
			flags = 1;
		}
		if(depth != null) {
			flags |= 2;
		}
		if(stencil != null) {
			flags |= 4;
		}
		Krom.clear(flags,color == null ? 0 : color,depth,stencil);
	}
	viewport(x,y,width,height) {
		Krom.viewport(x,y,width,height);
	}
	setVertexBuffer(vertexBuffer) {
		vertexBuffer.set(0);
	}
	setVertexBuffers(vertexBuffers) {
		Krom.setVertexBuffers(vertexBuffers);
	}
	setIndexBuffer(indexBuffer) {
		indexBuffer.set();
	}
	setCubeMap(unit,cubeMap) {
		if(cubeMap == null) {
			return;
		}
		if(cubeMap.texture_ != null) {
			Krom.setTexture(unit,cubeMap.texture_);
		} else {
			Krom.setRenderTarget(unit,cubeMap.renderTarget_);
		}
	}
	setCubeMapDepth(unit,cubeMap) {
		if(cubeMap == null) {
			return;
		}
		Krom.setTextureDepth(unit,cubeMap.renderTarget_);
	}
	setTexture(unit,texture) {
		if(texture == null) {
			return;
		}
		if(texture.texture_ != null) {
			Krom.setTexture(unit,texture.texture_);
		} else {
			Krom.setRenderTarget(unit,texture.renderTarget_);
		}
	}
	setTextureDepth(unit,texture) {
		if(texture == null) {
			return;
		}
		Krom.setTextureDepth(unit,texture.renderTarget_);
	}
	setImageTexture(unit,texture) {
		if(texture == null) {
			return;
		}
		Krom.setImageTexture(unit,texture.texture_);
	}
	setTextureParameters(texunit,uAddressing,vAddressing,minificationFilter,magnificationFilter,mipmapFilter) {
		Krom.setTextureParameters(texunit,uAddressing,vAddressing,minificationFilter,magnificationFilter,mipmapFilter);
	}
	setTexture3DParameters(texunit,uAddressing,vAddressing,wAddressing,minificationFilter,magnificationFilter,mipmapFilter) {
		Krom.setTexture3DParameters(texunit,uAddressing,vAddressing,wAddressing,minificationFilter,magnificationFilter,mipmapFilter);
	}
	setTextureCompareMode(texunit,enabled) {
		Krom.setTextureCompareMode(texunit,enabled);
	}
	setCubeMapCompareMode(texunit,enabled) {
		Krom.setCubeMapCompareMode(texunit,enabled);
	}
	setPipeline(pipeline) {
		pipeline.set();
	}
	setBool(location,value) {
		Krom.setBool(location,value);
	}
	setInt(location,value) {
		Krom.setInt(location,value);
	}
	setFloat(location,value) {
		Krom.setFloat(location,value);
	}
	setFloat2(location,value1,value2) {
		Krom.setFloat2(location,value1,value2);
	}
	setFloat3(location,value1,value2,value3) {
		Krom.setFloat3(location,value1,value2,value3);
	}
	setFloat4(location,value1,value2,value3,value4) {
		Krom.setFloat4(location,value1,value2,value3,value4);
	}
	setFloats(location,values) {
		Krom.setFloats(location,values.buffer);
	}
	drawIndexedVertices(start,count) {
		if(count == null) {
			count = -1;
		}
		if(start == null) {
			start = 0;
		}
		Krom.drawIndexedVertices(start,count);
	}
	drawIndexedVerticesInstanced(instanceCount,start,count) {
		if(count == null) {
			count = -1;
		}
		if(start == null) {
			start = 0;
		}
		Krom.drawIndexedVerticesInstanced(instanceCount,start,count);
	}
	scissor(x,y,width,height) {
		Krom.scissor(x,y,width,height);
	}
	disableScissor() {
		Krom.disableScissor();
	}
}
$hxClasses["kha.graphics4.Graphics"] = kha_graphics4_Graphics;
kha_graphics4_Graphics.__name__ = "kha.graphics4.Graphics";
Object.assign(kha_graphics4_Graphics.prototype, {
	__class__: kha_graphics4_Graphics
});
class kha_graphics4_IndexBuffer {
	constructor(indexCount,usage,canRead) {
		if(canRead == null) {
			canRead = false;
		}
		this.indexCount = indexCount;
		this.buffer = Krom.createIndexBuffer(indexCount);
	}
	delete() {
		Krom.deleteIndexBuffer(this.buffer);
		this.buffer = null;
	}
	lock(start,count) {
		this._data = Krom.lockIndexBuffer(this.buffer);
		if(start == null) {
			start = 0;
		}
		if(count == null) {
			count = this.indexCount;
		}
		return this._data.subarray(start,start + count);
	}
	unlock() {
		Krom.unlockIndexBuffer(this.buffer);
	}
	set() {
		Krom.setIndexBuffer(this.buffer);
	}
}
$hxClasses["kha.graphics4.IndexBuffer"] = kha_graphics4_IndexBuffer;
kha_graphics4_IndexBuffer.__name__ = "kha.graphics4.IndexBuffer";
Object.assign(kha_graphics4_IndexBuffer.prototype, {
	__class__: kha_graphics4_IndexBuffer
});
class kha_graphics4_PipelineState {
	constructor() {
		this.inputLayout = null;
		this.vertexShader = null;
		this.fragmentShader = null;
		this.geometryShader = null;
		this.tessellationControlShader = null;
		this.tessellationEvaluationShader = null;
		this.cullMode = 2;
		this.depthWrite = false;
		this.depthMode = 0;
		this.blendSource = 1;
		this.blendDestination = 2;
		this.blendOperation = 0;
		this.alphaBlendSource = 1;
		this.alphaBlendDestination = 2;
		this.alphaBlendOperation = 0;
		this.colorWriteMasksRed = [];
		this.colorWriteMasksGreen = [];
		this.colorWriteMasksBlue = [];
		this.colorWriteMasksAlpha = [];
		this.colorWriteMasksRed.push(true);
		this.colorWriteMasksRed.push(true);
		this.colorWriteMasksRed.push(true);
		this.colorWriteMasksRed.push(true);
		this.colorWriteMasksRed.push(true);
		this.colorWriteMasksRed.push(true);
		this.colorWriteMasksRed.push(true);
		this.colorWriteMasksRed.push(true);
		this.colorWriteMasksGreen.push(true);
		this.colorWriteMasksGreen.push(true);
		this.colorWriteMasksGreen.push(true);
		this.colorWriteMasksGreen.push(true);
		this.colorWriteMasksGreen.push(true);
		this.colorWriteMasksGreen.push(true);
		this.colorWriteMasksGreen.push(true);
		this.colorWriteMasksGreen.push(true);
		this.colorWriteMasksBlue.push(true);
		this.colorWriteMasksBlue.push(true);
		this.colorWriteMasksBlue.push(true);
		this.colorWriteMasksBlue.push(true);
		this.colorWriteMasksBlue.push(true);
		this.colorWriteMasksBlue.push(true);
		this.colorWriteMasksBlue.push(true);
		this.colorWriteMasksBlue.push(true);
		this.colorWriteMasksAlpha.push(true);
		this.colorWriteMasksAlpha.push(true);
		this.colorWriteMasksAlpha.push(true);
		this.colorWriteMasksAlpha.push(true);
		this.colorWriteMasksAlpha.push(true);
		this.colorWriteMasksAlpha.push(true);
		this.colorWriteMasksAlpha.push(true);
		this.colorWriteMasksAlpha.push(true);
		this.colorAttachmentCount = 1;
		this.colorAttachments = [];
		this.colorAttachments.push(0);
		this.colorAttachments.push(0);
		this.colorAttachments.push(0);
		this.colorAttachments.push(0);
		this.colorAttachments.push(0);
		this.colorAttachments.push(0);
		this.colorAttachments.push(0);
		this.colorAttachments.push(0);
		this.depthStencilAttachment = 0;
		this.conservativeRasterization = false;
		this.pipeline = Krom.createPipeline();
	}
	delete() {
		Krom.deletePipeline(this.pipeline);
		this.pipeline = null;
	}
	compile() {
		let structure0 = this.inputLayout.length > 0 ? this.inputLayout[0] : null;
		let structure1 = this.inputLayout.length > 1 ? this.inputLayout[1] : null;
		let structure2 = this.inputLayout.length > 2 ? this.inputLayout[2] : null;
		let structure3 = this.inputLayout.length > 3 ? this.inputLayout[3] : null;
		let gs = this.geometryShader != null ? this.geometryShader.shader : null;
		let tcs = this.tessellationControlShader != null ? this.tessellationControlShader.shader : null;
		let tes = this.tessellationEvaluationShader != null ? this.tessellationEvaluationShader.shader : null;
		let colorAttachments = [];
		colorAttachments.push(kha_graphics4_PipelineState.getRenderTargetFormat(this.colorAttachments[0]));
		colorAttachments.push(kha_graphics4_PipelineState.getRenderTargetFormat(this.colorAttachments[1]));
		colorAttachments.push(kha_graphics4_PipelineState.getRenderTargetFormat(this.colorAttachments[2]));
		colorAttachments.push(kha_graphics4_PipelineState.getRenderTargetFormat(this.colorAttachments[3]));
		colorAttachments.push(kha_graphics4_PipelineState.getRenderTargetFormat(this.colorAttachments[4]));
		colorAttachments.push(kha_graphics4_PipelineState.getRenderTargetFormat(this.colorAttachments[5]));
		colorAttachments.push(kha_graphics4_PipelineState.getRenderTargetFormat(this.colorAttachments[6]));
		colorAttachments.push(kha_graphics4_PipelineState.getRenderTargetFormat(this.colorAttachments[7]));
		Krom.compilePipeline(this.pipeline,structure0,structure1,structure2,structure3,this.inputLayout.length,this.vertexShader.shader,this.fragmentShader.shader,gs,tcs,tes,{ cullMode : kha_graphics4_PipelineState.convertCullMode(this.cullMode), depthWrite : this.depthWrite, depthMode : kha_graphics4_PipelineState.convertCompareMode(this.depthMode), blendSource : kha_graphics4_PipelineState.convertBlendingFactor(this.blendSource), blendDestination : kha_graphics4_PipelineState.convertBlendingFactor(this.blendDestination), alphaBlendSource : kha_graphics4_PipelineState.convertBlendingFactor(this.alphaBlendSource), alphaBlendDestination : kha_graphics4_PipelineState.convertBlendingFactor(this.alphaBlendDestination), colorWriteMaskRed : this.colorWriteMasksRed, colorWriteMaskGreen : this.colorWriteMasksGreen, colorWriteMaskBlue : this.colorWriteMasksBlue, colorWriteMaskAlpha : this.colorWriteMasksAlpha, colorAttachmentCount : this.colorAttachmentCount, colorAttachments : colorAttachments, depthAttachmentBits : kha_graphics4_PipelineState.getDepthBufferBits(this.depthStencilAttachment), stencilAttachmentBits : kha_graphics4_PipelineState.getStencilBufferBits(this.depthStencilAttachment), conservativeRasterization : this.conservativeRasterization});
	}
	set() {
		Krom.setPipeline(this.pipeline);
	}
	getConstantLocation(name) {
		return Krom.getConstantLocation(this.pipeline,name);
	}
	getTextureUnit(name) {
		return Krom.getTextureUnit(this.pipeline,name);
	}
	static getRenderTargetFormat(format) {
		switch(format) {
		case 0:
			return 0;
		case 1:
			return 5;
		case 2:
			return 3;
		case 3:
			return 4;
		case 4:
			return 1;
		case 5:
			return 2;
		case 6:
			return 6;
		default:
			return 0;
		}
	}
	static getDepthBufferBits(depthAndStencil) {
		switch(depthAndStencil) {
		case 0:
			return 0;
		case 1:
			return 24;
		case 2:
			return 24;
		case 3:
			return 24;
		case 4:
			return 32;
		case 5:
			return 16;
		}
	}
	static getStencilBufferBits(depthAndStencil) {
		switch(depthAndStencil) {
		case 0:
			return 0;
		case 1:
			return 0;
		case 2:
			return 8;
		case 3:
			return 8;
		case 4:
			return 8;
		case 5:
			return 0;
		}
	}
	static convertCullMode(mode) {
		switch(mode) {
		case 0:
			return 0;
		case 1:
			return 1;
		case 2:
			return 2;
		}
	}
	static convertCompareMode(mode) {
		switch(mode) {
		case 0:
			return 0;
		case 1:
			return 1;
		case 2:
			return 2;
		case 3:
			return 3;
		case 4:
			return 4;
		case 5:
			return 5;
		case 6:
			return 6;
		case 7:
			return 7;
		}
	}
	static convertBlendingFactor(factor) {
		switch(factor) {
		case 0:case 1:
			return 0;
		case 2:
			return 1;
		case 3:
			return 2;
		case 4:
			return 3;
		case 5:
			return 4;
		case 6:
			return 5;
		case 7:
			return 6;
		case 8:
			return 7;
		case 9:
			return 8;
		case 10:
			return 9;
		}
	}
}
$hxClasses["kha.graphics4.PipelineState"] = kha_graphics4_PipelineState;
kha_graphics4_PipelineState.__name__ = "kha.graphics4.PipelineState";
Object.assign(kha_graphics4_PipelineState.prototype, {
	__class__: kha_graphics4_PipelineState
});
class kha_graphics4_TessellationControlShader {
	constructor(sources,names) {
		this.shader = Krom.createTessellationControlShader(sources[0].bytes.b.bufferValue,names[0]);
	}
	delete() {
		Krom.deleteShader(this.shader);
		this.shader = null;
	}
}
$hxClasses["kha.graphics4.TessellationControlShader"] = kha_graphics4_TessellationControlShader;
kha_graphics4_TessellationControlShader.__name__ = "kha.graphics4.TessellationControlShader";
Object.assign(kha_graphics4_TessellationControlShader.prototype, {
	__class__: kha_graphics4_TessellationControlShader
});
class kha_graphics4_TessellationEvaluationShader {
	constructor(sources,names) {
		this.shader = Krom.createTessellationEvaluationShader(sources[0].bytes.b.bufferValue,names[0]);
	}
	delete() {
		Krom.deleteShader(this.shader);
		this.shader = null;
	}
}
$hxClasses["kha.graphics4.TessellationEvaluationShader"] = kha_graphics4_TessellationEvaluationShader;
kha_graphics4_TessellationEvaluationShader.__name__ = "kha.graphics4.TessellationEvaluationShader";
Object.assign(kha_graphics4_TessellationEvaluationShader.prototype, {
	__class__: kha_graphics4_TessellationEvaluationShader
});
class kha_graphics4_TextureUnit {
}
$hxClasses["kha.graphics4.TextureUnit"] = kha_graphics4_TextureUnit;
kha_graphics4_TextureUnit.__name__ = "kha.graphics4.TextureUnit";
kha_graphics4_TextureUnit.__isInterface__ = true;
class kha_graphics4_VertexBuffer {
	constructor(vertexCount,structure,usage,instanceDataStepRate,canRead) {
		if(canRead == null) {
			canRead = false;
		}
		if(instanceDataStepRate == null) {
			instanceDataStepRate = 0;
		}
		this.lastLockCount = 0;
		this.vertexCount = vertexCount;
		this.structure = structure;
		this.buffer = Krom.createVertexBuffer(vertexCount,structure.elements,usage,instanceDataStepRate);
	}
	delete() {
		Krom.deleteVertexBuffer(this.buffer);
		this.buffer = null;
	}
	lock(start,count) {
		if(start == null) {
			start = 0;
		}
		if(count == null) {
			count = this.count();
		}
		this.lastLockCount = count;
		this._data = kha_arrays_ByteArray._new(Krom.lockVertexBuffer(this.buffer,start,count));
		return this._data;
	}
	unlock(count) {
		Krom.unlockVertexBuffer(this.buffer,count == null ? this.lastLockCount : count);
	}
	count() {
		return this.vertexCount;
	}
	set(offset) {
		Krom.setVertexBuffer(this.buffer);
		return 0;
	}
}
$hxClasses["kha.graphics4.VertexBuffer"] = kha_graphics4_VertexBuffer;
kha_graphics4_VertexBuffer.__name__ = "kha.graphics4.VertexBuffer";
Object.assign(kha_graphics4_VertexBuffer.prototype, {
	__class__: kha_graphics4_VertexBuffer
});
class kha_graphics4_VertexElement {
	constructor(name,data) {
		this.name = name;
		this.data = data;
	}
}
$hxClasses["kha.graphics4.VertexElement"] = kha_graphics4_VertexElement;
kha_graphics4_VertexElement.__name__ = "kha.graphics4.VertexElement";
Object.assign(kha_graphics4_VertexElement.prototype, {
	__class__: kha_graphics4_VertexElement
});
class kha_graphics4_VertexShader {
	constructor(sources,names) {
		if(sources != null) {
			this.shader = Krom.createVertexShader(sources[0].bytes.b.bufferValue,names[0]);
		}
	}
	delete() {
		Krom.deleteShader(this.shader);
		this.shader = null;
	}
	static fromSource(source) {
		let shader = new kha_graphics4_VertexShader(null,null);
		shader.shader = Krom.createVertexShaderFromSource(source);
		return shader;
	}
}
$hxClasses["kha.graphics4.VertexShader"] = kha_graphics4_VertexShader;
kha_graphics4_VertexShader.__name__ = "kha.graphics4.VertexShader";
Object.assign(kha_graphics4_VertexShader.prototype, {
	__class__: kha_graphics4_VertexShader
});
class kha_graphics4_VertexStructure {
	constructor() {
		this.elements = [];
		this.instanced = false;
	}
	add(name,data) {
		this.elements.push(new kha_graphics4_VertexElement(name,data));
	}
	size() {
		return this.elements.length;
	}
	byteSize() {
		let byteSize = 0;
		let _g = 0;
		let _g1 = this.elements.length;
		while(_g < _g1) byteSize += kha_graphics4_VertexStructure.dataByteSize(this.elements[_g++].data);
		return byteSize;
	}
	get(index) {
		return this.elements[index];
	}
	static dataByteSize(data) {
		switch(data) {
		case 0:
			return 4;
		case 1:
			return 8;
		case 2:
			return 12;
		case 3:
			return 16;
		case 4:
			return 64;
		case 5:case 6:case 7:case 8:
			return 1;
		case 9:case 10:case 11:case 12:
			return 2;
		case 13:case 14:case 15:case 16:
			return 4;
		case 17:case 18:case 19:case 20:
			return 2;
		case 21:case 22:case 23:case 24:
			return 4;
		case 25:case 26:case 27:case 28:
			return 8;
		case 29:case 30:
			return 4;
		case 31:case 32:
			return 8;
		case 33:case 34:
			return 12;
		case 35:case 36:
			return 16;
		}
	}
}
$hxClasses["kha.graphics4.VertexStructure"] = kha_graphics4_VertexStructure;
kha_graphics4_VertexStructure.__name__ = "kha.graphics4.VertexStructure";
Object.assign(kha_graphics4_VertexStructure.prototype, {
	__class__: kha_graphics4_VertexStructure
});
class kha_input_Gamepad {
	constructor(index,id) {
		if(id == null) {
			id = "unknown";
		}
		if(index == null) {
			index = 0;
		}
		this.index = index;
		this.axisListeners = [];
		this.buttonListeners = [];
		kha_input_Gamepad.instances[index] = this;
	}
	notify(axisListener,buttonListener) {
		if(axisListener != null) {
			this.axisListeners.push(axisListener);
		}
		if(buttonListener != null) {
			this.buttonListeners.push(buttonListener);
		}
	}
	remove(axisListener,buttonListener) {
		if(axisListener != null) {
			HxOverrides.remove(this.axisListeners,axisListener);
		}
		if(buttonListener != null) {
			HxOverrides.remove(this.buttonListeners,buttonListener);
		}
	}
	get_id() {
		return kha_System.getGamepadId(this.index);
	}
	sendAxisEvent(axis,value) {
		let _g = 0;
		let _g1 = this.axisListeners;
		while(_g < _g1.length) _g1[_g++](axis,value);
	}
	sendButtonEvent(button,value) {
		let _g = 0;
		let _g1 = this.buttonListeners;
		while(_g < _g1.length) _g1[_g++](button,value);
	}
	static get(index) {
		if(index == null) {
			index = 0;
		}
		if(index >= kha_input_Gamepad.instances.length) {
			return null;
		}
		return kha_input_Gamepad.instances[index];
	}
	static notifyOnConnect(connectListener,disconnectListener) {
		if(connectListener != null) {
			kha_input_Gamepad.connectListeners.push(connectListener);
		}
		if(disconnectListener != null) {
			kha_input_Gamepad.disconnectListeners.push(disconnectListener);
		}
	}
	static removeConnect(connectListener,disconnectListener) {
		if(connectListener != null) {
			HxOverrides.remove(kha_input_Gamepad.connectListeners,connectListener);
		}
		if(disconnectListener != null) {
			HxOverrides.remove(kha_input_Gamepad.disconnectListeners,disconnectListener);
		}
	}
	static sendConnectEvent(index) {
		kha_input_Gamepad.instances[index].connected = true;
		let _g = 0;
		let _g1 = kha_input_Gamepad.connectListeners;
		while(_g < _g1.length) _g1[_g++](index);
	}
	static sendDisconnectEvent(index) {
		kha_input_Gamepad.instances[index].connected = false;
		let _g = 0;
		let _g1 = kha_input_Gamepad.disconnectListeners;
		while(_g < _g1.length) _g1[_g++](index);
	}
}
$hxClasses["kha.input.Gamepad"] = $hx_exports["kha"]["input"]["Gamepad"] = kha_input_Gamepad;
kha_input_Gamepad.__name__ = "kha.input.Gamepad";
Object.assign(kha_input_Gamepad.prototype, {
	__class__: kha_input_Gamepad
	,__properties__: {get_id: "get_id"}
});
class kha_input_Keyboard {
	constructor() {
		this.downListeners = [];
		this.upListeners = [];
		this.pressListeners = [];
		kha_input_Keyboard.instance = this;
	}
	notify(downListener,upListener,pressListener) {
		if(downListener != null) {
			this.downListeners.push(downListener);
		}
		if(upListener != null) {
			this.upListeners.push(upListener);
		}
		if(pressListener != null) {
			this.pressListeners.push(pressListener);
		}
	}
	remove(downListener,upListener,pressListener) {
		if(downListener != null) {
			HxOverrides.remove(this.downListeners,downListener);
		}
		if(upListener != null) {
			HxOverrides.remove(this.upListeners,upListener);
		}
		if(pressListener != null) {
			HxOverrides.remove(this.pressListeners,pressListener);
		}
	}
	show() {
		kha_System.showKeyboard();
	}
	hide() {
		kha_System.hideKeyboard();
	}
	sendDownEvent(code) {
		let _g = 0;
		let _g1 = this.downListeners;
		while(_g < _g1.length) _g1[_g++](code);
	}
	sendUpEvent(code) {
		let _g = 0;
		let _g1 = this.upListeners;
		while(_g < _g1.length) _g1[_g++](code);
	}
	sendPressEvent(char) {
		let _g = 0;
		let _g1 = this.pressListeners;
		while(_g < _g1.length) _g1[_g++](char);
	}
	static get(num) {
		if(num == null) {
			num = 0;
		}
		return kha_System.getKeyboard(num);
	}
}
$hxClasses["kha.input.Keyboard"] = $hx_exports["kha"]["input"]["Keyboard"] = kha_input_Keyboard;
kha_input_Keyboard.__name__ = "kha.input.Keyboard";
Object.assign(kha_input_Keyboard.prototype, {
	__class__: kha_input_Keyboard
});
class kha_input_Mouse {
	constructor() {
		kha_input_Mouse.instance = this;
	}
	notify(downListener,upListener,moveListener,wheelListener,leaveListener) {
		this.notifyWindowed(0,downListener,upListener,moveListener,wheelListener,leaveListener);
	}
	remove(downListener,upListener,moveListener,wheelListener,leaveListener) {
		this.removeWindowed(0,downListener,upListener,moveListener,wheelListener,leaveListener);
	}
	notifyWindowed(windowId,downListener,upListener,moveListener,wheelListener,leaveListener) {
		if(downListener != null) {
			if(this.windowDownListeners == null) {
				this.windowDownListeners = [];
			}
			while(this.windowDownListeners.length <= windowId) this.windowDownListeners.push([]);
			this.windowDownListeners[windowId].push(downListener);
		}
		if(upListener != null) {
			if(this.windowUpListeners == null) {
				this.windowUpListeners = [];
			}
			while(this.windowUpListeners.length <= windowId) this.windowUpListeners.push([]);
			this.windowUpListeners[windowId].push(upListener);
		}
		if(moveListener != null) {
			if(this.windowMoveListeners == null) {
				this.windowMoveListeners = [];
			}
			while(this.windowMoveListeners.length <= windowId) this.windowMoveListeners.push([]);
			this.windowMoveListeners[windowId].push(moveListener);
		}
		if(wheelListener != null) {
			if(this.windowWheelListeners == null) {
				this.windowWheelListeners = [];
			}
			while(this.windowWheelListeners.length <= windowId) this.windowWheelListeners.push([]);
			this.windowWheelListeners[windowId].push(wheelListener);
		}
		if(leaveListener != null) {
			if(this.windowLeaveListeners == null) {
				this.windowLeaveListeners = [];
			}
			while(this.windowLeaveListeners.length <= windowId) this.windowLeaveListeners.push([]);
			this.windowLeaveListeners[windowId].push(leaveListener);
		}
	}
	removeWindowed(windowId,downListener,upListener,moveListener,wheelListener,leaveListener) {
		if(downListener != null) {
			if(this.windowDownListeners != null) {
				if(windowId < this.windowDownListeners.length) {
					HxOverrides.remove(this.windowDownListeners[windowId],downListener);
				} else {
					haxe_Log.trace("no downListeners for window \"" + windowId + "\" are registered",{ fileName : "kha/input/Mouse.hx", lineNumber : 108, className : "kha.input.Mouse", methodName : "removeWindowed"});
				}
			} else {
				haxe_Log.trace("no downListeners were ever registered",{ fileName : "kha/input/Mouse.hx", lineNumber : 112, className : "kha.input.Mouse", methodName : "removeWindowed"});
			}
		}
		if(upListener != null) {
			if(this.windowUpListeners != null) {
				if(windowId < this.windowUpListeners.length) {
					HxOverrides.remove(this.windowUpListeners[windowId],upListener);
				} else {
					haxe_Log.trace("no upListeners for window \"" + windowId + "\" are registered",{ fileName : "kha/input/Mouse.hx", lineNumber : 122, className : "kha.input.Mouse", methodName : "removeWindowed"});
				}
			} else {
				haxe_Log.trace("no upListeners were ever registered",{ fileName : "kha/input/Mouse.hx", lineNumber : 126, className : "kha.input.Mouse", methodName : "removeWindowed"});
			}
		}
		if(moveListener != null) {
			if(this.windowMoveListeners != null) {
				if(windowId < this.windowMoveListeners.length) {
					HxOverrides.remove(this.windowMoveListeners[windowId],moveListener);
				} else {
					haxe_Log.trace("no moveListeners for window \"" + windowId + "\" are registered",{ fileName : "kha/input/Mouse.hx", lineNumber : 136, className : "kha.input.Mouse", methodName : "removeWindowed"});
				}
			} else {
				haxe_Log.trace("no moveListeners were ever registered",{ fileName : "kha/input/Mouse.hx", lineNumber : 140, className : "kha.input.Mouse", methodName : "removeWindowed"});
			}
		}
		if(wheelListener != null) {
			if(this.windowWheelListeners != null) {
				if(windowId < this.windowWheelListeners.length) {
					HxOverrides.remove(this.windowWheelListeners[windowId],wheelListener);
				} else {
					haxe_Log.trace("no wheelListeners for window \"" + windowId + "\" are registered",{ fileName : "kha/input/Mouse.hx", lineNumber : 150, className : "kha.input.Mouse", methodName : "removeWindowed"});
				}
			} else {
				haxe_Log.trace("no wheelListeners were ever registered",{ fileName : "kha/input/Mouse.hx", lineNumber : 154, className : "kha.input.Mouse", methodName : "removeWindowed"});
			}
		}
		if(leaveListener != null) {
			if(this.windowLeaveListeners != null) {
				if(windowId < this.windowLeaveListeners.length) {
					HxOverrides.remove(this.windowLeaveListeners[windowId],leaveListener);
				} else {
					haxe_Log.trace("no leaveListeners for window \"" + windowId + "\" are registered",{ fileName : "kha/input/Mouse.hx", lineNumber : 164, className : "kha.input.Mouse", methodName : "removeWindowed"});
				}
			} else {
				haxe_Log.trace("no leaveListeners were ever registered",{ fileName : "kha/input/Mouse.hx", lineNumber : 168, className : "kha.input.Mouse", methodName : "removeWindowed"});
			}
		}
	}
	lock() {
		kha_System.lockMouse();
	}
	unlock() {
		kha_System.unlockMouse();
	}
	canLock() {
		return kha_System.canLockMouse();
	}
	isLocked() {
		return kha_System.isMouseLocked();
	}
	notifyOnLockChange(change,error) {
		kha_System.notifyOfMouseLockChange(change,error);
	}
	removeFromLockChange(change,error) {
		kha_System.removeFromMouseLockChange(change,error);
	}
	hideSystemCursor() {
		kha_System.hideSystemCursor();
	}
	showSystemCursor() {
		kha_System.showSystemCursor();
	}
	sendLeaveEvent(windowId) {
		if(this.windowLeaveListeners != null) {
			let _g = 0;
			let _g1 = this.windowLeaveListeners[windowId];
			while(_g < _g1.length) _g1[_g++]();
		}
	}
	sendDownEvent(windowId,button,x,y) {
		if(this.windowDownListeners != null) {
			let _g = 0;
			let _g1 = this.windowDownListeners[windowId];
			while(_g < _g1.length) _g1[_g++](button,x,y);
		}
	}
	sendUpEvent(windowId,button,x,y) {
		if(this.windowUpListeners != null) {
			let _g = 0;
			let _g1 = this.windowUpListeners[windowId];
			while(_g < _g1.length) _g1[_g++](button,x,y);
		}
	}
	sendMoveEvent(windowId,x,y,movementX,movementY) {
		if(this.windowMoveListeners != null) {
			let _g = 0;
			let _g1 = this.windowMoveListeners[windowId];
			while(_g < _g1.length) _g1[_g++](x,y,movementX,movementY);
		}
	}
	sendWheelEvent(windowId,delta) {
		if(this.windowWheelListeners != null) {
			let _g = 0;
			let _g1 = this.windowWheelListeners[windowId];
			while(_g < _g1.length) _g1[_g++](delta);
		}
	}
	static get(num) {
		if(num == null) {
			num = 0;
		}
		return kha_System.getMouse(num);
	}
}
$hxClasses["kha.input.Mouse"] = $hx_exports["kha"]["input"]["Mouse"] = kha_input_Mouse;
kha_input_Mouse.__name__ = "kha.input.Mouse";
Object.assign(kha_input_Mouse.prototype, {
	__class__: kha_input_Mouse
});
class kha_input_Pen {
	constructor() {
		kha_input_Pen.instance = this;
	}
	notify(downListener,upListener,moveListener) {
		this.notifyWindowed(0,downListener,upListener,moveListener);
	}
	notifyWindowed(windowId,downListener,upListener,moveListener) {
		if(downListener != null) {
			if(this.windowDownListeners == null) {
				this.windowDownListeners = [];
			}
			while(this.windowDownListeners.length <= windowId) this.windowDownListeners.push([]);
			this.windowDownListeners[windowId].push(downListener);
		}
		if(upListener != null) {
			if(this.windowUpListeners == null) {
				this.windowUpListeners = [];
			}
			while(this.windowUpListeners.length <= windowId) this.windowUpListeners.push([]);
			this.windowUpListeners[windowId].push(upListener);
		}
		if(moveListener != null) {
			if(this.windowMoveListeners == null) {
				this.windowMoveListeners = [];
			}
			while(this.windowMoveListeners.length <= windowId) this.windowMoveListeners.push([]);
			this.windowMoveListeners[windowId].push(moveListener);
		}
	}
	sendDownEvent(windowId,x,y,pressure) {
		if(this.windowDownListeners != null) {
			let _g = 0;
			let _g1 = this.windowDownListeners[windowId];
			while(_g < _g1.length) _g1[_g++](x,y,pressure);
		}
	}
	sendUpEvent(windowId,x,y,pressure) {
		if(this.windowUpListeners != null) {
			let _g = 0;
			let _g1 = this.windowUpListeners[windowId];
			while(_g < _g1.length) _g1[_g++](x,y,pressure);
		}
	}
	sendMoveEvent(windowId,x,y,pressure) {
		if(this.windowMoveListeners != null) {
			let _g = 0;
			let _g1 = this.windowMoveListeners[windowId];
			while(_g < _g1.length) _g1[_g++](x,y,pressure);
		}
	}
	static get(num) {
		if(num == null) {
			num = 0;
		}
		return kha_System.getPen(num);
	}
}
$hxClasses["kha.input.Pen"] = kha_input_Pen;
kha_input_Pen.__name__ = "kha.input.Pen";
Object.assign(kha_input_Pen.prototype, {
	__class__: kha_input_Pen
});
class kha_input_Surface {
	constructor() {
		this.touchStartListeners = [];
		this.touchEndListeners = [];
		this.moveListeners = [];
		kha_input_Surface.instance = this;
	}
	notify(touchStartListener,touchEndListener,moveListener) {
		if(touchStartListener != null) {
			this.touchStartListeners.push(touchStartListener);
		}
		if(touchEndListener != null) {
			this.touchEndListeners.push(touchEndListener);
		}
		if(moveListener != null) {
			this.moveListeners.push(moveListener);
		}
	}
	remove(touchStartListener,touchEndListener,moveListener) {
		if(touchStartListener != null) {
			HxOverrides.remove(this.touchStartListeners,touchStartListener);
		}
		if(touchEndListener != null) {
			HxOverrides.remove(this.touchEndListeners,touchEndListener);
		}
		if(moveListener != null) {
			HxOverrides.remove(this.moveListeners,moveListener);
		}
	}
	sendTouchStartEvent(index,x,y) {
		let _g = 0;
		let _g1 = this.touchStartListeners;
		while(_g < _g1.length) _g1[_g++](index,x,y);
	}
	sendTouchEndEvent(index,x,y) {
		let _g = 0;
		let _g1 = this.touchEndListeners;
		while(_g < _g1.length) _g1[_g++](index,x,y);
	}
	sendMoveEvent(index,x,y) {
		let _g = 0;
		let _g1 = this.moveListeners;
		while(_g < _g1.length) _g1[_g++](index,x,y);
	}
	static get(num) {
		if(num == null) {
			num = 0;
		}
		if(num != 0) {
			return null;
		}
		return kha_input_Surface.instance;
	}
}
$hxClasses["kha.input.Surface"] = $hx_exports["kha"]["input"]["Surface"] = kha_input_Surface;
kha_input_Surface.__name__ = "kha.input.Surface";
Object.assign(kha_input_Surface.prototype, {
	__class__: kha_input_Surface
});
class zui_Nodes {
	constructor() {
		this.popupCommands = null;
		this.popupH = 0;
		this.popupW = 0;
		this.popupY = 0;
		this.popupX = 0;
		this.nodeId = -1;
		this.handle = new zui_Handle();
		this.snapY = 0.0;
		this.snapX = 0.0;
		this.snapSocket = 0;
		this.snapToId = -1;
		this.snapFromId = -1;
		this.isNewLink = false;
		this.linkDrag = null;
		this.moveOnTop = null;
		this.dragged = false;
		this.ELEMENT_H = 25;
		this.scaleFactor = 1.0;
		this._inputStarted = false;
		this.uih = 0;
		this.uiw = 0;
		this.zoom = 1.0;
		this.panY = 0.0;
		this.panX = 0.0;
		this.nodesSelected = [];
		this.nodesDrag = false;
	}
	BUTTONS_H(node) {
		let h = 0.0;
		let _g = 0;
		let _g1 = node.buttons;
		while(_g < _g1.length) {
			let but = _g1[_g];
			++_g;
			if(but.type == "RGBA") {
				h += 235 * (this.scaleFactor * this.zoom);
			} else if(but.type == "VECTOR") {
				h += (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) * 4;
			} else if(but.type == "CUSTOM") {
				h += (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) * but.height;
			} else {
				h += this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0;
			}
		}
		return h | 0;
	}
	OUTPUTS_H(sockets,length) {
		let h = 0.0;
		let _g = 0;
		let _g1 = length == null ? sockets.length : length;
		while(_g < _g1) {
			++_g;
			h += this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0;
		}
		return h | 0;
	}
	INPUTS_H(canvas,sockets,length) {
		let h = 0.0;
		let _g = 0;
		let _g1 = length == null ? sockets.length : length;
		while(_g < _g1) {
			let i = _g++;
			if(sockets[i].type == "VECTOR" && sockets[i].display == 1 && !this.inputLinked(canvas,sockets[i].node_id,i)) {
				h += (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) * 4;
			} else {
				h += this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0;
			}
		}
		return h | 0;
	}
	getNode(nodes,id) {
		let _g = 0;
		while(_g < nodes.length) {
			let node = nodes[_g];
			++_g;
			if(node.id == id) {
				return node;
			}
		}
		return null;
	}
	getNodeId(nodes) {
		if(this.nodeId == -1) {
			let _g = 0;
			while(_g < nodes.length) {
				let n = nodes[_g];
				++_g;
				if(this.nodeId < n.id) {
					this.nodeId = n.id;
				}
			}
		}
		return ++this.nodeId;
	}
	getLinkId(links) {
		let id = 0;
		let _g = 0;
		while(_g < links.length) {
			let l = links[_g];
			++_g;
			if(l.id >= id) {
				id = l.id + 1;
			}
		}
		return id;
	}
	getSocketId(nodes) {
		let id = 0;
		let _g = 0;
		while(_g < nodes.length) {
			let n = nodes[_g];
			++_g;
			let _g1 = 0;
			let _g2 = n.inputs;
			while(_g1 < _g2.length) {
				let s = _g2[_g1];
				++_g1;
				if(s.id >= id) {
					id = s.id + 1;
				}
			}
			let _g3 = 0;
			let _g4 = n.outputs;
			while(_g3 < _g4.length) {
				let s = _g4[_g3];
				++_g3;
				if(s.id >= id) {
					id = s.id + 1;
				}
			}
		}
		return id;
	}
	inputLinked(canvas,node_id,i) {
		let _g = 0;
		let _g1 = canvas.links;
		while(_g < _g1.length) {
			let l = _g1[_g];
			++_g;
			if(l.to_id == node_id && l.to_socket == i) {
				return true;
			}
		}
		return false;
	}
	bakeElements(ui) {
		ui.g.end();
		zui_Nodes.elementsBaked = true;
		zui_Nodes.socketImage = kha_Image.createRenderTarget(24,24);
		let g = zui_Nodes.socketImage.get_g2();
		g.begin(true,0);
		g.set_color(-16777216);
		kha_graphics2_GraphicsExtension.fillCircle(g,12,12,12);
		g.set_color(-1);
		kha_graphics2_GraphicsExtension.fillCircle(g,12,12,9);
		g.end();
		ui.g.begin(false);
	}
	nodeCanvas(ui,canvas) {
		if(!zui_Nodes.elementsBaked) {
			this.bakeElements(ui);
		}
		let wx = ui._windowX;
		let wy = ui._windowY;
		let _inputEnabled = ui.inputEnabled;
		ui.inputEnabled = _inputEnabled && this.popupCommands == null;
		let controls = zui_Nodes.onCanvasControl != null ? zui_Nodes.onCanvasControl() : { panX : ui.inputDownR ? ui.inputDX : 0.0, panY : ui.inputDownR ? ui.inputDY : 0.0, zoom : -ui.inputWheelDelta / 10.0};
		zui_Nodes.socketReleased = false;
		if(ui.inputEnabled && (controls.panX != 0.0 || controls.panY != 0.0)) {
			this.panX += controls.panX / (this.scaleFactor * this.zoom);
			this.panY += controls.panY / (this.scaleFactor * this.zoom);
		}
		if(ui.inputEnabled && controls.zoom != 0.0) {
			this.zoom += controls.zoom;
			if(this.zoom < 0.1) {
				this.zoom = 0.1;
			} else if(this.zoom > 1.0) {
				this.zoom = 1.0;
			}
			this.zoom = Math.round(this.zoom * 10) / 10;
			this.uiw = ui._w;
			this.uih = ui._h;
		}
		this.scaleFactor = ui.ops.scaleFactor;
		this.ELEMENT_H = ui.t.ELEMENT_H + 2;
		ui.setScale(this.scaleFactor * this.zoom);
		ui.elementsBaked = true;
		ui.g.set_font(ui.ops.font);
		ui.g.set_fontSize(ui.fontSize);
		let _g = 0;
		let _g1 = canvas.links;
		while(_g < _g1.length) {
			let link = _g1[_g];
			++_g;
			let from = this.getNode(canvas.nodes,link.from_id);
			let to = this.getNode(canvas.nodes,link.to_id);
			let fromX = from == null ? ui.inputX : wx + (from.x * (this.scaleFactor * this.zoom) + (this.panX * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uiw / 2.5)) + ((from.width != null ? from.width : 140) * (this.scaleFactor * this.zoom) | 0);
			let fromY = from == null ? ui.inputY : wy + (from.y * (this.scaleFactor * this.zoom) + (this.panY * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uih / 2.5)) + (((this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) * 1.62 | 0) + this.OUTPUTS_H(from.outputs,link.from_socket));
			let toX = to == null ? ui.inputX : wx + (to.x * (this.scaleFactor * this.zoom) + (this.panX * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uiw / 2.5));
			let toY = to == null ? ui.inputY : wy + (to.y * (this.scaleFactor * this.zoom) + (this.panY * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uih / 2.5)) + (((this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) * 1.62 | 0) + this.INPUTS_H(canvas,to.inputs,link.to_socket)) + this.OUTPUTS_H(to.outputs) + this.BUTTONS_H(to);
			if((toX > fromX ? toX : fromX) < 0 || (toX > fromX ? fromX : toX) > wx + ui._windowW || (toY > fromY ? toY : fromY) < 0 || (toY > fromY ? fromY : toY) > wy + ui._windowH) {
				continue;
			}
			if(this.linkDrag == link) {
				if(this.snapFromId != -1) {
					fromX = this.snapX;
					fromY = this.snapY;
				}
				if(this.snapToId != -1) {
					toX = this.snapX;
					toY = this.snapY;
				}
				this.snapFromId = this.snapToId = -1;
				let _g = 0;
				let _g1 = canvas.nodes;
				while(_g < _g1.length) {
					let node = _g1[_g];
					++_g;
					let inps = node.inputs;
					let outs = node.outputs;
					let nodeh = (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) * 1.2 + this.INPUTS_H(canvas,node.inputs) + this.OUTPUTS_H(node.outputs) + this.BUTTONS_H(node) | 0;
					if(ui.getInputInRect(wx + (node.x * (this.scaleFactor * this.zoom) + (this.panX * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uiw / 2.5)) - (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) / 2,wy + (node.y * (this.scaleFactor * this.zoom) + (this.panY * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uih / 2.5)) - (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) / 2,((node.width != null ? node.width : 140) * (this.scaleFactor * this.zoom) | 0) + (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0),nodeh + (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0))) {
						if(from == null && node.id != to.id) {
							let _g = 0;
							let _g1 = outs.length;
							while(_g < _g1) {
								let i = _g++;
								let sx = wx + (node.x * (this.scaleFactor * this.zoom) + (this.panX * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uiw / 2.5)) + ((node.width != null ? node.width : 140) * (this.scaleFactor * this.zoom) | 0);
								let sy = wy + (node.y * (this.scaleFactor * this.zoom) + (this.panY * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uih / 2.5)) + (((this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) * 1.62 | 0) + this.OUTPUTS_H(outs,i));
								if(ui.getInputInRect(sx - (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) / 2,sy - (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) / 2,this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0,this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0)) {
									this.snapX = sx;
									this.snapY = sy;
									this.snapFromId = node.id;
									this.snapSocket = i;
									break;
								}
							}
						} else if(to == null && node.id != from.id) {
							let _g = 0;
							let _g1 = inps.length;
							while(_g < _g1) {
								let i = _g++;
								let sx = wx + (node.x * (this.scaleFactor * this.zoom) + (this.panX * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uiw / 2.5));
								let sy = wy + (node.y * (this.scaleFactor * this.zoom) + (this.panY * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uih / 2.5)) + (((this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) * 1.62 | 0) + this.INPUTS_H(canvas,inps,i)) + this.OUTPUTS_H(outs) + this.BUTTONS_H(node);
								if(ui.getInputInRect(sx - (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) / 2,sy - (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) / 2,this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0,this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0)) {
									this.snapX = sx;
									this.snapY = sy;
									this.snapToId = node.id;
									this.snapSocket = i;
									break;
								}
							}
						}
					}
				}
			}
			let selected = false;
			let _g2 = 0;
			let _g3 = this.nodesSelected;
			while(_g2 < _g3.length) {
				let n = _g3[_g2];
				++_g2;
				if(link.from_id == n.id || link.to_id == n.id) {
					selected = true;
					break;
				}
			}
			this.drawLink(ui,fromX - wx,fromY - wy,toX - wx,toY - wy,selected);
		}
		let _g2 = 0;
		let _g3 = canvas.nodes;
		while(_g2 < _g3.length) {
			let node = _g3[_g2];
			++_g2;
			if(node.x * (this.scaleFactor * this.zoom) + (this.panX * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uiw / 2.5) > ui._windowW || node.x * (this.scaleFactor * this.zoom) + (this.panX * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uiw / 2.5) + ((node.width != null ? node.width : 140) * (this.scaleFactor * this.zoom) | 0) < 0 || node.y * (this.scaleFactor * this.zoom) + (this.panY * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uih / 2.5) > ui._windowH || node.y * (this.scaleFactor * this.zoom) + (this.panY * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uih / 2.5) + ((this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) * 1.2 + this.INPUTS_H(canvas,node.inputs) + this.OUTPUTS_H(node.outputs) + this.BUTTONS_H(node) | 0) < 0) {
				if(this.nodesSelected.indexOf(node) < 0) {
					continue;
				}
			}
			let inps = node.inputs;
			let outs = node.outputs;
			let nodeh = (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) * 1.2 + this.INPUTS_H(canvas,node.inputs) + this.OUTPUTS_H(node.outputs) + this.BUTTONS_H(node) | 0;
			if(ui.inputEnabled && ui.getInputInRect(wx + (node.x * (this.scaleFactor * this.zoom) + (this.panX * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uiw / 2.5)) - (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) / 2,wy + (node.y * (this.scaleFactor * this.zoom) + (this.panY * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uih / 2.5)),((node.width != null ? node.width : 140) * (this.scaleFactor * this.zoom) | 0) + (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0),this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0)) {
				if(ui.inputStarted) {
					if(ui.isShiftDown || ui.isCtrlDown) {
						if(this.nodesSelected.indexOf(node) >= 0) {
							HxOverrides.remove(this.nodesSelected,node);
						} else {
							this.nodesSelected.push(node);
						}
					} else if(this.nodesSelected.length <= 1) {
						this.nodesSelected = [node];
					}
					this.moveOnTop = node;
					this.nodesDrag = true;
					this.dragged = false;
				} else if(ui.inputReleased && !ui.isShiftDown && !ui.isCtrlDown && !this.dragged) {
					this.nodesSelected = [node];
					if(zui_Nodes.onHeaderReleased != null) {
						zui_Nodes.onHeaderReleased(node);
					}
				}
			}
			if(ui.inputStarted && ui.getInputInRect(wx + (node.x * (this.scaleFactor * this.zoom) + (this.panX * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uiw / 2.5)) - (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) / 2,wy + (node.y * (this.scaleFactor * this.zoom) + (this.panY * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uih / 2.5)) - (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) / 2,((node.width != null ? node.width : 140) * (this.scaleFactor * this.zoom) | 0) + (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0),nodeh + (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0))) {
				if(this.linkDrag == null) {
					let _g = 0;
					let _g1 = outs.length;
					while(_g < _g1) {
						let i = _g++;
						let sx = wx + (node.x * (this.scaleFactor * this.zoom) + (this.panX * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uiw / 2.5)) + ((node.width != null ? node.width : 140) * (this.scaleFactor * this.zoom) | 0);
						let sy = wy + (node.y * (this.scaleFactor * this.zoom) + (this.panY * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uih / 2.5)) + (((this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) * 1.62 | 0) + this.OUTPUTS_H(outs,i));
						if(ui.getInputInRect(sx - (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) / 2,sy - (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) / 2,this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0,this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0)) {
							let l = { id : this.getLinkId(canvas.links), from_id : node.id, from_socket : i, to_id : -1, to_socket : -1};
							canvas.links.push(l);
							this.linkDrag = l;
							this.isNewLink = true;
							break;
						}
					}
				}
				if(this.linkDrag == null) {
					let _g = 0;
					let _g1 = inps.length;
					while(_g < _g1) {
						let i = _g++;
						let sx = wx + (node.x * (this.scaleFactor * this.zoom) + (this.panX * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uiw / 2.5));
						let sy = wy + (node.y * (this.scaleFactor * this.zoom) + (this.panY * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uih / 2.5)) + (((this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) * 1.62 | 0) + this.INPUTS_H(canvas,inps,i)) + this.OUTPUTS_H(outs) + this.BUTTONS_H(node);
						if(ui.getInputInRect(sx - (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) / 2,sy - (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) / 2,this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0,this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0)) {
							let _g = 0;
							let _g1 = canvas.links;
							while(_g < _g1.length) {
								let l = _g1[_g];
								++_g;
								if(l.to_id == node.id && l.to_socket == i) {
									l.to_id = l.to_socket = -1;
									this.linkDrag = l;
									this.isNewLink = false;
									break;
								}
							}
							if(this.linkDrag != null) {
								break;
							}
							let l = { id : this.getLinkId(canvas.links), from_id : -1, from_socket : -1, to_id : node.id, to_socket : i};
							canvas.links.push(l);
							this.linkDrag = l;
							this.isNewLink = true;
							break;
						}
					}
				}
			} else if(ui.inputReleased) {
				if(this.snapToId != -1) {
					let _g = 0;
					let _g1 = canvas.links;
					while(_g < _g1.length) {
						let l = _g1[_g];
						++_g;
						if(l.to_id == this.snapToId && l.to_socket == this.snapSocket) {
							HxOverrides.remove(canvas.links,l);
							break;
						}
					}
					this.linkDrag.to_id = this.snapToId;
					this.linkDrag.to_socket = this.snapSocket;
					ui.changed = true;
				} else if(this.snapFromId != -1) {
					this.linkDrag.from_id = this.snapFromId;
					this.linkDrag.from_socket = this.snapSocket;
					ui.changed = true;
				} else if(this.linkDrag != null) {
					HxOverrides.remove(canvas.links,this.linkDrag);
					ui.changed = true;
					if(zui_Nodes.onLinkDrag != null) {
						zui_Nodes.onLinkDrag(this.linkDrag,this.isNewLink);
					}
				}
				this.snapToId = this.snapFromId = -1;
				this.linkDrag = null;
				this.nodesDrag = false;
			}
			if(this.nodesDrag && this.nodesSelected.indexOf(node) >= 0 && !ui.inputDownR) {
				if(ui.inputDX != 0 || ui.inputDY != 0) {
					this.dragged = true;
					node.x += ui.inputDX / (this.scaleFactor * this.zoom) | 0;
					node.y += ui.inputDY / (this.scaleFactor * this.zoom) | 0;
				}
			}
			this.drawNode(ui,node,canvas);
		}
		if(zui_Nodes.onCanvasReleased != null && ui.inputEnabled && (ui.inputReleased || ui.inputReleasedR) && !zui_Nodes.socketReleased) {
			zui_Nodes.onCanvasReleased();
		}
		if(zui_Nodes.boxSelect) {
			ui.g.set_color(573780957);
			ui.g.fillRect(zui_Nodes.boxSelectX,zui_Nodes.boxSelectY,ui.inputX - zui_Nodes.boxSelectX - ui._windowX,ui.inputY - zui_Nodes.boxSelectY - ui._windowY);
			ui.g.set_color(1999844317);
			ui.g.drawRect(zui_Nodes.boxSelectX,zui_Nodes.boxSelectY,ui.inputX - zui_Nodes.boxSelectX - ui._windowX,ui.inputY - zui_Nodes.boxSelectY - ui._windowY);
			ui.g.set_color(-1);
		}
		if(ui.inputEnabled && ui.inputStarted && !ui.isAltDown && this.linkDrag == null && !this.nodesDrag && !ui.changed) {
			zui_Nodes.boxSelect = true;
			zui_Nodes.boxSelectX = ui.inputX - ui._windowX | 0;
			zui_Nodes.boxSelectY = ui.inputY - ui._windowY | 0;
		} else if(zui_Nodes.boxSelect && !ui.inputDown) {
			zui_Nodes.boxSelect = false;
			let nodes = [];
			let left = zui_Nodes.boxSelectX;
			let top = zui_Nodes.boxSelectY;
			let right = ui.inputX - ui._windowX | 0;
			let bottom = ui.inputY - ui._windowY | 0;
			if(left > right) {
				let t = left;
				left = right;
				right = t;
			}
			if(top > bottom) {
				let t = top;
				top = bottom;
				bottom = t;
			}
			let _g = 0;
			let _g1 = canvas.nodes;
			while(_g < _g1.length) {
				let n = _g1[_g];
				++_g;
				if(n.x * (this.scaleFactor * this.zoom) + (this.panX * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uiw / 2.5) + ((n.width != null ? n.width : 140) * (this.scaleFactor * this.zoom) | 0) > left && n.x * (this.scaleFactor * this.zoom) + (this.panX * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uiw / 2.5) < right && n.y * (this.scaleFactor * this.zoom) + (this.panY * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uih / 2.5) + ((this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) * 1.2 + this.INPUTS_H(canvas,n.inputs) + this.OUTPUTS_H(n.outputs) + this.BUTTONS_H(n) | 0) > top && n.y * (this.scaleFactor * this.zoom) + (this.panY * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uih / 2.5) < bottom) {
					nodes.push(n);
				}
			}
			if(ui.isShiftDown || ui.isCtrlDown) {
				let _g = 0;
				while(_g < nodes.length) this.nodesSelected.push(nodes[_g++]);
			} else {
				this.nodesSelected = nodes;
			}
		}
		if(this.moveOnTop != null) {
			HxOverrides.remove(canvas.nodes,this.moveOnTop);
			canvas.nodes.push(this.moveOnTop);
			this.moveOnTop = null;
		}
		let cutSelected = false;
		if(zui_Zui.isCopy) {
			let copyNodes = [];
			let _g = 0;
			let _g1 = this.nodesSelected;
			while(_g < _g1.length) {
				let n = _g1[_g];
				++_g;
				if(zui_Nodes.excludeRemove.indexOf(n.type) >= 0) {
					continue;
				}
				copyNodes.push(n);
			}
			let copyLinks = [];
			let _g2 = 0;
			let _g3 = canvas.links;
			while(_g2 < _g3.length) {
				let l = _g3[_g2];
				++_g2;
				let from = this.getNode(this.nodesSelected,l.from_id);
				let to = this.getNode(this.nodesSelected,l.to_id);
				if(from != null && zui_Nodes.excludeRemove.indexOf(from.type) == -1 && to != null && zui_Nodes.excludeRemove.indexOf(to.type) == -1) {
					copyLinks.push(l);
				}
			}
			if(copyNodes.length > 0) {
				zui_Nodes.clipboard = JSON.stringify({ name : canvas.name, nodes : copyNodes, links : copyLinks});
			}
			cutSelected = zui_Zui.isCut;
		}
		if(zui_Zui.isPaste && !ui.isTyping) {
			let pasteCanvas = null;
			try {
				pasteCanvas = JSON.parse(zui_Nodes.clipboard);
			} catch( _g ) {
			}
			if(pasteCanvas != null) {
				let _g = 0;
				let _g1 = pasteCanvas.links;
				while(_g < _g1.length) {
					let l = _g1[_g];
					++_g;
					l.id = this.getLinkId(canvas.links);
					canvas.links.push(l);
				}
				let _g2 = 0;
				let _g3 = pasteCanvas.nodes;
				while(_g2 < _g3.length) {
					let n = _g3[_g2];
					++_g2;
					let old_id = n.id;
					n.id = this.getNodeId(canvas.nodes);
					let _g = 0;
					let _g1 = n.inputs;
					while(_g < _g1.length) {
						let soc = _g1[_g];
						++_g;
						soc.id = this.getSocketId(canvas.nodes);
						soc.node_id = n.id;
					}
					let _g4 = 0;
					let _g5 = n.outputs;
					while(_g4 < _g5.length) {
						let soc = _g5[_g4];
						++_g4;
						soc.id = this.getSocketId(canvas.nodes);
						soc.node_id = n.id;
					}
					let _g6 = 0;
					let _g7 = pasteCanvas.links;
					while(_g6 < _g7.length) {
						let l = _g7[_g6];
						++_g6;
						if(l.from_id == old_id) {
							l.from_id = n.id;
						} else if(l.to_id == old_id) {
							l.to_id = n.id;
						}
					}
					n.x += 10;
					n.y += 10;
					canvas.nodes.push(n);
				}
				this.nodesSelected = pasteCanvas.nodes;
				ui.changed = true;
			}
		}
		if(ui.isCtrlDown && ui.key == 65) {
			this.nodesSelected = [];
			let _g = 0;
			let _g1 = canvas.nodes;
			while(_g < _g1.length) this.nodesSelected.push(_g1[_g++]);
		}
		if(ui.inputEnabled && (ui.isBackspaceDown || ui.isDeleteDown || cutSelected) && !ui.isTyping) {
			let i = this.nodesSelected.length - 1;
			while(i >= 0) {
				let n = this.nodesSelected[i--];
				if(zui_Nodes.excludeRemove.indexOf(n.type) >= 0) {
					continue;
				}
				this.removeNode(n,canvas);
				ui.changed = true;
			}
		}
		ui.setScale(this.scaleFactor);
		ui.elementsBaked = true;
		ui.inputEnabled = _inputEnabled;
		if(this.popupCommands != null) {
			ui._x = this.popupX;
			ui._y = this.popupY;
			ui._w = this.popupW;
			ui.fill(-6,-6,ui._w / ui.ops.scaleFactor + 12,this.popupH + 12,ui.t.ACCENT_SELECT_COL);
			ui.fill(-5,-5,ui._w / ui.ops.scaleFactor + 10,this.popupH + 10,ui.t.SEPARATOR_COL);
			this.popupCommands(ui);
			if((ui.inputStarted || ui.inputStartedR) && (ui.inputX - wx < this.popupX - 6 || ui.inputX - wx > this.popupX + this.popupW + 6 || ui.inputY - wy < this.popupY - 6 || ui.inputY - wy > this.popupY + this.popupH * ui.ops.scaleFactor + 6) || ui.isEscapeDown) {
				this.popupCommands = null;
			}
		}
	}
	drawNode(ui,node,canvas) {
		let wx = ui._windowX;
		let wy = ui._windowY;
		let uiX = ui._x;
		let uiY = ui._y;
		let uiW = ui._w;
		let w = (node.width != null ? node.width : 140) * (this.scaleFactor * this.zoom) | 0;
		let g = ui.g;
		let h = (this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) * 1.2 + this.INPUTS_H(canvas,node.inputs) + this.OUTPUTS_H(node.outputs) + this.BUTTONS_H(node) | 0;
		let nx = node.x * (this.scaleFactor * this.zoom) + (this.panX * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uiw / 2.5);
		let ny = node.y * (this.scaleFactor * this.zoom) + (this.panY * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uih / 2.5);
		let text = zui_Nodes.tr(node.name);
		let lineh = this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0;
		this._inputStarted = ui.inputStarted;
		if(ui.inputStarted) {
			let _g = canvas.nodes.indexOf(node) + 1;
			let _g1 = canvas.nodes.length;
			while(_g < _g1) {
				let n = canvas.nodes[_g++];
				if(n.x * (this.scaleFactor * this.zoom) + (this.panX * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uiw / 2.5) < ui.inputX - ui._windowX && n.x * (this.scaleFactor * this.zoom) + (this.panX * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uiw / 2.5) + ((n.width != null ? n.width : 140) * (this.scaleFactor * this.zoom) | 0) > ui.inputX - ui._windowX && n.y * (this.scaleFactor * this.zoom) + (this.panY * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uih / 2.5) < ui.inputY - ui._windowY && n.y * (this.scaleFactor * this.zoom) + (this.panY * (this.scaleFactor * this.zoom) + (1.0 - this.zoom) * this.uih / 2.5) + ((this.ELEMENT_H * (this.scaleFactor * this.zoom) | 0) * 1.2 + this.INPUTS_H(canvas,n.inputs) + this.OUTPUTS_H(n.outputs) + this.BUTTONS_H(n) | 0) > ui.inputY - ui._windowY) {
					ui.inputStarted = false;
					break;
				}
			}
		}
		g.set_color(this.nodesSelected.indexOf(node) >= 0 ? ui.t.LABEL_COL : ui.t.CONTEXT_COL);
		g.fillRect(nx - 1,ny - 1,w + 2,h + 2);
		g.set_color(ui.t.WINDOW_BG_COL);
		g.fillRect(nx,ny,w,h);
		g.set_color(node.color);
		g.fillRect(nx,ny + lineh - 3 * (this.scaleFactor * this.zoom),w,3 * (this.scaleFactor * this.zoom));
		g.set_color(ui.t.LABEL_COL);
		g.get_font().width(ui.fontSize,text);
		g.drawString(text,nx + 10 * (this.scaleFactor * this.zoom),ny + 6 * (this.scaleFactor * this.zoom));
		ny += lineh * 0.5;
		let _g = 0;
		let _g1 = node.outputs;
		while(_g < _g1.length) {
			ny += lineh;
			g.set_color(_g1[_g++].color);
			g.drawScaledImage(zui_Nodes.socketImage,nx + w - 6 * (this.scaleFactor * this.zoom),ny - 3 * (this.scaleFactor * this.zoom),12 * (this.scaleFactor * this.zoom),12 * (this.scaleFactor * this.zoom));
		}
		ny -= lineh * node.outputs.length;
		g.set_color(ui.t.LABEL_COL);
		let _g2 = 0;
		let _g3 = node.outputs;
		while(_g2 < _g3.length) {
			let out = _g3[_g2];
			++_g2;
			ny += lineh;
			let strw = ui.ops.font.width(ui.fontSize,zui_Nodes.tr(out.name));
			g.drawString(zui_Nodes.tr(out.name),nx + w - strw - 12 * (this.scaleFactor * this.zoom),ny - 3 * (this.scaleFactor * this.zoom));
			if(zui_Nodes.onSocketReleased != null && ui.inputEnabled && (ui.inputReleased || ui.inputReleasedR)) {
				if(ui.inputX > wx + nx && ui.inputX < wx + nx + w && ui.inputY > wy + ny && ui.inputY < wy + ny + lineh) {
					zui_Nodes.onSocketReleased(out);
					zui_Nodes.socketReleased = true;
				}
			}
		}
		let nhandle = this.handle.nest(node.id);
		ny -= lineh / 3;
		let _g4 = 0;
		let _g5 = node.buttons.length;
		while(_g4 < _g5) {
			let buti = _g4++;
			let but = node.buttons[buti];
			if(but.type == "RGBA") {
				ny += lineh;
				ui._x = nx;
				ui._y = ny;
				ui._w = w;
				let val = node.outputs[but.output].default_value;
				nhandle.color = kha_Color.fromFloats(val[0],val[1],val[2]);
				zui_Ext.colorWheel(ui,nhandle);
				val[0] = ((nhandle.color & 16711680) >>> 16) * 0.00392156862745098;
				val[1] = ((nhandle.color & 65280) >>> 8) * 0.00392156862745098;
				val[2] = (nhandle.color & 255) * 0.00392156862745098;
			} else if(but.type == "VECTOR") {
				ny += lineh;
				ui._x = nx;
				ui._y = ny;
				ui._w = w;
				let min = but.min != null ? but.min : 0.0;
				let max = but.max != null ? but.max : 1.0;
				let textOff = ui.t.TEXT_OFFSET;
				ui.t.TEXT_OFFSET = 6;
				ui.text(zui_Nodes.tr(but.name));
				let val = but.default_value;
				val[0] = ui.slider(nhandle.nest(buti).nest(0,{ value : val[0]}),"X",min,max,true,100,true,0);
				val[1] = ui.slider(nhandle.nest(buti).nest(1,{ value : val[1]}),"Y",min,max,true,100,true,0);
				val[2] = ui.slider(nhandle.nest(buti).nest(2,{ value : val[2]}),"Z",min,max,true,100,true,0);
				ui.t.TEXT_OFFSET = textOff;
				if(but.output != null) {
					node.outputs[but.output].default_value = but.default_value;
				}
				ny += lineh * 3;
			} else if(but.type == "VALUE") {
				ny += lineh;
				ui._x = nx;
				ui._y = ny;
				ui._w = w;
				let soc = node.outputs[but.output];
				let min = but.min != null ? but.min : 0.0;
				let max = but.max != null ? but.max : 1.0;
				let prec = but.precision != null ? but.precision : 100.0;
				let textOff = ui.t.TEXT_OFFSET;
				ui.t.TEXT_OFFSET = 6;
				soc.default_value = ui.slider(nhandle.nest(buti,{ value : soc.default_value}),"Value",min,max,true,prec,true,0);
				ui.t.TEXT_OFFSET = textOff;
			} else if(but.type == "STRING") {
				ny += lineh;
				ui._x = nx;
				ui._y = ny;
				ui._w = w;
				let soc = but.output != null ? node.outputs[but.output] : null;
				but.default_value = ui.textInput(nhandle.nest(buti,{ text : soc != null ? soc.default_value : but.default_value != null ? but.default_value : ""}),zui_Nodes.tr(but.name));
				if(soc != null) {
					soc.default_value = but.default_value;
				}
			} else if(but.type == "ENUM") {
				ny += lineh;
				ui._x = nx;
				ui._y = ny;
				ui._w = w;
				let texts;
				if(((but.data) instanceof Array)) {
					let _g = [];
					let _g1 = 0;
					let _g2 = js_Boot.__cast(but.data , Array);
					while(_g1 < _g2.length) _g.push(zui_Nodes.tr(_g2[_g1++]));
					texts = _g;
				} else {
					texts = zui_Nodes.enumTexts(node.type);
				}
				let buthandle = nhandle.nest(buti);
				buthandle.position = but.default_value;
				but.default_value = ui.combo(buthandle,texts,zui_Nodes.tr(but.name));
			} else if(but.type == "BOOL") {
				ny += lineh;
				ui._x = nx;
				ui._y = ny;
				ui._w = w;
				but.default_value = ui.check(nhandle.nest(buti,{ selected : but.default_value}),zui_Nodes.tr(but.name));
			} else if(but.type == "CUSTOM") {
				ny += lineh;
				ui._x = nx;
				ui._y = ny;
				ui._w = w;
				let dot = but.name.lastIndexOf(".");
				let name = HxOverrides.substr(but.name,0,dot);
				Reflect.field($hxClasses[name],HxOverrides.substr(but.name,dot + 1,null))(ui,this,node);
				ny += lineh * (but.height - 1);
			}
		}
		ny += lineh / 3;
		let _g6 = 0;
		let _g7 = node.inputs.length;
		while(_g6 < _g7) {
			let i = _g6++;
			let inp = node.inputs[i];
			ny += lineh;
			g.set_color(inp.color);
			g.drawScaledImage(zui_Nodes.socketImage,nx - 6 * (this.scaleFactor * this.zoom),ny - 3 * (this.scaleFactor * this.zoom),12 * (this.scaleFactor * this.zoom),12 * (this.scaleFactor * this.zoom));
			let isLinked = this.inputLinked(canvas,node.id,i);
			if(!isLinked && inp.type == "VALUE") {
				ui._x = nx + 6 * (this.scaleFactor * this.zoom);
				ui._y = ny - 9 * (this.scaleFactor * this.zoom);
				ui._w = w - 6 * (this.scaleFactor * this.zoom) | 0;
				let soc = inp;
				let min = soc.min != null ? soc.min : 0.0;
				let max = soc.max != null ? soc.max : 1.0;
				let prec = soc.precision != null ? soc.precision : 100.0;
				let textOff = ui.t.TEXT_OFFSET;
				ui.t.TEXT_OFFSET = 6;
				soc.default_value = ui.slider(nhandle.nest(9).nest(i,{ value : soc.default_value}),zui_Nodes.tr(inp.name),min,max,true,prec,true,0);
				ui.t.TEXT_OFFSET = textOff;
			} else if(!isLinked && inp.type == "STRING") {
				ui._x = nx + 6 * (this.scaleFactor * this.zoom);
				ui._y = ny - 9 * (this.scaleFactor * this.zoom);
				ui._w = w - 6 * (this.scaleFactor * this.zoom) | 0;
				let soc = inp;
				let textOff = ui.t.TEXT_OFFSET;
				ui.t.TEXT_OFFSET = 6;
				soc.default_value = ui.textInput(nhandle.nest(9).nest(i,{ text : soc.default_value}),zui_Nodes.tr(inp.name),0);
				ui.t.TEXT_OFFSET = textOff;
			} else if(!isLinked && inp.type == "RGBA") {
				g.set_color(ui.t.LABEL_COL);
				g.drawString(zui_Nodes.tr(inp.name),nx + 12 * (this.scaleFactor * this.zoom),ny - 3 * (this.scaleFactor * this.zoom));
				let soc = inp;
				g.set_color(-16777216);
				g.fillRect(nx + w - 38 * (this.scaleFactor * this.zoom),ny - 6 * (this.scaleFactor * this.zoom),36 * (this.scaleFactor * this.zoom),18 * (this.scaleFactor * this.zoom));
				let val = soc.default_value;
				g.set_color(kha_Color.fromFloats(val[0],val[1],val[2]));
				let rx = nx + w - 37 * (this.scaleFactor * this.zoom);
				let ry = ny - 5 * (this.scaleFactor * this.zoom);
				let rw = 34 * (this.scaleFactor * this.zoom);
				let rh = 16 * (this.scaleFactor * this.zoom);
				g.fillRect(rx,ry,rw,rh);
				let ix = ui.inputX - wx;
				let iy = ui.inputY - wy;
				if(ui.inputStarted && ix > rx && iy > ry && ix < rx + rw && iy < ry + rh) {
					this._inputStarted = ui.inputStarted = false;
					this.rgbaPopup(ui,nhandle,soc.default_value,rx | 0,ry + ui.t.ELEMENT_H * ui.ops.scaleFactor | 0);
				}
			} else if(!isLinked && inp.type == "VECTOR" && inp.display == 1) {
				g.set_color(ui.t.LABEL_COL);
				g.drawString(zui_Nodes.tr(inp.name),nx + 12 * (this.scaleFactor * this.zoom),ny - 3 * (this.scaleFactor * this.zoom));
				ny += lineh / 2;
				ui._x = nx;
				ui._y = ny;
				ui._w = w;
				let min = inp.min != null ? inp.min : 0.0;
				let max = inp.max != null ? inp.max : 1.0;
				let textOff = ui.t.TEXT_OFFSET;
				ui.t.TEXT_OFFSET = 6;
				let val = inp.default_value;
				val[0] = ui.slider(nhandle.nest(9).nest(i).nest(0,{ value : val[0]}),"X",min,max,true,100,true,0);
				val[1] = ui.slider(nhandle.nest(9).nest(i).nest(1,{ value : val[1]}),"Y",min,max,true,100,true,0);
				val[2] = ui.slider(nhandle.nest(9).nest(i).nest(2,{ value : val[2]}),"Z",min,max,true,100,true,0);
				ui.t.TEXT_OFFSET = textOff;
				ny += lineh * 2.5;
			} else {
				g.set_color(ui.t.LABEL_COL);
				g.drawString(zui_Nodes.tr(inp.name),nx + 12 * (this.scaleFactor * this.zoom),ny - 3 * (this.scaleFactor * this.zoom));
			}
			if(zui_Nodes.onSocketReleased != null && ui.inputEnabled && (ui.inputReleased || ui.inputReleasedR)) {
				if(ui.inputX > wx + nx && ui.inputX < wx + nx + w && ui.inputY > wy + ny && ui.inputY < wy + ny + lineh) {
					zui_Nodes.onSocketReleased(inp);
					zui_Nodes.socketReleased = true;
				}
			}
		}
		ui._x = uiX;
		ui._y = uiY;
		ui._w = uiW;
		ui.inputStarted = this._inputStarted;
	}
	rgbaPopup(ui,nhandle,val,x,y) {
		this.popup(x,y,140 * this.scaleFactor | 0,ui.t.ELEMENT_H * 10 | 0,function(ui) {
			nhandle.color = kha_Color.fromFloats(val[0],val[1],val[2]);
			zui_Ext.colorWheel(ui,nhandle,false,null,null,true);
			val[0] = ((nhandle.color & 16711680) >>> 16) * 0.00392156862745098;
			val[1] = ((nhandle.color & 65280) >>> 8) * 0.00392156862745098;
			val[2] = (nhandle.color & 255) * 0.00392156862745098;
		});
	}
	drawLink(ui,x1,y1,x2,y2,highlight) {
		if(highlight == null) {
			highlight = false;
		}
		let g = ui.g;
		let c1 = ui.t.LABEL_COL;
		let c2 = ui.t.ACCENT_SELECT_COL;
		g.set_color(highlight ? kha_Color.fromBytes((c1 & 16711680) >>> 16,(c1 & 65280) >>> 8,c1 & 255,210) : kha_Color.fromBytes((c2 & 16711680) >>> 16,(c2 & 65280) >>> 8,c2 & 255,210));
		if(ui.t.LINK_STYLE == 0) {
			g.drawLine(x1,y1,x2,y2,1.0);
			g.set_color(highlight ? kha_Color.fromBytes((c1 & 16711680) >>> 16,(c1 & 65280) >>> 8,c1 & 255,150) : kha_Color.fromBytes((c2 & 16711680) >>> 16,(c2 & 65280) >>> 8,c2 & 255,150));
			g.drawLine(x1 + 0.5,y1,x2 + 0.5,y2,1.0);
			g.drawLine(x1 - 0.5,y1,x2 - 0.5,y2,1.0);
			g.drawLine(x1,y1 + 0.5,x2,y2 + 0.5,1.0);
			g.drawLine(x1,y1 - 0.5,x2,y2 - 0.5,1.0);
		} else if(ui.t.LINK_STYLE == 1) {
			kha_graphics2_GraphicsExtension.drawCubicBezier(g,[x1,x1 + Math.abs(x1 - x2) / 2,x2 - Math.abs(x1 - x2) / 2,x2],[y1,y1,y2,y2],30,highlight ? 2.0 : 1.0);
		}
	}
	removeNode(n,canvas) {
		if(n == null) {
			return;
		}
		let i = 0;
		while(i < canvas.links.length) {
			let l = canvas.links[i];
			if(l.from_id == n.id || l.to_id == n.id) {
				canvas.links.splice(i,1);
			} else {
				++i;
			}
		}
		HxOverrides.remove(canvas.nodes,n);
		if(zui_Nodes.onNodeRemove != null) {
			zui_Nodes.onNodeRemove(n);
		}
	}
	popup(x,y,w,h,commands) {
		this.popupX = x;
		this.popupY = y;
		this.popupW = w;
		this.popupH = h;
		this.popupCommands = commands;
	}
	static tr(id,vars) {
		return id;
	}
}
$hxClasses["zui.Nodes"] = zui_Nodes;
zui_Nodes.__name__ = "zui.Nodes";
Object.assign(zui_Nodes.prototype, {
	__class__: zui_Nodes
});
class zui_Themes {
}
$hxClasses["zui.Themes"] = zui_Themes;
zui_Themes.__name__ = "zui.Themes";
function $bind(o,m) { if( m == null ) return null; if( m.__id__ == null ) m.__id__ = $global.$haxeUID++; var f; if( o.hx__closures__ == null ) o.hx__closures__ = {}; else f = o.hx__closures__[m.__id__]; if( f == null ) { f = m.bind(o); o.hx__closures__[m.__id__] = f; } return f; }
$global.$haxeUID |= 0;
if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
	HxOverrides.now = performance.now.bind(performance);
}
$hxClasses["Math"] = Math;
if( String.fromCodePoint == null ) String.fromCodePoint = function(c) { return c < 0x10000 ? String.fromCharCode(c) : String.fromCharCode((c>>10)+0xD7C0)+String.fromCharCode((c&0x3FF)+0xDC00); }
{
	String.prototype.__class__ = $hxClasses["String"] = String;
	String.__name__ = "String";
	$hxClasses["Array"] = Array;
	Array.__name__ = "Array";
	var Int = { };
	var Dynamic = { };
	var Float = Number;
	var Bool = Boolean;
	var Class = { };
	var Enum = { };
}
js_Boot.__toStr = ({ }).toString;
haxe_ds_ObjectMap.count = 0;
Main.version = "0.9";
Main.sha = HxOverrides.substr("'350d865b'",1,7);
Main.date = "2022-02-27 13:33:32".split(" ")[0];
Xml.Element = 0;
Xml.PCData = 1;
Xml.CData = 2;
Xml.Comment = 3;
Xml.DocType = 4;
Xml.ProcessingInstruction = 5;
Xml.Document = 6;
zui_Handle.global = new zui_Handle();
arm_App.uiEnabled = true;
arm_App.isDragging = false;
arm_App.isResizing = false;
arm_App.dragTint = -1;
arm_App.dragSize = -1;
arm_App.dragOffX = 0.0;
arm_App.dragOffY = 0.0;
arm_App.dropX = 0.0;
arm_App.dropY = 0.0;
arm_App.defaultElementW = 100;
arm_App.defaultElementH = 28;
arm_App.defaultFontSize = 13;
arm_App.resHandle = new zui_Handle();
arm_App.bitsHandle = new zui_Handle();
arm_App.dropPaths = [];
arm_App.appx = 0;
arm_App.appy = 0;
arm_App.lastWindowWidth = 0;
arm_App.lastWindowHeight = 0;
arm_Args.useArgs = false;
arm_Args.assetPath = "";
arm_Args.reimportMesh = false;
arm_Args.exportTextures = false;
arm_Args.exportTexturesType = "";
arm_Args.exportTexturesPreset = "";
arm_Args.exportTexturesPath = "";
arm_Args.exportMesh = false;
arm_Args.exportMeshPath = "";
arm_Args.background = false;
arm_Config.configLoaded = false;
arm_Console.message = "";
arm_Console.messageTimer = 0.0;
arm_Console.messageColor = 0;
arm_Console.lastTraces = [""];
arm_Project.raw = { };
arm_Project.filepath = "";
arm_Project.assets = [];
arm_Project.assetNames = [];
arm_Project.assetId = 0;
arm_Project.meshAssets = [];
arm_Project.materialGroups = [];
arm_Project.assetMap = new haxe_ds_IntMap();
iron_math_Mat4.helpVec = new iron_math_Vec4();
iron_math_Mat4.helpMat = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
arm_Context.mergedObjectIsAtlas = false;
arm_Context.tool = 0;
arm_Context.ddirty = 0;
arm_Context.pdirty = 0;
arm_Context.rdirty = 0;
arm_Context.brushBlendDirty = true;
arm_Context.layerPreviewDirty = true;
arm_Context.layersPreviewDirty = false;
arm_Context.nodePreviewDirty = false;
arm_Context.nodePreviewSocket = 0;
arm_Context.colorIdPicked = false;
arm_Context.splitView = false;
arm_Context.viewIndex = -1;
arm_Context.viewIndexLast = -1;
arm_Context.materialPreview = false;
arm_Context.savedCamera = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
arm_Context.pickedColor = arm_Project.makeSwatch();
arm_Context.materialIdPicked = 0;
arm_Context.uvxPicked = 0.0;
arm_Context.uvyPicked = 0.0;
arm_Context.pickerSelectMaterial = true;
arm_Context.pickerMaskHandle = new zui_Handle();
arm_Context.pickPosNorTex = false;
arm_Context.posXPicked = 0.0;
arm_Context.posYPicked = 0.0;
arm_Context.posZPicked = 0.0;
arm_Context.norXPicked = 0.0;
arm_Context.norYPicked = 0.0;
arm_Context.norZPicked = 0.0;
arm_Context.envmapLoaded = false;
arm_Context.showEnvmap = false;
arm_Context.showEnvmapHandle = new zui_Handle({ selected : false});
arm_Context.showEnvmapBlur = false;
arm_Context.showEnvmapBlurHandle = new zui_Handle({ selected : false});
arm_Context.envmapAngle = 0.0;
arm_Context.drawWireframe = false;
arm_Context.wireframeHandle = new zui_Handle({ selected : false});
arm_Context.drawTexels = false;
arm_Context.texelsHandle = new zui_Handle({ selected : false});
arm_Context.cullBackfaces = true;
arm_Context.textureFilter = true;
arm_Context.colorIdHandle = zui_Handle.global.nest(121,null);
arm_Context.formatType = 0;
arm_Context.formatQuality = 100.0;
arm_Context.layersExport = 0;
arm_Context.layersDestination = 0;
arm_Context.splitBy = 0;
arm_Context.parseTransform = true;
arm_Context.parseVCols = false;
arm_Context.selectTime = 0.0;
arm_Context.decalPreview = false;
arm_Context.decalX = 0.0;
arm_Context.decalY = 0.0;
arm_Context.viewportMode = 0;
arm_Context.renderMode = 0;
arm_Context.hscaleWasChanged = false;
arm_Context.exportMeshFormat = 0;
arm_Context.exportMeshIndex = 0;
arm_Context.cacheDraws = false;
arm_Context.packAssetsOnExport = true;
arm_Context.writeIconOnExport = false;
arm_Context.particlePhysics = false;
arm_Context.particleHitX = 0.0;
arm_Context.particleHitY = 0.0;
arm_Context.particleHitZ = 0.0;
arm_Context.layerFilter = 0;
arm_Context.paintVec = new iron_math_Vec4();
arm_Context.lastPaintX = -1.0;
arm_Context.lastPaintY = -1.0;
arm_Context.foregroundEvent = false;
arm_Context.painted = 0;
arm_Context.brushTime = 0.0;
arm_Context.cloneStartX = -1.0;
arm_Context.cloneStartY = -1.0;
arm_Context.cloneDeltaX = 0.0;
arm_Context.cloneDeltaY = 0.0;
arm_Context.gizmoStarted = false;
arm_Context.gizmoOffset = 0.0;
arm_Context.gizmoDrag = 0.0;
arm_Context.gizmoDragLast = 0.0;
arm_Context.translateX = false;
arm_Context.translateY = false;
arm_Context.translateZ = false;
arm_Context.scaleX = false;
arm_Context.scaleY = false;
arm_Context.scaleZ = false;
arm_Context.rotateX = false;
arm_Context.rotateY = false;
arm_Context.rotateZ = false;
arm_Context.brushNodesRadius = 1.0;
arm_Context.brushNodesOpacity = 1.0;
arm_Context.brushMaskImageIsAlpha = false;
arm_Context.brushStencilImageIsAlpha = false;
arm_Context.brushStencilX = 0.02;
arm_Context.brushStencilY = 0.02;
arm_Context.brushStencilScale = 0.9;
arm_Context.brushStencilScaling = false;
arm_Context.brushStencilAngle = 0.0;
arm_Context.brushStencilRotating = false;
arm_Context.brushNodesScale = 1.0;
arm_Context.brushNodesAngle = 0.0;
arm_Context.brushNodesHardness = 1.0;
arm_Context.brushDirectional = false;
arm_Context.brushRadius = 0.5;
arm_Context.brushRadiusHandle = new zui_Handle({ value : 0.5});
arm_Context.brushDecalMaskRadius = 0.5;
arm_Context.brushDecalMaskRadiusHandle = new zui_Handle({ value : 0.5});
arm_Context.brushScaleX = 1.0;
arm_Context.brushScaleXHandle = new zui_Handle({ value : 1.0});
arm_Context.brushBlending = 0;
arm_Context.brushOpacity = 1.0;
arm_Context.brushOpacityHandle = new zui_Handle({ value : 1.0});
arm_Context.brushScale = 1.0;
arm_Context.brushAngle = 0.0;
arm_Context.brushAngleHandle = new zui_Handle({ value : 0.0});
arm_Context.brushHardness = 0.8;
arm_Context.brushLazyRadius = 0.0;
arm_Context.brushLazyStep = 0.0;
arm_Context.brushLazyX = 0.0;
arm_Context.brushLazyY = 0.0;
arm_Context.brushPaint = 0;
arm_Context.brushAngleRejectDot = 0.5;
arm_Context.bakeType = 0;
arm_Context.bakeAxis = 0;
arm_Context.bakeUpAxis = 0;
arm_Context.bakeAoStrength = 1.0;
arm_Context.bakeAoRadius = 1.0;
arm_Context.bakeAoOffset = 1.0;
arm_Context.bakeCurvStrength = 1.0;
arm_Context.bakeCurvRadius = 1.0;
arm_Context.bakeCurvOffset = 0.0;
arm_Context.bakeCurvSmooth = 1;
arm_Context.bakeHighPoly = 0;
arm_Context.xray = false;
arm_Context.symX = false;
arm_Context.symY = false;
arm_Context.symZ = false;
arm_Context.blurDirectional = false;
arm_Context.showCompass = true;
arm_Context.fillTypeHandle = new zui_Handle();
arm_Context.projectType = 0;
arm_Context.projectAspectRatio = 0;
arm_Context.lastPaintVecX = -1.0;
arm_Context.lastPaintVecY = -1.0;
arm_Context.prevPaintVecX = -1.0;
arm_Context.prevPaintVecY = -1.0;
arm_Context.frame = 0;
arm_Context.paint2d = false;
arm_Context.paint2dView = false;
arm_Context.lockStartedX = -1.0;
arm_Context.lockStartedY = -1.0;
arm_Context.brushLocked = false;
arm_Context.brushCanLock = false;
arm_Context.brushCanUnlock = false;
arm_Context.cameraType = 0;
arm_Context.camHandle = new zui_Handle();
arm_Context.vxaoExt = 1.0;
arm_Context.vxaoOffset = 1.5;
arm_Context.vxaoAperture = 1.2;
arm_Context.textureExportPath = "";
arm_Context.lastStatusPosition = 0;
arm_Context.lastHtab0Position = 0;
arm_Context.maximizedSidebarWidth = 0;
arm_Context.cameraControls = 0;
arm_Context.dragDestination = 0;
arm_History.undoI = 0;
arm_History.undos = 0;
arm_History.redos = 0;
arm_History.pushUndo = false;
arm_Plugin.plugins = new haxe_ds_StringMap();
kha_Scheduler.DIF_COUNT = 3;
kha_Scheduler.maxframetime = 0.5;
kha_Scheduler.startTime = 0;
arm_CoreBridge.Json = JSON;
arm_CoreBridge.ReflectFields = Reflect.fields;
arm_CoreBridge.ReflectField = Reflect.field;
arm_CoreBridge.ReflectSetField = Reflect.setField;
arm_CoreBridge.StdIs = Std.isOfType;
arm_CoreBridge.Bytes = haxe_io_Bytes;
arm_CoreBridge.BytesInput = haxe_io_BytesInput;
arm_CoreBridge.BytesOutput = haxe_io_BytesOutput;
arm_CoreBridge.Blob = kha_Blob;
arm_CoreBridge.Image = kha_Image;
arm_CoreBridge.Scheduler = kha_Scheduler;
iron_App.traitInits = [];
iron_App.traitUpdates = [];
iron_App.traitLateUpdates = [];
iron_App.traitRenders = [];
iron_App.traitRenders2D = [];
iron_App.pauseUpdates = false;
iron_App.lastw = -1;
iron_App.lasth = -1;
iron_data_Data.cachedSceneRaws = new haxe_ds_StringMap();
iron_data_Data.cachedMeshes = new haxe_ds_StringMap();
iron_data_Data.cachedLights = new haxe_ds_StringMap();
iron_data_Data.cachedCameras = new haxe_ds_StringMap();
iron_data_Data.cachedMaterials = new haxe_ds_StringMap();
iron_data_Data.cachedParticles = new haxe_ds_StringMap();
iron_data_Data.cachedWorlds = new haxe_ds_StringMap();
iron_data_Data.cachedShaders = new haxe_ds_StringMap();
iron_data_Data.cachedBlobs = new haxe_ds_StringMap();
iron_data_Data.cachedImages = new haxe_ds_StringMap();
iron_data_Data.cachedFonts = new haxe_ds_StringMap();
iron_data_Data.assetsLoaded = 0;
iron_data_Data.loadingMeshes = new haxe_ds_StringMap();
iron_data_Data.loadingLights = new haxe_ds_StringMap();
iron_data_Data.loadingCameras = new haxe_ds_StringMap();
iron_data_Data.loadingMaterials = new haxe_ds_StringMap();
iron_data_Data.loadingParticles = new haxe_ds_StringMap();
iron_data_Data.loadingWorlds = new haxe_ds_StringMap();
iron_data_Data.loadingShaders = new haxe_ds_StringMap();
iron_data_Data.loadingSceneRaws = new haxe_ds_StringMap();
iron_data_Data.loadingBlobs = new haxe_ds_StringMap();
iron_data_Data.loadingImages = new haxe_ds_StringMap();
iron_data_Data.loadingFonts = new haxe_ds_StringMap();
iron_data_Data.dataPath = "." + "\\" + "data" + "\\";
iron_system_Input.occupied = false;
iron_system_Input.gamepads = [];
iron_system_Input.registered = false;
iron_object_Object._hx_skip_constructor = false;
iron_object_Object.uidCounter = 0;
iron_object_Object.seed = 1;
iron_Scene.uidCounter = 0;
iron_Scene.framePassed = true;
iron_system_Time.scale = 1.0;
iron_system_Time.last = 0.0;
iron_system_Time.realDelta = 0.0;
arm_IronBridge.App = iron_App;
arm_IronBridge.Scene = iron_Scene;
arm_IronBridge.RenderPath = iron_RenderPath;
arm_IronBridge.Time = iron_system_Time;
arm_IronBridge.Input = iron_system_Input;
arm_IronBridge.ArmPack = iron_system_ArmPack;
arm_IronBridge.Object = iron_object_Object;
arm_IronBridge.Data = iron_data_Data;
zui_Ext._ELEMENT_OFFSET = 0;
zui_Ext._BUTTON_COL = 0;
zui_Ext.ar = [0.0,0.0,0.0];
zui_Zui.alwaysRedrawWindow = true;
zui_Zui.keyRepeat = true;
zui_Zui.dynamicGlyphLoad = true;
zui_Zui.touchControls = false;
zui_Zui.keyRepeatTime = 0.0;
zui_Zui.textToPaste = "";
zui_Zui.textToCopy = "";
zui_Zui.isCut = false;
zui_Zui.isCopy = false;
zui_Zui.isPaste = false;
zui_Zui.copyFrame = 0;
zui_Zui.comboFirst = true;
arm_ZuiBridge.Handle = zui_Handle;
arm_ZuiBridge.Zui = zui_Zui;
arm_ZuiBridge.Ext = zui_Ext;
arm_ConsoleBridge.log = arm_Console.log;
arm_ConsoleBridge.error = arm_Console.error;
arm_node_Brush.customNodes = new Map();
arm_node_Brush.packageName = "arm.node.brush";
arm_node_MakeMaterial.heightUsed = false;
arm_node_MakeMaterial.emisUsed = false;
arm_node_MakeMaterial.subsUsed = false;
arm_shader_MaterialParser.tex_coord = "texCoord";
arm_shader_MaterialParser.customNodes = new Map();
arm_shader_MaterialParser.parse_surface = true;
arm_shader_MaterialParser.parse_opacity = true;
arm_shader_MaterialParser.parse_height = false;
arm_shader_MaterialParser.parse_height_as_channel = false;
arm_shader_MaterialParser.parse_emission = false;
arm_shader_MaterialParser.parse_subsurface = false;
arm_shader_MaterialParser.parsing_basecolor = false;
arm_shader_MaterialParser.triplanar = false;
arm_shader_MaterialParser.sample_keep_aspect = false;
arm_shader_MaterialParser.sample_uv_scale = "1.0";
arm_shader_MaterialParser.transform_color_space = true;
arm_shader_MaterialParser.blur_passthrough = false;
arm_shader_MaterialParser.warp_passthrough = false;
arm_shader_MaterialParser.bake_passthrough = false;
arm_shader_MaterialParser.bake_passthrough_strength = "0.0";
arm_shader_MaterialParser.bake_passthrough_radius = "0.0";
arm_shader_MaterialParser.bake_passthrough_offset = "0.0";
arm_shader_MaterialParser.arm_export_tangents = true;
arm_shader_MaterialParser.parsedMap = new haxe_ds_StringMap();
arm_shader_MaterialParser.textureMap = new haxe_ds_StringMap();
arm_util_MeshUtil.unwrappers = new haxe_ds_StringMap();
arm_node_NodesBrush.categories = ["Nodes"];
arm_node_NodesBrush.list = (function($this) {
	var $r;
	let tmp = { id : 0, name : "Image Texture", type : "TEX_IMAGE", x : 0, y : 0, color : -11959648, inputs : [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_node_NodesBrush.f32([0.0,0.0,0.0])}], outputs : [{ id : 0, node_id : 0, name : "Color", type : "VALUE", color : -3684567, default_value : arm_node_NodesBrush.f32([0.0,0.0,0.0,1.0])},{ id : 0, node_id : 0, name : "Alpha", type : "VALUE", color : -6184543, default_value : 1.0}], buttons : [{ name : "file", type : "ENUM", default_value : 0, data : ""},{ name : "color_space", type : "ENUM", default_value : 0, data : ["linear","srgb"]}]};
	let tmp1 = { id : 0, name : "Separate Vector", type : "SeparateVectorNode", x : 0, y : 0, color : -11959648, inputs : [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_node_NodesBrush.f32([0.0,0.0,0.0])}], outputs : [{ id : 0, node_id : 0, name : "X", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "Y", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "Z", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : []};
	let tmp2 = { id : 0, name : "Vector", type : "VectorNode", x : 0, y : 0, color : -11959648, inputs : [{ id : 0, node_id : 0, name : "X", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "Y", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "Z", type : "VALUE", color : -6184543, default_value : 0.0}], outputs : [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_node_NodesBrush.f32([0.0,0.0,0.0])}], buttons : []};
	let tmp3 = [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_node_NodesBrush.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_node_NodesBrush.f32([0.0,0.0,0.0])}];
	$r = [[tmp,{ id : 0, name : "Input", type : "InputNode", x : 0, y : 0, color : -11959648, inputs : [{ id : 0, node_id : 0, name : "Lazy Radius", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "Lazy Step", type : "VALUE", color : -6184543, default_value : 0.0}], outputs : [{ id : 0, node_id : 0, name : "Position", type : "VECTOR", color : -10238109, default_value : null}], buttons : []},{ id : 0, name : "Math", type : "MathNode", x : 0, y : 0, color : -11959648, inputs : [{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 0.5},{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 0.5}], outputs : [{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : [{ name : "operation", type : "ENUM", data : ["Add","Subtract","Multiply","Divide","Power","Logarithm","Square Root","Inverse Square Root","Absolute","Exponent","Minimum","Maximum","Less Than","Greater Than","Sign","Round","Floor","Ceil","Truncate","Fraction","Modulo","Snap","Ping-Pong","Sine","Cosine","Tangent","Arcsine","Arccosine","Arctangent","Arctan2","Hyperbolic Sine","Hyperbolic Cosine","Hyperbolic Tangent","To Radians","To Degrees"], default_value : 0, output : 0},{ name : "use_clamp", type : "BOOL", default_value : false, output : 0}]},{ id : 0, name : "Random", type : "RandomNode", x : 0, y : 0, color : -5025958, inputs : [{ id : 0, node_id : 0, name : "Min", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "Max", type : "VALUE", color : -6184543, default_value : 1.0}], outputs : [{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 0.5}], buttons : []},tmp1,{ id : 0, name : "Time", type : "TimeNode", x : 0, y : 0, color : -11959648, inputs : [], outputs : [{ id : 0, node_id : 0, name : "Time", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "Delta", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "Brush", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : []},{ id : 0, name : "Value", type : "FloatNode", x : 0, y : 0, color : -5025958, inputs : [{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 0.5, min : 0.0, max : 10.0}], outputs : [{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 0.5}], buttons : []},tmp2,{ id : 0, name : "Vector Math", type : "VectorMathNode", x : 0, y : 0, color : -11959648, inputs : tmp3, outputs : [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_node_NodesBrush.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : [{ name : "operation", type : "ENUM", data : ["Add","Subtract","Multiply","Divide","Average","Cross Product","Project","Reflect","Dot Product","Distance","Length","Scale","Normalize","Absolute","Minimum","Maximum","Floor","Ceil","Fraction","Modulo","Snap","Sine","Cosine","Tangent"], default_value : 0, output : 0}]}]];
	return $r;
}(this));
arm_shader_NodesMaterial.categories = ["Input","Texture","Color","Vector","Converter","Group"];
arm_shader_NodesMaterial.list = (function($this) {
	var $r;
	let tmp = { id : 0, name : "Attribute", type : "ATTRIBUTE", x : 0, y : 0, color : -5025958, inputs : [], outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])},{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Fac", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : [{ name : "Name", type : "STRING"}]};
	let tmp1 = { id : 0, name : "Camera Data", type : "CAMERA", x : 0, y : 0, color : -5025958, inputs : [], outputs : [{ id : 0, node_id : 0, name : "View Vector", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "View Z Depth", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "View Distance", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : []};
	let tmp2 = { id : 0, name : "Fresnel", type : "FRESNEL", x : 0, y : 0, color : -5025958, inputs : [{ id : 0, node_id : 0, name : "IOR", type : "VALUE", color : -6184543, default_value : 1.45, min : 0, max : 3},{ id : 0, node_id : 0, name : "Normal", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])}], outputs : [{ id : 0, node_id : 0, name : "Fac", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : []};
	let tmp3 = { id : 0, name : "Geometry", type : "NEW_GEOMETRY", x : 0, y : 0, color : -5025958, inputs : [], outputs : [{ id : 0, node_id : 0, name : "Position", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Normal", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Tangent", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "True Normal", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Incoming", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Parametric", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Backfacing", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "Pointiness", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "Random Per Island", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : []};
	let tmp4 = { id : 0, name : "Layer", type : "LAYER", x : 0, y : 0, color : -11959648, inputs : [], outputs : [{ id : 0, node_id : 0, name : "Base Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0,1.0])},{ id : 0, node_id : 0, name : "Opacity", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Occlusion", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Roughness", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Metallic", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Normal Map", type : "VECTOR", color : -10238109, default_value : arm_shader_NodesMaterial.f32([0.5,0.5,1.0])},{ id : 0, node_id : 0, name : "Emission", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Height", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Subsurface", type : "VALUE", color : -6184543, default_value : 1.0}], buttons : [{ name : "Layer", type : "ENUM", default_value : 0, data : ""}]};
	let tmp5 = { id : 0, name : "Layer Weight", type : "LAYER_WEIGHT", x : 0, y : 0, color : -5025958, inputs : [{ id : 0, node_id : 0, name : "Blend", type : "VALUE", color : -6184543, default_value : 0.5},{ id : 0, node_id : 0, name : "Normal", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])}], outputs : [{ id : 0, node_id : 0, name : "Fresnel", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "Facing", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : []};
	let tmp6 = { id : 0, name : "Material", type : "MATERIAL", x : 0, y : 0, color : -11959648, inputs : [], outputs : [{ id : 0, node_id : 0, name : "Base Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0,1.0])},{ id : 0, node_id : 0, name : "Opacity", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Occlusion", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Roughness", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Metallic", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Normal Map", type : "VECTOR", color : -10238109, default_value : arm_shader_NodesMaterial.f32([0.5,0.5,1.0])},{ id : 0, node_id : 0, name : "Emission", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Height", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Subsurface", type : "VALUE", color : -6184543, default_value : 1.0}], buttons : [{ name : "Material", type : "ENUM", default_value : 0, data : ""}]};
	let tmp7 = { id : 0, name : "Object Info", type : "OBJECT_INFO", x : 0, y : 0, color : -5025958, inputs : [], outputs : [{ id : 0, node_id : 0, name : "Location", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0,1.0])},{ id : 0, node_id : 0, name : "Object Index", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "Material Index", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "Random", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : []};
	let tmp8 = { id : 0, name : "Picker", type : "PICKER", x : 0, y : 0, color : -11959648, inputs : [], outputs : [{ id : 0, node_id : 0, name : "Base Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0,1.0])},{ id : 0, node_id : 0, name : "Opacity", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Occlusion", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Roughness", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Metallic", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Normal Map", type : "VECTOR", color : -10238109, default_value : arm_shader_NodesMaterial.f32([0.5,0.5,1.0])},{ id : 0, node_id : 0, name : "Emission", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Height", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Subsurface", type : "VALUE", color : -6184543, default_value : 1.0}], buttons : []};
	let tmp9 = { id : 0, name : "RGB", type : "RGB", x : 0, y : 0, color : -5025958, inputs : [], outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.5,0.5,0.5,1.0])}], buttons : [{ name : "default_value", type : "RGBA", output : 0}]};
	let tmp10 = { id : 0, name : "Tangent", type : "TANGENT", x : 0, y : 0, color : -5025958, inputs : [], outputs : [{ id : 0, node_id : 0, name : "Tangent", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])}], buttons : []};
	let tmp11 = { id : 0, name : "Texture Coordinate", type : "TEX_COORD", x : 0, y : 0, color : -5025958, inputs : [], outputs : [{ id : 0, node_id : 0, name : "Generated", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Normal", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "UV", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Object", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Camera", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Window", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Reflection", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])}], buttons : []};
	let tmp12 = { id : 0, name : "UV Map", type : "UVMAP", x : 0, y : 0, color : -5025958, inputs : [], outputs : [{ id : 0, node_id : 0, name : "UV", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])}], buttons : []};
	let tmp13 = [tmp,tmp1,tmp2,tmp3,tmp4,{ id : 0, name : "Layer Mask", type : "LAYER_MASK", x : 0, y : 0, color : -11959648, inputs : [], outputs : [{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : [{ name : "Layer", type : "ENUM", default_value : 0, data : ""}]},tmp5,tmp6,tmp7,tmp8,tmp9,{ id : 0, name : "Script", type : "SCRIPT_CPU", x : 0, y : 0, color : -5025958, inputs : [], outputs : [{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 0.5}], buttons : [{ name : " ", type : "STRING", default_value : ""}]},{ id : 0, name : "Shader", type : "SHADER_GPU", x : 0, y : 0, color : -5025958, inputs : [], outputs : [{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 0.5}], buttons : [{ name : " ", type : "STRING", default_value : ""}]},tmp10,tmp11,tmp12,{ id : 0, name : "Value", type : "VALUE", x : 0, y : 0, color : -5025958, inputs : [], outputs : [{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 0.5}], buttons : [{ name : "default_value", type : "VALUE", output : 0, min : 0.0, max : 10.0}]},{ id : 0, name : "Vertex Color", type : "VERTEX_COLOR", x : 0, y : 0, color : -5025958, inputs : [], outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])},{ id : 0, node_id : 0, name : "Alpha", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : []},{ id : 0, name : "Wireframe", type : "WIREFRAME", x : 0, y : 0, color : -5025958, inputs : [{ id : 0, node_id : 0, name : "Size", type : "VALUE", color : -6184543, default_value : 0.01, max : 0.1}], outputs : [{ id : 0, node_id : 0, name : "Fac", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : [{ name : "Pixel Size", type : "BOOL", default_value : false, output : 0}]}];
	let tmp14 = { id : 0, name : "Brick Texture", type : "TEX_BRICK", x : 0, y : 0, color : -11959648, inputs : [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Color 1", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8])},{ id : 0, node_id : 0, name : "Color 2", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.2,0.2,0.2])},{ id : 0, node_id : 0, name : "Mortar", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Scale", type : "VALUE", color : -6184543, default_value : 5.0, min : 0.0, max : 10.0}], outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])},{ id : 0, node_id : 0, name : "Fac", type : "VALUE", color : -6184543, default_value : 1.0}], buttons : []};
	let tmp15 = { id : 0, name : "Checker Texture", type : "TEX_CHECKER", x : 0, y : 0, color : -11959648, inputs : [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Color 1", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8])},{ id : 0, node_id : 0, name : "Color 2", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.2,0.2,0.2])},{ id : 0, node_id : 0, name : "Scale", type : "VALUE", color : -6184543, default_value : 5.0, min : 0.0, max : 10.0}], outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])},{ id : 0, node_id : 0, name : "Fac", type : "VALUE", color : -6184543, default_value : 1.0}], buttons : []};
	let tmp16 = { id : 0, name : "Gradient Texture", type : "TEX_GRADIENT", x : 0, y : 0, color : -11959648, inputs : [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])}], outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])},{ id : 0, node_id : 0, name : "Fac", type : "VALUE", color : -6184543, default_value : 1.0}], buttons : [{ name : "gradient_type", type : "ENUM", data : ["Linear","Diagonal","Radial","Spherical"], default_value : 0, output : 0}]};
	let tmp17 = { id : 0, name : "Image Texture", type : "TEX_IMAGE", x : 0, y : 0, color : -11959648, inputs : [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])}], outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0,1.0])},{ id : 0, node_id : 0, name : "Alpha", type : "VALUE", color : -6184543, default_value : 1.0}], buttons : [{ name : "File", type : "ENUM", default_value : 0, data : ""},{ name : "Color Space", type : "ENUM", default_value : 0, data : ["Auto","Linear","sRGB","DirectX Normal Map"]}]};
	let tmp18 = { id : 0, name : "Magic Texture", type : "TEX_MAGIC", x : 0, y : 0, color : -11959648, inputs : [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Scale", type : "VALUE", color : -6184543, default_value : 5.0, min : 0.0, max : 10.0}], outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])},{ id : 0, node_id : 0, name : "Fac", type : "VALUE", color : -6184543, default_value : 1.0}], buttons : []};
	let tmp19 = { id : 0, name : "Musgrave Texture", type : "TEX_MUSGRAVE", x : 0, y : 0, color : -11959648, inputs : [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Scale", type : "VALUE", color : -6184543, default_value : 5.0, min : 0.0, max : 10.0}], outputs : [{ id : 0, node_id : 0, name : "Height", type : "VALUE", color : -6184543, default_value : 1.0}], buttons : []};
	let tmp20 = { id : 0, name : "Noise Texture", type : "TEX_NOISE", x : 0, y : 0, color : -11959648, inputs : [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Scale", type : "VALUE", color : -6184543, default_value : 5.0, min : 0.0, max : 10.0}], outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])},{ id : 0, node_id : 0, name : "Fac", type : "VALUE", color : -6184543, default_value : 1.0}], buttons : []};
	let tmp21 = { id : 0, name : "Voronoi Texture", type : "TEX_VORONOI", x : 0, y : 0, color : -11959648, inputs : [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Scale", type : "VALUE", color : -6184543, default_value : 5.0, min : 0.0, max : 10.0}], outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])},{ id : 0, node_id : 0, name : "Fac", type : "VALUE", color : -6184543, default_value : 1.0}], buttons : [{ name : "coloring", type : "ENUM", data : ["Intensity","Cells"], default_value : 0, output : 0}]};
	let tmp22 = [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Scale", type : "VALUE", color : -6184543, default_value : 5.0, min : 0.0, max : 10.0}];
	let tmp23 = [tmp14,tmp15,{ id : 0, name : "Curvature Bake", type : "BAKE_CURVATURE", x : 0, y : 0, color : -11959648, inputs : [{ id : 0, node_id : 0, name : "Strength", type : "VALUE", color : -6184543, default_value : 1.0, min : 0.0, max : 2.0},{ id : 0, node_id : 0, name : "Radius", type : "VALUE", color : -6184543, default_value : 1.0, min : 0.0, max : 2.0},{ id : 0, node_id : 0, name : "Offset", type : "VALUE", color : -6184543, default_value : 0.0, min : -2.0, max : 2.0}], outputs : [{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 1.0}], buttons : []},tmp16,tmp17,tmp18,tmp19,tmp20,tmp21,{ id : 0, name : "Wave Texture", type : "TEX_WAVE", x : 0, y : 0, color : -11959648, inputs : tmp22, outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])},{ id : 0, node_id : 0, name : "Fac", type : "VALUE", color : -6184543, default_value : 1.0}], buttons : []}];
	let tmp24 = { id : 0, name : "Blur", type : "BLUR", x : 0, y : 0, color : -12284819, inputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])},{ id : 0, node_id : 0, name : "Strength", type : "VALUE", color : -6184543, default_value : 0.5}], outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])}], buttons : []};
	let tmp25 = { id : 0, name : "Bright/Contrast", type : "BRIGHTCONTRAST", x : 0, y : 0, color : -12284819, inputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])},{ id : 0, node_id : 0, name : "Bright", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "Contrast", type : "VALUE", color : -6184543, default_value : 0.0}], outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])}], buttons : []};
	let tmp26 = { id : 0, name : "Gamma", type : "GAMMA", x : 0, y : 0, color : -12284819, inputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])},{ id : 0, node_id : 0, name : "Gamma", type : "VALUE", color : -6184543, default_value : 1.0}], outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])}], buttons : []};
	let tmp27 = { id : 0, name : "Hue/Saturation", type : "HUE_SAT", x : 0, y : 0, color : -12284819, inputs : [{ id : 0, node_id : 0, name : "Hue", type : "VALUE", color : -6184543, default_value : 0.5},{ id : 0, node_id : 0, name : "Saturation", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Fac", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])}], outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])}], buttons : []};
	let tmp28 = { id : 0, name : "Invert", type : "INVERT", x : 0, y : 0, color : -12284819, inputs : [{ id : 0, node_id : 0, name : "Fac", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0,1.0])}], outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])}], buttons : []};
	let tmp29 = { id : 0, node_id : 0, name : "Color 1", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.5,0.5,0.5,1.0])};
	let tmp30 = [tmp24,tmp25,tmp26,tmp27,tmp28,{ id : 0, name : "MixRGB", type : "MIX_RGB", x : 0, y : 0, color : -12284819, inputs : [{ id : 0, node_id : 0, name : "Fac", type : "VALUE", color : -6184543, default_value : 0.5},tmp29,{ id : 0, node_id : 0, name : "Color 2", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.5,0.5,0.5,1.0])}], outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])}], buttons : [{ name : "blend_type", type : "ENUM", data : ["Mix","Darken","Multiply","Burn","Lighten","Screen","Dodge","Add","Overlay","Soft Light","Linear Light","Difference","Subtract","Divide","Hue","Saturation","Color","Value"], default_value : 0, output : 0},{ name : "use_clamp", type : "BOOL", default_value : false, output : 0}]},{ id : 0, name : "Quantize", type : "QUANTIZE", x : 0, y : 0, color : -12284819, inputs : [{ id : 0, node_id : 0, name : "Stength", type : "VALUE", color : -6184543, default_value : 0.1, min : 0, max : 1},{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0,1.0])}], outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])}], buttons : []},{ id : 0, name : "Warp", type : "DIRECT_WARP", x : 0, y : 0, color : -12284819, inputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])},{ id : 0, node_id : 0, name : "Angle", type : "VALUE", color : -6184543, default_value : 0.0, min : 0.0, max : 360.0},{ id : 0, node_id : 0, name : "Mask", type : "VALUE", color : -6184543, default_value : 0.5, min : 0.0, max : 1.0}], outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])}], buttons : []}];
	let tmp31 = [{ id : 0, name : "Bump", type : "BUMP", x : 0, y : 0, color : -11391847, inputs : [{ id : 0, node_id : 0, name : "Strength", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Distance", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "Height", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Normal", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])}], outputs : [{ id : 0, node_id : 0, name : "Normal Map", type : "VECTOR", color : -10238109, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])}], buttons : []},{ id : 0, name : "Mapping", type : "MAPPING", x : 0, y : 0, color : -11391847, inputs : [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Location", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0]), display : 1},{ id : 0, node_id : 0, name : "Rotation", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0]), max : 360.0, display : 1},{ id : 0, node_id : 0, name : "Scale", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([1.0,1.0,1.0]), display : 1}], outputs : [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])}], buttons : []},{ id : 0, name : "Mix Normal Map", type : "MIX_NORMAL_MAP", x : 0, y : 0, color : -11391847, inputs : [{ id : 0, node_id : 0, name : "Normal Map 1", type : "VECTOR", color : -10238109, default_value : arm_shader_NodesMaterial.f32([0.5,0.5,1.0])},{ id : 0, node_id : 0, name : "Normal Map 2", type : "VECTOR", color : -10238109, default_value : arm_shader_NodesMaterial.f32([0.5,0.5,1.0])}], outputs : [{ id : 0, node_id : 0, name : "Normal Map", type : "VECTOR", color : -10238109, default_value : arm_shader_NodesMaterial.f32([0.5,0.5,1.0])}], buttons : [{ name : "blend_type", type : "ENUM", data : ["Partial Derivative","Whiteout","Reoriented"], default_value : 0, output : 0}]},{ id : 0, name : "Normal", type : "NORMAL", x : 0, y : 0, color : -11391847, inputs : [{ id : 0, node_id : 0, name : "Normal", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])}], outputs : [{ id : 0, node_id : 0, name : "Normal", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Dot", type : "VALUE", color : -6184543, default_value : 1.0}], buttons : [{ name : "Vector", type : "VECTOR", default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0]), output : 0}]},{ id : 0, name : "Normal Map", type : "NORMAL_MAP", x : 0, y : 0, color : -11391847, inputs : [{ id : 0, node_id : 0, name : "Stength", type : "VALUE", color : -6184543, default_value : 1.0, min : 0.0, max : 2.0},{ id : 0, node_id : 0, name : "Normal Map", type : "VECTOR", color : -10238109, default_value : arm_shader_NodesMaterial.f32([0.5,0.5,1.0])}], outputs : [{ id : 0, node_id : 0, name : "Normal Map", type : "VECTOR", color : -10238109, default_value : arm_shader_NodesMaterial.f32([0.5,0.5,1.0])}], buttons : []},{ id : 0, name : "Vector Curves", type : "CURVE_VEC", x : 0, y : 0, color : -11391847, inputs : [{ id : 0, node_id : 0, name : "Fac", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])}], outputs : [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])}], buttons : [{ name : "arm.shader.NodesMaterial.vectorCurvesButton", type : "CUSTOM", default_value : [[arm_shader_NodesMaterial.f32([0.0,0.0]),arm_shader_NodesMaterial.f32([0.0,0.0])],[arm_shader_NodesMaterial.f32([0.0,0.0]),arm_shader_NodesMaterial.f32([0.0,0.0])],[arm_shader_NodesMaterial.f32([0.0,0.0]),arm_shader_NodesMaterial.f32([0.0,0.0])]], output : 0, height : 8.5}]}];
	let tmp32 = [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0,1.0])},{ id : 0, node_id : 0, name : "Alpha", type : "VALUE", color : -6184543, default_value : 0.0}];
	let tmp33 = arm_shader_NodesMaterial.f32([1.0,1.0,1.0,1.0,0.0]);
	let tmp34 = { id : 0, name : "Color Mask", type : "COLMASK", x : 0, y : 0, color : -10328211, inputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])},{ id : 0, node_id : 0, name : "Mask Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])},{ id : 0, node_id : 0, name : "Radius", type : "VALUE", color : -6184543, default_value : 0.1, min : 0.0, max : 1.74},{ id : 0, node_id : 0, name : "Fuzziness", type : "VALUE", color : -6184543, default_value : 0.0}], outputs : [{ id : 0, node_id : 0, name : "Mask", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : []};
	let tmp35 = { id : 0, name : "Combine HSV", type : "COMBHSV", x : 0, y : 0, color : -10328211, inputs : [{ id : 0, node_id : 0, name : "H", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "S", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "V", type : "VALUE", color : -6184543, default_value : 0.0}], outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])}], buttons : []};
	let tmp36 = { id : 0, name : "Combine RGB", type : "COMBRGB", x : 0, y : 0, color : -10328211, inputs : [{ id : 0, node_id : 0, name : "R", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "G", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "B", type : "VALUE", color : -6184543, default_value : 0.0}], outputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])}], buttons : []};
	let tmp37 = { id : 0, name : "Combine XYZ", type : "COMBXYZ", x : 0, y : 0, color : -10328211, inputs : [{ id : 0, node_id : 0, name : "X", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "Y", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "Z", type : "VALUE", color : -6184543, default_value : 0.0}], outputs : [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])}], buttons : []};
	let tmp38 = { id : 0, name : "RGB to BW", type : "RGBTOBW", x : 0, y : 0, color : -10328211, inputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0,0.0])}], outputs : [{ id : 0, node_id : 0, name : "Val", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : []};
	let tmp39 = { id : 0, name : "Separate HSV", type : "SEPHSV", x : 0, y : 0, color : -10328211, inputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.5,0.5,0.5,1.0])}], outputs : [{ id : 0, node_id : 0, name : "H", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "S", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "V", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : []};
	let tmp40 = { id : 0, name : "Separate RGB", type : "SEPRGB", x : 0, y : 0, color : -10328211, inputs : [{ id : 0, node_id : 0, name : "Color", type : "RGBA", color : -3684567, default_value : arm_shader_NodesMaterial.f32([0.8,0.8,0.8,1.0])}], outputs : [{ id : 0, node_id : 0, name : "R", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "G", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "B", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : []};
	let tmp41 = { id : 0, name : "Separate XYZ", type : "SEPXYZ", x : 0, y : 0, color : -10328211, inputs : [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])}], outputs : [{ id : 0, node_id : 0, name : "X", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "Y", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "Z", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : []};
	let tmp42 = [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])}];
	$r = [tmp13,tmp23,tmp30,tmp31,[{ id : 0, name : "Clamp", type : "CLAMP", x : 0, y : 0, color : -10328211, inputs : [{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 0.5},{ id : 0, node_id : 0, name : "Min", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "Max", type : "VALUE", color : -6184543, default_value : 1.0}], outputs : [{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : [{ name : "operation", type : "ENUM", data : ["Min Max","Range"], default_value : 0, output : 0}]},{ id : 0, name : "Color Ramp", type : "VALTORGB", x : 0, y : 0, color : -10328211, inputs : [{ id : 0, node_id : 0, name : "Fac", type : "VALUE", color : -6184543, default_value : 0.5}], outputs : tmp32, buttons : [{ name : "arm.shader.NodesMaterial.colorRampButton", type : "CUSTOM", default_value : [tmp33], data : 0, output : 0, height : 4.5}]},tmp34,tmp35,tmp36,tmp37,{ id : 0, name : "Map Range", type : "MAPRANGE", x : 0, y : 0, color : -10328211, inputs : [{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 0.5},{ id : 0, node_id : 0, name : "From Min", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "From Max", type : "VALUE", color : -6184543, default_value : 1.0},{ id : 0, node_id : 0, name : "To Min", type : "VALUE", color : -6184543, default_value : 0.0},{ id : 0, node_id : 0, name : "To Max", type : "VALUE", color : -6184543, default_value : 1.0}], outputs : [{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : [{ name : "use_clamp", type : "BOOL", default_value : false, output : 0}]},{ id : 0, name : "Math", type : "MATH", x : 0, y : 0, color : -10328211, inputs : [{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 0.5},{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 0.5}], outputs : [{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : [{ name : "operation", type : "ENUM", data : ["Add","Subtract","Multiply","Divide","Power","Logarithm","Square Root","Inverse Square Root","Absolute","Exponent","Minimum","Maximum","Less Than","Greater Than","Sign","Round","Floor","Ceil","Truncate","Fraction","Modulo","Snap","Ping-Pong","Sine","Cosine","Tangent","Arcsine","Arccosine","Arctangent","Arctan2","Hyperbolic Sine","Hyperbolic Cosine","Hyperbolic Tangent","To Radians","To Degrees"], default_value : 0, output : 0},{ name : "use_clamp", type : "BOOL", default_value : false, output : 0}]},tmp38,tmp39,tmp40,tmp41,{ id : 0, name : "Vector Math", type : "VECT_MATH", x : 0, y : 0, color : -10328211, inputs : tmp42, outputs : [{ id : 0, node_id : 0, name : "Vector", type : "VECTOR", color : -10263609, default_value : arm_shader_NodesMaterial.f32([0.0,0.0,0.0])},{ id : 0, node_id : 0, name : "Value", type : "VALUE", color : -6184543, default_value : 0.0}], buttons : [{ name : "operation", type : "ENUM", data : ["Add","Subtract","Multiply","Divide","Average","Cross Product","Project","Reflect","Dot Product","Distance","Length","Scale","Normalize","Absolute","Minimum","Maximum","Floor","Ceil","Fraction","Modulo","Snap","Sine","Cosine","Tangent"], default_value : 0, output : 0}]}],[{ id : 0, name : "New Group", type : "GROUP", x : 0, y : 0, color : -5025958, inputs : [], outputs : [], buttons : [{ name : "arm.shader.NodesMaterial.newGroupButton", type : "CUSTOM", height : 1}]}]];
	return $r;
}(this));
arm_sys_Path.sep = "\\";
arm_sys_Path.meshFormats = ["obj","fbx","blend"];
arm_sys_Path.textureFormats = ["jpg","jpeg","png","tga","bmp","psd","gif","hdr"];
arm_sys_Path.meshImporters = new haxe_ds_StringMap();
arm_sys_Path.textureImporters = new haxe_ds_StringMap();
arm_sys_Path.baseColorExt = ["albedo","alb","basecol","basecolor","diffuse","diff","base","bc","d","color","col"];
arm_sys_Path.opacityExt = ["opac","opacity","alpha"];
arm_sys_Path.normalMapExt = ["normal","nor","n","nrm"];
arm_sys_Path.occlusionExt = ["ao","occlusion","ambientOcclusion","o","occ"];
arm_sys_Path.roughnessExt = ["roughness","rough","r","rgh"];
arm_sys_Path.metallicExt = ["metallic","metal","metalness","m","met"];
arm_sys_Path.displacementExt = ["displacement","height","h","disp"];
arm_Res.bundled = new haxe_ds_StringMap();
arm_ui_UIBox.show = false;
arm_ui_UIBox.draggable = true;
arm_ui_UIBox.hwnd = new zui_Handle();
arm_ui_UIBox.boxTitle = "";
arm_ui_UIBox.boxText = "";
arm_ui_UIBox.clickToHide = true;
arm_ui_UIBox.modalW = 400;
arm_ui_UIBox.modalH = 170;
arm_ui_UIBox.draws = 0;
arm_ui_UIBox.copyable = false;
arm_ui_UIFiles.path = "C:\\Users";
arm_ui_UIFiles.lastPath = "";
arm_ui_UIFiles.lastSearch = "";
arm_ui_UIFiles.selected = -1;
arm_ui_UIFiles.showExtensions = false;
arm_ui_UIFiles.offline = false;
arm_ui_UIMenu.show = false;
arm_ui_UIMenu.menuCategory = 0;
arm_ui_UIMenu.menuX = 0;
arm_ui_UIMenu.menuY = 0;
arm_ui_UIMenu.menuElements = 0;
arm_ui_UIMenu.keepOpen = false;
arm_ui_UIMenu.showMenuFirst = true;
arm_ui_UIMenu.hideMenu = false;
arm_ui_UIView2D.textInputHover = false;
arm_util_UVUtil.uvmapCached = false;
arm_util_UVUtil.trianglemapCached = false;
arm_util_UVUtil.dilatemapCached = false;
arm_util_UVUtil.uvislandmapCached = false;
arm_ArmBridge.App = arm_App;
arm_ArmBridge.Config = arm_Config;
arm_ArmBridge.Context = arm_Context;
arm_ArmBridge.History = arm_History;
arm_ArmBridge.Layers = arm_Layers;
arm_ArmBridge.Operator = arm_Operator;
arm_ArmBridge.Plugin = arm_Plugin;
arm_ArmBridge.Project = arm_Project;
arm_ArmBridge.Res = arm_Res;
arm_ArmBridge.Path = arm_sys_Path;
arm_ArmBridge.File = arm_sys_File;
arm_ArmBridge.NodesMaterial = arm_shader_NodesMaterial;
arm_ArmBridge.NodesBrush = arm_node_NodesBrush;
arm_ArmBridge.MaterialParser = arm_shader_MaterialParser;
arm_ArmBridge.MakeMaterial = arm_node_MakeMaterial;
arm_ArmBridge.Brush = arm_node_Brush;
arm_ArmBridge.UISidebar = arm_ui_UISidebar;
arm_ArmBridge.UINodes = arm_ui_UINodes;
arm_ArmBridge.UIFiles = arm_ui_UIFiles;
arm_ArmBridge.UIMenu = arm_ui_UIMenu;
arm_ArmBridge.UIView2D = arm_ui_UIView2D;
arm_ArmBridge.UIBox = arm_ui_UIBox;
arm_ArmBridge.MeshUtil = arm_util_MeshUtil;
arm_ArmBridge.RenderUtil = arm_util_RenderUtil;
arm_ArmBridge.UVUtil = arm_util_UVUtil;
arm_ArmBridge.Viewport = arm_Viewport;
arm_Translator.translations = new haxe_ds_StringMap();
arm_Translator.cjkFontIndices = (function($this) {
	var $r;
	let _g = new haxe_ds_StringMap();
	_g.h["ja"] = 0;
	_g.h["ko"] = 1;
	_g.h["zh_cn"] = 2;
	_g.h["zh_tw"] = 3;
	_g.h["zh_tw.big5"] = 4;
	$r = _g;
	return $r;
}(this));
arm_Translator.lastLocale = "en";
arm_data_ConstData.font_x0 = [1,2,6,10,18,25,34,42,45,50,55,61,68,71,75,79,85,92,97,104,111,118,1,8,15,22,29,32,35,41,48,55,61,72,81,89,97,105,112,119,1,9,13,20,28,35,45,53,61,69,77,85,93,101,109,1,12,20,28,36,40,46,50,56,62,66,73,80,87,94,101,106,113,120,123,1,8,11,21,28,35,42,49,54,61,66,73,80,90,97,104,111,116,119,1];
arm_data_ConstData.font_y0 = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,62];
arm_data_ConstData.font_x1 = [1,5,9,17,24,33,41,44,49,54,60,67,70,74,78,84,91,96,103,110,117,124,7,14,21,28,31,34,40,47,54,60,71,80,88,96,104,111,118,126,8,12,19,27,34,44,52,60,68,76,84,92,100,108,116,11,19,27,35,39,45,49,55,61,65,72,79,86,93,100,105,112,119,122,126,7,10,20,27,34,41,48,53,60,65,72,79,89,96,103,110,115,118,123,8];
arm_data_ConstData.font_y1 = [1,10,5,9,13,11,10,5,13,13,6,8,5,3,4,10,10,9,9,10,9,10,23,22,23,23,21,22,19,18,19,23,25,22,22,23,22,22,22,23,34,34,35,34,34,34,34,35,34,36,34,35,34,35,34,45,45,45,45,49,46,49,42,38,40,44,47,44,47,44,46,46,46,45,48,59,59,56,56,57,59,59,56,57,59,57,56,56,56,59,56,61,60,61,65];
arm_data_ConstData.font_xoff = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
arm_data_ConstData.font_yoff = [10,2,1,2,0,1,2,1,1,1,2,3,8,6,8,2,2,2,2,2,2,2,2,2,2,2,4,4,4,4,4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,2,0,2,10,1,4,1,4,1,4,1,4,1,2,2,1,1,4,4,4,4,4,4,4,2,4,4,4,4,4,4,1,2,1,5];
arm_data_ConstData.font_xadvance = [2.74625,2.85458,3.54791,6.83041,6.22916,8.125,6.89541,1.93375,3.79166,3.85666,4.7775,6.28875,2.1775,3.06041,2.91958,4.57166,6.22916,6.22916,6.22916,6.22916,6.22916,6.22916,6.22916,6.22916,6.22916,6.22916,2.68666,2.34541,5.63875,6.08833,5.79583,5.23791,9.96125,7.23666,6.90625,7.22041,7.27458,6.305,6.13166,7.55625,7.9083,3.01708,6.12083,6.955,5.96916,9.685,7.90833,7.62666,6.99833,7.62666,6.83041,6.58125,6.61916,7.19333,7.05791,9.84208,6.955,6.6625,6.64083,2.94125,4.55,2.94125,4.63666,5.005,3.42875,6.03416,6.22375,5.80666,6.25625,5.87708,3.85125,6.22375,6.11,2.69208,2.64875,5.6225,2.69208,9.72291,6.12083,6.32666,6.22375,6.305,3.75375,5.72,3.62375,6.11541,5.37333,8.33625,5.49791,5.24875,5.49791,3.75375,2.70291,3.75375,7.54541];
arm_format_FbxParser.parseTransform = false;
arm_format_FbxParser.parseVCols = false;
arm_format_ObjParser.splitCode = 111;
arm_format_ObjParser.vindOff = 0;
arm_format_ObjParser.tindOff = 0;
arm_format_ObjParser.nindOff = 0;
arm_io_ImportEnvmap.params = new iron_math_Vec4();
arm_io_ImportEnvmap.n = new iron_math_Vec4();
arm_io_ImportMesh.clearLayers = true;
arm_node_LogicNode._hx_skip_constructor = false;
iron_Trait._hx_skip_constructor = false;
arm_node_MakeMesh.layerPassCount = 1;
arm_node_MakeMeshPreview.opacityDiscardDecal = 0.05;
arm_node_brush_InputNode.coords = new iron_math_Vec4();
arm_node_brush_InputNode.startX = 0.0;
arm_node_brush_InputNode.startY = 0.0;
arm_node_brush_InputNode.lockBegin = false;
arm_node_brush_InputNode.lockX = false;
arm_node_brush_InputNode.lockY = false;
arm_node_brush_InputNode.lockStartX = 0.0;
arm_node_brush_InputNode.lockStartY = 0.0;
arm_node_brush_InputNode.registered = false;
iron_math_Quat.helpVec0 = new iron_math_Vec4();
iron_math_Quat.helpMat = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
iron_math_Quat.xAxis = new iron_math_Vec4(1.0,0.0,0.0);
iron_math_Quat.yAxis = new iron_math_Vec4(0.0,1.0,0.0);
arm_plugin_PhysicsBody.nextId = 0;
arm_plugin_PhysicsBody.ammoArray = -1;
arm_plugin_PhysicsBody.gimpactRegistered = false;
arm_plugin_PhysicsBody.first = true;
arm_plugin_PhysicsBody.quat = new iron_math_Quat();
arm_plugin_PhysicsBody.convexHullCache = new haxe_ds_ObjectMap();
arm_plugin_PhysicsBody.triangleMeshCache = new haxe_ds_ObjectMap();
arm_plugin_PhysicsBody.usersCache = new haxe_ds_ObjectMap();
arm_render_Gizmo.v = new iron_math_Vec4();
arm_render_Gizmo.v0 = new iron_math_Vec4();
arm_render_Gizmo.q = new iron_math_Quat();
arm_render_Gizmo.q0 = new iron_math_Quat();
arm_render_Inc.superSample = 1.0;
arm_render_Inc.lastX = -1.0;
arm_render_Inc.lastY = -1.0;
arm_render_Inc.voxelsCreated = false;
arm_render_LineDraw.color = -65536;
arm_render_LineDraw.strength = 0.005;
arm_render_LineDraw.lines = 0;
arm_render_LineDraw.vx = new iron_math_Vec4();
arm_render_LineDraw.vy = new iron_math_Vec4();
arm_render_LineDraw.vz = new iron_math_Vec4();
arm_render_LineDraw.v1 = new iron_math_Vec4();
arm_render_LineDraw.v2 = new iron_math_Vec4();
arm_render_LineDraw.t = new iron_math_Vec4();
arm_render_LineDraw.midPoint = new iron_math_Vec4();
arm_render_LineDraw.midLine = new iron_math_Vec4();
arm_render_LineDraw.corner1 = new iron_math_Vec4();
arm_render_LineDraw.corner2 = new iron_math_Vec4();
arm_render_LineDraw.corner3 = new iron_math_Vec4();
arm_render_LineDraw.corner4 = new iron_math_Vec4();
arm_render_LineDraw.cameraLook = new iron_math_Vec4();
arm_render_RenderPathDeferred.voxels = "voxels";
arm_render_RenderPathDeferred.taaFrame = 0;
arm_render_RenderPathPaint.dilated = true;
arm_render_RenderPathPaint.liveLayerDrawn = 0;
arm_render_RenderPathPaint.liveLayerLocked = false;
arm_render_RenderPathPaint.initVoxels = true;
arm_render_RenderPathPaint.mergedObjectVisible = false;
arm_render_RenderPathPaint.savedFov = 0.0;
arm_render_RenderPathPaint.baking = false;
arm_render_Uniforms.vec = new iron_math_Vec4();
arm_render_Uniforms.orthoP = new iron_math_Mat4(2.,0,0,0.,0,2.,0,0.,0,0,-2.,0.,0,0,0,1);
arm_shader_ShaderFunctions.str_tex_checker = "\r\nvec3 tex_checker(const vec3 co, const vec3 col1, const vec3 col2, const float scale) {\r\n\t// Prevent precision issues on unit coordinates\r\n\tvec3 p = (co + 0.000001 * 0.999999) * scale;\r\n\tfloat xi = abs(floor(p.x));\r\n\tfloat yi = abs(floor(p.y));\r\n\tfloat zi = abs(floor(p.z));\r\n\tbool check = ((mod(xi, 2.0) == mod(yi, 2.0)) == bool(mod(zi, 2.0)));\r\n\treturn check ? col1 : col2;\r\n}\r\nfloat tex_checker_f(const vec3 co, const float scale) {\r\n\tvec3 p = (co + 0.000001 * 0.999999) * scale;\r\n\tfloat xi = abs(floor(p.x));\r\n\tfloat yi = abs(floor(p.y));\r\n\tfloat zi = abs(floor(p.z));\r\n\treturn float((mod(xi, 2.0) == mod(yi, 2.0)) == bool(mod(zi, 2.0)));\r\n}\r\n";
arm_shader_ShaderFunctions.str_tex_voronoi = "\r\nvec4 tex_voronoi(const vec3 x, textureArg(snoise256)) {\r\n\tvec3 p = floor(x);\r\n\tvec3 f = fract(x);\r\n\tfloat id = 0.0;\r\n\tfloat res = 100.0;\r\n\tfor (int k = -1; k <= 1; k++)\r\n\tfor (int j = -1; j <= 1; j++)\r\n\tfor (int i = -1; i <= 1; i++) {\r\n\t\tvec3 b = vec3(float(i), float(j), float(k));\r\n\t\tvec3 pb = p + b;\r\n\t\tvec3 r = vec3(b) - f + texture(snoise256, (pb.xy + vec2(3.0, 1.0) * pb.z + 0.5) / 256.0).xyz;\r\n\t\tfloat d = dot(r, r);\r\n\t\tif (d < res) {\r\n\t\t\tid = dot(p + b, vec3(1.0, 57.0, 113.0));\r\n\t\t\tres = d;\r\n\t\t}\r\n\t}\r\n\tvec3 col = 0.5 + 0.5 * cos(id * 0.35 + vec3(0.0, 1.0, 2.0));\r\n\treturn vec4(col, sqrt(res));\r\n}\r\n";
arm_shader_ShaderFunctions.str_tex_noise = "\r\nfloat hash(float n) { return fract(sin(n) * 1e4); }\r\nfloat tex_noise_f(vec3 x) {\r\n    const vec3 step = vec3(110, 241, 171);\r\n    vec3 i = floor(x);\r\n    vec3 f = fract(x);\r\n    float n = dot(i, step);\r\n    vec3 u = f * f * (3.0 - 2.0 * f);\r\n    return mix(mix(mix(hash(n + dot(step, vec3(0, 0, 0))), hash(n + dot(step, vec3(1, 0, 0))), u.x),\r\n                   mix(hash(n + dot(step, vec3(0, 1, 0))), hash(n + dot(step, vec3(1, 1, 0))), u.x), u.y),\r\n               mix(mix(hash(n + dot(step, vec3(0, 0, 1))), hash(n + dot(step, vec3(1, 0, 1))), u.x),\r\n                   mix(hash(n + dot(step, vec3(0, 1, 1))), hash(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);\r\n}\r\nfloat tex_noise(vec3 p) {\r\n\tp *= 1.25;\r\n\tfloat f = 0.5 * tex_noise_f(p); p *= 2.01;\r\n\tf += 0.25 * tex_noise_f(p); p *= 2.02;\r\n\tf += 0.125 * tex_noise_f(p); p *= 2.03;\r\n\tf += 0.0625 * tex_noise_f(p);\r\n\treturn 1.0 - f;\r\n}\r\n";
arm_shader_ShaderFunctions.str_tex_musgrave = "\r\nvec3 random3(const vec3 c) {\r\n\tfloat j = 4096.0 * sin(dot(c, vec3(17.0, 59.4, 15.0)));\r\n\tvec3 r;\r\n\tr.z = fract(512.0 * j);\r\n\tj *= 0.125;\r\n\tr.x = fract(512.0 * j);\r\n\tj *= 0.125;\r\n\tr.y = fract(512.0 * j);\r\n\treturn r - 0.5;\r\n}\r\nfloat tex_musgrave_f(const vec3 p) {\r\n\tconst float F3 = 0.3333333;\r\n\tconst float G3 = 0.1666667;\r\n\tvec3 s = floor(p + dot(p, vec3(F3, F3, F3)));\r\n\tvec3 x = p - s + dot(s, vec3(G3, G3, G3));\r\n\tvec3 e = step(vec3(0.0, 0.0, 0.0), x - x.yzx);\r\n\tvec3 i1 = e*(1.0 - e.zxy);\r\n\tvec3 i2 = 1.0 - e.zxy*(1.0 - e);\r\n\tvec3 x1 = x - i1 + G3;\r\n\tvec3 x2 = x - i2 + 2.0*G3;\r\n\tvec3 x3 = x - 1.0 + 3.0*G3;\r\n\tvec4 w, d;\r\n\tw.x = dot(x, x);\r\n\tw.y = dot(x1, x1);\r\n\tw.z = dot(x2, x2);\r\n\tw.w = dot(x3, x3);\r\n\tw = max(0.6 - w, 0.0);\r\n\td.x = dot(random3(s), x);\r\n\td.y = dot(random3(s + i1), x1);\r\n\td.z = dot(random3(s + i2), x2);\r\n\td.w = dot(random3(s + 1.0), x3);\r\n\tw *= w;\r\n\tw *= w;\r\n\td *= w;\r\n\treturn clamp(dot(d, vec4(52.0, 52.0, 52.0, 52.0)), 0.0, 1.0);\r\n}\r\n";
arm_shader_ShaderFunctions.str_hue_sat = "\r\nvec3 hsv_to_rgb(const vec3 c) {\r\n\tconst vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\r\n\tvec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\r\n\treturn c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\r\n}\r\nvec3 rgb_to_hsv(const vec3 c) {\r\n\tconst vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\r\n\tvec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\r\n\tvec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\r\n\tfloat d = q.x - min(q.w, q.y);\r\n\tfloat e = 1.0e-10;\r\n\treturn vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\r\n}\r\nvec3 hue_sat(const vec3 col, const vec4 shift) {\r\n\tvec3 hsv = rgb_to_hsv(col);\r\n\thsv.x += shift.x;\r\n\thsv.y *= shift.y;\r\n\thsv.z *= shift.z;\r\n\treturn mix(hsv_to_rgb(hsv), col, shift.w);\r\n}\r\n";
arm_shader_ShaderFunctions.str_wavelength_to_rgb = "\r\nvec3 wavelength_to_rgb(const float t) {\r\n\tvec3 r = t * 2.1 - vec3(1.8, 1.14, 0.3);\r\n\treturn 1.0 - r * r;\r\n}\r\n";
arm_shader_ShaderFunctions.str_tex_magic = "\r\nvec3 tex_magic(const vec3 p) {\r\n\tfloat a = 1.0 - (sin(p.x) + sin(p.y));\r\n\tfloat b = 1.0 - sin(p.x - p.y);\r\n\tfloat c = 1.0 - sin(p.x + p.y);\r\n\treturn vec3(a, b, c);\r\n}\r\nfloat tex_magic_f(const vec3 p) {\r\n\tvec3 c = tex_magic(p);\r\n\treturn (c.x + c.y + c.z) / 3.0;\r\n}\r\n";
arm_shader_ShaderFunctions.str_tex_brick = "\r\nfloat tex_brick_noise(int n) { /* fast integer noise */\r\n\tint nn;\r\n\tn = (n >> 13) ^ n;\r\n\tnn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;\r\n\treturn 0.5f * float(nn) / 1073741824.0;\r\n}\r\nvec3 tex_brick(vec3 p, const vec3 c1, const vec3 c2, const vec3 c3) {\r\n\tvec3 brickSize = vec3(0.9, 0.49, 0.49);\r\n\tvec3 mortarSize = vec3(0.05, 0.1, 0.1);\r\n\tp /= brickSize / 2;\r\n\tif (fract(p.y * 0.5) > 0.5) p.x += 0.5;\r\n\tfloat col = floor(p.x / (brickSize.x + (mortarSize.x * 2.0)));\r\n\tfloat row = p.y;\r\n\tp = fract(p);\r\n\tvec3 b = step(p, 1.0 - mortarSize);\r\n\tfloat tint = min(max(tex_brick_noise((int(col) << 16) + (int(row) & 0xFFFF)), 0.0), 1.0);\r\n\treturn mix(c3, mix(c1, c2, tint), b.x * b.y * b.z);\r\n}\r\nfloat tex_brick_f(vec3 p) {\r\n\tp /= vec3(0.9, 0.49, 0.49) / 2;\r\n\tif (fract(p.y * 0.5) > 0.5) p.x += 0.5;\r\n\tp = fract(p);\r\n\tvec3 b = step(p, vec3(0.95, 0.9, 0.9));\r\n\treturn mix(1.0, 0.0, b.x * b.y * b.z);\r\n}\r\n";
arm_shader_ShaderFunctions.str_tex_wave = "\r\nfloat tex_wave_f(const vec3 p) {\r\n\treturn 1.0 - sin((p.x + p.y) * 10.0);\r\n}\r\n";
arm_shader_ShaderFunctions.str_brightcontrast = "\r\nvec3 brightcontrast(const vec3 col, const float bright, const float contr) {\r\n\tfloat a = 1.0 + contr;\r\n\tfloat b = bright - contr * 0.5;\r\n\treturn max(a * col + b, 0.0);\r\n}\r\n";
arm_shader_ShaderFunctions.str_traceAO = "\r\nfloat traceConeAO(sampler3D voxels, const vec3 origin, vec3 dir, const float aperture, const float maxDist, const float offset) {\r\n\tconst ivec3 voxelgiResolution = ivec3(256, 256, 256);\r\n\tconst float voxelgiStep = 1.0;\r\n\tconst float VOXEL_SIZE = (2.0 / voxelgiResolution.x) * voxelgiStep;\r\n\tdir = normalize(dir);\r\n\tfloat sampleCol = 0.0;\r\n\tfloat dist = offset;\r\n\tfloat diam = dist * aperture;\r\n\tvec3 samplePos;\r\n\twhile (sampleCol < 1.0 && dist < maxDist) {\r\n\t\tsamplePos = dir * dist + origin;\r\n\t\tfloat mip = max(log2(diam * voxelgiResolution.x), 0);\r\n\t\tfloat mipSample = textureLod(voxels, samplePos * 0.5 + vec3(0.5, 0.5, 0.5), mip).r;\r\n\t\tsampleCol += (1 - sampleCol) * mipSample;\r\n\t\tdist += max(diam / 2, VOXEL_SIZE);\r\n\t\tdiam = dist * aperture;\r\n\t}\r\n\treturn sampleCol;\r\n}\r\nvec3 tangent(const vec3 n) {\r\n\tvec3 t1 = cross(n, vec3(0, 0, 1));\r\n\tvec3 t2 = cross(n, vec3(0, 1, 0));\r\n\tif (length(t1) > length(t2)) return normalize(t1);\r\n\telse return normalize(t2);\r\n}\r\nfloat traceAO(const vec3 origin, const vec3 normal, const float vrange, const float voffset) {\r\n\tconst float angleMix = 0.5f;\r\n\tconst float aperture = 0.55785173935;\r\n\tvec3 o1 = normalize(tangent(normal));\r\n\tvec3 o2 = normalize(cross(o1, normal));\r\n\tvec3 c1 = 0.5f * (o1 + o2);\r\n\tvec3 c2 = 0.5f * (o1 - o2);\r\n\tfloat MAX_DISTANCE = 1.73205080757 * 2.0 * vrange;\r\n\tconst ivec3 voxelgiResolution = ivec3(256, 256, 256);\r\n\tconst float voxelgiStep = 1.0;\r\n\tconst float VOXEL_SIZE = (2.0 / voxelgiResolution.x) * voxelgiStep;\r\n\tfloat offset = 1.5 * VOXEL_SIZE * 2.5 * voffset;\r\n\tfloat col = traceConeAO(voxels, origin, normal, aperture, MAX_DISTANCE, offset);\r\n\tcol += traceConeAO(voxels, origin, mix(normal, o1, angleMix), aperture, MAX_DISTANCE, offset);\r\n\tcol += traceConeAO(voxels, origin, mix(normal, o2, angleMix), aperture, MAX_DISTANCE, offset);\r\n\tcol += traceConeAO(voxels, origin, mix(normal, -c1, angleMix), aperture, MAX_DISTANCE, offset);\r\n\tcol += traceConeAO(voxels, origin, mix(normal, -c2, angleMix), aperture, MAX_DISTANCE, offset);\r\n\tcol += traceConeAO(voxels, origin, mix(normal, -o1, angleMix), aperture, MAX_DISTANCE, offset);\r\n\tcol += traceConeAO(voxels, origin, mix(normal, -o2, angleMix), aperture, MAX_DISTANCE, offset);\r\n\tcol += traceConeAO(voxels, origin, mix(normal, c1, angleMix), aperture, MAX_DISTANCE, offset);\r\n\tcol += traceConeAO(voxels, origin, mix(normal, c2, angleMix), aperture, MAX_DISTANCE, offset);\r\n\treturn col / 9.0;\r\n}\r\n";
arm_shader_ShaderFunctions.str_cotangentFrame = "\r\nmat3 cotangentFrame(const vec3 n, const vec3 p, const vec2 duv1, const vec2 duv2) {\r\n\tvec3 dp1 = dFdx(p);\r\n\tvec3 dp2 = dFdy(p);\r\n\tvec3 dp2perp = cross(dp2, n);\r\n\tvec3 dp1perp = cross(n, dp1);\r\n\tvec3 t = dp2perp * duv1.x + dp1perp * duv2.x;\r\n\tvec3 b = dp2perp * duv1.y + dp1perp * duv2.y;\r\n\tfloat invmax = inversesqrt(max(dot(t, t), dot(b, b)));\r\n\treturn mat3(t * invmax, b * invmax, n);\r\n}\r\nmat3 cotangentFrame(const vec3 n, const vec3 p, const vec2 texCoord) {\r\n\treturn cotangentFrame(n, p, dFdx(texCoord), dFdy(texCoord));\r\n}\r\n";
arm_shader_ShaderFunctions.str_octahedronWrap = "\r\nvec2 octahedronWrap(const vec2 v) {\r\n\treturn (1.0 - abs(v.yx)) * (vec2(v.x >= 0.0 ? 1.0 : -1.0, v.y >= 0.0 ? 1.0 : -1.0));\r\n}\r\n";
arm_shader_ShaderFunctions.str_packFloatInt16 = "\r\nfloat packFloatInt16(const float f, const uint i) {\r\n\tconst float prec = float(1 << 16);\r\n\tconst float maxi = float(1 << 4);\r\n\tconst float precMinusOne = prec - 1.0;\r\n\tconst float t1 = ((prec / maxi) - 1.0) / precMinusOne;\r\n\tconst float t2 = (prec / maxi) / precMinusOne;\r\n\treturn t1 * f + t2 * float(i);\r\n}\r\n";
arm_shader_ShaderFunctions.str_shIrradiance = "vec3 shIrradiance(const vec3 nor, const vec4 shirr[7]) {\r\n\tconst float c1 = 0.429043;\r\n\tconst float c2 = 0.511664;\r\n\tconst float c3 = 0.743125;\r\n\tconst float c4 = 0.886227;\r\n\tconst float c5 = 0.247708;\r\n\tvec3 cl00 = vec3(shirr[0].x, shirr[0].y, shirr[0].z);\r\n\tvec3 cl1m1 = vec3(shirr[0].w, shirr[1].x, shirr[1].y);\r\n\tvec3 cl10 = vec3(shirr[1].z, shirr[1].w, shirr[2].x);\r\n\tvec3 cl11 = vec3(shirr[2].y, shirr[2].z, shirr[2].w);\r\n\tvec3 cl2m2 = vec3(shirr[3].x, shirr[3].y, shirr[3].z);\r\n\tvec3 cl2m1 = vec3(shirr[3].w, shirr[4].x, shirr[4].y);\r\n\tvec3 cl20 = vec3(shirr[4].z, shirr[4].w, shirr[5].x);\r\n\tvec3 cl21 = vec3(shirr[5].y, shirr[5].z, shirr[5].w);\r\n\tvec3 cl22 = vec3(shirr[6].x, shirr[6].y, shirr[6].z);\r\n\treturn (\r\n\t\tc1 * cl22 * (nor.y * nor.y - (-nor.z) * (-nor.z)) +\r\n\t\tc3 * cl20 * nor.x * nor.x +\r\n\t\tc4 * cl00 -\r\n\t\tc5 * cl20 +\r\n\t\t2.0 * c1 * cl2m2 * nor.y * (-nor.z) +\r\n\t\t2.0 * c1 * cl21  * nor.y * nor.x +\r\n\t\t2.0 * c1 * cl2m1 * (-nor.z) * nor.x +\r\n\t\t2.0 * c2 * cl11  * nor.y +\r\n\t\t2.0 * c2 * cl1m1 * (-nor.z) +\r\n\t\t2.0 * c2 * cl10  * nor.x\r\n\t);\r\n}\r\n";
arm_shader_ShaderFunctions.str_envMapEquirect = "\r\nvec2 envMapEquirect(const vec3 normal, const float angle) {\r\n\tconst float PI = 3.1415926535;\r\n\tconst float PI2 = PI * 2.0;\r\n\tfloat phi = acos(normal.z);\r\n\tfloat theta = atan2(-normal.y, normal.x) + PI + angle;\r\n\treturn vec2(theta / PI2, phi / PI);\r\n}\r\n";
arm_shader_ShaderFunctions.str_ltcEvaluate = "\r\nfloat integrateEdge(vec3 v1, vec3 v2) {\r\n\tfloat cosTheta = dot(v1, v2);\r\n\tfloat theta = acos(cosTheta);\r\n\tfloat res = cross(v1, v2).z * ((theta > 0.001) ? theta / sin(theta) : 1.0);\r\n\treturn res;\r\n}\r\nfloat ltcEvaluate(vec3 N, vec3 V, float dotNV, vec3 P, mat3 Minv, vec3 points0, vec3 points1, vec3 points2, vec3 points3) {\r\n\tvec3 T1 = normalize(V - N * dotNV);\r\n\tvec3 T2 = cross(N, T1);\r\n\tMinv = mul(transpose(mat3(T1, T2, N)), Minv);\r\n\tvec3 L0 = mul((points0 - P), Minv);\r\n\tvec3 L1 = mul((points1 - P), Minv);\r\n\tvec3 L2 = mul((points2 - P), Minv);\r\n\tvec3 L3 = mul((points3 - P), Minv);\r\n\tvec3 L4 = vec3(0.0, 0.0, 0.0);\r\n\tint n = 0;\r\n\tint config = 0;\r\n\tif (L0.z > 0.0) config += 1;\r\n\tif (L1.z > 0.0) config += 2;\r\n\tif (L2.z > 0.0) config += 4;\r\n\tif (L3.z > 0.0) config += 8;\r\n\tif (config == 0) {}\r\n\telse if (config == 1) {\r\n\t\tn = 3;\r\n\t\tL1 = -L1.z * L0 + L0.z * L1;\r\n\t\tL2 = -L3.z * L0 + L0.z * L3;\r\n\t}\r\n\telse if (config == 2) {\r\n\t\tn = 3;\r\n\t\tL0 = -L0.z * L1 + L1.z * L0;\r\n\t\tL2 = -L2.z * L1 + L1.z * L2;\r\n\t}\r\n\telse if (config == 3) {\r\n\t\tn = 4;\r\n\t\tL2 = -L2.z * L1 + L1.z * L2;\r\n\t\tL3 = -L3.z * L0 + L0.z * L3;\r\n\t}\r\n\telse if (config == 4) {\r\n\t\tn = 3;\r\n\t\tL0 = -L3.z * L2 + L2.z * L3;\r\n\t\tL1 = -L1.z * L2 + L2.z * L1;\r\n\t}\r\n\telse if (config == 5) { n = 0; }\r\n\telse if (config == 6) {\r\n\t\tn = 4;\r\n\t\tL0 = -L0.z * L1 + L1.z * L0;\r\n\t\tL3 = -L3.z * L2 + L2.z * L3;\r\n\t}\r\n\telse if (config == 7) {\r\n\t\tn = 5;\r\n\t\tL4 = -L3.z * L0 + L0.z * L3;\r\n\t\tL3 = -L3.z * L2 + L2.z * L3;\r\n\t}\r\n\telse if (config == 8) {\r\n\t\tn = 3;\r\n\t\tL0 = -L0.z * L3 + L3.z * L0;\r\n\t\tL1 = -L2.z * L3 + L3.z * L2;\r\n\t\tL2 =  L3;\r\n\t}\r\n\telse if (config == 9) {\r\n\t\tn = 4;\r\n\t\tL1 = -L1.z * L0 + L0.z * L1;\r\n\t\tL2 = -L2.z * L3 + L3.z * L2;\r\n\t}\r\n\telse if (config == 10) { n = 0; }\r\n\telse if (config == 11) {\r\n\t\tn = 5;\r\n\t\tL4 = L3;\r\n\t\tL3 = -L2.z * L3 + L3.z * L2;\r\n\t\tL2 = -L2.z * L1 + L1.z * L2;\r\n\t}\r\n\telse if (config == 12) {\r\n\t\tn = 4;\r\n\t\tL1 = -L1.z * L2 + L2.z * L1;\r\n\t\tL0 = -L0.z * L3 + L3.z * L0;\r\n\t}\r\n\telse if (config == 13) {\r\n\t\tn = 5;\r\n\t\tL4 = L3;\r\n\t\tL3 = L2;\r\n\t\tL2 = -L1.z * L2 + L2.z * L1;\r\n\t\tL1 = -L1.z * L0 + L0.z * L1;\r\n\t}\r\n\telse if (config == 14) {\r\n\t\tn = 5;\r\n\t\tL4 = -L0.z * L3 + L3.z * L0;\r\n\t\tL0 = -L0.z * L1 + L1.z * L0;\r\n\t}\r\n\telse if (config == 15) { n = 4; }\r\n\tif (n == 0) return 0.0;\r\n\tif (n == 3) L3 = L0;\r\n\tif (n == 4) L4 = L0;\r\n\tL0 = normalize(L0);\r\n\tL1 = normalize(L1);\r\n\tL2 = normalize(L2);\r\n\tL3 = normalize(L3);\r\n\tL4 = normalize(L4);\r\n\tfloat sum = 0.0;\r\n\tsum += integrateEdge(L0, L1);\r\n\tsum += integrateEdge(L1, L2);\r\n\tsum += integrateEdge(L2, L3);\r\n\tif (n >= 4) sum += integrateEdge(L3, L4);\r\n\tif (n == 5) sum += integrateEdge(L4, L0);\r\n\treturn max(0.0, -sum);\r\n}\r\n";
arm_shader_ShaderFunctions.str_get_pos_from_depth = "\r\nvec3 get_pos_from_depth(vec2 uv, mat4 invVP, textureArg(gbufferD)) {\r\n\t#if defined(HLSL) || defined(METAL) || defined(SPIRV)\r\n\tfloat depth = textureLod(gbufferD, vec2(uv.x, 1.0 - uv.y), 0.0).r;\r\n\t#else\r\n\tfloat depth = textureLod(gbufferD, uv, 0.0).r;\r\n\t#endif\r\n\tvec4 wpos = vec4(uv * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0);\r\n\twpos = mul(wpos, invVP);\r\n\treturn wpos.xyz / wpos.w;\r\n}\r\n";
arm_shader_ShaderFunctions.str_get_nor_from_depth = "\r\nvec3 get_nor_from_depth(vec3 p0, vec2 uv, mat4 invVP, vec2 texStep, textureArg(gbufferD)) {\r\n\tvec3 p1 = get_pos_from_depth(uv + vec2(texStep.x * 4.0, 0.0), invVP, texturePass(gbufferD));\r\n\tvec3 p2 = get_pos_from_depth(uv + vec2(0.0, texStep.y * 4.0), invVP, texturePass(gbufferD));\r\n\treturn normalize(cross(p2 - p0, p1 - p0));\r\n}\r\n";
arm_ui_BoxExport.htab = zui_Handle.global.nest(10,null);
arm_ui_BoxExport.hpreset = zui_Handle.global.nest(9,null);
arm_ui_BoxExport.channels = ["base_r","base_g","base_b","height","metal","nor_r","nor_g","nor_g_directx","nor_b","occ","opac","rough","smooth","emis","subs","0.0","1.0"];
arm_ui_BoxExport.colorSpaces = ["linear","srgb"];
arm_ui_BoxExport.exportMeshHandle = zui_Handle.global.nest(38,null);
kha_Color.Black = -16777216;
kha_Color.White = -1;
kha_Color.Red = -65536;
kha_Color.Blue = -16776961;
kha_Color.Green = -16711936;
kha_Color.Magenta = -65281;
kha_Color.Yellow = -256;
kha_Color.Cyan = -16711681;
kha_Color.Purple = -8388480;
kha_Color.Pink = -16181;
kha_Color.Orange = -23296;
kha_Color.Transparent = 0;
kha_Color.invMaxChannelValue = 0.00392156862745098;
arm_ui_BoxPreferences.htab = zui_Handle.global.nest(42,null);
arm_ui_BoxPreferences.worldColor = kha_Color._new(-16645630);
arm_ui_TabBrowser.hpath = new zui_Handle();
arm_ui_TabBrowser.hsearch = new zui_Handle();
arm_ui_TabBrowser.known = false;
arm_ui_TabBrowser.lastPath = "";
arm_ui_TabLayers.layerNameEdit = -1;
arm_ui_TabLayers.layerNameHandle = zui_Handle.global.nest(148,null);
arm_ui_TabScript.hscript = zui_Handle.global.nest(89,null);
haxe_io_FPHelper.helper = new DataView(new ArrayBuffer(8));
haxe_xml_Parser.escapes = (function($this) {
	var $r;
	let h = new haxe_ds_StringMap();
	h.h["lt"] = "<";
	h.h["gt"] = ">";
	h.h["amp"] = "&";
	h.h["quot"] = "\"";
	h.h["apos"] = "'";
	$r = h;
	return $r;
}(this));
iron_data_ConstData.skydomeIndices = [261,8,7,258,5,4,265,12,11,257,2,156,262,9,8,259,6,5,179,12,265,0,3,2,263,10,9,260,7,6,1,4,3,264,11,10,6,17,16,179,23,12,3,14,13,10,21,20,7,18,17,4,15,14,11,22,21,8,19,18,5,16,15,12,23,22,2,13,156,9,20,19,16,27,26,23,34,33,13,24,156,20,31,30,17,28,27,179,34,23,14,25,24,21,32,31,18,29,28,15,26,25,22,33,32,19,30,29,29,40,39,26,37,36,33,44,43,30,41,40,27,38,37,34,45,44,24,35,156,31,42,41,28,39,38,179,45,34,25,36,35,32,43,42,39,50,49,179,56,45,36,47,46,43,54,53,40,51,50,37,48,47,44,55,54,41,52,51,38,49,48,45,56,55,35,46,156,42,53,52,52,63,62,49,60,59,56,67,66,46,57,156,53,64,63,50,61,60,179,67,56,47,58,57,54,65,64,51,62,61,48,59,58,55,66,65,62,73,72,59,70,69,66,77,76,63,74,73,60,71,70,67,78,77,57,68,156,64,75,74,61,72,71,179,78,67,58,69,68,65,76,75,75,86,85,72,83,82,179,89,78,69,80,79,76,87,86,73,84,83,70,81,80,77,88,87,74,85,84,71,82,81,78,89,88,68,79,156,85,96,95,82,93,92,89,100,99,79,90,156,86,97,96,83,94,93,179,100,89,80,91,90,87,98,97,84,95,94,81,92,91,88,99,98,98,109,108,95,106,105,92,103,102,99,110,109,96,107,106,93,104,103,100,111,110,90,101,156,97,108,107,94,105,104,179,111,100,91,102,101,101,112,156,108,119,118,105,116,115,179,122,111,102,113,112,109,120,119,106,117,116,103,114,113,110,121,120,107,118,117,104,115,114,111,122,121,121,132,131,118,129,128,115,126,125,122,133,132,112,123,156,119,130,129,116,127,126,179,133,122,113,124,123,120,131,130,117,128,127,114,125,124,124,135,134,131,142,141,128,139,138,125,136,135,132,143,142,129,140,139,126,137,136,133,144,143,123,134,156,130,141,140,127,138,137,179,144,133,144,155,154,134,145,156,141,152,151,138,149,148,179,155,144,135,146,145,142,153,152,139,150,149,136,147,146,143,154,153,140,151,150,137,148,147,147,159,158,154,166,165,151,163,162,148,160,159,155,167,166,145,157,156,152,164,163,149,161,160,179,167,155,146,158,157,153,165,164,150,162,161,179,178,167,158,169,168,165,176,175,162,173,172,159,170,169,166,177,176,163,174,173,160,171,170,167,178,177,157,168,156,164,175,174,161,172,171,171,183,182,178,190,189,168,180,156,175,187,186,172,184,183,179,190,178,169,181,180,176,188,187,173,185,184,170,182,181,177,189,188,174,186,185,182,193,192,189,200,199,186,197,196,183,194,193,190,201,200,180,191,156,187,198,197,184,195,194,179,201,190,181,192,191,188,199,198,185,196,195,195,206,205,179,212,201,192,203,202,199,210,209,196,207,206,193,204,203,200,211,210,197,208,207,194,205,204,201,212,211,191,202,156,198,209,208,205,216,215,212,223,222,202,213,156,209,220,219,206,217,216,179,223,212,203,214,213,210,221,220,207,218,217,204,215,214,211,222,221,208,219,218,218,229,228,215,226,225,222,233,232,219,230,229,216,227,226,223,234,233,213,224,156,220,231,230,217,228,227,179,234,223,214,225,224,221,232,231,228,239,238,179,245,234,225,236,235,232,243,242,229,240,239,226,237,236,233,244,243,230,241,240,227,238,237,234,245,244,224,235,156,231,242,241,241,252,251,238,249,248,245,256,255,235,246,156,242,253,252,239,250,249,179,256,245,236,247,246,243,254,253,240,251,250,237,248,247,244,255,254,251,260,259,248,1,0,255,264,263,252,261,260,249,258,1,256,265,264,246,257,156,253,262,261,250,259,258,179,265,256,247,0,257,254,263,262,261,7,260,258,4,1,265,11,264,262,8,261,259,5,258,0,2,257,263,9,262,260,6,259,1,3,0,264,10,263,6,16,5,3,13,2,10,20,9,7,17,6,4,14,3,11,21,10,8,18,7,5,15,4,12,22,11,9,19,8,16,26,15,23,33,22,20,30,19,17,27,16,14,24,13,21,31,20,18,28,17,15,25,14,22,32,21,19,29,18,29,39,28,26,36,25,33,43,32,30,40,29,27,37,26,34,44,33,31,41,30,28,38,27,25,35,24,32,42,31,39,49,38,36,46,35,43,53,42,40,50,39,37,47,36,44,54,43,41,51,40,38,48,37,45,55,44,42,52,41,52,62,51,49,59,48,56,66,55,53,63,52,50,60,49,47,57,46,54,64,53,51,61,50,48,58,47,55,65,54,62,72,61,59,69,58,66,76,65,63,73,62,60,70,59,67,77,66,64,74,63,61,71,60,58,68,57,65,75,64,75,85,74,72,82,71,69,79,68,76,86,75,73,83,72,70,80,69,77,87,76,74,84,73,71,81,70,78,88,77,85,95,84,82,92,81,89,99,88,86,96,85,83,93,82,80,90,79,87,97,86,84,94,83,81,91,80,88,98,87,98,108,97,95,105,94,92,102,91,99,109,98,96,106,95,93,103,92,100,110,99,97,107,96,94,104,93,91,101,90,108,118,107,105,115,104,102,112,101,109,119,108,106,116,105,103,113,102,110,120,109,107,117,106,104,114,103,111,121,110,121,131,120,118,128,117,115,125,114,122,132,121,119,129,118,116,126,115,113,123,112,120,130,119,117,127,116,114,124,113,124,134,123,131,141,130,128,138,127,125,135,124,132,142,131,129,139,128,126,136,125,133,143,132,130,140,129,127,137,126,144,154,143,141,151,140,138,148,137,135,145,134,142,152,141,139,149,138,136,146,135,143,153,142,140,150,139,137,147,136,147,158,146,154,165,153,151,162,150,148,159,147,155,166,154,152,163,151,149,160,148,146,157,145,153,164,152,150,161,149,158,168,157,165,175,164,162,172,161,159,169,158,166,176,165,163,173,162,160,170,159,167,177,166,164,174,163,161,171,160,171,182,170,178,189,177,175,186,174,172,183,171,169,180,168,176,187,175,173,184,172,170,181,169,177,188,176,174,185,173,182,192,181,189,199,188,186,196,185,183,193,182,190,200,189,187,197,186,184,194,183,181,191,180,188,198,187,185,195,184,195,205,194,192,202,191,199,209,198,196,206,195,193,203,192,200,210,199,197,207,196,194,204,193,201,211,200,198,208,197,205,215,204,212,222,211,209,219,208,206,216,205,203,213,202,210,220,209,207,217,206,204,214,203,211,221,210,208,218,207,218,228,217,215,225,214,222,232,221,219,229,218,216,226,215,223,233,222,220,230,219,217,227,216,214,224,213,221,231,220,228,238,227,225,235,224,232,242,231,229,239,228,226,236,225,233,243,232,230,240,229,227,237,226,234,244,233,231,241,230,241,251,240,238,248,237,245,255,244,242,252,241,239,249,238,236,246,235,243,253,242,240,250,239,237,247,236,244,254,243,251,259,250,248,0,247,255,263,254,252,260,251,249,1,248,256,264,255,253,261,252,250,258,249,247,257,246,254,262,253];
iron_data_ConstData.skydomePos = [0.0,0.5,0.86603,0.0,0.70711,0.70711,0.06699,0.25,0.96593,0.12941,0.48296,0.86603,0.18301,0.68301,0.70711,0.22414,0.83652,0.5,0.25,0.93301,0.25882,0.25882,0.96593,-0.0,0.25,0.93301,-0.25882,0.22414,0.83652,-0.5,0.18301,0.68301,-0.70711,0.12941,0.48296,-0.86603,0.06699,0.25,-0.96593,0.12941,0.22414,0.96593,0.25,0.43301,0.86603,0.35355,0.61237,0.70711,0.43301,0.75,0.5,0.48296,0.83652,0.25882,0.5,0.86603,-0.0,0.48296,0.83652,-0.25882,0.43301,0.75,-0.5,0.35355,0.61237,-0.70711,0.25,0.43301,-0.86603,0.12941,0.22414,-0.96593,0.18301,0.18301,0.96593,0.35355,0.35355,0.86603,0.5,0.5,0.70711,0.61237,0.61237,0.5,0.68301,0.68301,0.25882,0.70711,0.70711,-0.0,0.68301,0.68301,-0.25882,0.61237,0.61237,-0.5,0.5,0.5,-0.70711,0.35355,0.35355,-0.86603,0.18301,0.18301,-0.96593,0.22414,0.12941,0.96593,0.43301,0.25,0.86603,0.61237,0.35355,0.70711,0.75,0.43301,0.5,0.83652,0.48296,0.25882,0.86603,0.5,-0.0,0.83652,0.48296,-0.25882,0.75,0.43301,-0.5,0.61237,0.35355,-0.70711,0.43301,0.25,-0.86603,0.22414,0.12941,-0.96593,0.25,0.06699,0.96593,0.48296,0.12941,0.86603,0.68301,0.18301,0.70711,0.83652,0.22414,0.5,0.93301,0.25,0.25882,0.96593,0.25882,-0.0,0.93301,0.25,-0.25882,0.83652,0.22414,-0.5,0.68301,0.18301,-0.70711,0.48296,0.12941,-0.86603,0.25,0.06699,-0.96593,0.25882,-0.0,0.96593,0.5,-0.0,0.86603,0.70711,-0.0,0.70711,0.86603,0.0,0.5,0.96593,-0.0,0.25882,1.0,-0.0,-0.0,0.96593,-0.0,-0.25882,0.86603,-0.0,-0.5,0.70711,-0.0,-0.70711,0.5,-0.0,-0.86603,0.25882,-0.0,-0.96593,0.25,-0.06699,0.96593,0.48296,-0.12941,0.86603,0.68301,-0.18301,0.70711,0.83652,-0.22414,0.5,0.93301,-0.25,0.25882,0.96593,-0.25882,-0.0,0.93301,-0.25,-0.25882,0.83652,-0.22414,-0.5,0.68301,-0.18301,-0.70711,0.48296,-0.12941,-0.86603,0.25,-0.06699,-0.96593,0.22414,-0.12941,0.96593,0.43301,-0.25,0.86603,0.61237,-0.35355,0.70711,0.75,-0.43301,0.5,0.83652,-0.48296,0.25882,0.86603,-0.5,-0.0,0.83652,-0.48296,-0.25882,0.75,-0.43301,-0.5,0.61237,-0.35355,-0.70711,0.43301,-0.25,-0.86603,0.22414,-0.12941,-0.96593,0.18301,-0.18301,0.96593,0.35355,-0.35355,0.86603,0.5,-0.5,0.70711,0.61237,-0.61237,0.5,0.68301,-0.68301,0.25882,0.70711,-0.70711,-0.0,0.68301,-0.68301,-0.25882,0.61237,-0.61237,-0.5,0.5,-0.5,-0.70711,0.35355,-0.35355,-0.86603,0.18301,-0.18301,-0.96593,0.12941,-0.22414,0.96593,0.25,-0.43301,0.86603,0.35355,-0.61237,0.70711,0.43301,-0.75,0.5,0.48296,-0.83652,0.25882,0.5,-0.86603,-0.0,0.48296,-0.83652,-0.25882,0.43301,-0.75,-0.5,0.35355,-0.61237,-0.70711,0.25,-0.43301,-0.86603,0.12941,-0.22414,-0.96593,0.06699,-0.25,0.96593,0.12941,-0.48296,0.86603,0.18301,-0.68301,0.70711,0.22414,-0.83652,0.5,0.25,-0.93301,0.25882,0.25882,-0.96593,-0.0,0.25,-0.93301,-0.25882,0.22414,-0.83652,-0.5,0.18301,-0.68301,-0.70711,0.12941,-0.48296,-0.86603,0.06699,-0.25,-0.96593,0.0,-0.25882,0.96593,-0.0,-0.5,0.86603,0.0,-0.70711,0.70711,0.0,-0.86603,0.5,0.0,-0.96593,0.25882,-0.0,-1.0,-0.0,0.0,-0.96593,-0.25882,0.0,-0.86603,-0.5,0.0,-0.70711,-0.70711,0.0,-0.5,-0.86603,0.0,-0.25882,-0.96593,-0.06699,-0.25,0.96593,-0.12941,-0.48296,0.86603,-0.18301,-0.68301,0.70711,-0.22414,-0.83652,0.5,-0.25,-0.93301,0.25882,-0.25882,-0.96593,-0.0,-0.25,-0.93301,-0.25882,-0.22414,-0.83652,-0.5,-0.18301,-0.68301,-0.70711,-0.12941,-0.48296,-0.86603,-0.06699,-0.25,-0.96593,-0.12941,-0.22414,0.96593,-0.25,-0.43301,0.86603,-0.35355,-0.61237,0.70711,-0.43301,-0.75,0.5,-0.48296,-0.83652,0.25882,-0.5,-0.86603,-0.0,-0.48296,-0.83652,-0.25882,-0.43301,-0.75,-0.5,-0.35355,-0.61237,-0.70711,-0.25,-0.43301,-0.86603,-0.12941,-0.22414,-0.96593,-0.0,-0.0,1.0,-0.18301,-0.18301,0.96593,-0.35355,-0.35355,0.86603,-0.5,-0.5,0.70711,-0.61237,-0.61237,0.5,-0.68301,-0.68301,0.25882,-0.70711,-0.70711,-0.0,-0.68301,-0.68301,-0.25882,-0.61237,-0.61237,-0.5,-0.5,-0.5,-0.70711,-0.35355,-0.35355,-0.86603,-0.18301,-0.18301,-0.96593,-0.22414,-0.12941,0.96593,-0.43301,-0.25,0.86603,-0.61237,-0.35355,0.70711,-0.75,-0.43301,0.5,-0.83652,-0.48296,0.25882,-0.86602,-0.5,-0.0,-0.83652,-0.48296,-0.25882,-0.75,-0.43301,-0.5,-0.61237,-0.35355,-0.70711,-0.43301,-0.25,-0.86603,-0.22414,-0.12941,-0.96593,0.0,-0.0,-1.0,-0.25,-0.06699,0.96593,-0.48296,-0.12941,0.86603,-0.68301,-0.18301,0.70711,-0.83652,-0.22414,0.5,-0.93301,-0.25,0.25882,-0.96593,-0.25882,-0.0,-0.93301,-0.25,-0.25882,-0.83652,-0.22414,-0.5,-0.68301,-0.18301,-0.70711,-0.48296,-0.12941,-0.86603,-0.25,-0.06699,-0.96593,-0.25882,-0.0,0.96593,-0.5,-0.0,0.86603,-0.70711,-0.0,0.70711,-0.86603,-0.0,0.5,-0.96593,-0.0,0.25882,-1.0,-0.0,-0.0,-0.96593,-0.0,-0.25882,-0.86603,-0.0,-0.5,-0.70711,-0.0,-0.70711,-0.5,-0.0,-0.86603,-0.25882,-0.0,-0.96593,-0.25,0.06699,0.96593,-0.48296,0.12941,0.86603,-0.68301,0.18301,0.70711,-0.83652,0.22414,0.5,-0.93301,0.25,0.25882,-0.96593,0.25882,-0.0,-0.93301,0.25,-0.25882,-0.83652,0.22414,-0.5,-0.68301,0.18301,-0.70711,-0.48296,0.12941,-0.86603,-0.25,0.06699,-0.96593,-0.22414,0.12941,0.96593,-0.43301,0.25,0.86603,-0.61237,0.35355,0.70711,-0.75,0.43301,0.5,-0.83652,0.48296,0.25882,-0.86602,0.5,-0.0,-0.83652,0.48296,-0.25882,-0.75,0.43301,-0.5,-0.61237,0.35355,-0.70711,-0.43301,0.25,-0.86603,-0.22414,0.12941,-0.96593,-0.18301,0.18301,0.96593,-0.35355,0.35355,0.86603,-0.5,0.5,0.70711,-0.61237,0.61237,0.5,-0.68301,0.68301,0.25882,-0.70711,0.70711,-0.0,-0.68301,0.68301,-0.25882,-0.61237,0.61237,-0.5,-0.5,0.5,-0.70711,-0.35355,0.35355,-0.86603,-0.18301,0.18301,-0.96593,-0.12941,0.22414,0.96593,-0.25,0.43301,0.86603,-0.35355,0.61237,0.70711,-0.43301,0.75,0.5,-0.48296,0.83652,0.25882,-0.5,0.86602,-0.0,-0.48296,0.83652,-0.25882,-0.43301,0.75,-0.5,-0.35355,0.61237,-0.70711,-0.25,0.43301,-0.86603,-0.12941,0.22414,-0.96593,-0.06699,0.25,0.96593,-0.12941,0.48296,0.86603,-0.18301,0.68301,0.70711,-0.22414,0.83652,0.5,-0.25,0.93301,0.25882,-0.25882,0.96593,-0.0,-0.25,0.93301,-0.25882,-0.22414,0.83652,-0.5,-0.18301,0.68301,-0.70711,-0.12941,0.48296,-0.86603,-0.06699,0.25,-0.96593,-0.0,0.25882,0.96593,-0.0,0.86603,0.5,-0.0,0.96593,0.25882,0.0,1.0,-0.0,-0.0,0.96593,-0.25882,-0.0,0.86603,-0.5,0.0,0.70711,-0.70711,0.0,0.5,-0.86603,-0.0,0.25882,-0.96593];
iron_data_ConstData.skydomeNor = [0.0,-0.50807,-0.86132,0.0,-0.71246,-0.70172,-0.0696,-0.25975,-0.96317,-0.1315,-0.49075,-0.86132,-0.1844,-0.68818,-0.70172,-0.22483,-0.83909,-0.49536,-0.25018,-0.9337,-0.25615,-0.25882,-0.96593,-0.0,-0.25018,-0.9337,0.25615,-0.22483,-0.83909,0.49536,-0.1844,-0.68818,0.70172,-0.1315,-0.49075,0.86132,-0.0696,-0.25975,0.96317,-0.13445,-0.23288,-0.96317,-0.25403,-0.44,-0.86132,-0.35623,-0.61701,-0.70172,-0.43434,-0.75231,-0.49536,-0.48332,-0.83713,-0.25615,-0.5,-0.86603,0.0,-0.48332,-0.83713,0.25615,-0.43434,-0.75231,0.49536,-0.35623,-0.61701,0.70172,-0.25403,-0.44,0.86132,-0.13445,-0.23288,0.96317,-0.19015,-0.19015,-0.96317,-0.35926,-0.35926,-0.86132,-0.50378,-0.50378,-0.70172,-0.61426,-0.61426,-0.49536,-0.68352,-0.68352,-0.25615,-0.70711,-0.70711,0.0,-0.68352,-0.68352,0.25615,-0.61426,-0.61426,0.49536,-0.50378,-0.50378,0.70172,-0.35926,-0.35926,0.86132,-0.19015,-0.19015,0.96317,-0.23288,-0.13445,-0.96317,-0.44,-0.25403,-0.86132,-0.61701,-0.35623,-0.70172,-0.75231,-0.43434,-0.49536,-0.83713,-0.48332,-0.25615,-0.86603,-0.5,0.0,-0.83713,-0.48332,0.25615,-0.75231,-0.43434,0.49536,-0.61701,-0.35623,0.70172,-0.44,-0.25403,0.86132,-0.23288,-0.13445,0.96317,-0.25975,-0.0696,-0.96317,-0.49075,-0.1315,-0.86132,-0.68818,-0.1844,-0.70172,-0.83909,-0.22483,-0.49536,-0.9337,-0.25018,-0.25615,-0.96593,-0.25882,0.0,-0.9337,-0.25018,0.25615,-0.83909,-0.22483,0.49536,-0.68818,-0.1844,0.70172,-0.49075,-0.1315,0.86132,-0.25975,-0.0696,0.96317,-0.26891,-0.0,-0.96317,-0.50807,0.0,-0.86132,-0.71246,0.0,-0.70172,-0.86869,-0.0,-0.49536,-0.96664,0.0,-0.25615,-1.0,0.0,0.0,-0.96664,0.0,0.25615,-0.86869,0.0,0.49536,-0.71246,0.0,0.70172,-0.50807,0.0,0.86132,-0.26891,-0.0,0.96317,-0.25975,0.0696,-0.96317,-0.49075,0.1315,-0.86132,-0.68818,0.1844,-0.70172,-0.83909,0.22483,-0.49536,-0.9337,0.25018,-0.25615,-0.96593,0.25882,0.0,-0.9337,0.25018,0.25615,-0.83909,0.22483,0.49536,-0.68818,0.1844,0.70172,-0.49075,0.1315,0.86132,-0.25975,0.0696,0.96317,-0.23288,0.13445,-0.96317,-0.44,0.25403,-0.86132,-0.61701,0.35623,-0.70172,-0.75231,0.43434,-0.49536,-0.83713,0.48332,-0.25615,-0.86603,0.5,0.0,-0.83713,0.48332,0.25615,-0.75231,0.43434,0.49536,-0.61701,0.35623,0.70172,-0.44,0.25403,0.86132,-0.23288,0.13445,0.96317,-0.19015,0.19015,-0.96317,-0.35926,0.35926,-0.86132,-0.50378,0.50378,-0.70172,-0.61426,0.61426,-0.49536,-0.68352,0.68352,-0.25615,-0.70711,0.70711,0.0,-0.68352,0.68352,0.25615,-0.61426,0.61426,0.49536,-0.50378,0.50378,0.70172,-0.35926,0.35926,0.86132,-0.19015,0.19015,0.96317,-0.13445,0.23288,-0.96317,-0.25403,0.44,-0.86132,-0.35623,0.61701,-0.70172,-0.43434,0.75231,-0.49536,-0.48332,0.83713,-0.25615,-0.5,0.86603,0.0,-0.48332,0.83713,0.25615,-0.43434,0.75231,0.49536,-0.35623,0.61701,0.70172,-0.25403,0.44,0.86132,-0.13445,0.23288,0.96317,-0.0696,0.25975,-0.96317,-0.1315,0.49075,-0.86132,-0.1844,0.68818,-0.70172,-0.22483,0.83909,-0.49536,-0.25018,0.9337,-0.25615,-0.25882,0.96593,0.0,-0.25018,0.9337,0.25615,-0.22483,0.83909,0.49536,-0.1844,0.68818,0.70172,-0.1315,0.49075,0.86132,-0.0696,0.25975,0.96317,-0.0,0.26891,-0.96317,0.0,0.50807,-0.86132,0.0,0.71246,-0.70172,-0.0,0.86869,-0.49536,0.0,0.96664,-0.25615,0.0,1.0,0.0,-0.0,0.96664,0.25615,0.0,0.86869,0.49536,0.0,0.71246,0.70172,0.0,0.50807,0.86132,0.0,0.26891,0.96317,0.0696,0.25975,-0.96317,0.1315,0.49075,-0.86132,0.1844,0.68818,-0.70172,0.22483,0.83909,-0.49536,0.25018,0.9337,-0.25615,0.25882,0.96593,0.0,0.25018,0.9337,0.25615,0.22483,0.83909,0.49536,0.1844,0.68818,0.70172,0.1315,0.49075,0.86132,0.0696,0.25975,0.96317,0.13445,0.23288,-0.96317,0.25403,0.44,-0.86132,0.35623,0.61701,-0.70172,0.43434,0.75231,-0.49536,0.48332,0.83713,-0.25615,0.5,0.86603,0.0,0.48332,0.83713,0.25615,0.43434,0.75231,0.49536,0.35623,0.61701,0.70172,0.25403,0.44,0.86132,0.13445,0.23288,0.96317,0.0,0.0,-1.0,0.19015,0.19015,-0.96317,0.35926,0.35926,-0.86132,0.50378,0.50378,-0.70172,0.61426,0.61426,-0.49536,0.68352,0.68352,-0.25615,0.70711,0.70711,0.0,0.68352,0.68352,0.25615,0.61426,0.61426,0.49536,0.50378,0.50378,0.70172,0.35926,0.35926,0.86132,0.19015,0.19015,0.96317,0.23288,0.13445,-0.96317,0.44,0.25403,-0.86132,0.61701,0.35623,-0.70172,0.75231,0.43434,-0.49536,0.83713,0.48332,-0.25615,0.86603,0.5,0.0,0.83713,0.48332,0.25615,0.75231,0.43434,0.49536,0.61701,0.35623,0.70172,0.44,0.25403,0.86132,0.23288,0.13445,0.96317,0.0,-0.0,1.0,0.25975,0.0696,-0.96317,0.49075,0.1315,-0.86132,0.68818,0.1844,-0.70172,0.83909,0.22483,-0.49536,0.9337,0.25018,-0.25615,0.96593,0.25882,0.0,0.9337,0.25018,0.25615,0.83909,0.22483,0.49536,0.68818,0.1844,0.70172,0.49075,0.1315,0.86132,0.25975,0.0696,0.96317,0.26891,-0.0,-0.96317,0.50807,-0.0,-0.86132,0.71246,0.0,-0.70172,0.86869,0.0,-0.49536,0.96664,-0.0,-0.25615,1.0,-0.0,0.0,0.96664,0.0,0.25615,0.86869,0.0,0.49536,0.71246,-0.0,0.70172,0.50807,0.0,0.86132,0.26891,-0.0,0.96317,0.25975,-0.0696,-0.96317,0.49075,-0.1315,-0.86132,0.68818,-0.1844,-0.70172,0.83909,-0.22483,-0.49536,0.9337,-0.25018,-0.25615,0.96593,-0.25882,0.0,0.9337,-0.25018,0.25615,0.83909,-0.22483,0.49536,0.68818,-0.1844,0.70172,0.49075,-0.1315,0.86132,0.25975,-0.0696,0.96317,0.23288,-0.13445,-0.96317,0.44,-0.25403,-0.86132,0.61701,-0.35623,-0.70172,0.75231,-0.43434,-0.49536,0.83713,-0.48332,-0.25615,0.86603,-0.5,0.0,0.83713,-0.48332,0.25615,0.75231,-0.43434,0.49536,0.617,-0.35623,0.70172,0.44,-0.25403,0.86132,0.23288,-0.13445,0.96317,0.19015,-0.19015,-0.96317,0.35926,-0.35926,-0.86132,0.50378,-0.50378,-0.70172,0.61426,-0.61426,-0.49536,0.68352,-0.68352,-0.25615,0.70711,-0.70711,-0.0,0.68352,-0.68352,0.25615,0.61426,-0.61426,0.49536,0.50378,-0.50378,0.70172,0.35926,-0.35926,0.86132,0.19015,-0.19015,0.96317,0.13445,-0.23288,-0.96317,0.25403,-0.44,-0.86132,0.35623,-0.61701,-0.70172,0.43434,-0.75231,-0.49536,0.48332,-0.83713,-0.25615,0.5,-0.86603,0.0,0.48332,-0.83713,0.25615,0.43434,-0.75231,0.49536,0.35623,-0.617,0.70172,0.25403,-0.44,0.86132,0.13445,-0.23288,0.96317,0.0696,-0.25975,-0.96317,0.1315,-0.49075,-0.86132,0.1844,-0.68818,-0.70172,0.22483,-0.83909,-0.49536,0.25018,-0.9337,-0.25615,0.25882,-0.96593,0.0,0.25018,-0.9337,0.25615,0.22483,-0.83909,0.49536,0.1844,-0.68818,0.70172,0.1315,-0.49075,0.86132,0.0696,-0.25975,0.96317,0.0,-0.26891,-0.96317,0.0,-0.86869,-0.49536,0.0,-0.96664,-0.25615,0.0,-1.0,-0.0,0.0,-0.96664,0.25615,0.0,-0.86869,0.49536,0.0,-0.71246,0.70172,0.0,-0.50807,0.86132,0.0,-0.26891,0.96317];
iron_data_MaterialData.uidCounter = 0;
iron_data_MaterialContext.num = 0;
iron_data_ShaderData.shaderPath = "../krom-resources/";
iron_math_RayCaster.VPInv = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
iron_math_RayCaster.PInv = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
iron_math_RayCaster.VInv = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
iron_object_Animation._hx_skip_constructor = false;
iron_object_CameraObject.temp = new iron_math_Vec4();
iron_object_CameraObject.sphereCenter = new iron_math_Vec4();
iron_object_CameraObject.vcenter = new iron_math_Vec4();
iron_object_CameraObject.vup = new iron_math_Vec4();
iron_object_LightObject.eye = new iron_math_Vec4();
iron_object_Transform.temp = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
iron_object_Transform.q = new iron_math_Quat();
iron_object_Uniforms.biasMat = new iron_math_Mat4(0.5,0.0,0.0,0.5,0.0,-0.5,0.0,0.5,0.0,0.0,0.5,0.5,0.0,0.0,0.0,1.0);
iron_object_Uniforms.helpMat = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
iron_object_Uniforms.helpMat2 = new iron_math_Mat4(1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
iron_object_Uniforms.helpMat3 = new iron_math_Mat3(1,0,0,0,1,0,0,0,1);
iron_object_Uniforms.helpVec = new iron_math_Vec4();
iron_object_Uniforms.helpVec2 = new iron_math_Vec4();
iron_object_Uniforms.helpQuat = new iron_math_Quat();
iron_object_Uniforms.defaultFilter = 1;
iron_system_VirtualInput._hx_skip_constructor = false;
iron_system_Mouse.buttons = ["left","right","middle"];
iron_system_Keyboard.keys = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","space","backspace","tab","enter","shift","control","alt","win","escape","delete","up","down","left","right","back",",",".",":",";","<","=",">","?","!","\"","#","$","%","&","_","(",")","*","|","{","}","[","]","~","`","/","\\","@","+","-","f1","f2","f3","f4","f5","f6","f7","f8","f9","f10","f11","f12"];
iron_system_Gamepad.buttonsPS = ["cross","circle","square","triangle","l1","r1","l2","r2","share","options","l3","r3","up","down","left","right","home","touchpad"];
iron_system_Gamepad.buttons = iron_system_Gamepad.buttonsPS;
kha_Display.displays = [];
kha_Shaders.vertexShaders = new haxe_ds_StringMap();
kha_Shaders.fragmentShaders = new haxe_ds_StringMap();
kha_Shaders.ext = ".d3d11";
kha_System.renderListeners = [];
kha_System.foregroundListeners = [];
kha_System.resumeListeners = [];
kha_System.pauseListeners = [];
kha_System.backgroundListeners = [];
kha_System.shutdownListeners = [];
kha_System.dropFilesListeners = [];
kha_System.maxGamepads = 4;
kha_System.mouseLockListeners = [];
kha_Window.windows = [];
kha_arrays_ByteArray.LITTLE_ENDIAN = new Uint8Array(new Uint32Array([0x12345678]).buffer)[0] === 0x78;
kha_graphics2_Graphics.fontGlyphs = (function($this) {
	var $r;
	let _g = [];
	{
		let _g1 = 32;
		while(_g1 < 256) _g.push(_g1++);
	}
	$r = _g;
	return $r;
}(this));
kha_graphics2_Graphics.thrown = false;
kha_graphics4_Graphics.mat = new Float32Array(16);
kha_input_Gamepad.__meta__ = { statics : { sendConnectEvent : { input : null}, sendDisconnectEvent : { input : null}}, fields : { sendAxisEvent : { input : null}, sendButtonEvent : { input : null}}};
kha_input_Gamepad.instances = [];
kha_input_Gamepad.connectListeners = [];
kha_input_Gamepad.disconnectListeners = [];
kha_input_Keyboard.__meta__ = { fields : { sendDownEvent : { input : null}, sendUpEvent : { input : null}, sendPressEvent : { input : null}}};
kha_input_Mouse.__meta__ = { fields : { sendLeaveEvent : { input : null}, sendDownEvent : { input : null}, sendUpEvent : { input : null}, sendMoveEvent : { input : null}, sendWheelEvent : { input : null}}};
zui_Nodes.elementsBaked = false;
zui_Nodes.socketReleased = false;
zui_Nodes.clipboard = "";
zui_Nodes.boxSelect = false;
zui_Nodes.boxSelectX = 0;
zui_Nodes.boxSelectY = 0;
zui_Nodes.excludeRemove = [];
zui_Themes.dark = { NAME : "Default Dark", WINDOW_BG_COL : -14079703, WINDOW_TINT_COL : -1, ACCENT_COL : -13027015, ACCENT_HOVER_COL : -12369085, ACCENT_SELECT_COL : -11513776, BUTTON_COL : -13092808, BUTTON_TEXT_COL : -1513499, BUTTON_HOVER_COL : -11974327, BUTTON_PRESSED_COL : -15000805, TEXT_COL : -1513499, LABEL_COL : -3618616, SEPARATOR_COL : -14671840, HIGHLIGHT_COL : -14656100, CONTEXT_COL : -14540254, PANEL_BG_COL : -12895429, FONT_SIZE : 13, ELEMENT_W : 100, ELEMENT_H : 24, ELEMENT_OFFSET : 4, ARROW_SIZE : 5, BUTTON_H : 22, CHECK_SIZE : 15, CHECK_SELECT_SIZE : 8, SCROLL_W : 9, TEXT_OFFSET : 8, TAB_W : 6, FILL_WINDOW_BG : false, FILL_BUTTON_BG : true, FILL_ACCENT_BG : false, LINK_STYLE : 0, FULL_TABS : false};
Main.main();
})(typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this, typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this);
