2
0
Эх сурвалжийг харах

added console (/rotate, /stop)

ncannasse 7 жил өмнө
parent
commit
0fb49c7308
1 өөрчлөгдсөн 27 нэмэгдсэн , 0 устгасан
  1. 27 0
      hide/view/Model.hx

+ 27 - 0
hide/view/Model.hx

@@ -19,6 +19,7 @@ class Model extends FileView {
 	var timeline : h2d.Graphics;
 	var timeline : h2d.Graphics;
 	var timecursor : h2d.Bitmap;
 	var timecursor : h2d.Bitmap;
 	var currentAnimation : { file : String, name : String };
 	var currentAnimation : { file : String, name : String };
+	var cameraMove : Void -> Void;
 
 
 	override function onDisplay() {
 	override function onDisplay() {
 		element.html('
 		element.html('
@@ -298,10 +299,34 @@ class Model extends FileView {
 			if( obj.currentAnimation != null ) obj.currentAnimation.speed = v;
 			if( obj.currentAnimation != null ) obj.currentAnimation.speed = v;
 		}, 1, 0, 2);
 		}, 1, 0, 2);
 
 
+		initConsole();
+
 		scene.onResize = buildTimeline;
 		scene.onResize = buildTimeline;
 		setAnimation(null);
 		setAnimation(null);
 	}
 	}
 
 
+	function initConsole() {
+		var c = new h2d.Console(hxd.res.DefaultFont.get(), scene.s2d);
+		c.addCommand("rotate",[{ name : "speed", t : AFloat }], function(r) {
+			cameraMove = function() {
+				var cam = scene.s3d.camera;
+				var dir = cam.pos.sub(cam.target);
+				dir.z = 0;
+				var angle = Math.atan2(dir.y, dir.x);
+				angle += r * hxd.Timer.tmod * 0.01;
+				var ray = dir.length();
+				cam.pos.set(
+					Math.cos(angle) * ray + cam.target.x,
+					Math.sin(angle) * ray + cam.target.y,
+					cam.pos.z);
+				control.loadFromCamera();
+			};
+		});
+		c.addCommand("stop", [], function() {
+			cameraMove = null;
+		});
+	}
+
 	override function buildTabMenu() {
 	override function buildTabMenu() {
 		var menu = super.buildTabMenu();
 		var menu = super.buildTabMenu();
 		var arr : Array<hide.comp.ContextMenu.ContextMenuItem> = [
 		var arr : Array<hide.comp.ContextMenu.ContextMenuItem> = [
@@ -425,6 +450,8 @@ class Model extends FileView {
 		if( timeline != null ) {
 		if( timeline != null ) {
 			timecursor.x = Std.int((obj.currentAnimation.frame / obj.currentAnimation.frameCount) * (scene.s2d.width - timecursor.tile.width));
 			timecursor.x = Std.int((obj.currentAnimation.frame / obj.currentAnimation.frameCount) * (scene.s2d.width - timecursor.tile.width));
 		}
 		}
+		if( cameraMove != null )
+			cameraMove();
 	}
 	}
 
 
 	static var _ = FileTree.registerExtension(Model,["hmd","hsd","fbx"],{ icon : "cube" });
 	static var _ = FileTree.registerExtension(Model,["hmd","hsd","fbx"],{ icon : "cube" });