Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for multiple cameras. camera switching #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jacokotze
Copy link

@jacokotze jacokotze commented Mar 18, 2023

Add support for multiple cameras whilst keeping a predefined camera.

Semi-breaking due to needing users to use g3d.camera.current() in order to retrieve the current camera.

Move Camera to an object, with the static component tracking the "current" active camera.

Additionally models may now specify a camera to draw with, defaulting to the current active camera.

Tested in a local project roughly :

local g3d = require('g3d')
local cameras = { "camA"=g3d.camera.current(); "camB"=g3d.camera.newCamera() };

function love.load()
 cameraUsed = "camA"
end

function love.keypressed(key, scancode)
 if key == "f" then
  if cameraUsed == "camA" then
   cameraUsed = "camB"
  else
   cameraUsed = "camA"
  end
  g3d.camera.setCurrent(cameras[cameraUsed])
 end
end

-- love.draw(); love.update() as per demo

Causes the game to switch between cameras.

Could be useful when using multiple view games (in game cctv etc)

@jacokotze jacokotze marked this pull request as ready for review March 18, 2023 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant