newModel.lua 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. return {
  2. tag = 'controller-models',
  3. summary = 'Get a Model for a device.',
  4. description = 'Returns a new Model for the specified device.',
  5. arguments = {
  6. device = {
  7. type = 'Device',
  8. default = [['head']],
  9. description = 'The device to load a model for.'
  10. },
  11. options = {
  12. type = 'table',
  13. default = '{}',
  14. description = 'Options for loading the model.',
  15. table = {
  16. {
  17. name = 'animated',
  18. type = 'boolean',
  19. default = 'false',
  20. description = [[
  21. Whether an animatable model should be loaded, for use with `lovr.headset.animate`.
  22. ]]
  23. }
  24. }
  25. }
  26. },
  27. returns = {
  28. model = {
  29. type = 'Model',
  30. description = 'The new Model, or `nil` if a model could not be loaded.'
  31. }
  32. },
  33. variants = {
  34. {
  35. arguments = { 'device', 'options' },
  36. returns = { 'model' }
  37. }
  38. },
  39. notes = 'Currently this is only implemented for hand models on the Oculus Quest.',
  40. example = [[
  41. local models = {}
  42. function lovr.draw(pass)
  43. for i, hand in ipairs(lovr.headset.getHands()) do
  44. models[hand] = models[hand] or lovr.headset.newModel(hand)
  45. if models[hand] then
  46. local x, y, z, angle, ax, ay, az = lovr.headset.getPose(hand)
  47. pass:draw(models[hand], x, y, z, 1, angle, ax, ay, az)
  48. end
  49. end
  50. end
  51. ]],
  52. related = {
  53. 'lovr.headset.animate'
  54. }
  55. }