Selaa lähdekoodia

Update to use new camera api

Jhonny Göransson 9 kuukautta sitten
vanhempi
commit
036c2f88e1

+ 1 - 0
.gitignore

@@ -16,3 +16,4 @@ node_modules/
 
 # Mac
 .DS_Store
+/.editor_settings

+ 6 - 13
examples/render/camera/camera.script

@@ -1,20 +1,13 @@
-function init(self)
-	msg.post("#camera", "acquire_camera_focus") -- <1>
-	msg.post("@render:", "use_camera_projection") -- <2>
-end
-
 function on_message(self, message_id, message, sender)
-	if message_id == hash("follow") then -- <3>
-		go.set_parent(".", sender) -- <4>
-	elseif message_id == hash("unfollow") then -- <5>
+	if message_id == hash("follow") then -- <1>
+		go.set_parent(".", sender) -- <2>
+	elseif message_id == hash("unfollow") then -- <3>
 		go.set_parent("camera", nil, true)
 	end
 end
 
 --[[
-1. Acquire camera focus for the camera component. When a camera has focus it will send view and projection updates to the render script.
-2. Tell the render script to use the view and projection provided by the camera.
-3. Start following the game object that sent the `follow` message.
-4. This is done by parenting the camera component to the game object that sent the message.
-5. Stop following any game object. This is done removing the parent game object while maintaining the current world transform.
+1. Start following the game object that sent the `follow` message.
+2. This is done by parenting the camera component to the game object that sent the message.
+3. Stop following any game object. This is done removing the parent game object while maintaining the current world transform.
 --]]

+ 0 - 2
examples/render/orbit_camera/orbit_camera.script

@@ -8,8 +8,6 @@ go.property("rotation_speed", 0.5)
 go.property("offset", vmath.vector3(0, 0, 0))
 
 function init(self)
-	-- Set the camera projection to be used
-	msg.post("@render:", "use_camera_projection")
 	-- Acquire input focus to receive input events
 	msg.post(".", "acquire_input_focus")
 

+ 3 - 8
examples/render/screen_to_world/bee.script

@@ -5,9 +5,9 @@ local DISPLAY_HEIGHT = sys.get_config_int("display.height")
 -- world coordinates given a camera component
 -- this function will use the camera view and projection to
 -- translate the screen coordinates into world coordinates
-local function screen_to_world(x, y, z, camera)
-	local projection = go.get(camera, "projection")
-	local view = go.get(camera, "view")
+local function screen_to_world(x, y, z, camera_id)
+	local projection = camera.get_projection(camera_id)
+	local view = camera.get_view(camera_id)
 	local w, h = window.get_size()
 	-- The window.get_size() function will return the scaled window size,
 	-- ie taking into account display scaling (Retina screens on macOS for
@@ -27,11 +27,6 @@ local function screen_to_world(x, y, z, camera)
 end
 
 function init(self)
-	-- activate the camera
-	msg.post("#camera", "acquire_camera_focus")
-	-- make sure the render script uses both the view and
-	-- the camera projection when rendering the world
-	msg.post("@render:", "use_camera_projection")
 	-- send input events to this script
 	msg.post(".", "acquire_input_focus")
 end

+ 1 - 1
game.project

@@ -2,7 +2,7 @@
 title = Defold-examples
 version = 0.1
 custom_resources = examples/resource/modify_atlas/resources
-dependencies#0 = https://github.com/defold/extension-spine/archive/refs/tags/3.5.3.zip
+dependencies#0 = https://github.com/defold/extension-spine/archive/refs/tags/3.6.2.zip
 
 [bootstrap]
 main_collection = /examples/main.collectionc