浏览代码

Do some ModelData functions;

bjorn 3 年之前
父节点
当前提交
6924117a71

+ 22 - 0
api/lovr/data/ModelData/getBlob.lua

@@ -0,0 +1,22 @@
+return {
+  summary = 'Get a Blob in the model.',
+  description = 'Returns one of the Blobs in the model, by index.',
+  arguments = {
+    {
+      name = 'index',
+      type = 'number',
+      description = 'The index of the Blob to get.'
+    }
+  },
+  returns = {
+    {
+      name = 'blob',
+      type = 'Blob',
+      description = 'The Blob object.'
+    }
+  },
+  related = {
+    'ModelData:getBlobCount',
+    'ModelData:getImage'
+  }
+}

+ 16 - 0
api/lovr/data/ModelData/getBlobCount.lua

@@ -0,0 +1,16 @@
+return {
+  summary = 'Get the number of Blobs stored in the model.',
+  description = 'Returns the number of Blobs in the model.',
+  arguments = {},
+  returns = {
+    {
+      name = 'count',
+      type = 'number',
+      description = 'The number of Blobs in the model.'
+    }
+  },
+  related = {
+    'ModelData:getBlob',
+    'ModelData:getImageCount'
+  }
+}

+ 22 - 0
api/lovr/data/ModelData/getImage.lua

@@ -0,0 +1,22 @@
+return {
+  summary = 'Get an Image in the model.',
+  description = 'Returns one of the Images in the model, by index.',
+  arguments = {
+    {
+      name = 'index',
+      type = 'number',
+      description = 'The index of the Image to get.'
+    }
+  },
+  returns = {
+    {
+      name = 'image',
+      type = 'Image',
+      description = 'The Image object.'
+    }
+  },
+  related = {
+    'ModelData:getImageCount',
+    'ModelData:getBlob'
+  }
+}

+ 16 - 0
api/lovr/data/ModelData/getImageCount.lua

@@ -0,0 +1,16 @@
+return {
+  summary = 'Get the number of Images stored in the model.',
+  description = 'Returns the number of Images in the model.',
+  arguments = {},
+  returns = {
+    {
+      name = 'count',
+      type = 'number',
+      description = 'The number of Images in the model.'
+    }
+  },
+  related = {
+    'ModelData:getImage',
+    'ModelData:getBlobCount'
+  }
+}

+ 16 - 0
api/lovr/data/ModelData/getMetadata.lua

@@ -0,0 +1,16 @@
+return {
+  summary = 'Get extra information from the model file.',
+  description = [[
+    Returns extra information stored in the model file.  Currently this is only implemented for glTF
+    models and returns the JSON string from the glTF or glb file.  The metadata can be used to get
+    application-specific data or add support for glTF extensions not supported by LÖVR.
+  ]],
+  arguments = {},
+  returns = {
+    {
+      name = 'metadata',
+      type = 'string',
+      description = 'The metadata from the model file.'
+    }
+  }
+}

+ 37 - 0
api/lovr/data/ModelData/getNodeChildren.lua

@@ -0,0 +1,37 @@
+return {
+  summary = 'Get the children of a node.',
+  description = [[
+    Given a parent node, this function returns a table with the indices of its children.
+  ]],
+  arguments = {
+    index = {
+      type = 'number',
+      description = 'The index of the parent node.'
+    },
+    name = {
+      type = 'string',
+      description = 'The name of the parent node.'
+    }
+  },
+  returns = {
+    parent = {
+      type = 'number',
+      description = 'The index of the node\'s parent.'
+    }
+  },
+  variants = {
+    {
+      arguments = { 'index' },
+      returns = { 'children' }
+    },
+    {
+      arguments = { 'name' },
+      returns = { 'children' }
+    }
+  },
+  notes = 'If the node does not have any children, this function returns an empty table.'
+  related = {
+    'ModelData:getNodeParent',
+    'ModelData:getRootNode'
+  }
+}

+ 12 - 0
api/lovr/data/ModelData/getNodeCount.lua

@@ -0,0 +1,12 @@
+return {
+  summary = 'Get the number of nodes in the model.',
+  description = 'Returns the number of nodes in the model.',
+  arguments = {},
+  returns = {
+    {
+      name = 'count',
+      type = 'number',
+      description = 'The number of nodes in the model.'
+    }
+  }
+}

+ 19 - 0
api/lovr/data/ModelData/getNodeName.lua

@@ -0,0 +1,19 @@
+return {
+  summary = 'Get the name of a node.',
+  description = 'Returns the name of a node.',
+  arguments = {
+    {
+      name = 'index',
+      type = 'number',
+      description = 'The index of the node.'
+    }
+  },
+  returns = {
+    {
+      name = 'name',
+      type = 'string',
+      description = 'The name of the node.'
+    }
+  },
+  notes = 'If the node does not have a name, this function returns `nil`.'
+}

+ 48 - 0
api/lovr/data/ModelData/getNodeOrientation.lua

@@ -0,0 +1,48 @@
+return {
+  summary = 'Returns the local orientation of a node.',
+  description = 'Returns local orientation of a node, relative to its parent.',
+  arguments = {
+    index = {
+      type = 'number',
+      description = 'The index of the node.'
+    },
+    name = {
+      type = 'string',
+      description = 'The name of the node.'
+    }
+  },
+  returns = {
+    angle = {
+      type = 'number',
+      description = 'The number of radians the node is rotated around its axis of rotation.'
+    },
+    ax = {
+      type = 'number',
+      description = 'The x component of the axis of rotation.'
+    },
+    ay = {
+      type = 'number',
+      description = 'The y component of the axis of rotation.'
+    },
+    az = {
+      type = 'number',
+      description = 'The z component of the axis of rotation.'
+    }
+  },
+  variants = {
+    {
+      arguments = { 'index' },
+      returns = { 'angle', 'ax', 'ay', 'az' }
+    },
+    {
+      arguments = { 'name' },
+      returns = { 'angle', 'ax', 'ay', 'az' }
+    }
+  },
+  related = {
+    'ModelData:getNodePosition',
+    'ModelData:getNodeScale',
+    'ModelData:getNodePose',
+    'ModelData:getNodeTransform'
+  }
+}

+ 34 - 0
api/lovr/data/ModelData/getNodeParent.lua

@@ -0,0 +1,34 @@
+return {
+  summary = 'Get the parent of a node.',
+  description = 'Given a child node, this function returns the index of its parent.',
+  arguments = {
+    index = {
+      type = 'number',
+      description = 'The index of the child node.'
+    },
+    name = {
+      type = 'string',
+      description = 'The name of the child node.'
+    }
+  },
+  returns = {
+    parent = {
+      type = 'number',
+      description = 'The index of the parent.'
+    }
+  },
+  variants = {
+    {
+      arguments = { 'index' },
+      returns = { 'parent' }
+    },
+    {
+      arguments = { 'name' },
+      returns = { 'parent' }
+    }
+  },
+  related = {
+    'ModelData:getNodeChildren',
+    'ModelData:getRootNode'
+  }
+}

+ 44 - 0
api/lovr/data/ModelData/getNodePosition.lua

@@ -0,0 +1,44 @@
+return {
+  summary = 'Returns the local position of a node.',
+  description = 'Returns local position of a node, relative to its parent.',
+  arguments = {
+    index = {
+      type = 'number',
+      description = 'The index of the node.'
+    },
+    name = {
+      type = 'string',
+      description = 'The name of the node.'
+    }
+  },
+  returns = {
+    x = {
+      type = 'number',
+      description = 'The x coordinate.'
+    },
+    y = {
+      type = 'number',
+      description = 'The y coordinate.'
+    }
+    z = {
+      type = 'number',
+      description = 'The z coordinate.'
+    }
+  },
+  variants = {
+    {
+      arguments = { 'index' },
+      returns = { 'x', 'y', 'z' }
+    },
+    {
+      arguments = { 'name' },
+      returns = { 'x', 'y', 'z' }
+    }
+  },
+  related = {
+    'ModelData:getNodeOrientation',
+    'ModelData:getNodeScale',
+    'ModelData:getNodePose',
+    'ModelData:getNodeTransform'
+  }
+}

+ 16 - 0
api/lovr/data/ModelData/getRootNode.lua

@@ -0,0 +1,16 @@
+return {
+  summary = 'Get the index of the root node.',
+  description = 'Returns the index of the model\'s root node.',
+  arguments = {},
+  returns = {
+    {
+      name = 'root',
+      type = 'number',
+      description = 'The index of the root node.'
+    }
+  },
+  related = {
+    'ModelData:getNodeCount',
+    'ModelData:getNodeParent'
+  }
+}