浏览代码

Make sure to reset projection when unloading example

Björn Ritzl 6 年之前
父节点
当前提交
7b2e054350
共有 3 个文件被更改,包括 25 次插入4 次删除
  1. 18 0
      examples/_main/loader.go
  2. 4 0
      examples/_main/loader.script
  3. 3 4
      examples/_main/menu.gui_script

+ 18 - 0
examples/_main/loader.go

@@ -514,3 +514,21 @@ embedded_components {
     w: 1.0
   }
 }
+embedded_components {
+  id: "render/camera"
+  type: "collectionproxy"
+  data: "collection: \"/examples/render/camera/camera.collection\"\n"
+  "exclude: false\n"
+  ""
+  position {
+    x: 0.0
+    y: 0.0
+    z: 0.0
+  }
+  rotation {
+    x: 0.0
+    y: 0.0
+    z: 0.0
+    w: 1.0
+  }
+}

+ 4 - 0
examples/_main/loader.script

@@ -21,6 +21,10 @@ function on_message(self, message_id, message, sender)
 		msg.post(self.current_proxy, "disable")
 		msg.post(self.current_proxy, "final")
 		msg.post(self.current_proxy, "unload")
+		-- reset projection if an example might have modified it
+		local view = vmath.matrix4()
+		local projection = vmath.matrix4_orthographic(0, tonumber(sys.get_config("display.width")), 0, tonumber(sys.get_config("display.height")), -1, 1)
+		msg.post("@render:", "set_view_projection", { id = hash("camera"), view = view, projection = projection })
 	elseif message_id == hash("proxy_loaded") then
 		msg.post(self.current_proxy, "init")
 		msg.post(self.current_proxy, "enable")

+ 3 - 4
examples/_main/menu.gui_script

@@ -99,7 +99,7 @@ local function show_category(self, category)
 end
 
 function init(self)
-	self.index = { "basics", "physics", "animation", "gui", "input", "particles", "sound", "render", "camera", "debug" }
+	self.index = { "basics", "physics", "animation", "gui", "input", "particles", "sound", "render", "debug" }
 	self.index["basics"] = { "simple_move", "message_passing", "follow", "parent_child", "spawn", "z_order" }
 	self.index["physics"] = { "dynamic", "kinematic", "raycast", "trigger" }
 	self.index["animation"] = { "spinner", "flipbook", "tween", "spine" }
@@ -107,10 +107,9 @@ function init(self)
 	self.index["input"] = { "move", "text", "down duration" }
 	self.index["particles"] = { "particlefx", "modifiers" }
 	self.index["sound"] = { "music", "fade_in_out" }
-	self.index["render"] = { "lorem ipsum" }
-	self.index["camera"] = { "lorem ipsum" }
+	self.index["render"] = { "camera" }
 	self.index["debug"] = { "physics", "profile" }
-
+	
 	self.examples = {}
 	self.categories = {}