newModel.lua 1.3 KB

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