Browse Source

fixes wrt quaternion direction fix

Nicolas Cannasse 4 years ago
parent
commit
3c9be554a5
2 changed files with 3 additions and 14 deletions
  1. 3 3
      hide/view/Model.hx
  2. 0 11
      hide/view/shadereditor/ShaderEditor.hx

+ 3 - 3
hide/view/Model.hx

@@ -130,7 +130,7 @@ class Model extends FileView {
 			l.kind = Directional;
 			l.kind = Directional;
 			l.power = 1.5;
 			l.power = 1.5;
 			var q = new h3d.Quat();
 			var q = new h3d.Quat();
-			q.initDirection(new h3d.Vector(-1,-1.5,-3));
+			q.initDirection(new h3d.Vector(-0.28,0.83,-0.47));
 			var a = q.toEuler();
 			var a = q.toEuler();
 			l.rotationX = Math.round(a.x * 180 / Math.PI);
 			l.rotationX = Math.round(a.x * 180 / Math.PI);
 			l.rotationY = Math.round(a.y * 180 / Math.PI);
 			l.rotationY = Math.round(a.y * 180 / Math.PI);
@@ -341,7 +341,7 @@ class Model extends FileView {
 		plight = root.getAll(hrt.prefab.Light)[0];
 		plight = root.getAll(hrt.prefab.Light)[0];
 		if( plight != null ) {
 		if( plight != null ) {
 			this.light = sceneEditor.context.shared.contexts.get(plight).local3d;
 			this.light = sceneEditor.context.shared.contexts.get(plight).local3d;
-			lightDirection = this.light.getDirection();
+			lightDirection = this.light.getLocalDirection();
 		}
 		}
 
 
 		undo.onChange = function() {};
 		undo.onChange = function() {};
@@ -674,7 +674,7 @@ class Model extends FileView {
 		saveDisplayState("Camera", { x : cam.pos.x, y : cam.pos.y, z : cam.pos.z, tx : cam.target.x, ty : cam.target.y, tz : cam.target.z });
 		saveDisplayState("Camera", { x : cam.pos.x, y : cam.pos.y, z : cam.pos.z, tx : cam.target.x, ty : cam.target.y, tz : cam.target.z });
 		if( light != null ) {
 		if( light != null ) {
 			if( sceneEditor.isSelected(plight) )
 			if( sceneEditor.isSelected(plight) )
-				lightDirection = light.getDirection();
+				lightDirection = light.getLocalDirection();
 			else {
 			else {
 				var angle = Math.atan2(cam.target.y - cam.pos.y, cam.target.x - cam.pos.x);
 				var angle = Math.atan2(cam.target.y - cam.pos.y, cam.target.x - cam.pos.x);
 				light.setDirection(new h3d.Vector(
 				light.setDirection(new h3d.Vector(

+ 0 - 11
hide/view/shadereditor/ShaderEditor.hx

@@ -33,10 +33,6 @@ class ShaderEditor extends hide.view.Graph {
 
 
 	var root : hrt.prefab.Prefab;
 	var root : hrt.prefab.Prefab;
 	var obj : h3d.scene.Object;
 	var obj : h3d.scene.Object;
-	var plight : hrt.prefab.Prefab;
-	var light : h3d.scene.Object;
-	var lightDirection : h3d.Vector;
-
 	var shaderGraph : ShaderGraph;
 	var shaderGraph : ShaderGraph;
 
 
 	var lastSnapshot : haxe.Json;
 	var lastSnapshot : haxe.Json;
@@ -301,13 +297,6 @@ class ShaderEditor extends hide.view.Graph {
 	}
 	}
 
 
 	function onRefresh() {
 	function onRefresh() {
-
-		plight = root.getAll(hrt.prefab.Light)[0];
-		if( plight != null ) {
-			this.light = sceneEditor.context.shared.contexts.get(plight).local3d;
-			lightDirection = this.light.getDirection();
-		}
-
 		var saveCustomModel = getDisplayState("customModel");
 		var saveCustomModel = getDisplayState("customModel");
 		if (saveCustomModel != null)
 		if (saveCustomModel != null)
 			obj = sceneEditor.scene.loadModel(saveCustomModel, true);
 			obj = sceneEditor.scene.loadModel(saveCustomModel, true);