Browse Source

lovr.headset.getDirection;

bjorn 1 year ago
parent
commit
73330f7365
3 changed files with 95 additions and 2 deletions
  1. 49 2
      api/init.lua
  2. 45 0
      api/lovr/headset/getDirection.lua
  3. 1 0
      api/lovr/headset/getOrientation.lua

+ 49 - 2
api/init.lua

@@ -22211,6 +22211,52 @@ return {
             }
           }
         },
+        {
+          name = "getDirection",
+          tag = "input",
+          summary = "Get the direction a device is pointing.",
+          description = "Returns the direction a device is pointing.  It will always be normalized.",
+          key = "lovr.headset.getDirection",
+          module = "lovr.headset",
+          notes = "If the device isn't tracked, all zeroes will be returned.\n\nThis is the same as `quat(lovr.headset.getOrientation(device)):direction():unpack()`.",
+          related = {
+            "lovr.headset.getPose",
+            "lovr.headset.getOrientation",
+            "lovr.headset.getVelocity",
+            "lovr.headset.getAngularVelocity",
+            "lovr.headset.isTracked",
+            "lovr.headset.getDriver"
+          },
+          variants = {
+            {
+              arguments = {
+                {
+                  name = "device",
+                  type = "Device",
+                  description = "The device to get the direction of.",
+                  default = "'head'"
+                }
+              },
+              returns = {
+                {
+                  name = "x",
+                  type = "number",
+                  description = "The x component of the direction."
+                },
+                {
+                  name = "y",
+                  type = "number",
+                  description = "The y component of the direction."
+                },
+                {
+                  name = "z",
+                  type = "number",
+                  description = "The z component of the direction."
+                }
+              }
+            }
+          }
+        },
         {
           name = "getDisplayDimensions",
           tag = "headset",
@@ -22429,6 +22475,7 @@ return {
           related = {
             "lovr.headset.getPose",
             "lovr.headset.getPosition",
+            "lovr.headset.getDirection",
             "lovr.headset.getVelocity",
             "lovr.headset.getAngularVelocity",
             "lovr.headset.isTracked",
@@ -23392,7 +23439,7 @@ return {
         {
           name = "gammaToLinear",
           tag = "mathOther",
-          summary = "\9Convert a color from gamma space to linear space.",
+          summary = "Convert a color from gamma space to linear space.",
           description = "Converts a color from gamma space to linear space.",
           key = "lovr.math.gammaToLinear",
           module = "lovr.math",
@@ -23505,7 +23552,7 @@ return {
         {
           name = "linearToGamma",
           tag = "mathOther",
-          summary = "\9Convert a color from linear space to gamma space.",
+          summary = "Convert a color from linear space to gamma space.",
           description = "Converts a color from linear space to gamma space.",
           key = "lovr.math.linearToGamma",
           module = "lovr.math",

+ 45 - 0
api/lovr/headset/getDirection.lua

@@ -0,0 +1,45 @@
+return {
+  tag = 'input',
+  summary = 'Get the direction a device is pointing.',
+  description = 'Returns the direction a device is pointing.  It will always be normalized.',
+  arguments = {
+    device = {
+      type = 'Device',
+      default = [['head']],
+      description = 'The device to get the direction of.'
+    }
+  },
+  returns = {
+    x = {
+      type = 'number',
+      description = 'The x component of the direction.'
+    },
+    y = {
+      type = 'number',
+      description = 'The y component of the direction.'
+    },
+    z = {
+      type = 'number',
+      description = 'The z component of the direction.'
+    }
+  },
+  variants = {
+    {
+      arguments = { 'device' },
+      returns = { 'x', 'y', 'z' }
+    }
+  },
+  notes = [[
+    If the device isn't tracked, all zeroes will be returned.
+
+    This is the same as `quat(lovr.headset.getOrientation(device)):direction():unpack()`.
+  ]],
+  related = {
+    'lovr.headset.getPose',
+    'lovr.headset.getOrientation',
+    'lovr.headset.getVelocity',
+    'lovr.headset.getAngularVelocity',
+    'lovr.headset.isTracked',
+    'lovr.headset.getDriver'
+  }
+}

+ 1 - 0
api/lovr/headset/getOrientation.lua

@@ -37,6 +37,7 @@ return {
   related = {
     'lovr.headset.getPose',
     'lovr.headset.getPosition',
+    'lovr.headset.getDirection',
     'lovr.headset.getVelocity',
     'lovr.headset.getAngularVelocity',
     'lovr.headset.isTracked',