Browse Source

Add texture variants to newModel;

bjorn 7 years ago
parent
commit
ee122f7f0a
2 changed files with 55 additions and 6 deletions
  1. 30 2
      api/init.lua
  2. 25 4
      api/lovr/graphics/newModel.lua

+ 30 - 2
api/init.lua

@@ -5086,6 +5086,7 @@ return {
           description = "Creates a new Model from a file.  The supported 3D file formats are `obj`, `fbx`, `gltf`, and collada.  Models use normals and texture coordinates, if provided.\n\nThe following features are not supported yet: animations, materials, vertex colors.",
           key = "lovr.graphics.newModel",
           module = "lovr.graphics",
+          notes = "Models loaded from glTF files do not currently import animations properly.",
           variants = {
             {
               arguments = {
@@ -5093,6 +5094,34 @@ return {
                   name = "filename",
                   type = "string",
                   description = "The filename of the model to load."
+                },
+                {
+                  name = "texture",
+                  type = "string",
+                  description = "The filename of the texture to apply to the model.",
+                  default = "nil"
+                }
+              },
+              returns = {
+                {
+                  name = "model",
+                  type = "Model",
+                  description = "The new Model."
+                }
+              }
+            },
+            {
+              arguments = {
+                {
+                  name = "filename",
+                  type = "string",
+                  description = "The filename of the model to load."
+                },
+                {
+                  name = "material",
+                  type = "Material",
+                  description = "The material to apply to the model.  If nil, the materials will be loaded from the model file.",
+                  default = "nil"
                 }
               },
               returns = {
@@ -5103,8 +5132,7 @@ return {
                 }
               }
             }
-          },
-          notes = "Models loaded from glTF files do not currently import animations properly."
+          }
         },
         {
           name = "newShader",

+ 25 - 4
api/lovr/graphics/newModel.lua

@@ -8,19 +8,40 @@ return {
     The following features are not supported yet: animations, materials, vertex colors.
   ]],
   arguments = {
-    {
-      name = 'filename',
+    filename = {
       type = 'string',
       description = 'The filename of the model to load.'
+    },
+    texture = {
+      type = 'string',
+      default = 'nil',
+      description = 'The filename of the texture to apply to the model.'
+    },
+    material = {
+      type = 'Material',
+      default = 'nil',
+      description = [[
+        The material to apply to the model.  If nil, the materials will be loaded from
+        the model file.
+      ]]
     }
   },
   returns = {
-    {
-      name = 'model',
+    model = {
       type = 'Model',
       description = 'The new Model.'
     }
   },
+  variants = {
+    {
+      arguments = { 'filename', 'texture' },
+      returns = { 'model' }
+    },
+    {
+      arguments = { 'filename', 'material' },
+      returns = { 'model' }
+    }
+  },
   notes = [[
     Models loaded from glTF files do not currently import animations properly.
   ]]