Ver código fonte

various minor fixes

ncannasse 7 anos atrás
pai
commit
712ea731c8

+ 2 - 0
hide/comp/Scene.hx

@@ -382,6 +382,8 @@ class Scene extends Component implements h3d.IDrawable {
 
 		if( obj == null ) obj = s3d;
 		var b = obj.getBounds();
+		if( b.isEmpty() )
+			return;
 		var dx = Math.max(Math.abs(b.xMax),Math.abs(b.xMin));
 		var dy = Math.max(Math.abs(b.yMax),Math.abs(b.yMin));
 		var dz = Math.max(Math.abs(b.zMax),Math.abs(b.zMin));

+ 10 - 0
hide/tools/MaterialScript.hx

@@ -34,6 +34,12 @@ class Properties extends hxd.impl.Properties {
 		this.interp = interp;
 	}
 
+	public function getFields( o : Dynamic ) {
+		if( o == obj )
+			return Reflect.fields(obj).concat(Lambda.array({ iterator : interp.variables.keys }));
+		return Reflect.fields(o);
+	}
+
 	override function getField( o : Dynamic, f : String ) {
 		if( o == obj && interp.variables.exists(f) )
 			return interp.variables.get(f);
@@ -51,6 +57,7 @@ class Properties extends hxd.impl.Properties {
 class MaterialScript extends h3d.mat.MaterialScript {
 
 	var ide : hide.ui.Ide;
+	public var renderer : Properties;
 
 	public function new() {
 		super(); // name will be set by script itself
@@ -130,6 +137,9 @@ class MaterialScript extends h3d.mat.MaterialScript {
 
 		var fnew = interp.variables.get("new");
 		if( fnew != null ) Reflect.callMethod(null, fnew, args == null ? [] : args);
+
+		renderer = props;
+
 		return obj;
 	}
 

+ 6 - 3
hide/ui/Ide.hx

@@ -44,9 +44,12 @@ class Ide {
 
 		var wp = props.global.current.hide.windowPos;
 		if( wp != null ) {
-			window.resizeBy(wp.w - Std.int(window.window.outerWidth), wp.h - Std.int(window.window.outerHeight));
-			window.moveTo(wp.x, wp.y);
-			if( wp.max ) window.maximize();
+			if( wp.w > 400 && wp.h > 300 )
+				window.resizeBy(wp.w - Std.int(window.window.outerWidth), wp.h - Std.int(window.window.outerHeight));
+			if( wp.x >= 0 && wp.y >= 0 ) {
+				window.moveTo(wp.x, wp.y);
+				if( wp.max ) window.maximize();
+			}
 		}
 		window.show(true);
 

+ 3 - 3
hide/ui/Menu.hx

@@ -12,7 +12,7 @@ class Menu {
 	function buildMenuRec( menu : nw.Menu, path : String, e : Element ) {
 		var cl = e.attr("class");
 		if( cl != null ) {
-			if( path == "" ) path = cl else path = path + "." + cl; 
+			if( path == "" ) path = cl else path = path + "." + cl;
 		}
 		var elt = e.get(0);
 		switch( elt.nodeName ) {
@@ -29,7 +29,7 @@ class Menu {
 			}
 			var label = e.attr("label");
 			if( label == null ) label = "???";
-			var checked = e.attr("checked") == "checked";
+			var checked = e.prop("checked") || e.attr("checked") == "checked";
 			var m = new nw.MenuItem(submenu == null ? { label : label, type : type } : { label : label, type : type, submenu : submenu });
 			if( type == Checkbox )
 				m.checked = checked;
@@ -38,7 +38,7 @@ class Menu {
 			m.click = function() {
 				if( type == Checkbox ) {
 					checked = !checked;
-					e.attr("checked", checked ? "checked" : "");
+					e.prop("checked", checked);
 					m.checked = checked;
 				}
 				e.click();

+ 1 - 0
hide/ui/View.hx

@@ -118,6 +118,7 @@ class View<T> extends hide.comp.Component {
 			}
 		syncTitle();
 		root.html('');
+		root.off();
 		onDisplay();
 	}
 

+ 2 - 1
hide/view/FileView.hx

@@ -7,7 +7,8 @@ class FileView extends hide.ui.View<{ path : String }> {
 
 	public function new(state) {
 		super(state);
-		watch(state.path, function() onFileChanged(!sys.FileSystem.exists(ide.getPath(state.path))), { checkDelete : true, keepOnRebuild : true });
+		if( state.path != null )
+			watch(state.path, function() onFileChanged(!sys.FileSystem.exists(ide.getPath(state.path))), { checkDelete : true, keepOnRebuild : true });
 	}
 
 	function onFileChanged( wasDeleted : Bool ) {

+ 4 - 1
hide/view/Particles3D.hx

@@ -166,7 +166,9 @@ class Particles3D extends FileView {
 		bounds = new h3d.scene.Box(0x808080, parts.bounds, parts);
 		bounds.visible = false;
 		initProperties();
-		scene.resetCamera(2);
+		haxe.Timer.delay(function() {
+			scene.resetCamera(2);
+		}, 0);
 		new h3d.scene.CameraController(scene.s3d).loadFromCamera();
 		scene.init(props);
 
@@ -203,6 +205,7 @@ class Particles3D extends FileView {
 					<dt>Show Bounds</dt><dd><input type="checkbox" class="bounds"/></dd>
 					<dt>Enable Lights</dt><dd><input type="checkbox" class="lights" checked="checked"/></dd>
 					<dt></dt><dd><input type="button" class="new" value="New Group"/></dd>
+					<dt></dt><dd><input type="button" class="reset" value="Reset Camera"/></dd>
 					</dl>
 				</div>
 			</div>