瀏覽代碼

added applyProps support

Nicolas Cannasse 8 年之前
父節點
當前提交
f0175c82ea
共有 1 個文件被更改,包括 18 次插入4 次删除
  1. 18 4
      h3d/mat/MaterialScript.hx

+ 18 - 4
h3d/mat/MaterialScript.hx

@@ -19,11 +19,27 @@ class MaterialScript extends MaterialSetup {
 		return v;
 	}
 
+
+	function initVars() {
+		#if js
+		variables.set("Element", js.jquery.JQuery);
+		#end
+		variables.set("BlendMode", h3d.mat.BlendMode);
+		variables.set("Blend", h3d.mat.Data.Blend);
+		variables.set("Face", h3d.mat.Data.Face);
+		variables.set("Compare", h3d.mat.Data.Compare);
+		variables.set("Operation", h3d.mat.Data.Operation);
+	}
+
 	#if hscript
 	override function getDefaults(?type:String):Any {
 		return try getVar("getDefaults")(type) catch( e : hscript.Expr.Error ) { onError(Std.string(e)); {}; }
 	}
 
+	override function applyProps(m:Material) {
+		try getVar("applyProps")(m) catch( e : hscript.Expr.Error ) onError(Std.string(e));
+	}
+
 	#if js
 	override function editMaterial( props : Any ) {
 		return try getVar("editMaterial")(props) catch( e : hscript.Expr.Error) { onError(Std.string(e)); new js.jquery.JQuery(); }
@@ -40,11 +56,9 @@ class MaterialScript extends MaterialSetup {
 		var parser = new hscript.Parser();
 		var expr = try parser.parseString(script, fileName) catch( e : hscript.Expr.Error ) { onError(Std.string(e)); return; }
 		var interp = new hscript.Interp();
-		#if js
-		interp.variables.set("Element", js.jquery.JQuery);
-		#end
-		try interp.execute(expr) catch( e : hscript.Expr.Error ) { onError(Std.string(e)); return; }
 		variables = interp.variables;
+		initVars();
+		try interp.execute(expr) catch( e : hscript.Expr.Error ) { onError(Std.string(e)); return; }
 		#end
 		name = getVar("name");
 	}