newModel.lua 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. return {
  2. tag = 'graphics-objects',
  3. summary = 'Create a new Model.',
  4. description = [[
  5. Loads a 3D model from a file. Currently, OBJ, glTF, and binary STL files are supported.
  6. ]],
  7. arguments = {
  8. filename = {
  9. type = 'string',
  10. description = 'The path to model file.'
  11. },
  12. blob = {
  13. type = 'Blob',
  14. description = 'A Blob containing 3D model data.'
  15. },
  16. modelData = {
  17. type = 'ModelData',
  18. description = 'An existing ModelData object to use for the Model.'
  19. },
  20. options = {
  21. type = 'table',
  22. description = 'Model options.',
  23. table = {
  24. {
  25. name = 'mipmaps',
  26. type = 'boolean',
  27. default = 'true',
  28. description = 'Whether the textures created for the Model should have mipmaps generated.'
  29. },
  30. {
  31. name = 'materials',
  32. type = 'boolean',
  33. default = 'true',
  34. description = [[
  35. Whether the textures and materials in the Model should be loaded. When false, the
  36. model will use the material set with `Pass:setMaterial`, although it will apply to all
  37. nodes.
  38. ]]
  39. }
  40. }
  41. }
  42. },
  43. returns = {
  44. model = {
  45. type = 'Model',
  46. description = 'The new Model.'
  47. }
  48. },
  49. variants = {
  50. {
  51. arguments = { 'filename', 'options' },
  52. returns = { 'model' }
  53. },
  54. {
  55. arguments = { 'blob', 'options' },
  56. returns = { 'model' }
  57. },
  58. {
  59. arguments = { 'modelData', 'options' },
  60. returns = { 'model' }
  61. }
  62. },
  63. notes = [[
  64. Currently, the following features are not supported by the model importer:
  65. - glTF: Only the default scene is loaded.
  66. - glTF: Currently, each skin in a Model can have up to 256 joints.
  67. - glTF: Meshes can't appear multiple times in the node hierarchy with different skins, they need
  68. to use 1 skin consistently.
  69. - glTF: `KHR_texture_transform` is supported, but all textures in a material will use the same
  70. transform.
  71. - STL: ASCII STL files are not supported.
  72. Diffuse and emissive textures will be loaded using sRGB encoding, all other textures will be
  73. loaded as linear.
  74. Loading a model file will fail if the asset references textures or other files using absolute
  75. paths. Relative paths should be used instead, and will be relative to the model file within the
  76. virtual filesystem.
  77. ]],
  78. related = {
  79. 'lovr.data.newModelData',
  80. 'Pass:draw'
  81. }
  82. }