Skip to content

Instantly share code, notes, and snippets.

@johannesl
Created September 22, 2020 21:53
Show Gist options
  • Save johannesl/6b1024e3d436202583df726812ce9d9e to your computer and use it in GitHub Desktop.
Save johannesl/6b1024e3d436202583df726812ce9d9e to your computer and use it in GitHub Desktop.
My first attempt live coding VR inside VR with indeck and LÖVR! :-)
local m = {}
function m.load()
end
function m.update(dt)
end
function m.draw()
-- draw ground and 12 rotating blocks around world origin
lovr.graphics.setColor(0x243f26)
lovr.graphics.cylinder(0,-1,0, 2, math.pi/2, 1,0,0, 2)
lovr.graphics.setColor(0xcf9733)
for i = 0, 60, 1 do
for angle = 0, math.pi * 2, math.pi / 6 do
local pose = mat4()
pose:rotate(angle + lovr.timer.getTime() / (5-i), 0,1,0) -- rotate over Y axis
pose:translate(0, 0.5+(i*0.3), -2*i) -- move away from origin
pose:scale(0.8, 1.2, 0.1) -- block size
lovr.graphics.box('fill', pose)
end
end
-- draw blocks synced to hand controllers
--lovr.graphics.setColor(0xd2b793)
lovr.graphics.setColor(0xFFFFFF)
for _, handName in ipairs(lovr.headset.getHands()) do
local handPose = mat4(lovr.headset.getPose(handName))
handPose:translate(0, 0, -1)
handPose:scale(0.04, 0.08, 2.12)
lovr.graphics.box('fill', handPose)
end
end
return m
@johannesl
Copy link
Author

20200922-234353

@johannesl
Copy link
Author

The picture is not really making this thing justice though..

  1. VR screenshots never convey the feeling of the scene inside VR.
  2. This thing is animated, I uploaded the video here: https://twitter.com/johannesl/status/1308531029037252613

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment