diff options
author | carsakiller <carsakiller@gmail.com> | 2023-10-27 20:42:08 -0400 |
---|---|---|
committer | carsakiller <carsakiller@gmail.com> | 2023-10-27 20:42:08 -0400 |
commit | 0bd15a68b3b864e071da647456653a27001bedfd (patch) | |
tree | 6c76095ec1f743a2324438fda733c938bd9053e1 | |
parent | e2b951f1485e7626867e64b667a6ebde6e9c3771 (diff) | |
download | lua-language-server-0bd15a68b3b864e071da647456653a27001bedfd.zip |
refactor: replace lovr with LuaCATS submodule
-rw-r--r-- | .gitmodules | 3 | ||||
m--------- | meta/3rd/lovr | 0 | ||||
-rw-r--r-- | meta/3rd/lovr/config.json | 7 | ||||
-rw-r--r-- | meta/3rd/lovr/library/callback.lua | 248 | ||||
-rw-r--r-- | meta/3rd/lovr/library/lovr.lua | 42 | ||||
-rw-r--r-- | meta/3rd/lovr/library/lovr/audio.lua | 864 | ||||
-rw-r--r-- | meta/3rd/lovr/library/lovr/data.lua | 1581 | ||||
-rw-r--r-- | meta/3rd/lovr/library/lovr/event.lua | 430 | ||||
-rw-r--r-- | meta/3rd/lovr/library/lovr/filesystem.lua | 333 | ||||
-rw-r--r-- | meta/3rd/lovr/library/lovr/graphics.lua | 3815 | ||||
-rw-r--r-- | meta/3rd/lovr/library/lovr/headset.lua | 826 | ||||
-rw-r--r-- | meta/3rd/lovr/library/lovr/math.lua | 1268 | ||||
-rw-r--r-- | meta/3rd/lovr/library/lovr/physics.lua | 1843 | ||||
-rw-r--r-- | meta/3rd/lovr/library/lovr/system.lua | 136 | ||||
-rw-r--r-- | meta/3rd/lovr/library/lovr/thread.lua | 170 | ||||
-rw-r--r-- | meta/3rd/lovr/library/lovr/timer.lua | 59 |
16 files changed, 3 insertions, 11622 deletions
diff --git a/.gitmodules b/.gitmodules index 9835ce66..5b8848c5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -43,3 +43,6 @@ [submodule "meta/3rd/love2d"] path = meta/3rd/love2d url = https://github.com/LuaCATS/love2d.git +[submodule "meta/3rd/lovr"] + path = meta/3rd/lovr + url = https://github.com/LuaCATS/lovr.git diff --git a/meta/3rd/lovr b/meta/3rd/lovr new file mode 160000 +Subproject 3ba215f98e1647111b50b311d45c31338fdc615 diff --git a/meta/3rd/lovr/config.json b/meta/3rd/lovr/config.json deleted file mode 100644 index 195c7661..00000000 --- a/meta/3rd/lovr/config.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name" : "LÖVR", - "words" : ["lovr%.%w+"], - "settings" : { - "Lua.runtime.version" : "LuaJIT" - } -} diff --git a/meta/3rd/lovr/library/callback.lua b/meta/3rd/lovr/library/callback.lua deleted file mode 100644 index 903a3e8e..00000000 --- a/meta/3rd/lovr/library/callback.lua +++ /dev/null @@ -1,248 +0,0 @@ ----@meta - ---- ----The `lovr.conf` callback lets you configure default settings for LÖVR. ---- ----It is called once right before the game starts. ---- ----Make sure you put `lovr.conf` in a file called `conf.lua`, a special file that's loaded before the rest of the framework initializes. ---- ---- ----### NOTE: ----Disabling unused modules can improve startup time. ---- ----`t.window` can be set to nil to avoid creating the window. ---- ----The window can later be opened manually using `lovr.system.openWindow`. ---- ----Enabling the `t.graphics.debug` flag will add additional error checks and will send messages from the GPU driver to the `lovr.log` callback. ---- ----This will decrease performance but can help provide information on performance problems or other bugs. ---- ----The `headset.offset` field is a vertical offset applied to the scene for headsets that do not center their tracking origin on the floor. ---- ----This can be thought of as a "default user height". Setting this offset makes it easier to design experiences that work in both seated and standing VR configurations. ---- ----@type fun(t: table) -lovr.conf = nil - ---- ----This callback is called every frame, and receives a `Pass` object as an argument which can be used to render graphics to the display. ---- ----If a VR headset is connected, this function renders to the headset display, otherwise it will render to the desktop window. ---- ---- ----### NOTE: ----To render to the desktop window when a VR headset is connected, use the `lovr.mirror` callback. ---- ----The display is cleared to the global background color before this callback is called, which can be changed using `lovr.graphics.setBackgroundColor`. ---- ----Since the `lovr.graphics.submit` function always returns true, the following idiom can be used to submit graphics work manually and override the default submission: ---- ---- function lovr.draw(pass) ---- local passes = {} ---- ---- -- ... record multiple passes and add to passes table ---- ---- return lovr.graphics.submit(passes) ---- end ---- ----@type fun(pass: lovr.Pass):boolean -lovr.draw = nil - ---- ----The `lovr.errhand` callback is run whenever an error occurs. ---- ----It receives a parameter containing the error message. ---- ----It should return a handler function that will run in a loop to render the error screen. ---- ----This handler function is of the same type as the one returned by `lovr.run` and has the same requirements (such as pumping events). ---- ----If an error occurs while this handler is running, the program will terminate immediately -- `lovr.errhand` will not be given a second chance. ---- ----Errors which occur in the error handler or in the handler it returns may not be cleanly reported, so be careful. ---- ----A default error handler is supplied that renders the error message as text to the headset and to the window. ---- ----@type fun(message: string):function -lovr.errhand = nil - ---- ----The `lovr.focus` callback is called whenever the application acquires or loses focus (for example, when opening or closing the Steam dashboard). ---- ----The callback receives a single argument, focused, which is a boolean indicating whether or not the application is now focused. ---- ----It may make sense to pause the game or reduce visual fidelity when the application loses focus. ---- ----@type fun(focused: boolean) -lovr.focus = nil - ---- ----This callback is called when a key is pressed. ---- ----@type fun(key: lovr.KeyCode, scancode: number, repeating: boolean) -lovr.keypressed = nil - ---- ----This callback is called when a key is released. ---- ----@type fun(key: lovr.KeyCode, scancode: number) -lovr.keyreleased = nil - ---- ----This callback is called once when the app starts. ---- ----It should be used to perform initial setup work, like loading resources and initializing classes and variables. ---- ---- ----### NOTE: ----If the project was loaded from a restart using `lovr.event.restart`, the return value from the previously-run `lovr.restart` callback will be made available to this callback as the `restart` key in the `arg` table. ---- ----The `arg` table follows the [Lua standard](https://en.wikibooks.org/wiki/Lua_Programming/command_line_parameter). ---- ----The arguments passed in from the shell are put into a global table named `arg` and passed to `lovr.load`, but with indices offset such that the "script" (the project path) is at index 0. ---- ----So all arguments (if any) intended for the project are at successive indices starting with 1, and the executable and its "internal" arguments are in normal order but stored in negative indices. ---- ----@type fun(arg: table) -lovr.load = nil - ---- ----This callback is called when a message is logged. ---- ----The default implementation of this callback prints the message to the console using `print`, but it's possible to override this callback to render messages in VR, write them to a file, filter messages, and more. ---- ----The message can have a "tag" that is a short string representing the sender, and a "level" indicating how severe the message is. ---- ----The `t.graphics.debug` flag in `lovr.conf` can be used to get log messages from the GPU driver (tagged as `GPU`). ---- ----It is also possible to emit customlog messages using `lovr.event.push`, or by calling the callback. ---- ----@type fun(message: string, level: string, tag: string) -lovr.log = nil - ---- ----This callback is called every frame after rendering to the headset and is usually used to render a mirror of the headset display onto the desktop window. ---- ----It can be overridden for custom mirroring behavior. ---- ----For example, a stereo view could be drawn instead of a single eye or a 2D HUD could be rendered. ---- ----@type fun(pass: lovr.Pass):boolean -lovr.mirror = nil - ---- ----This callback is called when the mouse is moved. ---- ----@type fun(x: number, y: number, dx: number, dy: number) -lovr.mousemoved = nil - ---- ----This callback is called when a mouse button is pressed. ---- ----@type fun(x: number, y: number, button: number) -lovr.mousepressed = nil - ---- ----This callback is called when a mouse button is released. ---- ----@type fun(x: number, y: number, button: number) -lovr.mousereleased = nil - ---- ----This callback contains a permission response previously requested with `lovr.system.requestPermission`. ---- ----The callback contains information on whether permission was granted or denied. ---- ----@type fun(permission: lovr.Permission, granted: boolean) -lovr.permission = nil - ---- ----This callback is called right before the application is about to quit. ---- ----Use it to perform any necessary cleanup work. ---- ----A truthy value can be returned from this callback to abort quitting. ---- ----@type fun():boolean -lovr.quit = nil - ---- ----This callback is called when the desktop window is resized. ---- ----@type fun(width: number, height: number) -lovr.resize = nil - ---- ----This callback is called when a restart from `lovr.event.restart` is happening. ---- ----A value can be returned to send it to the next LÖVR instance, available as the `restart` key in the argument table passed to `lovr.load`. ---- ----Object instances can not be used as the restart value, since they are destroyed as part of the cleanup process. ---- ---- ----### NOTE: ----Only nil, booleans, numbers, and strings are supported types for the return value. ---- ----@type fun():any -lovr.restart = nil - ---- ----This callback is the main entry point for a LÖVR program. ---- ----It calls `lovr.load` and returns a function that will be called every frame. ---- ---- ----### NOTE: ----The main loop function can return one of the following values: ---- ----- Returning `nil` will keep the main loop running. ----- Returning the string 'restart' plus an optional value will restart LÖVR. ---- ----The value can be ---- accessed in the `restart` key of the `arg` global. ----- Returning a number will exit LÖVR using the number as the exit code (0 means success). ---- ----Care should be taken when overriding this callback. ---- ----For example, if the main loop does not call `lovr.event.pump` then the OS will think LÖVR is unresponsive, and if the quit event is not handled then closing the window won't work. ---- ----@type fun():function -lovr.run = nil - ---- ----This callback is called when text has been entered. ---- ----For example, when `shift + 1` is pressed on an American keyboard, `lovr.textinput` will be called with `!`. ---- ---- ----### NOTE: ----Some characters in UTF-8 unicode take multiple bytes to encode. ---- ----Due to the way Lua works, the length of these strings will be bigger than 1 even though they are just a single character. `Pass:text` is compatible with UTF-8 but doing other string processing on these strings may require a library. ---- ----Lua 5.3+ has support for working with UTF-8 strings. ---- ----@type fun(text: string, code: number) -lovr.textinput = nil - ---- ----The `lovr.threaderror` callback is called whenever an error occurs in a Thread. ---- ----It receives the Thread object where the error occurred and an error message. ---- ----The default implementation of this callback will call `lovr.errhand` with the error. ---- ----@type fun(thread: lovr.Thread, message: string) -lovr.threaderror = nil - ---- ----The `lovr.update` callback should be used to update your game's logic. ---- ----It receives a single parameter, `dt`, which represents the amount of elapsed time between frames. ---- ----You can use this value to scale timers, physics, and animations in your game so they play at a smooth, consistent speed. ---- ----@type fun(dt: number) -lovr.update = nil diff --git a/meta/3rd/lovr/library/lovr.lua b/meta/3rd/lovr/library/lovr.lua deleted file mode 100644 index 7bff8ec9..00000000 --- a/meta/3rd/lovr/library/lovr.lua +++ /dev/null @@ -1,42 +0,0 @@ ----@meta - ---- ----`lovr` is the single global table that is exposed to every LÖVR app. It contains a set of **modules** and a set of **callbacks**. ---- ----@class lovr -lovr = {} - ---- ----Get the current major, minor, and patch version of LÖVR. ---- ----@return number major # The major version. ----@return number minor # The minor version. ----@return number patch # The patch number. -function lovr.getVersion() end - ---- ----The superclass of all LÖVR objects. ---- ----In addition to the methods here, all objects have a `__tostring` metamethod that returns the name of the object's type. ---- ----So `tostring(object) == 'Blob'` will check if a LÖVR object is a Blob. ---- ---- ----### NOTE: ----Note that the functions here don't apply to any vector objects, see `Vectors`. ---- ----@class lovr.Object -local Object = {} - ---- ----Immediately destroys Lua's reference to the object it's called on. ---- ----After calling this function on an object, it is an error to do anything with the object from Lua (call methods on it, pass it to other functions, etc.). ---- ----If nothing else is using the object, it will be destroyed immediately, which can be used to destroy something earlier than it would normally be garbage collected in order to reduce memory. ---- ---- ----### NOTE: ----The object may not be destroyed immediately if something else is referring to it (e.g. it is pushed to a Channel or exists in the payload of a pending event). ---- -function Object:release() end diff --git a/meta/3rd/lovr/library/lovr/audio.lua b/meta/3rd/lovr/library/lovr/audio.lua deleted file mode 100644 index ebe35714..00000000 --- a/meta/3rd/lovr/library/lovr/audio.lua +++ /dev/null @@ -1,864 +0,0 @@ ----@meta - ---- ----The `lovr.audio` module is responsible for playing sound effects and music. ---- ----To play a sound, create a `Source` object and call `Source:play` on it. ---- ----Currently ogg, wav, and mp3 audio formats are supported. ---- ----@class lovr.audio -lovr.audio = {} - ---- ----Returns the global air absorption coefficients for the medium. ---- ----This affects Sources that have the `absorption` effect enabled, causing audio volume to drop off with distance as it is absorbed by the medium it's traveling through (air, water, etc.). ---- ----The difference between absorption and the attenuation effect is that absorption is more subtle and is frequency-dependent, so higher-frequency bands can get absorbed more quickly than lower ones. This can be used to apply "underwater" effects and stuff. ---- ---- ----### NOTE: ----Absorption is currently only supported by the phonon spatializer. ---- ----The frequency bands correspond to `400Hz`, `2.5KHz`, and `15KHz`. ---- ----The default coefficients are `.0002`, `.0017`, and `.0182` for low, mid, and high. ---- ----@return number low # The absorption coefficient for the low frequency band. ----@return number mid # The absorption coefficient for the mid frequency band. ----@return number high # The absorption coefficient for the high frequency band. -function lovr.audio.getAbsorption() end - ---- ----Returns a list of playback or capture devices. ---- ----Each device has an `id`, `name`, and a `default` flag indicating whether it's the default device. ---- ----To use a specific device id for playback or capture, pass it to `lovr.audio.setDevice`. ---- ----@param type? lovr.AudioType # The type of devices to query (playback or capture). ----@return {["[].id"]: userdata, ["[].name"]: string, ["[].default"]: boolean} devices # The list of devices. -function lovr.audio.getDevices(type) end - ---- ----Returns the orientation of the virtual audio listener in angle/axis representation. ---- ----@return number angle # The number of radians the listener is rotated around its axis of rotation. ----@return number ax # The x component of the axis of rotation. ----@return number ay # The y component of the axis of rotation. ----@return number az # The z component of the axis of rotation. -function lovr.audio.getOrientation() end - ---- ----Returns the position and orientation of the virtual audio listener. ---- ----@return number x # The x position of the listener, in meters. ----@return number y # The y position of the listener, in meters. ----@return number z # The z position of the listener, in meters. ----@return number angle # The number of radians the listener is rotated around its axis of rotation. ----@return number ax # The x component of the axis of rotation. ----@return number ay # The y component of the axis of rotation. ----@return number az # The z component of the axis of rotation. -function lovr.audio.getPose() end - ---- ----Returns the position of the virtual audio listener, in meters. ---- ----@return number x # The x position of the listener. ----@return number y # The y position of the listener. ----@return number z # The z position of the listener. -function lovr.audio.getPosition() end - ---- ----Returns the sample rate used by the playback device. ---- ----This can be changed using `lovr.conf`. ---- ----@return number rate # The sample rate of the playback device, in Hz. -function lovr.audio.getSampleRate() end - ---- ----Returns the name of the active spatializer (`simple`, `oculus`, or `phonon`). ---- ----The `t.audio.spatializer` setting in `lovr.conf` can be used to express a preference for a particular spatializer. ---- ----If it's `nil`, all spatializers will be tried in the following order: `phonon`, `oculus`, `simple`. ---- ---- ----### NOTE: ----Using a feature or effect that is not supported by the current spatializer will not error, it just won't do anything. ---- ----<table> ---- <thead> ---- <tr> ---- <td>Feature</td> ---- <td>simple</td> ---- <td>phonon</td> ---- <td>oculus</td> ---- </tr> ---- </thead> ---- <tbody> ---- <tr> ---- <td>Effect: Spatialization</td> ---- <td>x</td> ---- <td>x</td> ---- <td>x</td> ---- </tr> ---- <tr> ---- <td>Effect: Attenuation</td> ---- <td>x</td> ---- <td>x</td> ---- <td>x</td> ---- </tr> ---- <tr> ---- <td>Effect: Absorption</td> ---- <td></td> ---- <td>x</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td>Effect: Occlusion</td> ---- <td></td> ---- <td>x</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td>Effect: Transmission</td> ---- <td></td> ---- <td>x</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td>Effect: Reverb</td> ---- <td></td> ---- <td>x</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td>lovr.audio.setGeometry</td> ---- <td></td> ---- <td>x</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td>Source:setDirectivity</td> ---- <td>x</td> ---- <td>x</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td>Source:setRadius</td> ---- <td></td> ---- <td>x</td> ---- <td></td> ---- </tr> ---- </tbody> </table> ---- ----@return string spatializer # The name of the active spatializer. -function lovr.audio.getSpatializer() end - ---- ----Returns the master volume. ---- ----All audio sent to the playback device has its volume multiplied by this factor. ---- ---- ----### NOTE: ----The default volume is 1.0 (0 dB). ---- ----@param units? lovr.VolumeUnit # The units to return (linear or db). ----@return number volume # The master volume. -function lovr.audio.getVolume(units) end - ---- ----Returns whether an audio device is started. ---- ----@param type? lovr.AudioType # The type of device to check. ----@return boolean started # Whether the device is active. -function lovr.audio.isStarted(type) end - ---- ----Creates a new Source from an ogg, wav, or mp3 file. ---- ----@overload fun(blob: lovr.Blob, options?: table):lovr.Source ----@overload fun(sound: lovr.Sound, options?: table):lovr.Source ----@param filename string # The filename of the sound to load. ----@param options? {decode: boolean, pitchable: boolean, spatial: boolean, effects: table} # Optional options. ----@return lovr.Source source # The new Source. -function lovr.audio.newSource(filename, options) end - ---- ----Sets the global air absorption coefficients for the medium. ---- ----This affects Sources that have the `absorption` effect enabled, causing audio volume to drop off with distance as it is absorbed by the medium it's traveling through (air, water, etc.). ---- ----The difference between absorption and the attenuation effect is that absorption is more subtle and is frequency-dependent, so higher-frequency bands can get absorbed more quickly than lower ones. ---- ----This can be used to apply "underwater" effects and stuff. ---- ---- ----### NOTE: ----Absorption is currently only supported by the phonon spatializer. ---- ----The frequency bands correspond to `400Hz`, `2.5KHz`, and `15KHz`. ---- ----The default coefficients are `.0002`, `.0017`, and `.0182` for low, mid, and high. ---- ----@param low number # The absorption coefficient for the low frequency band. ----@param mid number # The absorption coefficient for the mid frequency band. ----@param high number # The absorption coefficient for the high frequency band. -function lovr.audio.setAbsorption(low, mid, high) end - ---- ----Switches either the playback or capture device to a new one. ---- ----If a device for the given type is already active, it will be stopped and destroyed. ---- ----The new device will not be started automatically, use `lovr.audio.start` to start it. ---- ----A device id (previously retrieved using `lovr.audio.getDevices`) can be given to use a specific audio device, or `nil` can be used for the id to use the default audio device. ---- ----A sink can be also be provided when changing the device. ---- ----A sink is an audio stream (`Sound` object with a `stream` type) that will receive all audio samples played (for playback) or all audio samples captured (for capture). ---- ----When an audio device with a sink is started, be sure to periodically call `Sound:read` on the sink to read audio samples from it, otherwise it will overflow and discard old data. ---- ----The sink can have any format, data will be converted as needed. Using a sink for the playback device will reduce performance, but this isn't the case for capture devices. ---- ----Audio devices can be started in `shared` or `exclusive` mode. ---- ----Exclusive devices may have lower latency than shared devices, but there's a higher chance that requesting exclusive access to an audio device will fail (either because it isn't supported or allowed). ---- ----One strategy is to first try the device in exclusive mode, switching to shared if it doesn't work. ---- ----@param type? lovr.AudioType # The device to switch. ----@param id? userdata # The id of the device to use, or `nil` to use the default device. ----@param sink? lovr.Sound # An optional audio stream to use as a sink for the device. ----@param mode? lovr.AudioShareMode # The sharing mode for the device. ----@return boolean success # Whether creating the audio device succeeded. -function lovr.audio.setDevice(type, id, sink, mode) end - ---- ----Sets a mesh of triangles to use for modeling audio effects, using a table of vertices or a Model. ---- ----When the appropriate effects are enabled, audio from `Source` objects will correctly be occluded by walls and bounce around to create realistic reverb. ---- ----An optional `AudioMaterial` may be provided to specify the acoustic properties of the geometry. ---- ---- ----### NOTE: ----This is currently only supported/used by the `phonon` spatializer. ---- ----The `Effect`s that use geometry are: ---- ----- `occlusion` ----- `reverb` ----- `transmission` ---- ----If an existing geometry has been set, this function will replace it. ---- ----The triangles must use counterclockwise winding. ---- ----@overload fun(model: lovr.Model, material?: lovr.AudioMaterial):boolean ----@param vertices table # A flat table of vertices. Each vertex is 3 numbers representing its x, y, and z position. The units used for audio coordinates are up to you, but meters are recommended. ----@param indices table # A list of indices, indicating how the vertices are connected into triangles. Indices are 1-indexed and are 32 bits (they can be bigger than 65535). ----@param material? lovr.AudioMaterial # The acoustic material to use. ----@return boolean success # Whether audio geometry is supported by the current spatializer and the geometry was loaded successfully. -function lovr.audio.setGeometry(vertices, indices, material) end - ---- ----Sets the orientation of the virtual audio listener in angle/axis representation. ---- ----@overload fun(orientation: lovr.Quat) ----@param angle number # The number of radians the listener should be rotated around its rotation axis. ----@param ax number # The x component of the axis of rotation. ----@param ay number # The y component of the axis of rotation. ----@param az number # The z component of the axis of rotation. -function lovr.audio.setOrientation(angle, ax, ay, az) end - ---- ----Sets the position and orientation of the virtual audio listener. ---- ---- ----### NOTE: ----The position of the listener doesn't use any specific units, but usually they can be thought of as meters to match the headset module. ---- ----@overload fun(position: lovr.Vec3, orientation: lovr.Quat) ----@param x number # The x position of the listener. ----@param y number # The y position of the listener. ----@param z number # The z position of the listener. ----@param angle number # The number of radians the listener is rotated around its axis of rotation. ----@param ax number # The x component of the axis of rotation. ----@param ay number # The y component of the axis of rotation. ----@param az number # The z component of the axis of rotation. -function lovr.audio.setPose(x, y, z, angle, ax, ay, az) end - ---- ----Sets the position of the virtual audio listener. ---- ----The position doesn't have any specific units, but usually they can be thought of as meters, to match the headset module. ---- ----@overload fun(position: lovr.Vec3) ----@param x number # The x position of the listener. ----@param y number # The y position of the listener. ----@param z number # The z position of the listener. -function lovr.audio.setPosition(x, y, z) end - ---- ----Sets the master volume. ---- ----All audio sent to the playback device has its volume multiplied by this factor. ---- ---- ----### NOTE: ----The volume will be clamped to a 0-1 range (0 dB). ---- ----@param volume number # The master volume. ----@param units? lovr.VolumeUnit # The units of the value. -function lovr.audio.setVolume(volume, units) end - ---- ----Starts the active playback or capture device. ---- ----By default the playback device is initialized and started, but this can be controlled using the `t.audio.start` flag in `lovr.conf`. ---- ---- ----### NOTE: ----Starting an audio device may fail if: ---- ----- The device is already started ----- No device was initialized with `lovr.audio.setDevice` ----- Lack of `audiocapture` permission on Android (see `lovr.system.requestPermission`) ----- Some other problem accessing the audio device ---- ----@param type? lovr.AudioType # The type of device to start. ----@return boolean started # Whether the device was successfully started. -function lovr.audio.start(type) end - ---- ----Stops the active playback or capture device. ---- ----This may fail if: ---- ----- The device is not started ----- No device was initialized with `lovr.audio.setDevice` ---- ---- ----### NOTE: ----Switching devices with `lovr.audio.setDevice` will stop the existing one. ---- ----@param type? lovr.AudioType # The type of device to stop. ----@return boolean stopped # Whether the device was successfully stopped. -function lovr.audio.stop(type) end - ---- ----A Source is an object representing a single sound. ---- ----Currently ogg, wav, and mp3 formats are supported. ---- ----When a Source is playing, it will send audio to the speakers. ---- ----Sources do not play automatically when they are created. ---- ----Instead, the `play`, `pause`, and `stop` functions can be used to control when they should play. ---- ----`Source:seek` and `Source:tell` can be used to control the playback position of the Source. ---- ----A Source can be set to loop when it reaches the end using `Source:setLooping`. ---- ----@class lovr.Source -local Source = {} - ---- ----Creates a copy of the Source, referencing the same `Sound` object and inheriting all of the settings of this Source. ---- ----However, it will be created in the stopped state and will be rewound to the beginning. ---- ---- ----### NOTE: ----This is a good way to create multiple Sources that play the same sound, since the audio data won't be loaded multiple times and can just be reused. ---- ----You can also create multiple `Source` objects and pass in the same `Sound` object for each one, which will have the same effect. ---- ----@return lovr.Source source # A genetically identical copy of the Source. -function Source:clone() end - ---- ----Returns the directivity settings for the Source. ---- ----The directivity is controlled by two parameters: the weight and the power. ---- ----The weight is a number between 0 and 1 controlling the general "shape" of the sound emitted. 0.0 results in a completely omnidirectional sound that can be heard from all directions. ---- ----1.0 results in a full dipole shape that can be heard only from the front and back. ---- ----0.5 results in a cardioid shape that can only be heard from one direction. ---- ----Numbers in between will smoothly transition between these. ---- ----The power is a number that controls how "focused" or sharp the shape is. ---- ----Lower power values can be heard from a wider set of angles. ---- ----It is an exponent, so it can get arbitrarily large. ---- ----Note that a power of zero will still result in an omnidirectional source, regardless of the weight. ---- ----@return number weight # The dipole weight. 0.0 is omnidirectional, 1.0 is a dipole, 0.5 is cardioid. ----@return number power # The dipole power, controlling how focused the directivity shape is. -function Source:getDirectivity() end - ---- ----Returns the duration of the Source. ---- ----@param unit? lovr.TimeUnit # The unit to return. ----@return number duration # The duration of the Source. -function Source:getDuration(unit) end - ---- ----Returns the orientation of the Source, in angle/axis representation. ---- ----@return number angle # The number of radians the Source is rotated around its axis of rotation. ----@return number ax # The x component of the axis of rotation. ----@return number ay # The y component of the axis of rotation. ----@return number az # The z component of the axis of rotation. -function Source:getOrientation() end - ---- ----Returns the pitch of the Source. ---- ---- ----### NOTE: ----The default pitch is 1. ---- ----Every doubling/halving of the pitch will raise/lower the pitch by one octave. ---- ----Changing the pitch also changes the playback speed. ---- ----@return number pitch # The pitch. -function Source:getPitch() end - ---- ----Returns the position and orientation of the Source. ---- ----@return number x # The x position of the Source, in meters. ----@return number y # The y position of the Source, in meters. ----@return number z # The z position of the Source, in meters. ----@return number angle # The number of radians the Source is rotated around its axis of rotation. ----@return number ax # The x component of the axis of rotation. ----@return number ay # The y component of the axis of rotation. ----@return number az # The z component of the axis of rotation. -function Source:getPose() end - ---- ----Returns the position of the Source, in meters. ---- ----Setting the position will cause the Source to be distorted and attenuated based on its position relative to the listener. ---- ----@return number x # The x coordinate. ----@return number y # The y coordinate. ----@return number z # The z coordinate. -function Source:getPosition() end - ---- ----Returns the radius of the Source, in meters. ---- ----This does not control falloff or attenuation. ---- ----It is only used for smoothing out occlusion. ---- ----If a Source doesn't have a radius, then when it becomes occluded by a wall its volume will instantly drop. ---- ----Giving the Source a radius that approximates its emitter's size will result in a smooth transition between audible and occluded, improving realism. ---- ----@return number radius # The radius of the Source, in meters. -function Source:getRadius() end - ---- ----Returns the `Sound` object backing the Source. ---- ----Multiple Sources can share one Sound, allowing its data to only be loaded once. ---- ----An easy way to do this sharing is by using `Source:clone`. ---- ----@return lovr.Sound sound # The Sound object. -function Source:getSound() end - ---- ----Returns the current volume factor for the Source. ---- ----@param units? lovr.VolumeUnit # The units to return (linear or db). ----@return number volume # The volume of the Source. -function Source:getVolume(units) end - ---- ----Returns whether a given `Effect` is enabled for the Source. ---- ---- ----### NOTE: ----The active spatializer will determine which effects are supported. ---- ----If an unsupported effect is enabled on a Source, no error will be reported. ---- ----Instead, it will be silently ignored. ---- ----See `lovr.audio.getSpatializer` for a table showing the effects supported by each spatializer. ---- ----Calling this function on a non-spatial Source will always return false. ---- ----@param effect lovr.Effect # The effect. ----@return boolean enabled # Whether the effect is enabled. -function Source:isEffectEnabled(effect) end - ---- ----Returns whether or not the Source will loop when it finishes. ---- ----@return boolean looping # Whether or not the Source is looping. -function Source:isLooping() end - ---- ----Returns whether or not the Source is playing. ---- ----@return boolean playing # Whether the Source is playing. -function Source:isPlaying() end - ---- ----Returns whether the Source was created with the `spatial` flag. ---- ----Non-spatial sources are routed directly to the speakers and can not use effects. ---- ----@return boolean spatial # Whether the source is spatial. -function Source:isSpatial() end - ---- ----Pauses the source. ---- ----It can be resumed with `Source:resume` or `Source:play`. If a paused source is rewound, it will remain paused. ---- -function Source:pause() end - ---- ----Plays the Source. ---- ----This doesn't do anything if the Source is already playing. ---- ---- ----### NOTE: ----There is a maximum of 64 Sources that can be playing at once. ---- ----If 64 Sources are already playing, this function will return `false`. ---- ----@return boolean success # Whether the Source successfully started playing. -function Source:play() end - ---- ----Seeks the Source to the specified position. ---- ---- ----### NOTE: ----Seeking a Source backed by a stream `Sound` has no meaningful effect. ---- ----@param position number # The position to seek to. ----@param unit? lovr.TimeUnit # The units for the seek position. -function Source:seek(position, unit) end - ---- ----Sets the directivity settings for the Source. ---- ----The directivity is controlled by two parameters: the weight and the power. ---- ----The weight is a number between 0 and 1 controlling the general "shape" of the sound emitted. 0.0 results in a completely omnidirectional sound that can be heard from all directions. ---- ----1.0 results in a full dipole shape that can be heard only from the front and back. ---- ----0.5 results in a cardioid shape that can only be heard from one direction. ---- ----Numbers in between will smoothly transition between these. ---- ----The power is a number that controls how "focused" or sharp the shape is. ---- ----Lower power values can be heard from a wider set of angles. ---- ----It is an exponent, so it can get arbitrarily large. ---- ----Note that a power of zero will still result in an omnidirectional source, regardless of the weight. ---- ----@param weight number # The dipole weight. 0.0 is omnidirectional, 1.0 is a dipole, 0.5 is cardioid. ----@param power number # The dipole power, controlling how focused the directivity shape is. -function Source:setDirectivity(weight, power) end - ---- ----Enables or disables an effect on the Source. ---- ---- ----### NOTE: ----The active spatializer will determine which effects are supported. ---- ----If an unsupported effect is enabled on a Source, no error will be reported. ---- ----Instead, it will be silently ignored. ---- ----See `lovr.audio.getSpatializer` for a table showing the effects supported by each spatializer. ---- ----Calling this function on a non-spatial Source will throw an error. ---- ----@param effect lovr.Effect # The effect. ----@param enable boolean # Whether the effect should be enabled. -function Source:setEffectEnabled(effect, enable) end - ---- ----Sets whether or not the Source loops. ---- ---- ----### NOTE: ----Attempting to loop a Source backed by a stream `Sound` will cause an error. ---- ----@param loop boolean # Whether or not the Source will loop. -function Source:setLooping(loop) end - ---- ----Sets the orientation of the Source in angle/axis representation. ---- ----@overload fun(self: lovr.Source, orientation: lovr.Quat) ----@param angle number # The number of radians the Source should be rotated around its rotation axis. ----@param ax number # The x component of the axis of rotation. ----@param ay number # The y component of the axis of rotation. ----@param az number # The z component of the axis of rotation. -function Source:setOrientation(angle, ax, ay, az) end - ---- ----Sets the pitch of the Source. ---- ---- ----### NOTE: ----The default pitch is 1. ---- ----Every doubling/halving of the pitch will raise/lower the pitch by one octave. ---- ----Changing the pitch also changes the playback speed. ---- ----@param pitch number # The new pitch. -function Source:setPitch(pitch) end - ---- ----Sets the position and orientation of the Source. ---- ---- ----### NOTE: ----The position doesn't have any defined units, but meters are used by convention. ---- ----@overload fun(self: lovr.Source, position: lovr.Vec3, orientation: lovr.Quat) ----@param x number # The x position of the Source. ----@param y number # The y position of the Source. ----@param z number # The z position of the Source. ----@param angle number # The number of radians the Source is rotated around its axis of rotation. ----@param ax number # The x component of the axis of rotation. ----@param ay number # The y component of the axis of rotation. ----@param az number # The z component of the axis of rotation. -function Source:setPose(x, y, z, angle, ax, ay, az) end - ---- ----Sets the position of the Source. ---- ----Setting the position will cause the Source to be distorted and attenuated based on its position relative to the listener. ---- ----Only mono sources can be positioned. ---- ----Setting the position of a stereo Source will cause an error. ---- ---- ----### NOTE: ----The position doesn't have any defined units, but meters are used by convention. ---- ----@overload fun(self: lovr.Source, position: lovr.Vec3) ----@param x number # The x coordinate of the position. ----@param y number # The y coordinate of the position. ----@param z number # The z coordinate of the position. -function Source:setPosition(x, y, z) end - ---- ----Sets the radius of the Source, in meters. ---- ----This does not control falloff or attenuation. ---- ----It is only used for smoothing out occlusion. ---- ----If a Source doesn't have a radius, then when it becomes occluded by a wall its volume will instantly drop. ---- ----Giving the Source a radius that approximates its emitter's size will result in a smooth transition between audible and occluded, improving realism. ---- ----@param radius number # The new radius of the Source, in meters. -function Source:setRadius(radius) end - ---- ----Sets the current volume factor for the Source. ---- ---- ----### NOTE: ----The volume will be clamped to a 0-1 range (0 dB). ---- ----@param volume number # The new volume. ----@param units? lovr.VolumeUnit # The units of the value. -function Source:setVolume(volume, units) end - ---- ----Stops the source, also rewinding it to the beginning. ---- -function Source:stop() end - ---- ----Returns the current playback position of the Source. ---- ---- ----### NOTE: ----The return value for Sources backed by a stream `Sound` has no meaning. ---- ----@param unit? lovr.TimeUnit # The unit to return. ----@return number position # The current playback position. -function Source:tell(unit) end - ---- ----Different types of audio material presets, for use with `lovr.audio.setGeometry`. ---- ----@alias lovr.AudioMaterial ---- ----Generic default audio material. ---- ----| "generic" ---- ----Brick. ---- ----| "brick" ---- ----Carpet. ---- ----| "carpet" ---- ----Ceramic. ---- ----| "ceramic" ---- ----Concrete. ---- ----| "concrete" ---- ----Glass. ---- ----| "glass" ---- ----Gravel. ---- ----| "gravel" ---- ----Metal. ---- ----| "metal" ---- ----Plaster. ---- ----| "plaster" ---- ----Rock. ---- ----| "rock" ---- ----Wood. ---- ----| "wood" - ---- ----Audio devices can be created in shared mode or exclusive mode. ---- ----In exclusive mode, the audio device is the only one active on the system, which gives better performance and lower latency. However, exclusive devices aren't always supported and might not be allowed, so there is a higher chance that creating one will fail. ---- ----@alias lovr.AudioShareMode ---- ----Shared mode. ---- ----| "shared" ---- ----Exclusive mode. ---- ----| "exclusive" - ---- ----When referencing audio devices, this indicates whether it's the playback or capture device. ---- ----@alias lovr.AudioType ---- ----The playback device (speakers, headphones). ---- ----| "playback" ---- ----The capture device (microphone). ---- ----| "capture" - ---- ----Different types of effects that can be applied with `Source:setEffectEnabled`. ---- ---- ----### NOTE: ----The active spatializer will determine which effects are supported. ---- ----If an unsupported effect is enabled on a Source, no error will be reported. ---- ----Instead, it will be silently ignored. ---- ----See `lovr.audio.getSpatializer` for a table of the supported effects for each spatializer. ---- ----@alias lovr.Effect ---- ----Models absorption as sound travels through the air, water, etc. ---- ----| "absorption" ---- ----Decreases audio volume with distance (1 / max(distance, 1)). ---- ----| "attenuation" ---- ----Causes audio to drop off when the Source is occluded by geometry. ---- ----| "occlusion" ---- ----Models reverb caused by audio bouncing off of geometry. ---- ----| "reverb" ---- ----Spatializes the Source using either simple panning or an HRTF. ---- ----| "spatialization" ---- ----Causes audio to be heard through walls when occluded, based on audio materials. ---- ----| "transmission" - ---- ----When figuring out how long a Source is or seeking to a specific position in the sound file, units can be expressed in terms of seconds or in terms of frames. ---- ----A frame is one set of samples for each channel (one sample for mono, two samples for stereo). ---- ----@alias lovr.TimeUnit ---- ----Seconds. ---- ----| "seconds" ---- ----Frames. ---- ----| "frames" - ---- ----When accessing the volume of Sources or the audio listener, this can be done in linear units with a 0 to 1 range, or in decibels with a range of -∞ to 0. ---- ----@alias lovr.VolumeUnit ---- ----Linear volume range. ---- ----| "linear" ---- ----Decibels. ---- ----| "db" diff --git a/meta/3rd/lovr/library/lovr/data.lua b/meta/3rd/lovr/library/lovr/data.lua deleted file mode 100644 index 8c841962..00000000 --- a/meta/3rd/lovr/library/lovr/data.lua +++ /dev/null @@ -1,1581 +0,0 @@ ----@meta - ---- ----The `lovr.data` module provides functions for accessing underlying data representations for several LÖVR objects. ---- ----@class lovr.data -lovr.data = {} - ---- ----Creates a new Blob. ---- ----@overload fun(contents: string, name?: string):lovr.Blob ----@overload fun(source: lovr.Blob, name?: string):lovr.Blob ----@param size number # The amount of data to allocate for the Blob, in bytes. All of the bytes will be filled with zeroes. ----@param name? string # A name for the Blob (used in error messages) ----@return lovr.Blob blob # The new Blob. -function lovr.data.newBlob(size, name) end - ---- ----Creates a new Image. ---- ----Image data can be loaded and decoded from an image file, or a raw block of pixels with a specified width, height, and format can be created. ---- ---- ----### NOTE: ----The supported image file formats are png, jpg, hdr, dds (DXT1, DXT3, DXT5), ktx, and astc. ---- ----Only 2D textures are supported for DXT/ASTC. ---- ----Currently textures loaded as KTX need to be in DXT/ASTC formats. ---- ----@overload fun(width: number, height: number, format?: lovr.TextureFormat, data?: lovr.Blob):lovr.Image ----@overload fun(source: lovr.Image):lovr.Image ----@overload fun(blob: lovr.Blob, flip?: boolean):lovr.Image ----@param filename string # The filename of the image to load. ----@param flip? boolean # Whether to vertically flip the image on load. This should be true for normal textures, and false for textures that are going to be used in a cubemap. ----@return lovr.Image image # The new Image. -function lovr.data.newImage(filename, flip) end - ---- ----Loads a 3D model from a file. ---- ----The supported 3D file formats are OBJ and glTF. ---- ----@overload fun(blob: lovr.Blob):lovr.ModelData ----@param filename string # The filename of the model to load. ----@return lovr.ModelData modelData # The new ModelData. -function lovr.data.newModelData(filename) end - ---- ----Creates a new Rasterizer from a TTF file. ---- ----@overload fun(filename: string, size?: number):lovr.Rasterizer ----@overload fun(blob: lovr.Blob, size?: number):lovr.Rasterizer ----@param size? number # The resolution to render the fonts at, in pixels. Higher resolutions use more memory and processing power but may provide better quality results for some fonts/situations. ----@return lovr.Rasterizer rasterizer # The new Rasterizer. -function lovr.data.newRasterizer(size) end - ---- ----Creates a new Sound. ---- ----A sound can be loaded from an audio file, or it can be created empty with capacity for a certain number of audio frames. ---- ----When loading audio from a file, use the `decode` option to control whether compressed audio should remain compressed or immediately get decoded to raw samples. ---- ----When creating an empty sound, the `contents` parameter can be set to `'stream'` to create an audio stream. ---- ----On streams, `Sound:setFrames` will always write to the end of the stream, and `Sound:getFrames` will always read the oldest samples from the beginning. ---- ----The number of frames in the sound is the total capacity of the stream's buffer. ---- ---- ----### NOTE: ----It is highly recommended to use an audio format that matches the format of the audio module: `f32` sample formats at a sample rate of 48000, with 1 channel for spatialized sources or 2 channels for unspatialized sources. ---- ----This will avoid the need to convert audio during playback, which boosts performance of the audio thread. ---- ----The WAV importer supports 16, 24, and 32 bit integer data and 32 bit floating point data. ---- ----The data must be mono, stereo, or 4-channel full-sphere ambisonic. ---- ----The `WAVE_FORMAT_EXTENSIBLE` extension is supported. ---- ----Ambisonic channel layouts are supported for import (but not yet for playback). ---- ----Ambisonic data can be loaded from WAV files. ---- ----It must be first-order full-sphere ambisonic data with 4 channels. ---- ----If the WAV has a `WAVE_FORMAT_EXTENSIBLE` chunk with an `AMBISONIC_B_FORMAT` format GUID, then the data is understood as using the AMB format with Furse-Malham channel ordering and normalization. ---- ----*All other* 4-channel files are assumed to be using the AmbiX format with ACN channel ordering and SN3D normalization. ---- ----AMB files will get automatically converted to AmbiX on import, so ambisonic Sounds will always be in a consistent format. ---- ----OGG and MP3 files will always have the `f32` format when loaded. ---- ----@overload fun(filename: string, decode: boolean):lovr.Sound ----@overload fun(blob: lovr.Blob, decode: boolean):lovr.Sound ----@param frames number # The number of frames the Sound can hold. ----@param format? lovr.SampleFormat # The sample data type. ----@param channels? lovr.ChannelLayout # The channel layout. ----@param sampleRate? number # The sample rate, in Hz. ----@param contents? any # A Blob containing raw audio samples to use as the initial contents, 'stream' to create an audio stream, or `nil` to leave the data initialized to zero. ----@return lovr.Sound sound # Sounds good. -function lovr.data.newSound(frames, format, channels, sampleRate, contents) end - ---- ----A Blob is an object that holds binary data. ---- ----It can be passed to most functions that take filename arguments, like `lovr.graphics.newModel` or `lovr.audio.newSource`. ---- ----Blobs aren't usually necessary for simple projects, but they can be really helpful if: ---- ----- You need to work with low level binary data, potentially using the LuaJIT FFI for increased ---- performance. ----- You are working with data that isn't stored as a file, such as programmatically generated data ---- or a string from a network request. ----- You want to load data from a file once and then use it to create many different objects. ---- ----A Blob's size cannot be changed once it is created. ---- ----@class lovr.Blob -local Blob = {} - ---- ----Returns the filename the Blob was loaded from, or the custom name given to it when it was created. ---- ----This label is also used in error messages. ---- ----@return string name # The name of the Blob. -function Blob:getName() end - ---- ----Returns a raw pointer to the Blob's data. ---- ----This can be used to interface with other C libraries using the LuaJIT FFI. ---- ----Use this only if you know what you're doing! ---- ----@return userdata pointer # A pointer to the data. -function Blob:getPointer() end - ---- ----Returns the size of the Blob's contents, in bytes. ---- ----@return number bytes # The size of the Blob, in bytes. -function Blob:getSize() end - ---- ----Returns a binary string containing the Blob's data. ---- ----@param offset? number # A byte offset into the Blob where the string will start. ----@param size? number # The number of bytes the string will contain. If nil, the rest of the data in the Blob will be used, based on the `offset` parameter. ----@return string data # The Blob's data. -function Blob:getString(offset, size) end - ---- ----An Image stores raw 2D pixel info for `Texture`s. ---- ----It has a width, height, and format. ---- ----The Image can be initialized with the contents of an image file or it can be created with uninitialized contents. ---- ----The supported image formats are `png`, `jpg`, `hdr`, `dds`, `ktx`, and `astc`. ---- ----Usually you can just use Textures, but Image can be useful if you want to manipulate individual pixels, load Textures in a background thread, or use the FFI to efficiently access the raw image data. ---- ----@class lovr.Image -local Image = {} - ---- ----Encodes the Image to an uncompressed png. ---- ----This intended mainly for debugging. ---- ----@return lovr.Blob blob # A new Blob containing the PNG image data. -function Image:encode() end - ---- ----Returns a Blob containing the raw bytes of the Image. ---- ----@return lovr.Blob blob # The Blob instance containing the bytes for the `Image`. -function Image:getBlob() end - ---- ----Returns the dimensions of the Image, in pixels. ---- ----@return number width # The width of the Image, in pixels. ----@return number height # The height of the Image, in pixels. -function Image:getDimensions() end - ---- ----Returns the format of the Image. ---- ----@return lovr.TextureFormat format # The format of the pixels in the Image. -function Image:getFormat() end - ---- ----Returns the height of the Image, in pixels. ---- ----@return number height # The height of the Image, in pixels. -function Image:getHeight() end - ---- ----Returns the value of a pixel of the Image. ---- ---- ----### NOTE: ----The following texture formats are supported: `r8`, `rg8`, `rgba8`, `r16`, `rg16`, `rgba16`, `r32f`, `rg32f`, `rgba32f`. ---- ----@param x number # The x coordinate of the pixel to get (0-indexed). ----@param y number # The y coordinate of the pixel to get (0-indexed). ----@return number r # The red component of the pixel, from 0.0 to 1.0. ----@return number g # The green component of the pixel, from 0.0 to 1.0. ----@return number b # The blue component of the pixel, from 0.0 to 1.0. ----@return number a # The alpha component of the pixel, from 0.0 to 1.0. -function Image:getPixel(x, y) end - ---- ----Returns the width of the Image, in pixels. ---- ----@return number width # The width of the Image, in pixels. -function Image:getWidth() end - ---- ----Copies a rectangle of pixels from one Image to this one. ---- ---- ----### NOTE: ----The two Images must have the same pixel format. ---- ----Compressed images cannot be copied. ---- ----The rectangle cannot go outside the dimensions of the source or destination textures. ---- ----@param source lovr.Image # The Image to copy pixels from. ----@param x? number # The x coordinate to paste to (0-indexed). ----@param y? number # The y coordinate to paste to (0-indexed). ----@param fromX? number # The x coordinate in the source to paste from (0-indexed). ----@param fromY? number # The y coordinate in the source to paste from (0-indexed). ----@param width? number # The width of the region to copy. ----@param height? number # The height of the region to copy. -function Image:paste(source, x, y, fromX, fromY, width, height) end - ---- ----Sets the value of a pixel of the Image. ---- ---- ----### NOTE: ----The following texture formats are supported: `r8`, `rg8`, `rgba8`, `r16`, `rg16`, `rgba16`, `r32f`, `rg32f`, `rgba32f`. ---- ----@param x number # The x coordinate of the pixel to set (0-indexed). ----@param y number # The y coordinate of the pixel to set (0-indexed). ----@param r number # The red component of the pixel, from 0.0 to 1.0. ----@param g number # The green component of the pixel, from 0.0 to 1.0. ----@param b number # The blue component of the pixel, from 0.0 to 1.0. ----@param a? number # The alpha component of the pixel, from 0.0 to 1.0. -function Image:setPixel(x, y, r, g, b, a) end - ---- ----A ModelData is a container object that loads and holds data contained in 3D model files. ---- ----This can include a variety of things like the node structure of the asset, the vertex data it contains, contains, the `Image` and `Material` properties, and any included animations. ---- ----The current supported formats are OBJ, glTF, and STL. ---- ----Usually you can just load a `Model` directly, but using a `ModelData` can be helpful if you want to load models in a thread or access more low-level information about the Model. ---- ----@class lovr.ModelData -local ModelData = {} - ---- ----Returns the number of channels in an animation. ---- ----A channel is a set of keyframes for a single property of a node. ---- ----@overload fun(self: lovr.ModelData, name: string):number ----@param index number # The index of an animation. ----@return number count # The number of channels in the animation. -function ModelData:getAnimationChannelCount(index) end - ---- ----Returns the number of animations in the model. ---- ----@return number count # The number of animations in the model. -function ModelData:getAnimationCount() end - ---- ----Returns the duration of an animation. ---- ---- ----### NOTE: ----The duration of the animation is calculated as the latest timestamp of all of its channels. ---- ----@overload fun(self: lovr.ModelData, name: string):number ----@param index number # The index of the animation. ----@return number duration # The duration of the animation, in seconds. -function ModelData:getAnimationDuration(index) end - ---- ----Returns a single keyframe in a channel of an animation. ---- ----@overload fun(self: lovr.ModelData, name: string, channel: number, keyframe: number):number, number ----@param index number # The index of an animation. ----@param channel number # The index of a channel in the animation. ----@param keyframe number # The index of a keyframe in the channel. ----@return number time # The timestamp of the keyframe. -function ModelData:getAnimationKeyframe(index, channel, keyframe) end - ---- ----Returns the number of keyframes in a channel of an animation. ---- ----@overload fun(self: lovr.ModelData, name: string, channel: number):number ----@param index number # The index of an animation. ----@param channel number # The index of a channel in the animation. ----@return number count # The number of keyframes in the channel. -function ModelData:getAnimationKeyframeCount(index, channel) end - ---- ----Returns the name of an animation. ---- ---- ----### NOTE: ----If the animation does not have a name, this function returns `nil`. ---- ----@param index number # The index of the animation. ----@return string name # The name of the animation. -function ModelData:getAnimationName(index) end - ---- ----Returns the index of a node targeted by an animation's channel. ---- ----@overload fun(self: lovr.ModelData, name: string, channel: number):number ----@param index number # The index of an animation. ----@param channel number # The index of a channel in the animation. ----@return number node # The index of the node targeted by the channel. -function ModelData:getAnimationNode(index, channel) end - ---- ----Returns the property targeted by an animation's channel. ---- ----@overload fun(self: lovr.ModelData, name: string, channel: number):lovr.AnimationProperty ----@param index number # The index of an animation. ----@param channel number # The index of a channel in the animation. ----@return lovr.AnimationProperty property # The property (translation, rotation, scale, weights) affected by the keyframes. -function ModelData:getAnimationProperty(index, channel) end - ---- ----Returns the smooth mode of a channel in an animation. ---- ----@overload fun(self: lovr.ModelData, name: string, channel: number):lovr.SmoothMode ----@param index number # The index of an animation. ----@param channel number # The index of a channel in the animation. ----@return lovr.SmoothMode smooth # The smooth mode of the keyframes. -function ModelData:getAnimationSmoothMode(index, channel) end - ---- ----Returns the number of blend shapes in the model. ---- ----@return number count # The number of blend shapes in the model. -function ModelData:getBlendShapeCount() end - ---- ----Returns the name of a blend shape in the model. ---- ---- ----### NOTE: ----This function will throw an error if the blend shape index is invalid. ---- ----@param index number # The index of a blend shape. ----@return string name # The name of the blend shape. -function ModelData:getBlendShapeName(index) end - ---- ----Returns one of the Blobs in the model, by index. ---- ----@param index number # The index of the Blob to get. ----@return lovr.Blob blob # The Blob object. -function ModelData:getBlob(index) end - ---- ----Returns the number of Blobs in the model. ---- ----@return number count # The number of Blobs in the model. -function ModelData:getBlobCount() end - ---- ----Returns the 6 values of the model's axis-aligned bounding box. ---- ----@return number minx # The minimum x coordinate of the vertices in the model. ----@return number maxx # The maximum x coordinate of the vertices in the model. ----@return number miny # The minimum y coordinate of the vertices in the model. ----@return number maxy # The maximum y coordinate of the vertices in the model. ----@return number minz # The minimum z coordinate of the vertices in the model. ----@return number maxz # The maximum z coordinate of the vertices in the model. -function ModelData:getBoundingBox() end - ---- ----Returns a sphere approximately enclosing the vertices in the model. ---- ----@return number x # The x coordinate of the position of the sphere. ----@return number y # The y coordinate of the position of the sphere. ----@return number z # The z coordinate of the position of the sphere. ----@return number radius # The radius of the bounding sphere. -function ModelData:getBoundingSphere() end - ---- ----Returns the center of the model's axis-aligned bounding box, relative to the model's origin. ---- ----@return number x # The x offset of the center of the bounding box. ----@return number y # The y offset of the center of the bounding box. ----@return number z # The z offset of the center of the bounding box. -function ModelData:getCenter() end - ---- ----Returns the depth of the model, computed from its axis-aligned bounding box. ---- ----@return number depth # The depth of the model. -function ModelData:getDepth() end - ---- ----Returns the width, height, and depth of the model, computed from its axis-aligned bounding box. ---- ----@return number width # The width of the model. ----@return number height # The height of the model. ----@return number depth # The depth of the model. -function ModelData:getDimensions() end - ---- ----Returns the height of the model, computed from its axis-aligned bounding box. ---- ----@return number height # The height of the model. -function ModelData:getHeight() end - ---- ----Returns one of the Images in the model, by index. ---- ----@param index number # The index of the Image to get. ----@return lovr.Image image # The Image object. -function ModelData:getImage(index) end - ---- ----Returns the number of Images in the model. ---- ----@return number count # The number of Images in the model. -function ModelData:getImageCount() end - ---- ----Returns a table with all of the properties of a material. ---- ---- ----### NOTE: ----All images are optional and may be `nil`. ---- ----@overload fun(self: lovr.ModelData, name: string):table ----@param index number # The index of a material. ----@return {color: table, glow: table, uvShift: table, uvScale: table, metalness: number, roughness: number, clearcoat: number, clearcoatRoughness: number, occlusionStrength: number, normalScale: number, alphaCutoff: number, texture: number, glowTexture: number, occlusionTexture: number, metalnessTexture: number, roughnessTexture: number, clearcoatTexture: number, normalTexture: number} properties # The material properties. -function ModelData:getMaterial(index) end - ---- ----Returns the number of materials in the model. ---- ----@return number count # The number of materials in the model. -function ModelData:getMaterialCount() end - ---- ----Returns the name of a material in the model. ---- ----@param index number # The index of a material. ----@return string name # The name of the material, or nil if the material does not have a name. -function ModelData:getMaterialName(index) end - ---- ----Returns the number of meshes in the model. ---- ----@return number count # The number of meshes in the model. -function ModelData:getMeshCount() end - ---- ----Returns the draw mode of a mesh. ---- ----This controls how its vertices are connected together (points, lines, or triangles). ---- ----@param mesh number # The index of a mesh. ----@return lovr.DrawMode mode # The draw mode of the mesh. -function ModelData:getMeshDrawMode(mesh) end - ---- ----Returns one of the vertex indices in a mesh. ---- ----If a mesh has vertex indices, they define the order and connectivity of the vertices in the mesh, allowing a vertex to be reused multiple times without duplicating its data. ---- ----@param mesh number # The index of a mesh to get the vertex from. ----@param index number # The index of a vertex index in the mesh to retrieve. ----@return number vertexindex # The vertex index. Like all indices in Lua, this is 1-indexed. -function ModelData:getMeshIndex(mesh, index) end - ---- ----Returns the number of vertex indices in a mesh. ---- ----Vertex indices allow for vertices to be reused when defining triangles. ---- ---- ----### NOTE: ----This may return zero if the mesh does not use indices. ---- ----@param mesh number # The index of a mesh. ----@return number count # The number of vertex indices in the mesh. -function ModelData:getMeshIndexCount(mesh) end - ---- ----Returns the data format of vertex indices in a mesh. ---- ----If a mesh doesn't use vertex indices, this function returns nil. ---- ----@param mesh number # The index of a mesh. ----@return lovr.AttributeType type # The data type of each vertex index (always u16 or u32). ----@return number blob # The index of a Blob in the mesh where the binary data is stored. ----@return number offset # A byte offset into the Blob's data where the index data starts. ----@return number stride # The number of bytes between subsequent vertex indices. Indices are always tightly packed, so this will always be 2 or 4 depending on the data type. -function ModelData:getMeshIndexFormat(mesh) end - ---- ----Returns the index of the material applied to a mesh. ---- ----@param mesh number # The index of a mesh. ----@return number material # The index of the material applied to the mesh, or nil if the mesh does not have a material. -function ModelData:getMeshMaterial(mesh) end - ---- ----Returns the data for a single vertex in a mesh. ---- ----The data returned depends on the vertex format of a mesh, which is given by `ModelData:getMeshVertexFormat`. ---- ----@param mesh number # The index of a mesh to get the vertex from. ----@param vertex number # The index of a vertex in the mesh to retrieve. -function ModelData:getMeshVertex(mesh, vertex) end - ---- ----Returns the number of vertices in a mesh. ---- ----@param mesh number # The index of a mesh. ----@return number count # The number of vertices in the mesh. -function ModelData:getMeshVertexCount(mesh) end - ---- ----Returns the vertex format of a mesh. ---- ----The vertex format defines the properties associated with each vertex (position, color, etc.), including their types and binary data layout. ---- ---- ----### NOTE: ----The format is given as a table of vertex attributes. ---- ----Each attribute is a table containing the following: ---- ---- { name, type, components, blob, offset, stride } ---- ----- The `name` will be a `DefaultAttribute`. ----- The `type` will be an `AttributeType`. ----- The `component` count will be 1-4. ----- The `blob` is an index of one of the Blobs in the model (see `ModelData:getBlob`). ----- The `offset` is a byte offset from the start of the Blob where the attribute's data starts. ----- The `stride` is the number of bytes between consecutive values. ---- ----@param mesh number # The index of a mesh. ----@return table format # The vertex format of the mesh. -function ModelData:getMeshVertexFormat(mesh) end - ---- ----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. ---- ----@return string metadata # The metadata from the model file. -function ModelData:getMetadata() end - ---- ----Given a parent node, this function returns a table with the indices of its children. ---- ---- ----### NOTE: ----If the node does not have any children, this function returns an empty table. ---- ----@overload fun(self: lovr.ModelData, name: string):table ----@param index number # The index of the parent node. ----@return table children # A table containing a node index for each child of the node. -function ModelData:getNodeChildren(index) end - ---- ----Returns the number of nodes in the model. ---- ----@return number count # The number of nodes in the model. -function ModelData:getNodeCount() end - ---- ----Returns a table of mesh indices attached to a node. ---- ----Meshes define the geometry and materials of a model, as opposed to the nodes which define the transforms and hierarchy. ---- ----A node can have multiple meshes, and meshes can be reused in multiple nodes. ---- ----@overload fun(self: lovr.ModelData, name: string):table ----@param index number # The index of the node. ----@return table meshes # A table with the node's mesh indices. -function ModelData:getNodeMeshes(index) end - ---- ----Returns the name of a node. ---- ---- ----### NOTE: ----If the node does not have a name, this function returns `nil`. ---- ----@param index number # The index of the node. ----@return string name # The name of the node. -function ModelData:getNodeName(index) end - ---- ----Returns local orientation of a node, relative to its parent. ---- ----@overload fun(self: lovr.ModelData, name: string):number, number, number, number ----@param index number # The index of the node. ----@return number angle # The number of radians the node is rotated around its axis of rotation. ----@return number ax # The x component of the axis of rotation. ----@return number ay # The y component of the axis of rotation. ----@return number az # The z component of the axis of rotation. -function ModelData:getNodeOrientation(index) end - ---- ----Given a child node, this function returns the index of its parent. ---- ----@overload fun(self: lovr.ModelData, name: string):number ----@param index number # The index of the child node. ----@return number parent # The index of the parent. -function ModelData:getNodeParent(index) end - ---- ----Returns local pose (position and orientation) of a node, relative to its parent. ---- ----@overload fun(self: lovr.ModelData, name: string):number, number, number, number, number, number, number ----@param index number # The index of the node. ----@return number x # The x coordinate. ----@return number y # The y coordinate. ----@return number z # The z coordinate. ----@return number angle # The number of radians the node is rotated around its axis of rotation. ----@return number ax # The x component of the axis of rotation. ----@return number ay # The y component of the axis of rotation. ----@return number az # The z component of the axis of rotation. -function ModelData:getNodePose(index) end - ---- ----Returns local position of a node, relative to its parent. ---- ----@overload fun(self: lovr.ModelData, name: string):number, number, number ----@param index number # The index of the node. ----@return number x # The x coordinate. ----@return number y # The y coordinate. ----@return number z # The z coordinate. -function ModelData:getNodePosition(index) end - ---- ----Returns local scale of a node, relative to its parent. ---- ----@overload fun(self: lovr.ModelData, name: string):number, number, number ----@param index number # The index of the node. ----@return number sx # The x scale. ----@return number sy # The y scale. ----@return number sz # The z scale. -function ModelData:getNodeScale(index) end - ---- ----Returns the index of the skin used by a node. ---- ----Skins are collections of joints used for skeletal animation. ---- ----A model can have multiple skins, and each node can use at most one skin to drive the animation of its meshes. ---- ----@overload fun(self: lovr.ModelData, name: string):number ----@param index number # The index of the node. ----@return number skin # The index of the node's skin, or nil if the node isn't skeletally animated. -function ModelData:getNodeSkin(index) end - ---- ----Returns local transform (position, orientation, and scale) of a node, relative to its parent. ---- ---- ----### NOTE: ----For best results when animating, it's recommended to keep the 3 components of the scale the same. ---- ----@overload fun(self: lovr.ModelData, name: string):number, number, number, number, number, number, number, number, number, number ----@param index number # The index of the node. ----@return number x # The x coordinate. ----@return number y # The y coordinate. ----@return number z # The z coordinate. ----@return number sx # The x scale. ----@return number sy # The y scale. ----@return number sz # The z scale. ----@return number angle # The number of radians the node is rotated around its axis of rotation. ----@return number ax # The x component of the axis of rotation. ----@return number ay # The y component of the axis of rotation. ----@return number az # The z component of the axis of rotation. -function ModelData:getNodeTransform(index) end - ---- ----Returns the index of the model's root node. ---- ----@return number root # The index of the root node. -function ModelData:getRootNode() end - ---- ----Returns the number of skins in the model. ---- ----A skin is a collection of joints targeted by an animation. ---- ---- ----### NOTE: ----There is currently a maximum of 256 skins. ---- ----@return number count # The number of skins in the model. -function ModelData:getSkinCount() end - ---- ----Returns the inverse bind matrix for a joint in the skin. ---- ----@param skin number # The index of a skin. ----@param joint number # The index of a joint in the skin. -function ModelData:getSkinInverseBindMatrix(skin, joint) end - ---- ----Returns a table with the node indices of the joints in a skin. ---- ----@param skin number # The index of a skin. ----@return table joints # The joints in the skin. -function ModelData:getSkinJoints(skin) end - ---- ----Returns the total number of triangles in the model. ---- ----This count includes meshes that are attached to multiple nodes, and the count corresponds to the triangles returned by `ModelData:getTriangles`. ---- ----@return number count # The total number of triangles in the model. -function ModelData:getTriangleCount() end - ---- ----Returns the data for all triangles in the model. ---- ----There are a few differences between this and the mesh-specific functions like `ModelData:getMeshVertex` and `ModelData:getMeshIndex`: ---- ----- Only vertex positions are returned, not other vertex attributes. ----- Positions are relative to the origin of the whole model, instead of local to a node. ----- If a mesh is attached to more than one node, its vertices will be in the table multiple times. ----- Vertex indices will be relative to the whole triangle list instead of a mesh. ---- ---- ----### NOTE: ----After this function is called on a ModelData once, the result is cached. ---- ----@return table vertices # The triangle vertex positions, returned as a flat (non-nested) table of numbers. The position of each vertex is given as an x, y, and z coordinate. ----@return table indices # The vertex indices. Every 3 indices describes a triangle. -function ModelData:getTriangles() end - ---- ----Returns the total vertex count of a model. ---- ----This count includes meshes that are attached to multiple nodes, and the count corresponds to the vertices returned by `ModelData:getTriangles`. ---- ----@return number count # The total number of vertices in the model. -function ModelData:getVertexCount() end - ---- ----Returns the width of the model, computed from its axis-aligned bounding box. ---- ----@return number width # The width of the model. -function ModelData:getWidth() end - ---- ----A Rasterizer is an object that parses a TTF file, decoding and rendering glyphs from it. ---- ----Usually you can just use `Font` objects. ---- ----@class lovr.Rasterizer -local Rasterizer = {} - ---- ----Returns the advance metric for a glyph, in pixels. ---- ----The advance is the horizontal distance to advance the cursor after rendering the glyph. ---- ----@overload fun(self: lovr.Rasterizer, codepoint: number):number ----@param character string # A character. ----@return number advance # The advance of the glyph, in pixels. -function Rasterizer:getAdvance(character) end - ---- ----Returns the ascent metric of the font, in pixels. ---- ----The ascent represents how far any glyph of the font ascends above the baseline. ---- ----@return number ascent # The ascent of the font, in pixels. -function Rasterizer:getAscent() end - ---- ----Returns the bearing metric for a glyph, in pixels. ---- ----The bearing is the horizontal distance from the cursor to the edge of the glyph. ---- ----@overload fun(self: lovr.Rasterizer, codepoint: number):number ----@param character string # A character. ----@return number bearing # The bearing of the glyph, in pixels. -function Rasterizer:getBearing(character) end - ---- ----Returns the bounding box of a glyph, or the bounding box surrounding all glyphs. ---- ----Note that font coordinates use a cartesian "y up" coordinate system. ---- ----@overload fun(self: lovr.Rasterizer, codepoint: number):number, number, number, number ----@overload fun(self: lovr.Rasterizer):number, number, number, number ----@param character string # A character. ----@return number x1 # The left edge of the bounding box, in pixels. ----@return number y1 # The bottom edge of the bounding box, in pixels. ----@return number x2 # The right edge of the bounding box, in pixels. ----@return number y2 # The top edge of the bounding box, in pixels. -function Rasterizer:getBoundingBox(character) end - ---- ----Returns the bezier curve control points defining the shape of a glyph. ---- ----@overload fun(self: lovr.Rasterizer, codepoint: number, three: boolean):table ----@param character string # A character. ----@param three boolean # Whether the control points should be 3D or 2D. ----@return table curves # A table of curves. Each curve is a table of numbers representing the control points (2 for a line, 3 for a quadratic curve, etc.). -function Rasterizer:getCurves(character, three) end - ---- ----Returns the descent metric of the font, in pixels. ---- ----The descent represents how far any glyph of the font descends below the baseline. ---- ----@return number descent # The descent of the font, in pixels. -function Rasterizer:getDescent() end - ---- ----Returns the dimensions of a glyph, or the dimensions of any glyph. ---- ----@overload fun(self: lovr.Rasterizer, codepoint: number):number, number ----@overload fun(self: lovr.Rasterizer):number, number ----@param character string # A character. ----@return number width # The width, in pixels. ----@return number height # The height, in pixels. -function Rasterizer:getDimensions(character) end - ---- ----Returns the size of the font, in pixels. ---- ----This is the size the rasterizer was created with, and defines the size of images it rasterizes. ---- ----@return number size # The font size, in pixels. -function Rasterizer:getFontSize() end - ---- ----Returns the number of glyphs stored in the font file. ---- ----@return number count # The number of glyphs stored in the font file. -function Rasterizer:getGlyphCount() end - ---- ----Returns the height of a glyph, or the maximum height of any glyph. ---- ----@overload fun(self: lovr.Rasterizer, codepoint: number):number ----@overload fun(self: lovr.Rasterizer):number ----@param character string # A character. ----@return number height # The height, in pixels. -function Rasterizer:getHeight(character) end - ---- ----Returns the kerning between 2 glyphs, in pixels. ---- ----Kerning is a slight horizontal adjustment between 2 glyphs to improve the visual appearance. ---- ----It will often be negative. ---- ----@overload fun(self: lovr.Rasterizer, firstCodepoint: number, second: string):number ----@overload fun(self: lovr.Rasterizer, first: string, secondCodepoint: number):number ----@overload fun(self: lovr.Rasterizer, firstCodepoint: number, secondCodepoint: number):number ----@param first string # The first character. ----@param second string # The second character. ----@return number keming # The kerning between the two glyphs. -function Rasterizer:getKerning(first, second) end - ---- ----Returns the leading metric of the font, in pixels. ---- ----This is the full amount of space between lines. ---- ----@return number leading # The font leading, in pixels. -function Rasterizer:getLeading() end - ---- ----Returns the width of a glyph, or the maximum width of any glyph. ---- ----@overload fun(self: lovr.Rasterizer, codepoint: number):number ----@overload fun(self: lovr.Rasterizer):number ----@param character string # A character. ----@return number width # The width, in pixels. -function Rasterizer:getWidth(character) end - ---- ----Returns whether the Rasterizer can rasterize a set of glyphs. ---- ----@vararg any # Strings (sets of characters) or numbers (character codes) to check for. ----@return boolean hasGlyphs # true if the Rasterizer can rasterize all of the supplied characters, false otherwise. -function Rasterizer:hasGlyphs(...) end - ---- ----Returns an `Image` containing a rasterized glyph. ---- ----@overload fun(self: lovr.Rasterizer, codepoint: number, spread?: number, padding?: number):lovr.Image ----@param character string # A character. ----@param spread? number # The width of the distance field, for signed distance field rasterization. ----@param padding? number # The number of pixels of padding to add at the edges of the image. ----@return lovr.Image image # The glyph image. It will be in the `rgba32f` format. -function Rasterizer:newImage(character, spread, padding) end - ---- ----A Sound stores the data for a sound. ---- ----The supported sound formats are OGG, WAV, and MP3. ---- ----Sounds cannot be played directly. ---- ----Instead, there are `Source` objects in `lovr.audio` that are used for audio playback. ---- ----All Source objects are backed by one of these Sounds, and multiple Sources can share a single Sound to reduce memory usage. ---- ----Metadata ------- ---- ----Sounds hold a fixed number of frames. ---- ----Each frame contains one audio sample for each channel. The `SampleFormat` of the Sound is the data type used for each sample (floating point, integer, etc.). ---- ----The Sound has a `ChannelLayout`, representing the number of audio channels and how they map to speakers (mono, stereo, etc.). ---- ----The sample rate of the Sound indicates how many frames should be played per second. ---- ----The duration of the sound (in seconds) is the number of frames divided by the sample rate. ---- ----Compression ------- ---- ----Sounds can be compressed. ---- ----Compressed sounds are stored compressed in memory and are decoded as they are played. ---- ----This uses a lot less memory but increases CPU usage during playback. ---- ----OGG and MP3 are compressed audio formats. ---- ----When creating a sound from a compressed format, there is an option to immediately decode it, storing it uncompressed in memory. ---- ----It can be a good idea to decode short sound effects, since they won't use very much memory even when uncompressed and it will improve CPU usage. ---- ----Compressed sounds can not be written to using `Sound:setFrames`. ---- ----Streams ------- ---- ----Sounds can be created as a stream by passing `'stream'` as their contents when creating them. Audio frames can be written to the end of the stream, and read from the beginning. ---- ----This works well for situations where data is being generated in real time or streamed in from some other data source. ---- ----Sources can be backed by a stream and they'll just play whatever audio is pushed to the stream. The audio module also lets you use a stream as a "sink" for an audio device. ---- ----For playback devices, this works like loopback, so the mixed audio from all playing Sources will get written to the stream. ---- ----For capture devices, all the microphone input will get written to the stream. Conversion between sample formats, channel layouts, and sample rates will happen automatically. ---- ----Keep in mind that streams can still only hold a fixed number of frames. ---- ----If too much data is written before it is read, older frames will start to get overwritten. ---- ----Similary, it's possible to read too much data without writing fast enough. ---- ----Ambisonics ------- ---- ----Ambisonic sounds can be imported from WAVs, but can not yet be played. ---- ----Sounds with a `ChannelLayout` of `ambisonic` are stored as first-order full-sphere ambisonics using the AmbiX format (ACN channel ordering and SN3D channel normalization). ---- ----The AMB format is supported for import and will automatically get converted to AmbiX. ---- ----See `lovr.data.newSound` for more info. ---- ----@class lovr.Sound -local Sound = {} - ---- ----Returns a Blob containing the raw bytes of the Sound. ---- ---- ----### NOTE: ----Samples for each channel are stored interleaved. ---- ----The data type of each sample is given by `Sound:getFormat`. ---- ----@return lovr.Blob blob # The Blob instance containing the bytes for the `Sound`. -function Sound:getBlob() end - ---- ----Returns the number of frames that can be written to the Sound. ---- ----For stream sounds, this is the number of frames that can be written without overwriting existing data. ---- ----For normal sounds, this returns the same value as `Sound:getFrameCount`. ---- ----@return number capacity # The number of frames that can be written to the Sound. -function Sound:getCapacity() end - ---- ----Returns the number of channels in the Sound. ---- ----Mono sounds have 1 channel, stereo sounds have 2 channels, and ambisonic sounds have 4 channels. ---- ----@return number channels # The number of channels in the sound. -function Sound:getChannelCount() end - ---- ----Returns the channel layout of the Sound. ---- ----@return lovr.ChannelLayout channels # The channel layout. -function Sound:getChannelLayout() end - ---- ----Returns the duration of the Sound, in seconds. ---- ---- ----### NOTE: ----This can be computed as `(frameCount / sampleRate)`. ---- ----@return number duration # The duration of the Sound, in seconds. -function Sound:getDuration() end - ---- ----Returns the sample format of the Sound. ---- ----@return lovr.SampleFormat format # The data type of each sample. -function Sound:getFormat() end - ---- ----Returns the number of frames in the Sound. ---- ----A frame stores one sample for each channel. ---- ---- ----### NOTE: ----For streams, this returns the number of frames in the stream's buffer. ---- ----@return number frames # The number of frames in the Sound. -function Sound:getFrameCount() end - ---- ----Reads frames from the Sound into a table, Blob, or another Sound. ---- ----@overload fun(self: lovr.Sound, t: table, count?: number, srcOffset?: number, dstOffset?: number):table, number ----@overload fun(self: lovr.Sound, blob: lovr.Blob, count?: number, srcOffset?: number, dstOffset?: number):number ----@overload fun(self: lovr.Sound, sound: lovr.Sound, count?: number, srcOffset?: number, dstOffset?: number):number ----@param count? number # The number of frames to read. If nil, reads as many frames as possible. - -Compressed sounds will automatically be decoded. - -Reading from a stream will ignore the source offset and read the oldest frames. ----@param srcOffset? number # A frame offset to apply to the sound when reading frames. ----@return table t # A table containing audio frames. ----@return number count # The number of frames read. -function Sound:getFrames(count, srcOffset) end - ---- ----Returns the total number of samples in the Sound. ---- ---- ----### NOTE: ----For streams, this returns the number of samples in the stream's buffer. ---- ----@return number samples # The total number of samples in the Sound. -function Sound:getSampleCount() end - ---- ----Returns the sample rate of the Sound, in Hz. ---- ----This is the number of frames that are played every second. ---- ----It's usually a high number like 48000. ---- ----@return number frequency # The number of frames per second in the Sound. -function Sound:getSampleRate() end - ---- ----Returns whether the Sound is compressed. ---- ----Compressed sounds are loaded from compressed audio formats like MP3 and OGG. ---- ----They use a lot less memory but require some extra CPU work during playback. ---- ----Compressed sounds can not be modified using `Sound:setFrames`. ---- ----@return boolean compressed # Whether the Sound is compressed. -function Sound:isCompressed() end - ---- ----Returns whether the Sound is a stream. ---- ----@return boolean stream # Whether the Sound is a stream. -function Sound:isStream() end - ---- ----Writes frames to the Sound. ---- ----@overload fun(self: lovr.Sound, blob: lovr.Blob, count?: number, dstOffset?: number, srcOffset?: number):number ----@overload fun(self: lovr.Sound, sound: lovr.Sound, count?: number, dstOffset?: number, srcOffset?: number):number ----@param t table # A table containing frames to write. ----@param count? number # How many frames to write. If nil, writes as many as possible. ----@param dstOffset? number # A frame offset to apply when writing the frames. ----@param srcOffset? number # A frame, byte, or index offset to apply when reading frames from the source. ----@return number count # The number of frames written. -function Sound:setFrames(t, count, dstOffset, srcOffset) end - ---- ----This indicates the different node properties that can be animated. ---- ----@alias lovr.AnimationProperty ---- ----Node translation. ---- ----| "translation" ---- ----Node rotation. ---- ----| "rotation" ---- ----Node scale. ---- ----| "scale" ---- ----Node blend shape weights. ---- ----| "weights" - ---- ----These are the data types that can be used by vertex data in meshes. ---- ----@alias lovr.AttributeType ---- ----Signed 8 bit integers (-128 to 127). ---- ----| "i8" ---- ----Unsigned 8 bit integers (0 to 255). ---- ----| "u8" ---- ----Signed 16 bit integers (-32768 to 32767). ---- ----| "i16" ---- ----Unsigned 16 bit integers (0 to 65535). ---- ----| "u16" ---- ----Signed 32 bit integers (-2147483648 to 2147483647). ---- ----| "i32" ---- ----Unsigned 32 bit integers (0 to 429467295). ---- ----| "u32" ---- ----Floating point numbers. ---- ----| "f32" - ---- ----Sounds can have different numbers of channels, and those channels can map to various speaker layouts. ---- ----@alias lovr.ChannelLayout ---- ----1 channel. ---- ----| "mono" ---- ----2 channels. ---- ----The first channel is for the left speaker and the second is for the right. ---- ----| "stereo" ---- ----4 channels. ---- ----Ambisonic channels don't map directly to speakers but instead represent directions in 3D space, sort of like the images of a skybox. ---- ----Currently, ambisonic sounds can only be loaded, not played. ---- ----| "ambisonic" - ---- ----These are the different types of attributes that may be present in meshes loaded from models. ---- ----@alias lovr.DefaultAttribute ---- ----Vertex positions. ---- ----| "position" ---- ----Vertex normal vectors. ---- ----| "normal" ---- ----Vertex texture coordinates. ---- ----| "uv" ---- ----Vertex colors. ---- ----| "color" ---- ----Vertex tangent vectors. ---- ----| "tangent" ---- ----Vertex joint indices. ---- ----| "joints" ---- ----Vertex joint weights. ---- ----| "weights" - ---- ----The DrawMode of a mesh determines how its vertices are connected together. ---- ----@alias lovr.DrawMode ---- ----Each vertex is draw as a single point. ---- ----| "points" ---- ----Every pair of vertices is drawn as a line. ---- ----| "lines" ---- ----Draws a single line through all of the vertices. ---- ----| "linestrip" ---- ----Draws a single line through all of the vertices, then connects back to the first vertex. ---- ----| "lineloop" ---- ----Vertices are rendered as triangles. ---- ----After the first 3 vertices, each subsequent vertex connects to the previous two. ---- ----| "strip" ---- ----Every 3 vertices forms a triangle. ---- ----| "triangles" ---- ----Vertices are rendered as triangles. ---- ----After the first 3 vertices, each subsequent vertex is connected to the previous vertex and the first vertex. ---- ----| "fan" - ---- ----Sounds can store audio samples as 16 bit integers or 32 bit floats. ---- ----@alias lovr.SampleFormat ---- ----32 bit floating point samples (between -1.0 and 1.0). ---- ----| "f32" ---- ----16 bit integer samples (between -32768 and 32767). ---- ----| "i16" - ---- ----Different ways to interpolate between animation keyframes. ---- ----@alias lovr.SmoothMode ---- ----The animated property will snap to the nearest keyframe. ---- ----| "step" ---- ----The animated property will linearly interpolate between keyframes. ---- ----| "linear" ---- ----The animated property will follow a smooth curve between nearby keyframes. ---- ----| "cubic" - ---- ----Different data layouts for pixels in `Image` and `Texture` objects. ---- ----Formats starting with `d` are depth formats, used for depth/stencil render targets. ---- ----Formats starting with `bc` and `astc` are compressed formats. ---- ----Compressed formats have better performance since they stay compressed on the CPU and GPU, reducing the amount of memory bandwidth required to look up all the pixels needed for shading. ---- ----Formats without the `f` suffix are unsigned normalized formats, which store values in the range `[0,1]`. ---- ----The `f` suffix indicates a floating point format which can store values outside this range, and is used for HDR rendering or storing data in a texture. ---- ----@alias lovr.TextureFormat ---- ----One 8-bit channel. ---- ----1 byte per pixel. ---- ----| "r8" ---- ----Two 8-bit channels. ---- ----2 bytes per pixel. ---- ----| "rg8" ---- ----Four 8-bit channels. ---- ----4 bytes per pixel. ---- ----| "rgba8" ---- ----One 16-bit channel. ---- ----2 bytes per pixel. ---- ----| "r16" ---- ----Two 16-bit channels. ---- ----4 bytes per pixel. ---- ----| "rg16" ---- ----Four 16-bit channels. ---- ----8 bytes per pixel. ---- ----| "rgba16" ---- ----One 16-bit floating point channel. ---- ----2 bytes per pixel. ---- ----| "r16f" ---- ----Two 16-bit floating point channels. ---- ----4 bytes per pixel. ---- ----| "rg16f" ---- ----Four 16-bit floating point channels. ---- ----8 bytes per pixel. ---- ----| "rgba16f" ---- ----One 32-bit floating point channel. ---- ----4 bytes per pixel. ---- ----| "r32f" ---- ----Two 32-bit floating point channels. ---- ----8 bytes per pixel. ---- ----| "rg32f" ---- ----Four 32-bit floating point channels. ---- ----16 bytes per pixel. ---- ----| "rgba32f" ---- ----Packs three channels into 16 bits. ---- ----2 bytes per pixel. ---- ----| "rgb565" ---- ----Packs four channels into 16 bits, with "cutout" alpha. ---- ----2 bytes per pixel. ---- ----| "rgb5a1" ---- ----Packs four channels into 32 bits. ---- ----4 bytes per pixel. ---- ----| "rgb10a2" ---- ----Packs three unsigned floating point channels into 32 bits. ---- ----4 bytes per pixel. ---- ----| "rg11b10f" ---- ----One 16-bit depth channel. ---- ----2 bytes per pixel. ---- ----| "d16" ---- ----One 24-bit depth channel and one 8-bit stencil channel. ---- ----4 bytes per pixel. ---- ----| "d24s8" ---- ----One 32-bit floating point depth channel. ---- ----4 bytes per pixel. ---- ----| "d32f" ---- ----One 32-bit floating point depth channel and one 8-bit stencil channel. ---- ----5 bytes per pixel. ---- ----| "d32fs8" ---- ----3 channels. ---- ----8 bytes per 4x4 block, or 0.5 bytes per pixel. ---- ----Good for opaque images. ---- ----| "bc1" ---- ----Four channels. ---- ----16 bytes per 4x4 block or 1 byte per pixel. ---- ----Not good for anything, because it only has 16 distinct levels of alpha. ---- ----| "bc2" ---- ----Four channels. ---- ----16 bytes per 4x4 block or 1 byte per pixel. ---- ----Good for color images with transparency. ---- ----| "bc3" ---- ----One unsigned normalized channel. ---- ----8 bytes per 4x4 block or 0.5 bytes per pixel. ---- ----Good for grayscale images, like heightmaps. ---- ----| "bc4u" ---- ----One signed normalized channel. ---- ----8 bytes per 4x4 block or 0.5 bytes per pixel. ---- ----Similar to bc4u but has a range of -1 to 1. ---- ----| "bc4s" ---- ----Two unsigned normalized channels. ---- ----16 bytes per 4x4 block, or 1 byte per pixel. ---- ----Good for normal maps. ---- ----| "bc5u" ---- ----Two signed normalized channels. ---- ----16 bytes per 4x4 block or 1 byte per pixel. ---- ----Good for normal maps. ---- ----| "bc5s" ---- ----Three unsigned floating point channels. ---- ----16 bytes per 4x4 block or 1 byte per pixel. ---- ----Good for HDR images. ---- ----| "bc6uf" ---- ----Three floating point channels. ---- ----16 bytes per 4x4 block or 1 byte per pixel. ---- ----Good for HDR images. ---- ----| "bc6sf" ---- ----Four channels. ---- ----16 bytes per 4x4 block or 1 byte per pixel. ---- ----High quality. ---- ----Good for most color images, including transparency. ---- ----| "bc7" ---- ----Four channels, 16 bytes per 4x4 block or 1 byte per pixel. ---- ----| "astc4x4" ---- ----Four channels, 16 bytes per 5x4 block or 0.80 bytes per pixel. ---- ----| "astc5x4" ---- ----Four channels, 16 bytes per 5x5 block or 0.64 bytes per pixel. ---- ----| "astc5x5" ---- ----Four channels, 16 bytes per 6x5 block or 0.53 bytes per pixel. ---- ----| "astc6x5" ---- ----Four channels, 16 bytes per 6x6 block or 0.44 bytes per pixel. ---- ----| "astc6x6" ---- ----Four channels, 16 bytes per 8x5 block or 0.40 bytes per pixel. ---- ----| "astc8x5" ---- ----Four channels, 16 bytes per 8x6 block or 0.33 bytes per pixel. ---- ----| "astc8x6" ---- ----Four channels, 16 bytes per 8x8 block or 0.25 bytes per pixel. ---- ----| "astc8x8" ---- ----Four channels, 16 bytes per 10x5 block or 0.32 bytes per pixel. ---- ----| "astc10x5" ---- ----Four channels, 16 bytes per 10x6 block or 0.27 bytes per pixel. ---- ----| "astc10x6" ---- ----Four channels, 16 bytes per 10x8 block or 0.20 bytes per pixel. ---- ----| "astc10x8" ---- ----Four channels, 16 bytes per 10x10 block or 0.16 bytes per pixel. ---- ----| "astc10x10" ---- ----Four channels, 16 bytes per 12x10 block or 0.13 bytes per pixel. ---- ----| "astc12x10" ---- ----Four channels, 16 bytes per 12x12 block or 0.11 bytes per pixel. ---- ----| "astc12x12" diff --git a/meta/3rd/lovr/library/lovr/event.lua b/meta/3rd/lovr/library/lovr/event.lua deleted file mode 100644 index a515c1ab..00000000 --- a/meta/3rd/lovr/library/lovr/event.lua +++ /dev/null @@ -1,430 +0,0 @@ ----@meta - ---- ----The `lovr.event` module handles events from the operating system. ---- ----Due to its low-level nature, it's rare to use `lovr.event` in simple projects. ---- ---- ----### NOTE: ----You can define your own custom events by adding a function to the `lovr.handlers` table with a key of the name of the event you want to add. ---- ----Then, push the event using `lovr.event.push`. ---- ----@class lovr.event -lovr.event = {} - ---- ----Clears the event queue, removing any unprocessed events. ---- -function lovr.event.clear() end - ---- ----This function returns a Lua iterator for all of the unprocessed items in the event queue. ---- ----Each event consists of a name as a string, followed by event-specific arguments. ---- ----This function is called in the default implementation of `lovr.run`, so it is normally not necessary to poll for events yourself. ---- ----@return function iterator # The iterator function, usable in a for loop. -function lovr.event.poll() end - ---- ----Fills the event queue with unprocessed events from the operating system. ---- ----This function should be called often, otherwise the operating system will consider the application unresponsive. This function is called in the default implementation of `lovr.run`. ---- -function lovr.event.pump() end - ---- ----Pushes an event onto the event queue. ---- ----It will be processed the next time `lovr.event.poll` is called. ---- ----For an event to be processed properly, there needs to be a function in the `lovr.handlers` table with a key that's the same as the event name. ---- ---- ----### NOTE: ----Only nil, booleans, numbers, strings, and LÖVR objects are supported types for event data. ---- ----@param name string # The name of the event. ----@vararg any # The arguments for the event. Currently, up to 4 are supported. -function lovr.event.push(name, ...) end - ---- ----Pushes an event to quit. ---- ----An optional number can be passed to set the exit code for the application. ---- ----An exit code of zero indicates normal termination, whereas a nonzero exit code indicates that an error occurred. ---- ---- ----### NOTE: ----This function is equivalent to calling `lovr.event.push('quit', <args>)`. ---- ----The event won't be processed until the next time `lovr.event.poll` is called. ---- ----The `lovr.quit` callback will be called when the event is processed, which can be used to do any cleanup work. ---- ----The callback can also return `false` to abort the quitting process. ---- ----@param code? number # The exit code of the program. -function lovr.event.quit(code) end - ---- ----Pushes an event to restart the framework. ---- ---- ----### NOTE: ----The event won't be processed until the next time `lovr.event.poll` is called. ---- ----The `lovr.restart` callback can be used to persist a value between restarts. ---- -function lovr.event.restart() end - ---- ----Keys that can be pressed on a keyboard. ---- ----Notably, numpad keys are missing right now. ---- ----@alias lovr.KeyCode ---- ----The A key. ---- ----| "a" ---- ----The B key. ---- ----| "b" ---- ----The C key. ---- ----| "c" ---- ----The D key. ---- ----| "d" ---- ----The E key. ---- ----| "e" ---- ----The F key. ---- ----| "f" ---- ----The G key. ---- ----| "g" ---- ----The H key. ---- ----| "h" ---- ----The I key. ---- ----| "i" ---- ----The J key. ---- ----| "j" ---- ----The K key. ---- ----| "k" ---- ----The L key. ---- ----| "l" ---- ----The M key. ---- ----| "m" ---- ----The N key. ---- ----| "n" ---- ----The O key. ---- ----| "o" ---- ----The P key. ---- ----| "p" ---- ----The Q key. ---- ----| "q" ---- ----The R key. ---- ----| "r" ---- ----The S key. ---- ----| "s" ---- ----The T key. ---- ----| "t" ---- ----The U key. ---- ----| "u" ---- ----The V key. ---- ----| "v" ---- ----The W key. ---- ----| "w" ---- ----The X key. ---- ----| "x" ---- ----The Y key. ---- ----| "y" ---- ----The Z key. ---- ----| "z" ---- ----The 0 key. ---- ----| "0" ---- ----The 1 key. ---- ----| "1" ---- ----The 2 key. ---- ----| "2" ---- ----The 3 key. ---- ----| "3" ---- ----The 4 key. ---- ----| "4" ---- ----The 5 key. ---- ----| "5" ---- ----The 6 key. ---- ----| "6" ---- ----The 7 key. ---- ----| "7" ---- ----The 8 key. ---- ----| "8" ---- ----The 9 key. ---- ----| "9" ---- ----The space bar. ---- ----| "space" ---- ----The enter key. ---- ----| "return" ---- ----The tab key. ---- ----| "tab" ---- ----The escape key. ---- ----| "escape" ---- ----The backspace key. ---- ----| "backspace" ---- ----The up arrow key. ---- ----| "up" ---- ----The down arrow key. ---- ----| "down" ---- ----The left arrow key. ---- ----| "left" ---- ----The right arrow key. ---- ----| "right" ---- ----The home key. ---- ----| "home" ---- ----The end key. ---- ----| "end" ---- ----The page up key. ---- ----| "pageup" ---- ----The page down key. ---- ----| "pagedown" ---- ----The insert key. ---- ----| "insert" ---- ----The delete key. ---- ----| "delete" ---- ----The F1 key. ---- ----| "f1" ---- ----The F2 key. ---- ----| "f2" ---- ----The F3 key. ---- ----| "f3" ---- ----The F4 key. ---- ----| "f4" ---- ----The F5 key. ---- ----| "f5" ---- ----The F6 key. ---- ----| "f6" ---- ----The F7 key. ---- ----| "f7" ---- ----The F8 key. ---- ----| "f8" ---- ----The F9 key. ---- ----| "f9" ---- ----The F10 key. ---- ----| "f10" ---- ----The F11 key. ---- ----| "f11" ---- ----The F12 key. ---- ----| "f12" ---- ----The backtick/backquote/grave accent key. ---- ----| "`" ---- ----The dash/hyphen/minus key. ---- ----| "-" ---- ----The equal sign key. ---- ----| "=" ---- ----The left bracket key. ---- ----| "[" ---- ----The right bracket key. ---- ----| "]" ---- ----The backslash key. ---- ----| "\\" ---- ----The semicolon key. ---- ----| ";" ---- ----The single quote key. ---- ----| "'" ---- ----The comma key. ---- ----| "," ---- ----The period key. ---- ----| "." ---- ----The slash key. ---- ----| "/" ---- ----The left control key. ---- ----| "lctrl" ---- ----The left shift key. ---- ----| "lshift" ---- ----The left alt key. ---- ----| "lalt" ---- ----The left OS key (windows, command, super). ---- ----| "lgui" ---- ----The right control key. ---- ----| "rctrl" ---- ----The right shift key. ---- ----| "rshift" ---- ----The right alt key. ---- ----| "ralt" ---- ----The right OS key (windows, command, super). ---- ----| "rgui" ---- ----The caps lock key. ---- ----| "capslock" ---- ----The scroll lock key. ---- ----| "scrolllock" ---- ----The numlock key. ---- ----| "numlock" diff --git a/meta/3rd/lovr/library/lovr/filesystem.lua b/meta/3rd/lovr/library/lovr/filesystem.lua deleted file mode 100644 index c2a1220b..00000000 --- a/meta/3rd/lovr/library/lovr/filesystem.lua +++ /dev/null @@ -1,333 +0,0 @@ ----@meta - ---- ----The `lovr.filesystem` module provides access to the filesystem. ---- ----All files written will go in a special folder called the "save directory". ---- ----The location of the save directory is platform-specific: ---- ----<table> ---- <tr> ---- <td>Windows</td> ---- <td><code>C:\Users\<user>\AppData\Roaming\LOVR\<identity></code></td> ---- </tr> ---- <tr> ---- <td>macOS</td> ---- <td><code>/Users/<user>/Library/Application Support/LOVR/<identity></code></td> ---- </tr> ---- <tr> ---- <td>Linux</td> ---- <td><code>/home/<user>/.local/share/LOVR/<identity></code></td> ---- </tr> ---- <tr> ---- <td>Android</td> ---- <td><code>/sdcard/Android/data/<identity>/files</code></td> ---- </tr> </table> ---- ----`<identity>` is a unique identifier for the project, and can be set in `lovr.conf`. ---- ----On Android, the identity can not be changed and will always be the package id (e.g. `org.lovr.app`). ---- ----When files are read, they will be searched for in multiple places. ---- ----By default, the save directory is checked first, then the project source (folder or zip). ---- ----That way, when data is written to a file, any future reads will see the new data. ---- ----The `t.saveprecedence` conf setting can be used to change this precedence. ---- ----Conceptually, `lovr.filesystem` uses a "virtual filesystem", which is an ordered list of folders and zip files that are merged into a single filesystem hierarchy. ---- ----Folders and archives in the list can be added and removed with `lovr.filesystem.mount` and `lovr.filesystem.unmount`. ---- ----LÖVR extends Lua's `require` function to look for modules in the virtual filesystem. ---- ----The search patterns can be changed with `lovr.filesystem.setRequirePath`, similar to `package.path`. ---- ----@class lovr.filesystem -lovr.filesystem = {} - ---- ----Appends content to the end of a file. ---- ---- ----### NOTE: ----If the file does not exist, it is created. ---- ----@overload fun(filename: string, blob: lovr.Blob):number ----@param filename string # The file to append to. ----@param content string # A string to write to the end of the file. ----@return number bytes # The number of bytes actually appended to the file. -function lovr.filesystem.append(filename, content) end - ---- ----Creates a directory in the save directory. ---- ----Any parent directories that don't exist will also be created. ---- ----@param path string # The directory to create, recursively. ----@return boolean success # Whether the directory was created. -function lovr.filesystem.createDirectory(path) end - ---- ----Returns the application data directory. ---- ----This will be something like: ---- ----- `C:\Users\user\AppData\Roaming` on Windows. ----- `/home/user/.config` on Linux. ----- `/Users/user/Library/Application Support` on macOS. ---- ----@return string path # The absolute path to the appdata directory. -function lovr.filesystem.getAppdataDirectory() end - ---- ----Returns a sorted table containing all files and folders in a single directory. ---- ---- ----### NOTE: ----This function calls `table.sort` to sort the results, so if `table.sort` is not available in the global scope the results are not guaranteed to be sorted. ---- ----@param path string # The directory. ----@return lovr.items table # A table with a string for each file and subfolder in the directory. -function lovr.filesystem.getDirectoryItems(path) end - ---- ----Returns the absolute path of the LÖVR executable. ---- ----@return string path # The absolute path of the LÖVR executable, or `nil` if it is unknown. -function lovr.filesystem.getExecutablePath() end - ---- ----Returns the identity of the game, which is used as the name of the save directory. ---- ----The default is `default`. ---- ----It can be changed using `t.identity` in `lovr.conf`. ---- ---- ----### NOTE: ----On Android, this is always the package id (like `org.lovr.app`). ---- ----@return string identity # The name of the save directory, or `nil` if it isn't set. -function lovr.filesystem.getIdentity() end - ---- ----Returns when a file was last modified, since some arbitrary time in the past. ---- ----@param path string # The file to check. ----@return number time # The modification time of the file, in seconds, or `nil` if it's unknown. -function lovr.filesystem.getLastModified(path) end - ---- ----Get the absolute path of the mounted archive containing a path in the virtual filesystem. ---- ----This can be used to determine if a file is in the game's source directory or the save directory. ---- ----@param path string # The path to check. ----@return string realpath # The absolute path of the mounted archive containing `path`. -function lovr.filesystem.getRealDirectory(path) end - ---- ----Returns the require path. ---- ----The require path is a semicolon-separated list of patterns that LÖVR will use to search for files when they are `require`d. ---- ----Any question marks in the pattern will be replaced with the module that is being required. ---- ----It is similar to Lua\'s `package.path` variable, but the main difference is that the patterns are relative to the virtual filesystem. ---- ---- ----### NOTE: ----The default reqiure path is '?.lua;?/init.lua'. ---- ----@return string path # The semicolon separated list of search patterns. -function lovr.filesystem.getRequirePath() end - ---- ----Returns the absolute path to the save directory. ---- ---- ----### NOTE: ----The save directory takes the following form: ---- ---- <appdata>/LOVR/<identity> ---- ----Where `<appdata>` is `lovr.filesystem.getAppdataDirectory` and `<identity>` is `lovr.filesystem.getIdentity` and can be customized using `lovr.conf`. ---- ----@return string path # The absolute path to the save directory. -function lovr.filesystem.getSaveDirectory() end - ---- ----Returns the size of a file, in bytes. ---- ---- ----### NOTE: ----If the file does not exist, an error is thrown. ---- ----@param file string # The file. ----@return number size # The size of the file, in bytes. -function lovr.filesystem.getSize(file) end - ---- ----Get the absolute path of the project's source directory or archive. ---- ----@return string path # The absolute path of the project's source, or `nil` if it's unknown. -function lovr.filesystem.getSource() end - ---- ----Returns the absolute path of the user's home directory. ---- ----@return string path # The absolute path of the user's home directory. -function lovr.filesystem.getUserDirectory() end - ---- ----Returns the absolute path of the working directory. ---- ----Usually this is where the executable was started from. ---- ----@return string path # The current working directory, or `nil` if it's unknown. -function lovr.filesystem.getWorkingDirectory() end - ---- ----Check if a path exists and is a directory. ---- ----@param path string # The path to check. ----@return boolean isDirectory # Whether or not the path is a directory. -function lovr.filesystem.isDirectory(path) end - ---- ----Check if a path exists and is a file. ---- ----@param path string # The path to check. ----@return boolean isFile # Whether or not the path is a file. -function lovr.filesystem.isFile(path) end - ---- ----Returns whether the current project source is fused to the executable. ---- ----@return boolean fused # Whether or not the project is fused. -function lovr.filesystem.isFused() end - ---- ----Load a file containing Lua code, returning a Lua chunk that can be run. ---- ---- ----### NOTE: ----An error is thrown if the file contains syntax errors. ---- ----@param filename string # The file to load. ----@return function chunk # The runnable chunk. -function lovr.filesystem.load(filename) end - ---- ----Mounts a directory or `.zip` archive, adding it to the virtual filesystem. ---- ----This allows you to read files from it. ---- ---- ----### NOTE: ----The `append` option lets you control the priority of the archive's files in the event of naming collisions. ---- ----This function is not thread safe. ---- ----Mounting or unmounting an archive while other threads call lovr.filesystem functions is not supported. ---- ----@param path string # The path to mount. ----@param mountpoint? string # The path in the virtual filesystem to mount to. ----@param append? boolean # Whether the archive will be added to the end or the beginning of the search path. ----@param root? string # A subdirectory inside the archive to use as the root. If `nil`, the actual root of the archive is used. ----@return boolean success # Whether the archive was successfully mounted. -function lovr.filesystem.mount(path, mountpoint, append, root) end - ---- ----Creates a new Blob that contains the contents of a file. ---- ----@param filename string # The file to load. ----@return lovr.Blob blob # The new Blob. -function lovr.filesystem.newBlob(filename) end - ---- ----Read the contents of a file. ---- ---- ----### NOTE: ----If the file does not exist or cannot be read, nil is returned. ---- ----@param filename string # The name of the file to read. ----@param bytes? number # The number of bytes to read (if -1, all bytes will be read). ----@return string contents # The contents of the file. ----@return number bytes # The number of bytes read from the file. -function lovr.filesystem.read(filename, bytes) end - ---- ----Remove a file or directory in the save directory. ---- ---- ----### NOTE: ----A directory can only be removed if it is empty. ---- ----To recursively remove a folder, use this function with `lovr.filesystem.getDirectoryItems`. ---- ----@param path string # The file or directory to remove. ----@return boolean success # Whether the path was removed. -function lovr.filesystem.remove(path) end - ---- ----Set the name of the save directory. ---- ----This function can only be called once and is called automatically at startup, so this function normally isn't called manually. ---- ----However, the identity can be changed by setting the `t.identity` option in `lovr.conf`. ---- ----@param identity string # The name of the save directory. -function lovr.filesystem.setIdentity(identity) end - ---- ----Sets the require path. ---- ----The require path is a semicolon-separated list of patterns that LÖVR will use to search for files when they are `require`d. ---- ----Any question marks in the pattern will be replaced with the module that is being required. ---- ----It is similar to Lua\'s `package.path` variable, except the patterns will be checked using `lovr.filesystem` APIs. This allows `require` to work even when the project is packaged into a zip archive, or when the project is launched from a different directory. ---- ---- ----### NOTE: ----The default reqiure path is '?.lua;?/init.lua'. ---- ----@param path? string # An optional semicolon separated list of search patterns. -function lovr.filesystem.setRequirePath(path) end - ---- ----Unmounts a directory or archive previously mounted with `lovr.filesystem.mount`. ---- ---- ----### NOTE: ----This function is not thread safe. ---- ----Mounting or unmounting an archive while other threads call lovr.filesystem functions is not supported. ---- ----@param path string # The path to unmount. ----@return boolean success # Whether the archive was unmounted. -function lovr.filesystem.unmount(path) end - ---- ----Write to a file in the save directory. ---- ---- ----### NOTE: ----If the file does not exist, it is created. ---- ----If the file already has data in it, it will be replaced with the new content. ---- ----If the path contains subdirectories, all of the parent directories need to exist first or the write will fail. ---- ----Use `lovr.filesystem.createDirectory` to make sure they're created first. ---- ----@overload fun(filename: string, blob: lovr.Blob):boolean ----@param filename string # The file to write to. ----@param content string # A string to write to the file. ----@return boolean success # Whether the write was successful. -function lovr.filesystem.write(filename, content) end diff --git a/meta/3rd/lovr/library/lovr/graphics.lua b/meta/3rd/lovr/library/lovr/graphics.lua deleted file mode 100644 index 956d91ae..00000000 --- a/meta/3rd/lovr/library/lovr/graphics.lua +++ /dev/null @@ -1,3815 +0,0 @@ ----@meta - ---- ----The graphics module renders graphics and performs computation using the GPU. ---- ----Most of the graphics functions are on the `Pass` object. ---- ----@class lovr.graphics -lovr.graphics = {} - ---- ----Compiles shader code to SPIR-V bytecode. ---- ----The bytecode can be passed to `lovr.graphics.newShader` to create shaders, which will be faster than creating it from GLSL. The bytecode is portable, so bytecode compiled on one platform will work on other platforms. This allows shaders to be precompiled in a build step. ---- ---- ----### NOTE: ----The input can be GLSL or SPIR-V. ---- ----If it's SPIR-V, it will be returned unchanged as a Blob. ---- ----If the shader fails to compile, an error will be thrown with the error message. ---- ----@overload fun(stage: lovr.ShaderStage, blob: lovr.Blob):lovr.Blob ----@param stage lovr.ShaderStage # The type of shader to compile. ----@param source string # A string or filename with shader code. ----@return lovr.Blob bytecode # A Blob containing compiled SPIR-V code. -function lovr.graphics.compileShader(stage, source) end - ---- ----Returns the global background color. ---- ----The textures in a render pass will be cleared to this color at the beginning of the pass if no other clear option is specified. ---- ----Additionally, the headset and window will be cleared to this color before rendering. ---- ---- ----### NOTE: ----Setting the background color in `lovr.draw` will apply on the following frame, since the default pass is cleared before `lovr.draw` is called. ---- ----Internally, this color is applied to the default pass objects when retrieving one of them using `lovr.headset.getPass` or `lovr.graphics.getPass`. ---- ----Both are called automatically by the default `lovr.run` implementation. ---- ----Using the background color to clear the display is expected to be more efficient than manually clearing after a render pass begins, especially on mobile GPUs. ---- ----@return number r # The red component of the background color. ----@return number g # The green component of the background color. ----@return number b # The blue component of the background color. ----@return number a # The alpha component of the background color. -function lovr.graphics.getBackgroundColor() end - ---- ----Creates a temporary Buffer. ---- ---- ----### NOTE: ----The format table can contain a list of `FieldType`s or a list of tables to provide extra information about each field. ---- ----Each inner table has the following keys: ---- ----- `type` is the `FieldType` of the field and is required. ----- `offset` is the byte offset of the field. ---- ----Any fields with a `nil` offset will be placed next ---- to each other sequentially in memory, subject to any padding required by the Buffer's layout. ---- In practice this means that an `offset` should be set for either all of the fields or none of ---- them. ----- `location` is the vertex attribute location of each field. ---- ----This is used to match up each ---- field with an attribute declared in a shader, and doesn't have any purpose when binding the ---- buffer as a uniform or storage buffer. ---- ----Any fields with a `nil` location will use an ---- autoincrementing location starting at zero. ---- ----Named locations are not currently supported, but ---- may be added in the future. ---- ----If no table or Blob is used to define the initial Buffer contents, its data will be undefined. ---- ----There is currently a max of 16 fields. ---- ----@overload fun(data: table, type: lovr.FieldType):lovr.Buffer ----@overload fun(length: number, format: table):lovr.Buffer ----@overload fun(data: table, format: table):lovr.Buffer ----@overload fun(blob: lovr.Blob, type: lovr.FieldType):lovr.Buffer ----@overload fun(blob: lovr.Blob, format: table):lovr.Buffer ----@param length number # The length of the Buffer. ----@param type lovr.FieldType # The type of each item in the Buffer. ----@return lovr.Buffer buffer # The new Buffer. -function lovr.graphics.getBuffer(length, type) end - ---- ----Returns the default Font. ---- ----The default font is Varela Round, created at 32px with a spread value of `4.0`. ---- ----It's used by `Pass:text` if no Font is provided. ---- ----@return lovr.Font font # The default Font object. -function lovr.graphics.getDefaultFont() end - ---- ----Returns information about the graphics device and driver. ---- ---- ----### NOTE: ----The device and vendor ID numbers will usually be PCI IDs, which are standardized numbers consisting of 4 hex digits. ---- ----Various online databases and system utilities can be used to look up these numbers. ---- ----Here are some example vendor IDs for a few popular GPU manufacturers: ---- ----<table> ---- <thead> ---- <tr> ---- <td>ID</td> ---- <td>Vendor</td> ---- </tr> ---- </thead> ---- <tbody> ---- <tr> ---- <td><code>0x1002</code></td> ---- <td>Advanced Micro Devices, Inc.</td> ---- </tr> ---- <tr> ---- <td><code>0x8086</code></td> ---- <td>Intel Corporation</td> ---- </tr> ---- <tr> ---- <td><code>0x10de</code></td> ---- <td>NVIDIA Corporation</td> ---- </tr> ---- </tbody> </table> ---- ----It is not currently possible to get the version of the driver, although this could be added. ---- ----Regarding multiple GPUs: If OpenXR is enabled, the OpenXR runtime has control over which GPU is used, which ensures best compatibility with the VR headset. ---- ----Otherwise, the "first" GPU returned by the renderer will be used. ---- ----There is currently no other way to pick a GPU to use. ---- ----@return {id: number, vendor: number, name: string, renderer: string, subgroupSize: number, discrete: boolean} device # nil -function lovr.graphics.getDevice() end - ---- ----Returns a table indicating which features are supported by the GPU. ---- ----@return {textureBC: boolean, textureASTC: boolean, wireframe: boolean, depthClamp: boolean, depthResolve: boolean, indirectDrawFirstInstance: boolean, float64: boolean, int64: boolean, int16: boolean} features # -function lovr.graphics.getFeatures() end - ---- ----Returns limits of the current GPU. ---- ---- ----### NOTE: ----The limit ranges are as follows: ---- ----<table> ---- <thead> ---- <tr> ---- <td>Limit</td> ---- <td>Minimum</td> ---- <td>Maximum</td> ---- </tr> ---- </thead> ---- <tbody> ---- <tr> ---- <td><code>textureSize2D</code></td> ---- <td>4096</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td><code>textureSize3D</code></td> ---- <td>256</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td><code>textureSizeCube</code></td> ---- <td>4096</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td><code>textureLayers</code></td> ---- <td>256</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td><code>renderSize</code></td> ---- <td>{ 4096, 4096, 6 }</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td><code>uniformBuffersPerStage</code></td> ---- <td>9</td> ---- <td>32*</td> ---- </tr> ---- <tr> ---- <td><code>storageBuffersPerStage</code></td> ---- <td>4</td> ---- <td>32*</td> ---- </tr> ---- <tr> ---- <td><code>sampledTexturesPerStage</code></td> ---- <td>32</td> ---- <td>32*</td> ---- </tr> ---- <tr> ---- <td><code>storageTexturesPerStage</code></td> ---- <td>4</td> ---- <td>32*</td> ---- </tr> ---- <tr> ---- <td><code>samplersPerStage</code></td> ---- <td>15</td> ---- <td>32*</td> ---- </tr> ---- <tr> ---- <td><code>resourcesPerShader</code></td> ---- <td>32</td> ---- <td>32*</td> ---- </tr> ---- <tr> ---- <td><code>uniformBufferRange</code></td> ---- <td>65536</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td><code>storageBufferRange</code></td> ---- <td>134217728 (128MB)</td> ---- <td>1073741824 (1GB)*</td> ---- </tr> ---- <tr> ---- <td><code>uniformBufferAlign</code></td> ---- <td></td> ---- <td>256</td> ---- </tr> ---- <tr> ---- <td><code>storageBufferAlign</code></td> ---- <td></td> ---- <td>64</td> ---- </tr> ---- <tr> ---- <td><code>vertexAttributes</code></td> ---- <td>16</td> ---- <td>16*</td> ---- </tr> ---- <tr> ---- <td><code>vertexBufferStride</code></td> ---- <td>2048</td> ---- <td>65535*</td> ---- </tr> ---- <tr> ---- <td><code>vertexShaderOutputs</code></td> ---- <td>64</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td><code>clipDistances</code></td> ---- <td>0</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td><code>cullDistances</code></td> ---- <td>0</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td><code>clipAndCullDistances</code></td> ---- <td>0</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td><code>computeDispatchCount</code></td> ---- <td>{ 65536, 65536, 65536 }</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td><code>computeWorkgroupSize</code></td> ---- <td>{ 128, 128, 64 }</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td><code>computeWorkgroupVolume</code></td> ---- <td>128</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td><code>computeSharedMemory</code></td> ---- <td>16384 (16KB)</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td><code>pushConstantSize</code></td> ---- <td>128</td> ---- <td>256*</td> ---- </tr> ---- <tr> ---- <td><code>indirectDrawCount</code></td> ---- <td>1</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td><code>instances</code></td> ---- <td>134217727</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td><code>anisotropy</code></td> ---- <td>0.0</td> ---- <td></td> ---- </tr> ---- <tr> ---- <td><code>pointSize</code></td> ---- <td>1.0</td> ---- <td></td> ---- </tr> ---- </tbody> </table> ---- ----Note: in the table above, `*` means that LÖVR itself is imposing a cap on the limit, instead of the GPU. ---- ----@return {textureSize2D: number, textureSize3D: number, textureSizeCube: number, textureLayers: number, renderSize: table, uniformBuffersPerStage: number, storageBuffersPerStage: number, sampledTexturesPerStage: number, storageTexturesPerStage: number, samplersPerStage: number, resourcesPerShader: number, uniformBufferRange: number, storageBufferRange: number, uniformBufferAlign: number, storageBufferAlign: number, vertexAttributes: number, vertexBufferStride: number, vertexShaderOutputs: number, clipDistances: number, cullDistances: number, clipAndCullDistances: number, workgroupCount: table, workgroupSize: table, totalWorkgroupSize: number, computeSharedMemory: number, shaderConstantSize: number, indirectDrawCount: number, instances: number, anisotropy: number, pointSize: number} limits # -function lovr.graphics.getLimits() end - ---- ----Creates and returns a temporary Pass object. ---- ---- ----### NOTE: ----Fun facts about render passes: ---- ----- Textures must have been created with the `render` `TextureUsage`. ----- Textures must have the same dimensions, layer counts, and sample counts. ----- When rendering to textures with multiple layers, each draw will be broadcast to all layers. ---- Render passes have multiple "views" (cameras), and each layer uses a corresponding view, ---- allowing each layer to be rendered from a different viewpoint. ---- ----This enables fast stereo ---- rendering, but can also be used to efficiently render to cubemaps. ---- ----The `ViewIndex` variable ---- can also be used in shaders to set up any desired per-view behavior. ----- If `mipmap` is true, then any textures with mipmaps must have the `transfer` `TextureUsage`. ----- It's okay to have zero color textures, but in this case there must be a depth texture. ----- Setting `clear` to `false` for textures is usually very slow on mobile GPUs. ----- It's possible to render to a specific mipmap level of a Texture, or a subset of its layers, by ---- rendering to texture views, see `Texture:newView`. ---- ----For `compute` and `transfer` passes, all of the commands in the pass act as though they run in parallel. ---- ----This means that writing to the same element of a buffer twice, or writing to it and reading from it again is not guaranteed to work properly on all GPUs. ---- ----LÖVR is not currently able to check for this. ---- ----If compute or transfers need to be sequenced, multiple passes should be used. ---- ----It is, however, completely fine to read and write to non-overlapping regions of the same buffer or texture. ---- ----@overload fun(type: lovr.PassType, texture: lovr.Texture):lovr.Pass ----@overload fun(type: lovr.PassType, canvas: table):lovr.Pass ----@param type lovr.PassType # The type of pass to create. ----@return lovr.Pass pass # The new Pass. -function lovr.graphics.getPass(type) end - ---- ----Returns the window pass. ---- ----This is a builtin render `Pass` object that renders to the desktop window texture. ---- ----If the desktop window was not open when the graphics module was initialized, this function will return `nil`. ---- ---- ----### NOTE: ----`lovr.conf` may be used to change the settings for the pass: `t.graphics.antialias` enables antialiasing, and `t.graphics.stencil` enables the stencil buffer. ---- ----This pass clears the window texture to the background color, which can be changed using `lovr.graphics.setBackgroundColor`. ---- ----@return lovr.Pass pass # The window pass, or `nil` if there is no window. -function lovr.graphics.getWindowPass() end - ---- ----Returns the type of operations the GPU supports for a texture format, if any. ---- ----@param format lovr.TextureFormat # The texture format to query. ----@param features lovr.TextureFeature # Zero or more features to check. If no features are given, this function will return whether the GPU supports *any* feature for this format. Otherwise, this function will only return true if *all* of the input features are supported. ----@return boolean supported # Whether the GPU supports these operations for textures with this format. -function lovr.graphics.isFormatSupported(format, features) end - ---- ----Creates a Buffer. ---- ---- ----### NOTE: ----The format table can contain a list of `FieldType`s or a list of tables to provide extra information about each field. ---- ----Each inner table has the following keys: ---- ----- `type` is the `FieldType` of the field and is required. ----- `offset` is the byte offset of the field. ---- ----Any fields with a `nil` offset will be placed next ---- to each other sequentially in memory, subject to any padding required by the Buffer's layout. ---- In practice this means that you probably want to provide an `offset` for either all of the ---- fields or none of them. ----- `location` is the vertex attribute location of each field. ---- ----This is used to match up each ---- field with an attribute declared in a shader, and doesn't have any purpose when binding the ---- buffer as a uniform or storage buffer. ---- ----Any fields with a `nil` location will use an ---- autoincrementing location starting at zero. ---- ----Named locations are not currently supported, but ---- may be added in the future. ---- ----If no table or Blob is used to define the initial Buffer contents, its data will be undefined. ---- ----There is currently a max of 16 fields. ---- ----@overload fun(data: table, type: lovr.FieldType):lovr.Buffer ----@overload fun(length: number, format: table):lovr.Buffer ----@overload fun(data: table, format: table):lovr.Buffer ----@overload fun(blob: lovr.Blob, type: lovr.FieldType):lovr.Buffer ----@overload fun(blob: lovr.Blob, format: table):lovr.Buffer ----@param length number # The length of the Buffer. ----@param type lovr.FieldType # The type of each item in the Buffer. ----@return lovr.Buffer buffer # The new Buffer. -function lovr.graphics.newBuffer(length, type) end - ---- ----Creates a new Font. ---- ----@overload fun(blob: lovr.Blob, size?: number, spread?: number):lovr.Font ----@overload fun(size?: number, spread?: number):lovr.Font ----@overload fun(rasterizer: lovr.Rasterizer, spread?: number):lovr.Font ----@param filename string # A path to a TTF file. ----@param size? number # The size of the Font in pixels. Larger sizes are slower to initialize and use more memory, but have better quality. ----@param spread? number # For signed distance field fonts (currently all fonts), the width of the SDF, in pixels. The greater the distance the font is viewed from, the larger this value needs to be for the font to remain properly antialiased. Increasing this will have a performance penalty similar to increasing the size of the font. ----@return lovr.Font font # The new Font. -function lovr.graphics.newFont(filename, size, spread) end - ---- ----Creates a new Material from a table of properties and textures. ---- ----All fields are optional. ---- ----Once a Material is created, its properties can not be changed. ---- ----Instead, a new Material should be created with the updated properties. ---- ---- ----### NOTE: ----The non-texture material properties can be accessed in shaders using `Material.<property>`, where the property is the same as the Lua table key. ---- ----The textures use capitalized names in shader code, e.g. `ColorTexture`. ---- ----@param properties {color: lovr.Vec4, glow: lovr.Vec4, uvShift: lovr.Vec2, uvScale: lovr.Vec2, metalness: number, roughness: number, clearcoat: number, clearcoatRoughness: number, occlusionStrength: number, normalScale: number, alphaCutoff: number, texture: lovr.Texture, glowTexture: lovr.Texture, metalnessTexture: lovr.Texture, roughnessTexture: lovr.Texture, clearcoatTexture: lovr.Texture, occlusionTexture: lovr.Texture, normalTexture: lovr.Texture} # Material properties. ----@return lovr.Material material # The new material. -function lovr.graphics.newMaterial(properties) end - ---- ----Loads a 3D model from a file. ---- ----Currently, OBJ, glTF, and binary STL files are supported. ---- ---- ----### NOTE: ----Currently, the following features are not supported by the model importer: ---- ----- glTF: Only the default scene is loaded. ----- glTF: Currently, each skin in a Model can have up to 256 joints. ----- glTF: Meshes can't appear multiple times in the node hierarchy with different skins, they need ---- to use 1 skin consistently. ----- glTF: `KHR_texture_transform` is supported, but all textures in a material will use the same ---- transform. ----- STL: ASCII STL files are not supported. ---- ----Diffuse and emissive textures will be loaded using sRGB encoding, all other textures will be loaded as linear. ---- ----Loading a model file will fail if the asset references textures or other files using absolute paths. ---- ----Relative paths should be used instead, and will be relative to the model file within the virtual filesystem. ---- ----@overload fun(blob: lovr.Blob, options?: table):lovr.Model ----@overload fun(modelData: lovr.ModelData, options?: table):lovr.Model ----@param filename string # The path to model file. ----@param options? {mipmaps: boolean} # Model options. ----@return lovr.Model model # The new Model. -function lovr.graphics.newModel(filename, options) end - ---- ----Creates a new Sampler. ---- ----Samplers are immutable, meaning their parameters can not be changed after the sampler is created. ---- ----Instead, a new sampler should be created with the updated properties. ---- ----@param parameters {filter: {["[1]"]: lovr.FilterMode, ["[2]"]: lovr.FilterMode, ["[3]"]: lovr.FilterMode}, wrap: {["[1]"]: lovr.WrapMode, ["[2]"]: lovr.WrapMode, ["[3]"]: lovr.FilterMode}, compare: lovr.CompareMode, anisotropy: number, mipmaprange: table} # Parameters for the sampler. ----@return lovr.Sampler sampler # The new sampler. -function lovr.graphics.newSampler(parameters) end - ---- ----Creates a Shader, which is a small program that runs on the GPU. ---- ----Shader code is usually written in GLSL and compiled to SPIR-V bytecode. ---- ----SPIR-V is faster to load but requires a build step. ---- ----Either form can be used to create a shader. ---- ----@overload fun(compute: string, options: table):lovr.Shader ----@overload fun(default: lovr.DefaultShader, options: table):lovr.Shader ----@param vertex string # A string, path to a file, or Blob containing GLSL or SPIR-V code for the vertex stage. Can also be a `DefaultShader` to use that shader's vertex code. ----@param fragment string # A string, path to a file, or Blob containing GLSL or SPIR-V code for the fragment stage. Can also be a `DefaultShader` to use that shader's fragment code. ----@param options {flags: table, label: string} # Shader options. ----@return lovr.Shader shader # The new shader. -function lovr.graphics.newShader(vertex, fragment, options) end - ---- ----Creates a new Tally. ---- ----@param type lovr.TallyType # The type of the Tally, which controls what "thing" it measures. ----@param count number # The number of slots in the Tally. Each slot holds one measurement. ----@param views? number # Tally objects with the `time` type can only be used in render passes with a certain number of views. This is ignored for other types of tallies. ----@return lovr.Tally tally # The new Tally. -function lovr.graphics.newTally(type, count, views) end - ---- ----Creates a new Texture. ---- ----Image filenames or `Image` objects can be used to provide the initial pixel data and the dimensions, format, and type. ---- ----Alternatively, dimensions can be provided, which will create an empty texture. ---- ---- ----### NOTE: ----If no `type` is provided in the options table, LÖVR will guess the `TextureType` of the Texture based on the number of layers: ---- ----- If there's only 1 layer, the type will be `2d`. ----- If there are 6 images provided, the type will be `cube`. ----- Otherwise, the type will be `array`. ---- ----Note that an Image can contain multiple layers and mipmaps. ---- ----When a single Image is provided, its layer count will be used as the Texture's layer count. ---- ----If multiple Images are used to initialize the Texture, they must all have a single layer, and their dimensions, format, and mipmap counts must match. ---- ----When providing cubemap images in a table, they can be in one of the following forms: ---- ---- { 'px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png' } ---- { right = 'px.png', left = 'nx.png', top = 'py.png', bottom = 'ny.png', back = 'pz.png', front = 'nz.png' } ---- { px = 'px.png', nx = 'nx.png', py = 'py.png', ny = 'ny.png', pz = 'pz.png', nz = 'nz.png' } ---- ----(Where 'p' stands for positive and 'n' stands for negative). ---- ----If no `usage` is provided in the options table, LÖVR will guess the `TextureUsage` of the Texture. ---- ----The `sample` usage is always included, but if the texture was created without any images then the texture will have the `render` usage as well. ---- ----The supported image formats are png, jpg, hdr, dds, ktx1, ktx2, and astc. ---- ----If image data is provided, mipmaps will be generated for any missing mipmap levels. ---- ----@overload fun(width: number, height: number, options: table):lovr.Texture ----@overload fun(width: number, height: number, layers: number, options: table):lovr.Texture ----@overload fun(image: string, options: table):lovr.Texture ----@overload fun(images: table, options: table):lovr.Texture ----@overload fun(blob: lovr.Blob, options: table):lovr.Texture ----@param filename string # The filename of an image to load. ----@param options {type: lovr.TextureType, format: lovr.TextureFormat, linear: boolean, samples: number, mipmaps: any, usage: table, label: string} # Texture options. ----@return lovr.Texture texture # The new Texture. -function lovr.graphics.newTexture(filename, options) end - ---- ----Presents the window texture to the desktop window. ---- ----This function is called automatically by the default implementation of `lovr.run`, so it normally does not need to be called. ---- ---- ----### NOTE: ----This should be called after submitting the window pass (`lovr.graphics.getWindowPass`). ---- ----If the window texture has not been rendered to since the last present, this function does nothing. ---- -function lovr.graphics.present() end - ---- ----Changes the global background color. ---- ----The textures in a render pass will be cleared to this color at the beginning of the pass if no other clear option is specified. ---- ----Additionally, the headset and window will be cleared to this color before rendering. ---- ---- ----### NOTE: ----Setting the background color in `lovr.draw` will apply on the following frame, since the default pass is cleared before `lovr.draw` is called. ---- ----Internally, this color is applied to the default pass objects when retrieving one of them using `lovr.headset.getPass` or `lovr.graphics.getPass`. ---- ----Both are called automatically by the default `lovr.run` implementation. ---- ----Using the background color to clear the display is expected to be more efficient than manually clearing after a render pass begins, especially on mobile GPUs. ---- ----@overload fun(hex: number, a?: number) ----@overload fun(table: table) ----@param r number # The red component of the background color. ----@param g number # The green component of the background color. ----@param b number # The blue component of the background color. ----@param a? number # The alpha component of the background color. -function lovr.graphics.setBackgroundColor(r, g, b, a) end - ---- ----Submits work to the GPU. ---- ---- ----### NOTE: ----The submitted `Pass` objects will run in the order specified. ---- ----Commands within a single Pass do not have any ordering guarantees. ---- ----Submitting work to the GPU is not thread safe. ---- ----No other `lovr.graphics` or `Pass` functions may run at the same time as `lovr.graphics.submit`. ---- ----Calling this function will invalidate any temporary buffers or passes that were created during the frame. ---- ----Submitting work to the GPU is a relatively expensive operation. ---- ----It's a good idea to batch all `Pass` objects into 1 submission if possible, unless there's a good reason not to. ---- ----One such reason would be that the frame has so much work that some of it needs to be submitted early to prevent the GPU from running out of things to do. ---- ----Another would be for `Readback` objects. ---- ----By default, this function is called with the default pass at the end of `lovr.draw` and `lovr.mirror`. ---- ----It is valid to submit zero passes. ---- ----This will send an empty batch of work to the GPU. ---- ----@overload fun(t: table):boolean ----@vararg lovr.Pass # The pass objects to submit. Falsy values will be skipped. ----@return boolean true # Always returns true, for convenience when returning from `lovr.draw`. -function lovr.graphics.submit(...) end - ---- ----Waits for all submitted GPU work to finish. ---- ----A normal application that is trying to render graphics at a high framerate should never use this function, since waiting like this prevents the CPU from doing other useful work. ---- ----Otherwise, reasons to use this function might be for debugging or to force a `Readback` to finish immediately. ---- -function lovr.graphics.wait() end - ---- ----A Buffer is a block of GPU memory. ---- ----Buffers are similar to Lua tables or arrays: they have a length and store a list of values. ---- ----The length of a Buffer and its format (the type of each value) are declared upfront and can't be changed. ---- ----Each value of a Buffer consists of one or more fields, and each field has a type. ---- ----For example, if a Buffer is used to store vertices, each value might store 3 fields for the position, normal vector, and UV coordinates of a vertex. ---- ----Buffers are commonly used for: ---- ----- Mesh data: Buffers hold the data that define the vertices in a mesh. Buffers also store the ---- vertex indices of a mesh, which define the order the vertices are connected together into ---- triangles. These are often called vertex buffers and index buffers. ----- Shader data: Buffers can be bound to a Shader, letting the Shader read arbitrary data. For ---- example, Lua code could create a Buffer with the positions and colors of all the lights in a ---- scene, which a Shader can use to do lighting calculations. ----- Compute: Compute shaders can write data to Buffers. ---- ----This GPU-generated data can be used in ---- later rendering work or sent back to Lua. ----- Indirect: Indirect rendering is an advanced technique where instructions for rendering work ---- are recorded to a Buffer (potentially by a compute shader) and later drawn. ---- ----There are two types of Buffers: ---- ----- **Temporary** buffers are very inexpensive to create, and writing to them from Lua is fast. ---- However, they become invalid at the end of `lovr.draw` (i.e. when `lovr.graphics.submit` is ---- called). ---- ----The GPU is slightly slower at accessing data from temporary buffers, and compute ---- shaders can not write to them. ---- ----They are designed for storing data that changes every frame. ----- **Permanent** buffers are more expensive to create, and updating their contents requires a ---- transfer from CPU memory to VRAM. ---- ----They act like normal LÖVR objects and don't need to be ---- recreated every frame. ---- ----They often have faster performance when used by the GPU, and compute ---- shaders can write to them. ---- ----They are great for large pieces of data that are initialized once ---- at load time, or data that is updated infrequently. ---- ----@class lovr.Buffer -local Buffer = {} - ---- ----Clears some or all of the data in the **temporary** Buffer to zero. ---- ----Permanent Buffers can be cleared in a transfer pass using `Pass:clear`. ---- ---- ----### NOTE: ----Clearing a permanent buffer requires the byte offset and byte count of the cleared range to be a multiple of 4. ---- ----This will usually be true for most data types. ---- ----@param index? number # The index of the first item to clear. ----@param count? number # The number of items to clear. If `nil`, clears to the end of the Buffer. -function Buffer:clear(index, count) end - ---- ----Returns the format of the Buffer. ---- ----This is the list of fields that comprise each item in the buffer. ---- ----Each field has a type, byte offset, and vertex attribute location. ---- ----@return table format # The format of the Buffer. -function Buffer:getFormat() end - ---- ----Returns the length of the Buffer. ---- ----@return number length # The length of the Buffer. -function Buffer:getLength() end - ---- ----Returns a raw pointer to the Buffer's memory as a lightuserdata, intended for use with the LuaJIT FFI or for passing to C libraries. ---- ----This is only available for temporary buffers, so the pointer is only valid until `lovr.graphics.submit` is called. ---- ----@return lightuserdata pointer # A pointer to the Buffer's memory. -function Buffer:getPointer() end - ---- ----Returns the size of the Buffer, in bytes. ---- ----This is the same as `length * stride`. ---- ----@return number size # The size of the Buffer, in bytes. -function Buffer:getSize() end - ---- ----Returns the distance between each item in the Buffer, in bytes. ---- ---- ----### NOTE: ----When a Buffer is created, the stride can be set explicitly, otherwise it will be automatically computed based on the fields in the Buffer. ---- ----Strides can not be zero, and can not be smaller than the size of a single item. ---- ----To work around this, bind the Buffer as a storage buffer and fetch data from the buffer manually. ---- ----@return number stride # The stride of the Buffer, in bytes. -function Buffer:getStride() end - ---- ----Returns whether the Buffer is temporary. ---- ----@return boolean temporary # Whether the Buffer is temporary. -function Buffer:isTemporary() end - ---- ----Changes data in a temporary Buffer using a table or a Blob. ---- ----Permanent buffers can be changed using `Pass:copy`. ---- ---- ----### NOTE: ----When using a table, the table can contain a nested table for each value in the Buffer, or it can be a flat list of field component values. ---- ----It is not possible to mix both nested tables and flat values. ---- ----For each item updated, components of each field in the item (according to the Buffer's format) are read from either the nested subtable or the table itself. ---- ----A single number can be used to update a field with a scalar type. ---- ----Multiple numbers or a `lovr.math` vector can be used to update a field with a vector or mat4 type. ---- ----Multiple numbers can be used to update mat2 and mat3 fields. ---- ----When updating normalized field types, components read from the table will be clamped to the normalized range ([0,1] or [-1,1]). ---- ----In the Buffer, each field is written at its byte offset according to the Buffer's format, and subsequent items are separated by the byte stride of the Buffer. ---- ----Any missing components for an updated field will be set to zero. ---- ----@overload fun(self: lovr.Buffer, blob: lovr.Blob, sourceOffset?: number, destinationOffset?: number, size?: number) ----@param data table # A flat or nested table of items to copy to the Buffer (see notes for format). ----@param sourceIndex? number # The index in the table to copy from. ----@param destinationIndex? number # The index of the first value in the Buffer to update. ----@param count? number # The number of values to update. `nil` will copy as many items as possible, based on the lengths of the source and destination. -function Buffer:setData(data, sourceIndex, destinationIndex, count) end - ---- ----Font objects are used to render text with `Pass:text`. ---- ----The active font can be changed using `Pass:setFont`. ---- ----The default font is Varela Round, which is used when no font is active, and can be retrieved using `lovr.graphics.getDefaultFont`. ---- ----Custom fonts can be loaded from TTF files using `lovr.graphics.newFont`. ---- ----Each Font uses a `Rasterizer` to load the TTF file and create images for each glyph. As text is drawn, the Font uploads images from the Rasterizer to a GPU texture atlas as needed. ---- ----The Font also performs text layout and mesh generation for strings of text. ---- ----LÖVR uses a text rendering technique called "multichannel signed distance fields" (MSDF), which makes the font rendering remain crisp when text is viewed up close. ---- ---- ----### NOTE: ----MSDF text requires a special shader to work. ---- ----LÖVR will automatically switch to this shader if no shader is active on the `Pass`. ---- ----This font shader is also available as a `DefaultShader`. ---- ----@class lovr.Font -local Font = {} - ---- ----Returns the ascent of the font. ---- ----The ascent is the maximum amount glyphs ascend above the baseline. ---- ----The units depend on the font's pixel density. ---- ----With the default density, the units correspond to meters. ---- ----@return number ascent # The ascent of the font. -function Font:getAscent() end - ---- ----Returns the descent of the font. ---- ----The descent is the maximum amount glyphs descend below the baseline. ---- ----The units depend on the font's pixel density. ---- ----With the default density, the units correspond to meters. ---- ----@return number descent # The descent of the font. -function Font:getDescent() end - ---- ----Returns the height of the font, sometimes also called the leading. ---- ----This is the full height of a line of text, including the space between lines. ---- ----Each line of a multiline string is separated on the y axis by this height, multiplied by the font's line spacing. ---- ----The units depend on the font's pixel density. ---- ----With the default density, the units correspond to meters. ---- ----@return number height # The height of the font. -function Font:getHeight() end - ---- ----Returns the kerning between 2 glyphs. ---- ----Kerning is a slight horizontal adjustment between 2 glyphs to improve the visual appearance. ---- ----It will often be negative. ---- ----The units depend on the font's pixel density. ---- ----With the default density, the units correspond to meters. ---- ----@overload fun(self: lovr.Font, firstCodepoint: number, second: string):number ----@overload fun(self: lovr.Font, first: string, secondCodepoint: number):number ----@overload fun(self: lovr.Font, firstCodepoint: number, secondCodepoint: number):number ----@param first string # The first character. ----@param second string # The second character. ----@return number keming # The kerning between the two glyphs. -function Font:getKerning(first, second) end - ---- ----Returns the line spacing of the Font. ---- ----When spacing out lines, the height of the font is multiplied the line spacing to get the final spacing value. ---- ----The default is 1.0. ---- ----@return number spacing # The line spacing of the font. -function Font:getLineSpacing() end - ---- ----Returns a table of wrapped lines for a piece of text, given a line length limit. ---- ----Newlines are handled correctly. ---- ----The wrap limit units depend on the pixel density of the font. ---- ----With the default pixel density, the units correspond to meters when the font is drawn at 1.0 scale. ---- ----@overload fun(self: lovr.Font, strings: table, wrap: number):table ----@param string string # The text to wrap. ----@param wrap number # The line length to wrap at. ----@return table lines # A table strings, one for each wrapped line (without any color information). -function Font:getLines(string, wrap) end - ---- ----Returns the pixel density of the font. ---- ----The density is a "pixels per world unit" factor that controls how the pixels in the font's texture are mapped to units in the coordinate space. ---- ----The default pixel density is set to the height of the font. ---- ----This means that lines of text rendered with a scale of 1.0 come out to 1 unit (meter) tall. ---- ----However, if this font was drawn to a 2D texture where the units are in pixels, the font would still be drawn 1 unit (pixel) tall! Scaling the coordinate space or the size of the text by the height of the font would fix this. ---- ----However, a more convenient option is to set the pixel density of the font to 1.0 when doing 2D rendering to make the font's size match up with the pixels of the canvas. ---- ----@return number density # The pixel density of the font. -function Font:getPixelDensity() end - ---- ----Returns the Rasterizer object backing the Font. ---- ----@return lovr.Rasterizer rasterizer # The Rasterizer. -function Font:getRasterizer() end - ---- ----Returns a table of vertices for a piece of text, along with a Material to use when rendering it. The Material returned by this function may not be the same if the Font's texture atlas needs to be recreated with a bigger size to make room for more glyphs. ---- ---- ----### NOTE: ----Each vertex is a table of 4 floating point numbers with the following data: ---- ---- { x, y, u, v } ---- ----These could be placed in a vertex buffer using the following buffer format: ---- ---- { 'vec2:VertexPosition', 'vec2:VertexUV' } ---- ----@param halign lovr.HorizontalAlign # The horizontal align. ----@param valign lovr.VerticalAlign # The vertical align. ----@return table vertices # The table of vertices. See below for the format of each vertex. ----@return lovr.Material material # A Material to use when rendering the vertices. -function Font:getVertices(halign, valign) end - ---- ----Returns the maximum width of a piece of text. ---- ----This function does not perform wrapping but does respect newlines in the text. ---- ----@overload fun(self: lovr.Font, strings: table):number ----@param string string # The text to measure. ----@return number width # The maximum width of the text. -function Font:getWidth(string) end - ---- ----Sets the line spacing of the Font. ---- ----When spacing out lines, the height of the font is multiplied by the line spacing to get the final spacing value. ---- ----The default is 1.0. ---- ----@param spacing number # The new line spacing. -function Font:setLineSpacing(spacing) end - ---- ----Sets the pixel density of the font. ---- ----The density is a "pixels per world unit" factor that controls how the pixels in the font's texture are mapped to units in the coordinate space. ---- ----The default pixel density is set to the height of the font. ---- ----This means that lines of text rendered with a scale of 1.0 come out to 1 unit (meter) tall. ---- ----However, if this font was drawn to a 2D texture where the units are in pixels, the font would still be drawn 1 unit (pixel) tall! Scaling the coordinate space or the size of the text by the height of the font would fix this. ---- ----However, a more convenient option is to set the pixel density of the font to 1.0 when doing 2D rendering to make the font's size match up with the pixels of the canvas. ---- ----@overload fun(self: lovr.Font) ----@param density number # The new pixel density of the font. -function Font:setPixelDensity(density) end - ---- ----Materials are a set of properties and textures that define the properties of a surface, like what color it is, how bumpy or shiny it is, etc. `Shader` code can use the data from a material to compute lighting. ---- ----Materials are immutable, and can't be changed after they are created. ---- ----Instead, a new Material should be created with the updated properties. ---- ----`Pass:setMaterial` changes the active material, causing it to affect rendering until the active material is changed again. ---- ----Using material objects is optional. ---- ----`Pass:setMaterial` can take a `Texture`, and `Pass:setColor` can change the color of objects, so basic tinting and texturing of surfaces does not require a full material to be created. ---- ----Also, a custom material system could be developed by sending textures and other data to shaders manually. ---- ----`Model` objects will create materials for all of the materials defined in the model file. ---- ----In shader code, non-texture material properties can be accessed as `Material.<property>`, and material textures can be accessed as `<Type>Texture`, e.g. `RoughnessTexture`. ---- ----@class lovr.Material -local Material = {} - ---- ----Returns the properties of the Material in a table. ---- ----@return table properties # The Material properties. -function Material:getProperties() end - ---- ----Models are 3D model assets loaded from files. ---- ----Currently, OBJ, glTF, and binary STL files are supported. ---- ----A model can be drawn using `Pass:draw`. ---- ----The raw CPU data for a model is held in a `ModelData` object, which can be loaded on threads or reused for multiple Model instances. ---- ----Models have a hierarchy of nodes which can have their transforms modified. ---- ----Meshes are attached to these nodes. ---- ----The same mesh can be attached to multiple nodes, allowing it to be drawn multiple times while only storing a single copy of its data. ---- ----Models can have animations. ---- ----Animations have keyframes which affect the transforms of nodes. Right now each model can only be drawn with a single animated pose per frame. ---- ----Models can have materials, which are collections of properties and textures that define how its surface is affected by lighting. ---- ----Each mesh in the model can use a single material. ---- ----@class lovr.Model -local Model = {} - ---- ----Animates a Model by setting or blending the transforms of nodes using data stored in the keyframes of an animation. ---- ----The animation from the model file is evaluated at the timestamp, resulting in a set of node properties. ---- ----These properties are then applied to the nodes in the model, using an optional blend factor. ---- ----If the animation doesn't have keyframes that target a given node, the node will remain unchanged. ---- ---- ----### NOTE: ----If the timestamp is larger than the duration of the animation, it will wrap back around to zero, so looping an animation doesn't require using the modulo operator. ---- ----To change the speed of the animation, multiply the timestamp by a speed factor. ---- ----For each animated property in the animation, if the timestamp used for the animation is less than the timestamp of the first keyframe, the data of the first keyframe will be used. ---- ----This function can be called multiple times to layer and blend animations. ---- ----The model joints will be drawn in the final resulting pose. ---- ----`Model:resetNodeTransforms` can be used to reset the model nodes to their initial transforms, which is helpful to ensure animating starts from a clean slate. ---- ----@overload fun(self: lovr.Model, index: number, time: number, blend?: number) ----@param name string # The name of an animation in the model file. ----@param time number # The timestamp to evaluate the keyframes at, in seconds. ----@param blend? number # How much of the animation's pose to blend into the nodes, from 0 to 1. -function Model:animate(name, time, blend) end - ---- ----Returns the number of animations in the Model. ---- ----@return number count # The number of animations in the Model. -function Model:getAnimationCount() end - ---- ----Returns the duration of an animation in the Model, in seconds. ---- ---- ----### NOTE: ----The duration of an animation is calculated as the largest timestamp of all of its keyframes. ---- ----@overload fun(self: lovr.Model, name: string):number ----@param index number # The animation index. ----@return number duration # The duration of the animation, in seconds. -function Model:getAnimationDuration(index) end - ---- ----Returns the name of an animation in the Model. ---- ----@param index number # The index of an animation. ----@return string name # The name of the animation. -function Model:getAnimationName(index) end - ---- ----Returns the number of blend shapes in the model. ---- ----@return number count # The number of blend shapes in the model. -function Model:getBlendShapeCount() end - ---- ----Returns the name of a blend shape in the model. ---- ---- ----### NOTE: ----This function will throw an error if the blend shape index is invalid. ---- ----@param index number # The index of a blend shape. ----@return string name # The name of the blend shape. -function Model:getBlendShapeName(index) end - ---- ----Returns the weight of a blend shape. ---- ----A blend shape contains offset values for the vertices of one of the meshes in a Model. ---- ----Whenever the Model is drawn, the offsets are multiplied by the weight of the blend shape, allowing for smooth blending between different meshes. ---- ----A weight of zero won't apply any displacement and will skip processing of the blend shape. ---- ---- ----### NOTE: ----The initial weights are declared in the model file. ---- ----Weights can be any number, but usually they're kept between 0 and 1. ---- ----This function will throw an error if the blend shape name or index doesn't exist. ---- ----@overload fun(self: lovr.Model, name: string):number ----@param index number # The index of a blend shape. ----@return number weight # The weight of the blend shape. -function Model:getBlendShapeWeight(index) end - ---- ----Returns the 6 values of the Model's axis-aligned bounding box. ---- ----@return number minx # The minimum x coordinate of the vertices in the Model. ----@return number maxx # The maximum x coordinate of the vertices in the Model. ----@return number miny # The minimum y coordinate of the vertices in the Model. ----@return number maxy # The maximum y coordinate of the vertices in the Model. ----@return number minz # The minimum z coordinate of the vertices in the Model. ----@return number maxz # The maximum z coordinate of the vertices in the Model. -function Model:getBoundingBox() end - ---- ----Returns a sphere approximately enclosing the vertices in the Model. ---- ----@return number x # The x coordinate of the position of the sphere. ----@return number y # The y coordinate of the position of the sphere. ----@return number z # The z coordinate of the position of the sphere. ----@return number radius # The radius of the bounding sphere. -function Model:getBoundingSphere() end - ---- ----Returns the center of the Model's axis-aligned bounding box, relative to the Model's origin. ---- ----@return number x # The x offset of the center of the bounding box. ----@return number y # The y offset of the center of the bounding box. ----@return number z # The z offset of the center of the bounding box. -function Model:getCenter() end - ---- ----Returns the ModelData this Model was created from. ---- ----@return lovr.ModelData data # The ModelData. -function Model:getData() end - ---- ----Returns the depth of the Model, computed from its axis-aligned bounding box. ---- ----@return number depth # The depth of the Model. -function Model:getDepth() end - ---- ----Returns the width, height, and depth of the Model, computed from its axis-aligned bounding box. ---- ----@return number width # The width of the Model. ----@return number height # The height of the Model. ----@return number depth # The depth of the Model. -function Model:getDimensions() end - ---- ----Returns the height of the Model, computed from its axis-aligned bounding box. ---- ----@return number height # The height of the Model. -function Model:getHeight() end - ---- ----Returns the index buffer used by the Model. ---- ----The index buffer describes the order used to draw the vertices in each mesh. ---- ----@return lovr.Buffer buffer # The index buffer. -function Model:getIndexBuffer() end - ---- ----Returns a `Material` loaded from the Model. ---- ----@overload fun(self: lovr.Model, index: number):lovr.Material ----@param name string # The name of the Material to return. ----@return lovr.Material material # The material. -function Model:getMaterial(name) end - ---- ----Returns the number of materials in the Model. ---- ----@return number count # The number of materials in the Model. -function Model:getMaterialCount() end - ---- ----Returns the name of a material in the Model. ---- ----@param index number # The index of a material. ----@return string name # The name of the material. -function Model:getMaterialName(index) end - ---- ----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. ---- ----@return string metadata # The metadata from the model file. -function Model:getMetadata() end - ---- ----Given a parent node, this function returns a table with the indices of its children. ---- ---- ----### NOTE: ----If the node does not have any children, this function returns an empty table. ---- ----@overload fun(self: lovr.Model, name: string):table ----@param index number # The index of the parent node. ----@return table children # A table containing a node index for each child of the node. -function Model:getNodeChildren(index) end - ---- ----Returns the number of nodes in the model. ---- ----@return number count # The number of nodes in the model. -function Model:getNodeCount() end - ---- ----Returns the draw mode, material, and vertex range of a mesh in the model. ---- ----@overload fun(self: lovr.Model, name: string, index: number):lovr.MeshMode, lovr.Material, number, number, number ----@param node number # The index of the node. ----@param index number # The index of the draw. ----@return lovr.MeshMode mode # Whether the vertices are points, lines, or triangles. ----@return lovr.Material material # The Material used by the draw. ----@return number start # The offset of the first vertex in the draw. ----@return number count # The number of vertices in the draw. ----@return number base # The base vertex of the draw (added to each instance value), or nil if the draw does not use an index buffer. -function Model:getNodeDraw(node, index) end - ---- ----Returns the number of meshes attached to a node. ---- ----Each mesh is drawn individually. ---- ----@overload fun(self: lovr.Model, name: string):number ----@param index number # The index of a node. ----@return number count # The number of draws in the node. -function Model:getNodeDrawCount(index) end - ---- ----Returns the name of a node. ---- ----@param index number # The index of the node. ----@return string name # The name of the node. -function Model:getNodeName(index) end - ---- ----Returns the orientation of a node. ---- ----@overload fun(self: lovr.Model, name: string, origin?: lovr.OriginType):number, number, number, number ----@param index number # The index of the node. ----@param origin? lovr.OriginType # Whether the orientation should be returned relative to the root node or the node's parent. ----@return number angle # The number of radians the node is rotated around its axis of rotation. ----@return number ax # The x component of the axis of rotation. ----@return number ay # The y component of the axis of rotation. ----@return number az # The z component of the axis of rotation. -function Model:getNodeOrientation(index, origin) end - ---- ----Given a child node, this function returns the index of its parent. ---- ----@overload fun(self: lovr.Model, name: string):number ----@param index number # The index of the child node. ----@return number parent # The index of the parent. -function Model:getNodeParent(index) end - ---- ----Returns the pose (position and orientation) of a node. ---- ----@overload fun(self: lovr.Model, name: string, origin?: lovr.OriginType):number, number, number, number, number, number, number ----@param index number # The index of a node. ----@param origin? lovr.OriginType # Whether the pose should be returned relative to the root node or the node's parent. ----@return number x # The x position of the node. ----@return number y # The y position of the node. ----@return number z # The z position of the node. ----@return number angle # The number of radians the node is rotated around its axis of rotation. ----@return number ax # The x component of the axis of rotation. ----@return number ay # The y component of the axis of rotation. ----@return number az # The z component of the axis of rotation. -function Model:getNodePose(index, origin) end - ---- ----Returns the position of a node. ---- ----@overload fun(self: lovr.Model, name: string, space?: lovr.OriginType):number, number, number ----@param index number # The index of the node. ----@param space? lovr.OriginType # Whether the position should be returned relative to the root node or the node's parent. ----@return number x # The x coordinate. ----@return number y # The y coordinate. ----@return number z # The z coordinate. -function Model:getNodePosition(index, space) end - ---- ----Returns the scale of a node. ---- ----@overload fun(self: lovr.Model, name: string, origin?: lovr.OriginType):number, number, number ----@param index number # The index of the node. ----@param origin? lovr.OriginType # Whether the scale should be returned relative to the root node or the node's parent. ----@return number x # The x scale. ----@return number y # The y scale. ----@return number z # The z scale. -function Model:getNodeScale(index, origin) end - ---- ----Returns the transform (position, scale, and rotation) of a node. ---- ----@overload fun(self: lovr.Model, name: string, origin?: lovr.OriginType):number, number, number, number, number, number, number, number, number, number ----@param index number # The index of a node. ----@param origin? lovr.OriginType # Whether the transform should be returned relative to the root node or the node's parent. ----@return number x # The x position of the node. ----@return number y # The y position of the node. ----@return number z # The z position of the node. ----@return number sx # The x scale of the node. ----@return number sy # The y scale of the node. ----@return number sz # The z scale of the node. ----@return number angle # The number of radians the node is rotated around its axis of rotation. ----@return number ax # The x component of the axis of rotation. ----@return number ay # The y component of the axis of rotation. ----@return number az # The z component of the axis of rotation. -function Model:getNodeTransform(index, origin) end - ---- ----Returns the index of the model's root node. ---- ----@return number root # The index of the root node. -function Model:getRootNode() end - ---- ----Returns one of the textures in the Model. ---- ----@param index number # The index of the texture to get. ----@return lovr.Texture texture # The texture. -function Model:getTexture(index) end - ---- ----Returns the number of textures in the Model. ---- ----@return number count # The number of textures in the Model. -function Model:getTextureCount() end - ---- ----Returns the total number of triangles in the Model. ---- ---- ----### NOTE: ----This isn't always related to the length of the vertex buffer, since a mesh in the Model could be drawn by multiple nodes. ---- ----@return number count # The total number of triangles in the Model. -function Model:getTriangleCount() end - ---- ----Returns 2 tables containing mesh data for the Model. ---- ----The first table is a list of vertex positions and contains 3 numbers for the x, y, and z coordinate of each vertex. ---- ----The second table is a list of triangles and contains 1-based indices into the first table representing the first, second, and third vertices that make up each triangle. ---- ----The vertex positions will be affected by node transforms. ---- ---- ----### NOTE: ----After this function is called on a Model once, the result is cached (in its ModelData). ---- ----@return table vertices # The triangle vertex positions, returned as a flat (non-nested) table of numbers. The position of each vertex is given as an x, y, and z coordinate. ----@return table indices # The vertex indices. Every 3 indices describes a triangle. -function Model:getTriangles() end - ---- ----Returns a `Buffer` that holds the vertices of all of the meshes in the Model. ---- ----@return lovr.Buffer buffer # The vertex buffer. -function Model:getVertexBuffer() end - ---- ----Returns the total vertex count of the Model. ---- ---- ----### NOTE: ----This isn't always the same as the length of the vertex buffer, since a mesh in the Model could be drawn by multiple nodes. ---- ----@return number count # The total number of vertices. -function Model:getVertexCount() end - ---- ----Returns the width of the Model, computed from its axis-aligned bounding box. ---- ----@return number width # The width of the Model. -function Model:getWidth() end - ---- ----Returns whether the Model has any skeletal animations. ---- ---- ----### NOTE: ----This will return when there's at least one skin in the model, as returned by `ModelData:getSkinCount`. ---- ----Even if this function returns true, the model could still have non-skeletal animations. ---- ----Right now a model can only be drawn with one skeletal pose per frame. ---- ----@return boolean jointed # Whether the animation uses joint nodes for skeletal animation. -function Model:hasJoints() end - ---- ----Resets node transforms to the original ones defined in the model file. ---- -function Model:resetNodeTransforms() end - ---- ----Sets the weight of a blend shape. ---- ----A blend shape contains offset values for the vertices of one of the meshes in a Model. ---- ----Whenever the Model is drawn, the offsets are multiplied by the weight of the blend shape, allowing for smooth blending between different meshes. ---- ----A weight of zero won't apply any displacement and will skip processing of the blend shape. ---- ---- ----### NOTE: ----The initial weights are declared in the model file. ---- ----Weights can be any number, but usually they're kept between 0 and 1. ---- ----This function will throw an error if the blend shape name or index doesn't exist. ---- ----@overload fun(self: lovr.Model, name: string, weight: number) ----@param index number # The index of a blend shape. ----@param weight number # The new weight for the blend shape. -function Model:setBlendShapeWeight(index, weight) end - ---- ----Sets or blends the orientation of a node to a new orientation. ---- ----This sets the local orientation of the node, relative to its parent. ---- ----@overload fun(self: lovr.Model, name: string, angle: number, ax: number, ay: number, az: number, blend?: number) ----@overload fun(self: lovr.Model, index: number, orientation: lovr.Quat, blend?: number) ----@overload fun(self: lovr.Model, name: string, orientation: lovr.Quat, blend?: number) ----@param index number # The index of the node. ----@param angle number # The number of radians the node should be rotated around its rotation axis. ----@param ax number # The x component of the axis of rotation. ----@param ay number # The y component of the axis of rotation. ----@param az number # The z component of the axis of rotation. ----@param blend? number # A number from 0 to 1 indicating how much of the target orientation to blend in. A value of 0 will not change the node's orientation at all, whereas 1 will fully blend to the target orientation. -function Model:setNodeOrientation(index, angle, ax, ay, az, blend) end - ---- ----Sets or blends the pose (position and orientation) of a node to a new pose. ---- ----This sets the local pose of the node, relative to its parent. ---- ----The scale will remain unchanged. ---- ----@overload fun(self: lovr.Model, name: string, x: number, y: number, z: number, angle: number, ax: number, ay: number, az: number, blend?: number) ----@overload fun(self: lovr.Model, index: number, position: lovr.Vec3, orientation: lovr.Quat, blend?: number) ----@overload fun(self: lovr.Model, name: string, position: lovr.Vec3, orientation: lovr.Quat, blend?: number) ----@param index number # The index of the node. ----@param x number # The x component of the position. ----@param y number # The y component of the position. ----@param z number # The z component of the position. ----@param angle number # The number of radians the node should be rotated around its rotation axis. ----@param ax number # The x component of the axis of rotation. ----@param ay number # The y component of the axis of rotation. ----@param az number # The z component of the axis of rotation. ----@param blend? number # A number from 0 to 1 indicating how much of the target pose to blend in. A value of 0 will not change the node's pose at all, whereas 1 will fully blend to the target pose. -function Model:setNodePose(index, x, y, z, angle, ax, ay, az, blend) end - ---- ----Sets or blends the position of a node. ---- ----This sets the local position of the node, relative to its parent. ---- ----@overload fun(self: lovr.Model, name: string, x: number, y: number, z: number, blend?: number) ----@overload fun(self: lovr.Model, index: number, position: lovr.Vec3, blend?: number) ----@overload fun(self: lovr.Model, name: string, position: lovr.Vec3, blend?: number) ----@param index number # The index of the node. ----@param x number # The x coordinate of the new position. ----@param y number # The y coordinate of the new position. ----@param z number # The z coordinate of the new position. ----@param blend? number # A number from 0 to 1 indicating how much of the new position to blend in. A value of 0 will not change the node's position at all, whereas 1 will fully blend to the target position. -function Model:setNodePosition(index, x, y, z, blend) end - ---- ----Sets or blends the scale of a node to a new scale. ---- ----This sets the local scale of the node, relative to its parent. ---- ---- ----### NOTE: ----For best results when animating, it's recommended to keep the 3 scale components the same. ---- ----@overload fun(self: lovr.Model, name: string, sx: number, sy: number, sz: number, blend?: number) ----@overload fun(self: lovr.Model, index: number, scale: lovr.Vec3, blend?: number) ----@overload fun(self: lovr.Model, name: string, scale: lovr.Vec3, blend?: number) ----@param index number # The index of the node. ----@param sx number # The x scale. ----@param sy number # The y scale. ----@param sz number # The z scale. ----@param blend? number # A number from 0 to 1 indicating how much of the new scale to blend in. A value of 0 will not change the node's scale at all, whereas 1 will fully blend to the target scale. -function Model:setNodeScale(index, sx, sy, sz, blend) end - ---- ----Sets or blends the transform of a node to a new transform. ---- ----This sets the local transform of the node, relative to its parent. ---- ---- ----### NOTE: ----For best results when animating, it's recommended to keep the 3 components of the scale the same. ---- ----Even though the translation, scale, and rotation parameters are given in TSR order, they are applied in the normal TRS order. ---- ----@overload fun(self: lovr.Model, name: string, x: number, y: number, z: number, sx: number, sy: number, sz: number, angle: number, ax: number, ay: number, az: number, blend?: number) ----@overload fun(self: lovr.Model, index: number, position: lovr.Vec3, scale: lovr.Vec3, orientation: lovr.Quat, blend?: number) ----@overload fun(self: lovr.Model, name: string, position: lovr.Vec3, scale: lovr.Vec3, orientation: lovr.Quat, blend?: number) ----@overload fun(self: lovr.Model, index: number, transform: lovr.Mat4, blend?: number) ----@overload fun(self: lovr.Model, name: string, transform: lovr.Mat4, blend?: number) ----@param index number # The index of the node. ----@param x number # The x component of the position. ----@param y number # The y component of the position. ----@param z number # The z component of the position. ----@param sx number # The x component of the scale. ----@param sy number # The y component of the scale. ----@param sz number # The z component of the scale. ----@param angle number # The number of radians the node should be rotated around its rotation axis. ----@param ax number # The x component of the axis of rotation. ----@param ay number # The y component of the axis of rotation. ----@param az number # The z component of the axis of rotation. ----@param blend? number # A number from 0 to 1 indicating how much of the target transform to blend in. A value of 0 will not change the node's transform at all, whereas 1 will fully blend to the target transform. -function Model:setNodeTransform(index, x, y, z, sx, sy, sz, angle, ax, ay, az, blend) end - ---- ----Pass objects are used to record commands for the GPU. ---- ----Commands can be recorded by calling functions on the Pass. ---- ----After recording a set of passes, they can be submitted for the GPU to process using `lovr.graphics.submit`. ---- ----Pass objects are **temporary** and only exist for a single frame. ---- ----Once `lovr.graphics.submit` is called to end the frame, any passes that were created during that frame become **invalid**. Each frame, a new set of passes must be created and recorded. ---- ----LÖVR tries to detect if you use a pass after it's invalid, but this error checking is not 100% accurate at the moment. ---- ----There are 3 types of passes. ---- ----Each type can record a specific type of command: ---- ----- `render` passes render graphics to textures. ----- `compute` passes run compute shaders. ----- `transfer` passes can transfer data to/from GPU objects, like `Buffer` and `Texture`. ---- ----@class lovr.Pass -local Pass = {} - ---- ----Copies data between textures. ---- ----Similar to `Pass:copy`, except the source and destination sizes can be different. ---- ----The pixels from the source texture will be scaled to the destination size. This can only be called on a transfer pass, which can be created with `lovr.graphics.getPass`. ---- ---- ----### NOTE: ----When blitting between 3D textures, the layer counts do not need to match, and the layers will be treated as a continuous axis (i.e. pixels will be smoothed between layers). ---- ----When blitting between array textures, the layer counts must match, and the blit occurs as a sequence of distinct 2D blits layer-by-layer. ---- ----@param src lovr.Texture # The texture to copy from. ----@param dst lovr.Texture # The texture to copy to. ----@param srcx? number # The x offset from the left of the source texture to blit from, in pixels. ----@param srcy? number # The y offset from the top of the source texture to blit from, in pixels. ----@param srcz? number # The index of the first layer in the source texture to blit from. ----@param dstx? number # The x offset from the left of the destination texture to blit to, in pixels. ----@param dsty? number # The y offset from the top of the destination texture to blit to, in pixels. ----@param dstz? number # The index of the first layer in the destination texture to blit to. ----@param srcw? number # The width of the region in the source texture to blit. If nil, the region will extend to the right side of the texture. ----@param srch? number # The height of the region in the source texture to blit. If nil, the region will extend to the bottom of the texture. ----@param srcd? number # The number of layers in the source texture to blit. ----@param dstw? number # The width of the region in the destination texture to blit to. If nil, the region will extend to the right side of the texture. ----@param dsth? number # The height of the region in the destination texture to blit to. If nil, the region will extend to the bottom of the texture. ----@param dstd? number # The number of the layers in the destination texture to blit to. ----@param srclevel? number # The index of the mipmap level in the source texture to blit from. ----@param dstlevel? number # The index of the mipmap level in the destination texture to blit to. ----@param filter? lovr.FilterMode # The filtering algorithm used when rescaling. -function Pass:blit(src, dst, srcx, srcy, srcz, dstx, dsty, dstz, srcw, srch, srcd, dstw, dsth, dstd, srclevel, dstlevel, filter) end - ---- ----Draw a box. ---- ----This is like `Pass:cube`, except it takes 3 separate values for the scale. ---- ----@overload fun(self: lovr.Pass, position: lovr.Vec3, size: lovr.Vec3, orientation: lovr.Quat, style?: lovr.DrawStyle) ----@overload fun(self: lovr.Pass, transform: lovr.Mat4, style?: lovr.DrawStyle) ----@param x? number # The x coordinate of the center of the box. ----@param y? number # The y coordinate of the center of the box. ----@param z? number # The z coordinate of the center of the box. ----@param width? number # The width of the box. ----@param height? number # The height of the box. ----@param depth? number # The depth of the box. ----@param angle? number # The rotation of the box around its rotation axis, in radians. ----@param ax? number # The x component of the axis of rotation. ----@param ay? number # The y component of the axis of rotation. ----@param az? number # The z component of the axis of rotation. ----@param style? lovr.DrawStyle # Whether the box should be drawn filled or outlined. -function Pass:box(x, y, z, width, height, depth, angle, ax, ay, az, style) end - ---- ----Draws a capsule. ---- ----A capsule is shaped like a cylinder with a hemisphere on each end. ---- ---- ----### NOTE: ----The length of the capsule does not include the end caps. ---- ----The local origin of the capsule is in the center, and the local z axis points towards the end caps. ---- ----@overload fun(self: lovr.Pass, position: lovr.Vec3, scale: lovr.Vec3, orientation: lovr.Quat, segments?: number) ----@overload fun(self: lovr.Pass, transform: lovr.Mat4, segments?: number) ----@overload fun(self: lovr.Pass, p1: lovr.Vec3, p2: lovr.Vec3, radius?: number, segments?: number) ----@param x? number # The x coordinate of the center of the capsule. ----@param y? number # The y coordinate of the center of the capsule. ----@param z? number # The z coordinate of the center of the capsule. ----@param radius? number # The radius of the capsule. ----@param length? number # The length of the capsule. ----@param angle? number # The rotation of the capsule around its rotation axis, in radians. ----@param ax? number # The x component of the axis of rotation. ----@param ay? number # The y component of the axis of rotation. ----@param az? number # The z component of the axis of rotation. ----@param segments? number # The number of circular segments to render. -function Pass:capsule(x, y, z, radius, length, angle, ax, ay, az, segments) end - ---- ----Draws a circle. ---- ---- ----### NOTE: ----The local origin of the circle is in its center. ---- ----The local z axis is perpendicular to the circle. ---- ----@overload fun(self: lovr.Pass, position: lovr.Vec3, radius?: number, orientation: lovr.Quat, style?: lovr.DrawStyle, angle1?: number, angle2?: number, segments?: number) ----@overload fun(self: lovr.Pass, transform: lovr.Mat4, style?: lovr.DrawStyle, angle1?: number, angle2?: number, segments?: number) ----@param x? number # The x coordinate of the center of the circle. ----@param y? number # The y coordinate of the center of the circle. ----@param z? number # The z coordinate of the center of the circle. ----@param radius? number # The radius of the circle. ----@param angle? number # The rotation of the circle around its rotation axis, in radians. ----@param ax? number # The x component of the axis of rotation. ----@param ay? number # The y component of the axis of rotation. ----@param az? number # The z component of the axis of rotation. ----@param style? lovr.DrawStyle # Whether the circle should be filled or outlined. ----@param angle1? number # The angle of the beginning of the arc. ----@param angle2? number # angle of the end of the arc. ----@param segments? number # The number of segments to render. -function Pass:circle(x, y, z, radius, angle, ax, ay, az, style, angle1, angle2, segments) end - ---- ----Clears a Buffer or Texture. ---- ----This can only be called on a transfer pass, which can be created with `lovr.graphics.getPass`. ---- ----@overload fun(self: lovr.Pass, texture: lovr.Texture, color: lovr.Vec4, layer?: number, layers?: number, level?: number, levels?: number) ----@param buffer lovr.Buffer # The Buffer to clear. ----@param index? number # The index of the first item to clear. ----@param count? number # The number of items to clear. If `nil`, clears to the end of the Buffer. -function Pass:clear(buffer, index, count) end - ---- ----Runs a compute shader. ---- ----Before calling this, a compute shader needs to be active, using `Pass:setShader`. ---- ----This can only be called on a Pass with the `compute` type, which can be created using `lovr.graphics.getPass`. ---- ---- ----### NOTE: ----Usually compute shaders are run many times in parallel: once for each pixel in an image, once per particle, once per object, etc. ---- ----The 3 arguments represent how many times to run, or "dispatch", the compute shader, in up to 3 dimensions. ---- ----Each element of this grid is called a **workgroup**. ---- ----To make things even more complicated, each workgroup itself is made up of a set of "mini GPU threads", which are called **local workgroups**. ---- ----Like workgroups, the local workgroup size can also be 3D. ---- ----It's declared in the shader code, like this: ---- ---- layout(local_size_x = w, local_size_y = h, local_size_z = d) in; ---- ----All these 3D grids can get confusing, but the basic idea is to make the local workgroup size a small block of e.g. 32 particles or 8x8 pixels or 4x4x4 voxels, and then dispatch however many workgroups are needed to cover a list of particles, image, voxel field, etc. ---- ----The reason to do it this way is that the GPU runs its threads in little fixed-size bundles called subgroups. ---- ----Subgroups are usually 32 or 64 threads (the exact size is given by the `subgroupSize` property of `lovr.graphics.getDevice`) and all run together. ---- ----If the local workgroup size was `1x1x1`, then the GPU would only run 1 thread per subgroup and waste the other 31 or 63. ---- ----So for the best performance, be sure to set a local workgroup size bigger than 1! ---- ----Inside the compute shader, a few builtin variables can be used to figure out which workgroup is running: ---- ----- `uvec3 WorkgroupCount` is the workgroup count per axis (the `Pass:compute` arguments). ----- `uvec3 WorkgroupSize` is the local workgroup size (declared in the shader). ----- `uvec3 WorkgroupID` is the index of the current (global) workgroup. ----- `uvec3 LocalThreadID` is the index of the local workgroup inside its workgroup. ----- `uint LocalThreadIndex` is a 1D version of `LocalThreadID`. ----- `uvec3 GlobalThreadID` is the unique identifier for a thread within all workgroups in a ---- dispatch. It's equivalent to `WorkgroupID * WorkgroupSize + LocalThreadID` (usually what you ---- want!) ---- ----Indirect compute dispatches are useful to "chain" compute shaders together, while keeping all of the data on the GPU. ---- ----The first dispatch can do some computation and write some results to buffers, then the second indirect dispatch can use the data in those buffers to know how many times it should run. ---- ----An example would be a compute shader that does some sort of object culling, writing the number of visible objects to a buffer along with the IDs of each one. Subsequent compute shaders can be indirectly dispatched to perform extra processing on the visible objects. ---- ----Finally, an indirect draw can be used to render them. ---- ----@overload fun(self: lovr.Pass, buffer: lovr.Buffer, offset?: number) ----@param x? number # The number of workgroups to dispatch in the x dimension. ----@param y? number # The number of workgroups to dispatch in the y dimension. ----@param z? number # The number of workgroups to dispatch in the z dimension. -function Pass:compute(x, y, z) end - ---- ----Draws a cone. ---- ---- ----### NOTE: ----The local origin is at the center of the base of the cone, and the negative z axis points towards the tip. ---- ----@overload fun(self: lovr.Pass, position: lovr.Vec3, scale: lovr.Vec3, orientation: lovr.Quat, segments?: number) ----@overload fun(self: lovr.Pass, transform: lovr.Mat4, segments?: number) ----@overload fun(self: lovr.Pass, p1: lovr.Vec3, p2: lovr.Vec3, radius?: number, segments?: number) ----@param x? number # The x coordinate of the center of the base of the cone. ----@param y? number # The y coordinate of the center of the base of the cone. ----@param z? number # The z coordinate of the center of the base of the cone. ----@param radius? number # The radius of the cone. ----@param length? number # The length of the cone. ----@param angle? number # The rotation of the cone around its rotation axis, in radians. ----@param ax? number # The x component of the axis of rotation. ----@param ay? number # The y component of the axis of rotation. ----@param az? number # The z component of the axis of rotation. ----@param segments? number # The number of segments in the cone. -function Pass:cone(x, y, z, radius, length, angle, ax, ay, az, segments) end - ---- ----Copies data to or between `Buffer` and `Texture` objects. ---- ----This can only be called on a transfer pass, which can be created with `lovr.graphics.getPass`. ---- ----@overload fun(self: lovr.Pass, blob: lovr.Blob, bufferdst: lovr.Buffer, srcoffset?: number, dstoffset?: number, size?: number) ----@overload fun(self: lovr.Pass, buffersrc: lovr.Buffer, bufferdst: lovr.Buffer, srcoffset?: number, dstoffset?: number, size?: number) ----@overload fun(self: lovr.Pass, image: lovr.Image, texturedst: lovr.Texture, srcx?: number, srcy?: number, dstx?: number, dsty?: number, width?: number, height?: number, srclayer?: number, dstlayer?: number, layers?: number, srclevel?: number, dstlevel?: number) ----@overload fun(self: lovr.Pass, texturesrc: lovr.Texture, texturedst: lovr.Texture, srcx?: number, srcy?: number, dstx?: number, dsty?: number, width?: number, height?: number, srclayer?: number, dstlayer?: number, layers?: number, srclevel?: number, dstlevel?: number) ----@overload fun(self: lovr.Pass, tally: lovr.Tally, bufferdst: lovr.Buffer, srcindex?: number, dstoffset?: number, count?: number) ----@param table table # A table to copy to the buffer. ----@param bufferdst lovr.Buffer # The buffer to copy to. ----@param srcindex? number # The index of the first item to begin copying from. ----@param dstindex? number # The index of the first item in the buffer to begin copying to. ----@param count? number # The number of items to copy. If nil, copies as many items as possible. -function Pass:copy(table, bufferdst, srcindex, dstindex, count) end - ---- ----Draws a cube. ---- ---- ----### NOTE: ----The local origin is in the center of the cube. ---- ----@overload fun(self: lovr.Pass, position: lovr.Vec3, size?: number, orientation: lovr.Quat, style?: lovr.DrawStyle) ----@overload fun(self: lovr.Pass, transform: lovr.Mat4, style?: lovr.DrawStyle) ----@param x? number # The x coordinate of the center of the cube. ----@param y? number # The y coordinate of the center of the cube. ----@param z? number # The z coordinate of the center of the cube. ----@param size? number # The size of the cube. ----@param angle? number # The rotation of the cube around its rotation axis, in radians. ----@param ax? number # The x component of the axis of rotation. ----@param ay? number # The y component of the axis of rotation. ----@param az? number # The z component of the axis of rotation. ----@param style? lovr.DrawStyle # Whether the cube should be drawn filled or outlined. -function Pass:cube(x, y, z, size, angle, ax, ay, az, style) end - ---- ----Draws a cylinder. ---- ---- ----### NOTE: ----The local origin is in the center of the cylinder, and the length of the cylinder is along the z axis. ---- ----@overload fun(self: lovr.Pass, position: lovr.Vec3, scale: lovr.Vec3, orientation: lovr.Quat, capped?: boolean, angle1?: number, angle2?: number, segments?: number) ----@overload fun(self: lovr.Pass, transform: lovr.Mat4, capped?: boolean, angle1?: number, angle2?: number, segments?: number) ----@overload fun(self: lovr.Pass, p1: lovr.Vec3, p2: lovr.Vec3, radius?: number, capped?: boolean, angle1?: number, angle2?: number, segments?: number) ----@param x? number # The x coordinate of the center of the cylinder. ----@param y? number # The y coordinate of the center of the cylinder. ----@param z? number # The z coordinate of the center of the cylinder. ----@param radius? number # The radius of the cylinder. ----@param length? number # The length of the cylinder. ----@param angle? number # The rotation of the cylinder around its rotation axis, in radians. ----@param ax? number # The x component of the axis of rotation. ----@param ay? number # The y component of the axis of rotation. ----@param az? number # The z component of the axis of rotation. ----@param capped? boolean # Whether the tops and bottoms of the cylinder should be rendered. ----@param angle1? number # The angle of the beginning of the arc. ----@param angle2? number # angle of the end of the arc. ----@param segments? number # The number of circular segments to render. -function Pass:cylinder(x, y, z, radius, length, angle, ax, ay, az, capped, angle1, angle2, segments) end - ---- ----Draws a model. ---- ----@overload fun(self: lovr.Pass, model: lovr.Model, position: lovr.Vec3, scale?: number, orientation: lovr.Quat, nodeindex?: number, children?: boolean, instances?: number) ----@overload fun(self: lovr.Pass, model: lovr.Model, transform: lovr.Mat4, nodeindex?: number, children?: boolean, instances?: number) ----@overload fun(self: lovr.Pass, model: lovr.Model, x?: number, y?: number, z?: number, scale?: number, angle?: number, ax?: number, ay?: number, az?: number, nodename?: string, children?: boolean, instances?: number) ----@overload fun(self: lovr.Pass, model: lovr.Model, position: lovr.Vec3, scale?: number, orientation: lovr.Quat, nodename?: string, children?: boolean, instances?: number) ----@overload fun(self: lovr.Pass, model: lovr.Model, transform: lovr.Mat4, nodename?: string, children?: boolean, instances?: number) ----@param model lovr.Model # The model to draw. ----@param x? number # The x coordinate to draw the model at. ----@param y? number # The y coordinate to draw the model at. ----@param z? number # The z coordinate to draw the model at. ----@param scale? number # The scale of the model. ----@param angle? number # The rotation of the model around its rotation axis, in radians. ----@param ax? number # The x component of the axis of rotation. ----@param ay? number # The y component of the axis of rotation. ----@param az? number # The z component of the axis of rotation. ----@param nodeindex? number # The index of the node to draw. If nil, the root node is drawn. ----@param children? boolean # Whether the children of the node should be drawn. ----@param instances? number # The number of instances to draw. -function Pass:draw(model, x, y, z, scale, angle, ax, ay, az, nodeindex, children, instances) end - ---- ----Draws a fullscreen triangle. ---- ----The `fill` shader is used, which stretches the triangle across the screen. ---- ---- ----### NOTE: ----This function has some special behavior for array textures: ---- ----- Filling a single-layer texture to a multi-layer canvas will mirror the texture to all layers, ---- just like regular drawing. ----- Filling a 2-layer texture to a mono canvas will render the 2 layers side-by-side. ----- Filling a multi-layer texture to a multi-layer canvas will do a layer-by-layer fill (the layer ---- counts must match). ---- ----@overload fun(self: lovr.Pass) ----@param texture lovr.Texture # The texture to fill. If nil, the texture from the active material is used. -function Pass:fill(texture) end - ---- ----Returns the clear values of the pass. ---- ----@return table clears # The clear values for the pass. Numeric keys will contain clear values for color textures, either as a table of r, g, b, a values or a boolean. If the pass has a depth texture, there will also be `depth` and `stencil` keys containing the clear values or booleans. -function Pass:getClear() end - ---- ----Returns the dimensions of the textures attached to the render pass. ---- ---- ----### NOTE: ----If the pass is not a render pass, this function returns zeros. ---- ----@return number width # The texture width. ----@return number height # The texture height. -function Pass:getDimensions() end - ---- ----Returns the height of the textures attached to the render pass. ---- ---- ----### NOTE: ----If the pass is not a render pass, this function returns zero. ---- ----@return number height # The texture height. -function Pass:getHeight() end - ---- ----Returns the projection for a single view. ---- ----@overload fun(self: lovr.Pass, view: number, matrix: lovr.Mat4):lovr.Mat4 ----@param view number # The view index. ----@return number left # The left field of view angle, in radians. ----@return number right # The right field of view angle, in radians. ----@return number up # The top field of view angle, in radians. ----@return number down # The bottom field of view angle, in radians. -function Pass:getProjection(view) end - ---- ----Returns the antialiasing setting of a render pass. ---- ----@return number samples # The number of samples used for rendering. Currently, will be 1 or 4. -function Pass:getSampleCount() end - ---- ----Returns the textures a render pass is rendering to. ---- ----@return table target # A table of the color textures targeted by the pass, with an additional `depth` key if the pass has a depth texture. -function Pass:getTarget() end - ---- ----Returns the type of the pass (render, compute, or transfer). ---- ----The type restricts what kinds of functions can be called on the pass. ---- ----@return lovr.PassType type # The type of the Pass. -function Pass:getType() end - ---- ----Returns the view count of a render pass. ---- ----This is the layer count of the textures it is rendering to. ---- ---- ----### NOTE: ----A render pass has one "camera" for each view. ---- ----Whenever something is drawn, it is broadcast to each view (layer) of each texture, using the corresponding camera. ---- ----@return number views # The view count. -function Pass:getViewCount() end - ---- ----Get the pose of a single view. ---- ----@overload fun(self: lovr.Pass, view: number, matrix: lovr.Mat4, invert: boolean):lovr.Mat4 ----@param view number # The view index. ----@return number x # The x position of the viewer, in meters. ----@return number y # The y position of the viewer, in meters. ----@return number z # The z position of the viewer, in meters. ----@return number angle # The number of radians the viewer is rotated around its axis of rotation. ----@return number ax # The x component of the axis of rotation. ----@return number ay # The y component of the axis of rotation. ----@return number az # The z component of the axis of rotation. -function Pass:getViewPose(view) end - ---- ----Returns the width of the textures attached to the render pass. ---- ---- ----### NOTE: ----If the pass is not a render pass, this function returns zero. ---- ----@return number width # The texture width. -function Pass:getWidth() end - ---- ----Draws a line between points. ---- ----`Pass:mesh` can also be used to draw line segments using the `line` `MeshMode`. ---- ---- ----### NOTE: ----There is currently no way to increase line thickness. ---- ----@overload fun(self: lovr.Pass, t: table) ----@overload fun(self: lovr.Pass, v1: lovr.Vec3, v2: lovr.Vec3, ...) ----@param x1 number # The x coordinate of the first point. ----@param y1 number # The y coordinate of the first point. ----@param z1 number # The z coordinate of the first point. ----@param x2 number # The x coordinate of the next point. ----@param y2 number # The y coordinate of the next point. ----@param z2 number # The z coordinate of the next point. ----@vararg any # More points to add to the line. -function Pass:line(x1, y1, z1, x2, y2, z2, ...) end - ---- ----Draws a mesh. ---- ---- ----### NOTE: ----The index buffer defines the order the vertices are drawn in. ---- ----It can be used to reorder, reuse, or omit vertices from the mesh. ---- ----When drawing without a vertex buffer, the `VertexIndex` variable can be used in shaders to compute the position of each vertex, possibly by reading data from other `Buffer` or `Texture` resources. ---- ----The active `MeshMode` controls whether the vertices are drawn as points, lines, or triangles. ---- ----The active `Material` is applied to the mesh. ---- ----@overload fun(self: lovr.Pass, vertices?: lovr.Buffer, position: lovr.Vec3, scales: lovr.Vec3, orientation: lovr.Quat, start?: number, count?: number, instances?: number) ----@overload fun(self: lovr.Pass, vertices?: lovr.Buffer, transform: lovr.Mat4, start?: number, count?: number, instances?: number) ----@overload fun(self: lovr.Pass, vertices?: lovr.Buffer, indices: lovr.Buffer, x?: number, y?: number, z?: number, scale?: number, angle?: number, ax?: number, ay?: number, az?: number, start?: number, count?: number, instances?: number, base?: number) ----@overload fun(self: lovr.Pass, vertices?: lovr.Buffer, indices: lovr.Buffer, position: lovr.Vec3, scales: lovr.Vec3, orientation: lovr.Quat, start?: number, count?: number, instances?: number, base?: number) ----@overload fun(self: lovr.Pass, vertices?: lovr.Buffer, indices: lovr.Buffer, transform: lovr.Mat4, start?: number, count?: number, instances?: number, base?: number) ----@overload fun(self: lovr.Pass, vertices?: lovr.Buffer, indices: lovr.Buffer, draws: lovr.Buffer, drawcount: number, offset: number, stride: number) ----@param vertices? lovr.Buffer # The buffer containing the vertices to draw. ----@param x? number # The x coordinate of the position to draw the mesh at. ----@param y? number # The y coordinate of the position to draw the mesh at. ----@param z? number # The z coordinate of the position to draw the mesh at. ----@param scale? number # The scale of the mesh. ----@param angle? number # The number of radians the mesh is rotated around its rotational axis. ----@param ax? number # The x component of the axis of rotation. ----@param ay? number # The y component of the axis of rotation. ----@param az? number # The z component of the axis of rotation. ----@param start? number # The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer). ----@param count? number # The number of vertices to render (or the number of indices, when using an index buffer). When `nil`, as many vertices or indices as possible will be drawn (based on the length of the Buffers and `start`). ----@param instances? number # The number of copies of the mesh to render. -function Pass:mesh(vertices, x, y, z, scale, angle, ax, ay, az, start, count, instances) end - ---- ----Generates mipmaps for a texture. ---- ----This can only be called on a transfer pass, which can be created with `lovr.graphics.getPass`. ---- ----When rendering to textures with a render pass, it's also possible to automatically regenerate mipmaps after rendering by adding the `mipmaps` flag when creating the pass. ---- ----@param texture lovr.Texture # The texture to mipmap. ----@param base? number # The index of the mipmap used to generate the remaining mipmaps. ----@param count? number # The number of mipmaps to generate. If nil, generates the remaining mipmaps. -function Pass:mipmap(texture, base, count) end - ---- ----Resets the transform back to the origin. ---- -function Pass:origin() end - ---- ----Draws a plane. ---- ----@overload fun(self: lovr.Pass, position: lovr.Vec3, size: lovr.Vec2, orientation: lovr.Quat, style?: lovr.DrawStyle, columns?: number, rows?: number) ----@overload fun(self: lovr.Pass, transform: lovr.Mat4, style?: lovr.DrawStyle, columns?: number, rows?: number) ----@param x? number # The x coordinate of the center of the plane. ----@param y? number # The y coordinate of the center of the plane. ----@param z? number # The z coordinate of the center of the plane. ----@param width? number # The width of the plane. ----@param height? number # The height of the plane. ----@param angle? number # The rotation of the plane around its rotation axis, in radians. ----@param ax? number # The x component of the axis of rotation. ----@param ay? number # The y component of the axis of rotation. ----@param az? number # The z component of the axis of rotation. ----@param style? lovr.DrawStyle # Whether the plane should be drawn filled or outlined. ----@param columns? number # The number of horizontal segments in the plane. ----@param rows? number # The number of vertical segments in the plane. -function Pass:plane(x, y, z, width, height, angle, ax, ay, az, style, columns, rows) end - ---- ----Draws points. ---- ----`Pass:mesh` can also be used to draw points using a `Buffer`. ---- ---- ----### NOTE: ----To change the size of points, set the `pointSize` shader flag in `lovr.graphics.newShader` or write to the `PointSize` variable in the vertex shader. ---- ----Points are always the same size on the screen, regardless of distance, and the units are in pixels. ---- ----@overload fun(self: lovr.Pass, t: table) ----@overload fun(self: lovr.Pass, v: lovr.Vec3, ...) ----@param x number # The x coordinate of the first point. ----@param y number # The y coordinate of the first point. ----@param z number # The z coordinate of the first point. ----@vararg any # More points. -function Pass:points(x, y, z, ...) end - ---- ----Pops the transform or render state stack, restoring it to the state it was in when it was last pushed. ---- ---- ----### NOTE: ----If a stack is popped without a corresponding push, the stack "underflows" which causes an error. ---- ----@param stack? lovr.StackType # The type of stack to pop. -function Pass:pop(stack) end - ---- ----Saves a copy of the transform or render states. ---- ----Further changes can be made to the transform or render states, and afterwards `Pass:pop` can be used to restore the original state. ---- ----Pushes and pops can be nested, but it's an error to pop without a corresponding push. ---- ---- ----### NOTE: ----Each stack has a limit of the number of copies it can store. ---- ----There can be 16 transforms and 4 render states saved. ---- ----The `state` stack does not save the camera info or shader variables changed with `Pass:send`. ---- ----@param stack? lovr.StackType # The type of stack to push. -function Pass:push(stack) end - ---- ----Creates a `Readback` object which asynchronously downloads data from a `Buffer`, `Texture`, or `Tally`. ---- ----The readback can be polled for completion, or, after this transfer pass is submitted, `Readback:wait` can be used to block until the download is complete. ---- ----This can only be called on a transfer pass, which can be created with `lovr.graphics.getPass`. ---- ----@overload fun(self: lovr.Pass, texture: lovr.Texture, x?: number, y?: number, layer?: number, level?: number, width?: number, height?: number):lovr.Readback ----@overload fun(self: lovr.Pass, tally: lovr.Tally, index: number, count: number):lovr.Readback ----@param buffer lovr.Buffer # The Buffer to download data from. ----@param index number # The index of the first item to download. ----@param count number # The number of items to download. ----@return lovr.Readback readback # The new readback. -function Pass:read(buffer, index, count) end - ---- ----Rotates the coordinate system. ---- ----@overload fun(self: lovr.Pass, rotation: lovr.Quat) ----@param angle number # The amount to rotate the coordinate system by, in radians. ----@param ax number # The x component of the axis of rotation. ----@param ay number # The y component of the axis of rotation. ----@param az number # The z component of the axis of rotation. -function Pass:rotate(angle, ax, ay, az) end - ---- ----Draws a rounded rectangle. ---- ----@overload fun(self: lovr.Pass, position: lovr.Vec3, size: lovr.Vec3, orientation: lovr.Quat, radius?: number, segments?: number) ----@overload fun(self: lovr.Pass, transform: lovr.Mat4, radius?: number, segments?: number) ----@param x? number # The x coordinate of the center of the rectangle. ----@param y? number # The y coordinate of the center of the rectangle. ----@param z? number # The z coordinate of the center of the rectangle. ----@param width? number # The width of the rectangle. ----@param height? number # The height of the rectangle. ----@param thickness? number # The thickness of the rectangle. ----@param angle? number # The rotation of the rectangle around its rotation axis, in radians. ----@param ax? number # The x component of the axis of rotation. ----@param ay? number # The y component of the axis of rotation. ----@param az? number # The z component of the axis of rotation. ----@param radius? number # The radius of the rectangle corners. If the radius is zero or negative, the rectangle will have sharp corners. ----@param segments? number # The number of circular segments to use for each corner. This increases the smoothness, but increases the number of vertices in the mesh. -function Pass:roundrect(x, y, z, width, height, thickness, angle, ax, ay, az, radius, segments) end - ---- ----Scales the coordinate system. ---- ----@overload fun(self: lovr.Pass, scale: lovr.Vec3) ----@param sx number # The x component of the scale. ----@param sy? number # The y component of the scale. ----@param sz? number # The z component of the scale. -function Pass:scale(sx, sy, sz) end - ---- ----Sends a value to a variable in the Pass's active `Shader`. ---- ----The active shader is changed using `Pass:setShader`. ---- ---- ----### NOTE: ----Shader variables can be in different "sets". ---- ----Variables changed by this function must be in set #2, because LÖVR uses set #0 and set #1 internally. ---- ----The new value will persist until a new shader is set that uses a different "type" for the binding number of the variable. ---- ----See `Pass:setShader` for more details. ---- ----@overload fun(self: lovr.Pass, name: string, texture: lovr.Texture) ----@overload fun(self: lovr.Pass, name: string, sampler: lovr.Sampler) ----@overload fun(self: lovr.Pass, name: string, constant: any) ----@overload fun(self: lovr.Pass, binding: number, buffer: lovr.Buffer, offset?: number, extent?: number) ----@overload fun(self: lovr.Pass, binding: number, texture: lovr.Texture) ----@overload fun(self: lovr.Pass, binding: number, sampler: lovr.Sampler) ----@param name string # The name of the Shader variable. ----@param buffer lovr.Buffer # The Buffer to assign. ----@param offset? number # An offset from the start of the buffer where data will be read, in bytes. ----@param extent? number # The number of bytes that will be available for reading. If zero, as much data as possible will be bound, depending on the offset, buffer size, and the `uniformBufferRange` or `storageBufferRange` limit. -function Pass:send(name, buffer, offset, extent) end - ---- ----Sets whether alpha to coverage is enabled. ---- ----Alpha to coverage factors the alpha of a pixel into antialiasing calculations. ---- ----It can be used to get antialiased edges on textures with transparency. ---- ----It's often used for foliage. ---- ---- ----### NOTE: ----By default, alpha to coverage is disabled. ---- ----@param enable boolean # Whether alpha to coverage should be enabled. -function Pass:setAlphaToCoverage(enable) end - ---- ----Sets the blend mode. ---- ----When a pixel is drawn, the blend mode controls how it is mixed with the color and alpha of the pixel underneath it. ---- ---- ----### NOTE: ----The default blend mode is `alpha` with the `alphamultiply` alpha mode. ---- ----@overload fun(self: lovr.Pass) ----@param blend lovr.BlendMode # The blend mode. ----@param alphaBlend lovr.BlendAlphaMode # The alpha blend mode, used to control premultiplied alpha. -function Pass:setBlendMode(blend, alphaBlend) end - ---- ----Sets the color used for drawing. ---- ----Color components are from 0 to 1. ---- ---- ----### NOTE: ----The default color is `(1, 1, 1, 1)`. ---- ----@overload fun(self: lovr.Pass, t: table) ----@overload fun(self: lovr.Pass, hex: number, a?: number) ----@param r number # The red component of the color. ----@param g number # The green component of the color. ----@param b number # The blue component of the color. ----@param a? number # The alpha component of the color. -function Pass:setColor(r, g, b, a) end - ---- ----Sets the color channels affected by drawing, on a per-channel basis. ---- ----Disabling color writes is often used to render to the depth or stencil buffer without affecting existing pixel colors. ---- ---- ----### NOTE: ----By default, color writes are enabled for all channels. ---- ----@overload fun(self: lovr.Pass, r: boolean, g: boolean, b: boolean, a: boolean) ----@param enable boolean # Whether all color components should be affected by draws. -function Pass:setColorWrite(enable) end - ---- ----Sets whether the front or back faces of triangles are culled. ---- ---- ----### NOTE: ----The default cull mode is `none`. ---- ----@param mode? lovr.CullMode # Whether `front` faces, `back` faces, or `none` of the faces should be culled. -function Pass:setCullMode(mode) end - ---- ----Enables or disables depth clamp. ---- ----Normally, when pixels fall outside of the clipping planes, they are clipped (not rendered). ---- ----Depth clamp will instead render these pixels, clamping their depth on to the clipping planes. ---- ---- ----### NOTE: ----This isn\'t supported on all GPUs. ---- ----Use the `depthClamp` feature of `lovr.graphics.getFeatures` to check for support. ---- ----If depth clamp is enabled when unsupported, it will silently fall back to depth clipping. ---- ----Depth clamping is not enabled by default. ---- ----@param enable boolean # Whether depth clamp should be enabled. -function Pass:setDepthClamp(enable) end - ---- ----Set the depth offset. ---- ----This is a constant offset added to the depth value of pixels. ---- ----It can be used to fix Z fighting when rendering decals or other nearly-overlapping objects. ---- ---- ----### NOTE: ----The default depth offset is zero for both values. ---- ----@param offset? number # The depth offset. ----@param sloped? number # The sloped depth offset. -function Pass:setDepthOffset(offset, sloped) end - ---- ----Sets the depth test. ---- ---- ----### NOTE: ----When using LÖVR's default projection (reverse Z with infinite far plane) the default depth test is `gequal`, depth values of 0.0 are on the far plane and depth values of 1.0 are on the near plane, closer to the camera. ---- ----A depth buffer must be present to use the depth test, but this is enabled by default. ---- ----@overload fun(self: lovr.Pass) ----@param test lovr.CompareMode # The new depth test to use. -function Pass:setDepthTest(test) end - ---- ----Sets whether draws write to the depth buffer. ---- ----When a pixel is drawn, if depth writes are enabled and the pixel passes the depth test, the depth buffer will be updated with the pixel's depth value. ---- ---- ----### NOTE: ----The default depth write is `true`. ---- ----@param write boolean # Whether the depth buffer should be affected by draws. -function Pass:setDepthWrite(write) end - ---- ----Sets the font used for `Pass:text`. ---- ----@param font lovr.Font # The Font to use when rendering text. -function Pass:setFont(font) end - ---- ----Sets the material. ---- ----This will apply to most drawing, except for text, skyboxes, and models, which use their own materials. ---- ----@overload fun(self: lovr.Pass, texture: lovr.Texture) ----@overload fun(self: lovr.Pass) ----@param material lovr.Material # The material to use for drawing. -function Pass:setMaterial(material) end - ---- ----Changes the way vertices are connected together when drawing using `Pass:mesh`. ---- ---- ----### NOTE: ----The default mesh mode is `triangles`. ---- ----@param mode lovr.MeshMode # The mesh mode to use. -function Pass:setMeshMode(mode) end - ---- ----Sets the projection for a single view. ---- ----4 field of view angles can be used, similar to the field of view returned by `lovr.headset.getViewAngles`. ---- ----Alternatively, a projection matrix can be used for other types of projections like orthographic, oblique, etc. ---- ----Up to 6 views are supported. ---- ----The Pass returned by `lovr.headset.getPass` will have its views automatically configured to match the headset. ---- ---- ----### NOTE: ----A far clipping plane of 0.0 can be used for an infinite far plane with reversed Z range. ---- ----This is the default because it improves depth precision and reduces Z fighting. ---- ----Using a non-infinite far plane requires the depth buffer to be cleared to 1.0 instead of 0.0 and the default depth test to be changed to `lequal` instead of `gequal`. ---- ----@overload fun(self: lovr.Pass, view: number, matrix: lovr.Mat4) ----@param view number # The index of the view to update. ----@param left number # The left field of view angle, in radians. ----@param right number # The right field of view angle, in radians. ----@param up number # The top field of view angle, in radians. ----@param down number # The bottom field of view angle, in radians. ----@param near? number # The near clipping plane distance, in meters. ----@param far? number # The far clipping plane distance, in meters. -function Pass:setProjection(view, left, right, up, down, near, far) end - ---- ----Sets the default `Sampler` to use when sampling textures. ---- ----It is also possible to send a custom sampler to a shader using `Pass:send` and use that instead, which allows customizing the sampler on a per-texture basis. ---- ---- ----### NOTE: ----The `getPixel` shader helper function will use this sampler. ---- ----@overload fun(self: lovr.Pass, sampler: lovr.Sampler) ----@param filter? lovr.FilterMode # The default filter mode to use when sampling textures (the `repeat` wrap mode will be used). -function Pass:setSampler(filter) end - ---- ----Sets the scissor rectangle. ---- ----Any pixels outside the scissor rectangle will not be drawn. ---- ---- ----### NOTE: ----`x` and `y` can not be negative. ---- ----The default scissor rectangle covers the entire dimensions of the render pass textures. ---- ----@param x number # The x coordinate of the upper-left corner of the scissor rectangle. ----@param y number # The y coordinate of the upper-left corner of the scissor rectangle. ----@param w number # The width of the scissor rectangle. ----@param h number # The height of the scissor rectangle. -function Pass:setScissor(x, y, w, h) end - ---- ----Sets the active shader. ---- ----In a render pass, the Shader will affect all drawing operations until it is changed again. ---- ----In a compute pass, the Shader will be run when `Pass:compute` is called. ---- ---- ----### NOTE: ----Changing the shader will preserve resource bindings (the ones set using `Pass:send`) **unless** the new shader declares a resource for a binding number using a different type than the current shader. ---- ----In this case, the resource "type" means one of the following: ---- ----- Uniform buffer (`uniform`). ----- Storage buffer (`buffer`). ----- Sampled texture, (`uniform texture<type>`). ----- Storage texture, (`uniform image<type>`). ----- Sampler (`uniform sampler`). ---- ----If the new shader doesn't declare a resource in a particular binding number, any resource there will be preserved. ---- ----If there's a clash in resource types like this, the variable will be "cleared". ---- ----Using a buffer variable that has been cleared is not well-defined, and may return random data or even crash the GPU. ---- ----For textures, white pixels will be returned. ---- ----Samplers will use `linear` filtering and the `repeat` wrap mode. ---- ----Changing the shader will not clear push constants set in the `Constants` block. ---- ----@overload fun(self: lovr.Pass, default: lovr.DefaultShader) ----@overload fun(self: lovr.Pass) ----@param shader lovr.Shader # The shader to use. -function Pass:setShader(shader) end - ---- ----Sets the stencil test. ---- ----Any pixels that fail the stencil test won't be drawn. ---- ----For example, setting the stencil test to `('equal', 1)` will only draw pixels that have a stencil value of 1. The stencil buffer can be modified by drawing while stencil writes are enabled with `lovr.graphics.setStencilWrite`. ---- ---- ----### NOTE: ----The stencil test is disabled by default. ---- ----Setting the stencil test requires the `Pass` to have a depth texture with the `d24s8` or `d32fs8` format (the `s` means "stencil"). ---- ----The `t.graphics.stencil` and `t.headset.stencil` flags in `lovr.conf` can be used to request a stencil format for the default window and headset passes, respectively. ---- ----@overload fun(self: lovr.Pass) ----@param test lovr.CompareMode # The new stencil test to use. ----@param value number # The stencil value to compare against. ----@param mask? number # An optional mask to apply to stencil values before the comparison. -function Pass:setStencilTest(test, value, mask) end - ---- ----Sets or disables stencil writes. ---- ----When stencil writes are enabled, any pixels drawn will update the values in the stencil buffer using the `StencilAction` set. ---- ---- ----### NOTE: ----By default, stencil writes are disabled. ---- ----Setting the stencil test requires the `Pass` to have a depth texture with the `d24s8` or `d32fs8` format (the `s` means "stencil"). ---- ----The `t.graphics.stencil` and `t.headset.stencil` flags in `lovr.conf` can be used to request a stencil format for the default window and headset passes, respectively. ---- ----@overload fun(self: lovr.Pass, actions: table, value?: number, mask?: number) ----@overload fun(self: lovr.Pass) ----@param action lovr.StencilAction # How pixels drawn will update the stencil buffer. ----@param value? number # When using the 'replace' action, this is the value to replace with. ----@param mask? number # An optional mask to apply to stencil values before writing. -function Pass:setStencilWrite(action, value, mask) end - ---- ----Sets the pose for a single view. ---- ----Objects rendered in this view will appear as though the camera is positioned using the given pose. ---- ----Up to 6 views are supported. ---- ----When rendering to the headset, views are changed to match the eye positions. ---- ----These view poses are also available using `lovr.headset.getViewPose`. ---- ----@overload fun(self: lovr.Pass, view: number, position: lovr.Vec3, orientation: lovr.Quat) ----@overload fun(self: lovr.Pass, view: number, matrix: lovr.Mat4, inverted: boolean) ----@param view number # The index of the view to update. ----@param x number # The x position of the viewer, in meters. ----@param y number # The y position of the viewer, in meters. ----@param z number # The z position of the viewer, in meters. ----@param angle number # The number of radians the viewer is rotated around its axis of rotation. ----@param ax number # The x component of the axis of rotation. ----@param ay number # The y component of the axis of rotation. ----@param az number # The z component of the axis of rotation. -function Pass:setViewPose(view, x, y, z, angle, ax, ay, az) end - ---- ----Sets the viewport. ---- ----Everything rendered will get mapped to the rectangle defined by the viewport. ---- ----More specifically, this defines the transformation from normalized device coordinates to pixel coordinates. ---- ---- ----### NOTE: ----The viewport rectangle can use floating point numbers. ---- ----A negative viewport height (with a y coordinate equal to the bottom of the viewport) can be used to flip the rendering vertically. ---- ----The default viewport extends from `(0, 0)` to the dimensions of the target textures, with min depth and max depth respectively set to 0 and 1. ---- ----@param x number # The x coordinate of the upper-left corner of the viewport. ----@param y number # The y coordinate of the upper-left corner of the viewport. ----@param w number # The width of the viewport. ----@param h number # The height of the viewport. May be negative. ----@param dmin? number # The min component of the depth range. ----@param dmax? number # The max component of the depth range. -function Pass:setViewport(x, y, w, h, dmin, dmax) end - ---- ----Sets whether vertices in the clockwise or counterclockwise order vertices are considered the "front" face of a triangle. ---- ----This is used for culling with `Pass:setCullMode`. ---- ---- ----### NOTE: ----The default winding is counterclockwise. ---- ----LÖVR's builtin shapes are wound counterclockwise. ---- ----@param winding lovr.Winding # Whether triangle vertices are ordered `clockwise` or `counterclockwise`. -function Pass:setWinding(winding) end - ---- ----Enables or disables wireframe rendering. ---- ----This will draw all triangles as lines while active. It's intended to be used for debugging, since it usually has a performance cost. ---- ---- ----### NOTE: ----Wireframe rendering is disabled by default. ---- ----There is currently no way to change the thickness of the lines. ---- ----@param enable boolean # Whether wireframe rendering should be enabled. -function Pass:setWireframe(enable) end - ---- ----Draws a skybox. ---- ---- ----### NOTE: ----The skybox will be rotated based on the camera rotation. ---- ----The skybox is drawn using a fullscreen triangle. ---- ----The skybox uses a custom shader, so set the shader to `nil` before calling this function (unless explicitly using a custom shader). ---- ----@overload fun(self: lovr.Pass) ----@param skybox lovr.Texture # The skybox to render. Its `TextureType` can be `cube` to render as a cubemap, or `2d` to render as an equirectangular (spherical) 2D image. -function Pass:skybox(skybox) end - ---- ----Draws a sphere ---- ---- ----### NOTE: ----The local origin of the sphere is in its center. ---- ----@overload fun(self: lovr.Pass, position: lovr.Vec3, radius?: number, orientation: lovr.Quat, longitudes?: number, latitudes?: number) ----@overload fun(self: lovr.Pass, transform: lovr.Mat4, longitudes?: number, latitudes?: number) ----@param x? number # The x coordinate of the center of the sphere. ----@param y? number # The y coordinate of the center of the sphere. ----@param z? number # The z coordinate of the center of the sphere. ----@param radius? number # The radius of the sphere. ----@param angle? number # The rotation of the sphere around its rotation axis, in radians. ----@param ax? number # The x component of the axis of rotation. ----@param ay? number # The y component of the axis of rotation. ----@param az? number # The z component of the axis of rotation. ----@param longitudes? number # The number of "horizontal" segments. ----@param latitudes? number # The number of "vertical" segments. -function Pass:sphere(x, y, z, radius, angle, ax, ay, az, longitudes, latitudes) end - ---- ----Draws text. ---- ----The font can be changed using `Pass:setFont`. ---- ---- ----### NOTE: ----UTF-8 encoded strings are supported. ---- ----Newlines will start a new line of text. ---- ----Tabs will be rendered as four spaces. ---- ----Carriage returns are ignored. ---- ----With the default font pixel density, a scale of 1.0 makes the text height 1 meter. ---- ----The wrap value does not take into account the text's scale. ---- ----Text rendering requires a special shader, which will only be automatically used when the active shader is set to `nil`. ---- ----Blending should be enabled when rendering text (it's on by default). ---- ----This function can draw up to 16384 visible characters at a time, and will currently throw an error if the string is too long. ---- ----@overload fun(self: lovr.Pass, text: string, position: lovr.Vec3, scale?: number, orientation: lovr.Quat, wrap?: number, halign?: lovr.HorizontalAlign, valign?: lovr.VerticalAlign) ----@overload fun(self: lovr.Pass, text: string, transform: lovr.Mat4, wrap?: number, halign?: lovr.HorizontalAlign, valign?: lovr.VerticalAlign) ----@overload fun(self: lovr.Pass, colortext: table, x?: number, y?: number, z?: number, scale?: number, angle?: number, ax?: number, ay?: number, az?: number, wrap?: number, halign?: lovr.HorizontalAlign, valign?: lovr.VerticalAlign) ----@overload fun(self: lovr.Pass, colortext: table, position: lovr.Vec3, scale?: number, orientation: lovr.Quat, wrap?: number, halign?: lovr.HorizontalAlign, valign?: lovr.VerticalAlign) ----@overload fun(self: lovr.Pass, colortext: table, transform: lovr.Mat4, wrap?: number, halign?: lovr.HorizontalAlign, valign?: lovr.VerticalAlign) ----@param text string # The text to render. ----@param x? number # The x coordinate of the text origin. ----@param y? number # The y coordinate of the text origin. ----@param z? number # The z coordinate of the text origin. ----@param scale? number # The scale of the text (with the default pixel density, units are meters). ----@param angle? number # The rotation of the text around its rotation axis, in radians. ----@param ax? number # The x component of the axis of rotation. ----@param ay? number # The y component of the axis of rotation. ----@param az? number # The z component of the axis of rotation. ----@param wrap? number # The maximum width of each line in meters (before scale is applied). When zero, the text will not wrap. ----@param halign? lovr.HorizontalAlign # The horizontal alignment relative to the text origin. ----@param valign? lovr.VerticalAlign # The vertical alignment relative to the text origin. -function Pass:text(text, x, y, z, scale, angle, ax, ay, az, wrap, halign, valign) end - ---- ----Starts a GPU measurement. ---- ----One of the slots in a `Tally` object will be used to hold the result. Commands on the Pass will continue being measured until `Pass:tock` is called with the same tally and slot combination. ---- ----Afterwards, `Pass:read` can be used to read back the tally result, or the tally can be copied to a `Buffer`. ---- ---- ----### NOTE: ----`pixel` and `shader` measurements can not be nested, but `time` measurements can be nested. ---- ----For `time` measurements, the view count of the pass (`Pass:getViewCount`) must match the view count of the tally, which defaults to `2`. ---- ----@param tally lovr.Tally # The tally that will store the measurement. ----@param slot number # The index of the slot in the tally to store the measurement in. -function Pass:tick(tally, slot) end - ---- ----Stops a GPU measurement. ---- ----`Pass:tick` must be called to start the measurement before this can be called. ---- ----Afterwards, `Pass:read` can be used to read back the tally result, or the tally can be copied to a `Buffer`. ---- ----@param tally lovr.Tally # The tally storing the measurement. ----@param slot number # The index of the slot in the tally storing the measurement. -function Pass:tock(tally, slot) end - ---- ----Draws a torus. ---- ---- ----### NOTE: ----The local origin is in the center of the torus, and the torus forms a circle around the local Z axis. ---- ----@overload fun(self: lovr.Pass, position: lovr.Vec3, scale: lovr.Vec3, orientation: lovr.Quat, tsegments?: number, psegments?: number) ----@overload fun(self: lovr.Pass, transform: lovr.Mat4, tsegments?: number, psegments?: number) ----@param x? number # The x coordinate of the center of the torus. ----@param y? number # The y coordinate of the center of the torus. ----@param z? number # The z coordinate of the center of the torus. ----@param radius? number # The radius of the torus. ----@param thickness? number # The thickness of the torus. ----@param angle? number # The rotation of the torus around its rotation axis, in radians. ----@param ax? number # The x component of the axis of rotation. ----@param ay? number # The y component of the axis of rotation. ----@param az? number # The z component of the axis of rotation. ----@param tsegments? number # The number of toroidal (circular) segments to render. ----@param psegments? number # The number of poloidal (tubular) segments to render. -function Pass:torus(x, y, z, radius, thickness, angle, ax, ay, az, tsegments, psegments) end - ---- ----Transforms the coordinate system. ---- ----@overload fun(self: lovr.Pass, translation: lovr.Vec3, scale: lovr.Vec3, rotation: lovr.Quat) ----@overload fun(self: lovr.Pass, transform: lovr.Mat4) ----@param x number # The x component of the translation. ----@param y number # The y component of the translation. ----@param z number # The z component of the translation. ----@param sx number # The x component of the scale. ----@param sy number # The y component of the scale. ----@param sz number # The z component of the scale. ----@param angle number # The amount to rotate the coordinate system by, in radians. ----@param ax number # The x component of the axis of rotation. ----@param ay number # The y component of the axis of rotation. ----@param az number # The z component of the axis of rotation. -function Pass:transform(x, y, z, sx, sy, sz, angle, ax, ay, az) end - ---- ----Translates the coordinate system. ---- ---- ----### NOTE: ----Order matters when scaling, translating, and rotating the coordinate system. ---- ----@overload fun(self: lovr.Pass, translation: lovr.Vec3) ----@param x number # The x component of the translation. ----@param y number # The y component of the translation. ----@param z number # The z component of the translation. -function Pass:translate(x, y, z) end - ---- ----Readbacks track the progress of an asynchronous read of a `Buffer`, `Texture`, or `Tally`. ---- ----Once a Readback is created in a transfer pass, and the transfer pass is submitted, the Readback can be polled for completion or the CPU can wait for it to finish using `Readback:wait`. ---- ----@class lovr.Readback -local Readback = {} - ---- ----Returns the Readback's data as a Blob. ---- ---- ----### NOTE: ----If the Readback is reading back a Texture, returns `nil`. ---- ----@return lovr.Blob blob # The Blob. -function Readback:getBlob() end - ---- ----Returns the data from the Readback, as a table. ---- ---- ----### NOTE: ----This currently returns `nil` for readbacks of `Buffer` and `Texture` objects. ---- ----Only readbacks of `Tally` objects return valid data. ---- ----For `time` and `pixel` tallies, the table will have 1 number per slot that was read. ---- ----For `shader` tallies, there will be 4 numbers for each slot. ---- ----@return table data # A flat table of numbers containing the values that were read back. -function Readback:getData() end - ---- ----Returns the Readback's data as an Image. ---- ---- ----### NOTE: ----If the Readback is not reading back a Texture, returns `nil`. ---- ----@return lovr.Image image # The Image. -function Readback:getImage() end - ---- ----Returns whether the Readback has completed on the GPU and its data is available. ---- ----@return boolean complete # Whether the readback is complete. -function Readback:isComplete() end - ---- ----Blocks the CPU until the Readback is finished on the GPU. ---- ---- ----### NOTE: ----If the transfer pass that created the readback has not been submitted yet, no wait will occur and this function will return `false`. ---- ----@return boolean waited # Whether the CPU had to be blocked for waiting. -function Readback:wait() end - ---- ----Samplers are objects that control how pixels are read from a texture. ---- ----They can control whether the pixels are smoothed, whether the texture wraps at the edge of its UVs, and more. ---- ----Each `Pass` has a default sampler that will be used by default, which can be changed using `Pass:setSampler`. ---- ----Also, samplers can be declared in shaders using the following syntax: ---- ---- layout(set = 2, binding = X) uniform sampler mySampler; ---- ----A Sampler can be sent to the variable using `Pass:send('mySampler', sampler)`. ---- ----The properties of a Sampler are immutable, and can't be changed after it's created. ---- ----@class lovr.Sampler -local Sampler = {} - ---- ----Returns the anisotropy level of the Sampler. ---- ----Anisotropy smooths out a texture's appearance when viewed at grazing angles. ---- ---- ----### NOTE: ----Not all GPUs support anisotropy. ---- ----The maximum anisotropy level is given by the `anisotropy` limit of `lovr.graphics.getLimits`, which may be zero. ---- ----It's very common for the maximum to be 16, however. ---- ----@return number anisotropy # The anisotropy level of the sampler. -function Sampler:getAnisotropy() end - ---- ----Returns the compare mode of the Sampler. ---- ----This is a feature typically only used for shadow mapping. ---- ----Using a sampler with a compare mode requires it to be declared in a shader as a `samplerShadow` instead of a `sampler` variable, and used with a texture that has a depth format. ---- ----The result of sampling a depth texture with a shadow sampler is a number between 0 and 1, indicating the percentage of sampled pixels that passed the comparison. ---- ----@return lovr.CompareMode compare # The compare mode of the sampler. -function Sampler:getCompareMode() end - ---- ----Returns the filter mode of the Sampler. ---- ----@return lovr.FilterMode min # The filter mode used when the texture is minified. ----@return lovr.FilterMode mag # The filter mode used when the texture is magnified. ----@return lovr.FilterMode mip # The filter mode used to select a mipmap level. -function Sampler:getFilter() end - ---- ----Returns the mipmap range of the Sampler. ---- ----This is used to clamp the range of mipmap levels that can be accessed from a texture. ---- ----@return number min # The minimum mipmap level that will be sampled (0 is the largest image). ----@return number max # The maximum mipmap level that will be sampled. -function Sampler:getMipmapRange() end - ---- ----Returns the wrap mode of the sampler, used to wrap or clamp texture coordinates when the extend outside of the 0-1 range. ---- ----@return lovr.WrapMode x # The wrap mode used in the horizontal direction. ----@return lovr.WrapMode y # The wrap mode used in the vertical direction. ----@return lovr.WrapMode z # The wrap mode used in the "z" direction, for 3D textures only. -function Sampler:getWrap() end - ---- ----Shaders are small GPU programs. ---- ----See the `Shaders` guide for a full introduction to Shaders. ---- ----@class lovr.Shader -local Shader = {} - ---- ----Clones a shader. ---- ----This creates an inexpensive copy of it with different flags. ---- ----It can be used to create several variants of a shader with different behavior. ---- ----@param source lovr.Shader # The Shader to clone. ----@param flags table # The flags used by the clone. ----@return lovr.Shader shader # The new Shader. -function Shader:clone(source, flags) end - ---- ----Returns whether the shader is a graphics or compute shader. ---- ----@return lovr.ShaderType type # The type of the Shader. -function Shader:getType() end - ---- ----Returns the workgroup size of a compute shader. ---- ----The workgroup size defines how many times a compute shader is invoked for each workgroup dispatched by `Pass:compute`. ---- ---- ----### NOTE: ----For example, if the workgroup size is `8x8x1` and `16x16x16` workgroups are dispatched, then the compute shader will run `16 * 16 * 16 * (8 * 8 * 1) = 262144` times. ---- ----@return number x # The x size of a workgroup. ----@return number y # The y size of a workgroup. ----@return number z # The z size of a workgroup. -function Shader:getWorkgroupSize() end - ---- ----Returns whether the Shader has a vertex attribute, by name or location. ---- ----@overload fun(self: lovr.Shader, location: number):boolean ----@param name string # The name of an attribute. ----@return boolean exists # Whether the Shader has the attribute. -function Shader:hasAttribute(name) end - ---- ----Returns whether the Shader has a given stage. ---- ----@param stage lovr.ShaderStage # The stage. ----@return boolean exists # Whether the Shader has the stage. -function Shader:hasStage(stage) end - ---- ----Tally objects are able to measure events on the GPU. ---- ----Tallies can measure three types of things: ---- ----- `time` - measures elapsed GPU time. ----- `pixel` - measures how many pixels were rendered, which can be used for occlusion culling. ----- `shader` - measure how many times shaders were run. ---- ----Tally objects can be created with up to 4096 slots. ---- ----Each slot can hold a single measurement value. ---- ----`Pass:tick` is used to begin a measurement, storing the result in one of the slots. ---- ----All commands recorded on the Pass will be measured until `Pass:tock` is called with the same tally and slot. ---- ----The measurement value stored in the slots can be copied to a `Buffer` using `Pass:copy`, or they can be read back to Lua using `Pass:read`. ---- ----@class lovr.Tally -local Tally = {} - ---- ----Returns the number of slots in the Tally. ---- ----@return number count # The number of slots in the Tally. -function Tally:getCount() end - ---- ----Returns the type of the tally, which is the thing it measures between `Pass:tick` and `Pass:tock`. ---- ----@return lovr.TallyType type # The type of measurement. -function Tally:getType() end - ---- ----Tally objects with the `time` type can only be used in render passes with a certain number of views. ---- ----This returns that number. ---- ----@return number views # The number of views the Tally is compatible with. -function Tally:getViewCount() end - ---- ----Textures are multidimensional blocks of memory on the GPU, contrasted with `Buffer` objects which are one-dimensional. ---- ----Textures are used as the destination for rendering operations, and textures loaded from images provide surface data to `Material` objects. ---- ----@class lovr.Texture -local Texture = {} - ---- ----Returns the width, height, and depth of the Texture. ---- ----@return number width # The width of the Texture. ----@return number height # The height of the Texture. ----@return number layers # The number of layers in the Texture. -function Texture:getDimensions() end - ---- ----Returns the format of the texture. ---- ----@return lovr.TextureFormat format # The format of the Texture. -function Texture:getFormat() end - ---- ----Returns the height of the Texture, in pixels. ---- ----@return number height # The height of the Texture, in pixels. -function Texture:getHeight() end - ---- ----Returns the layer count of the Texture. ---- ----2D textures always have 1 layer and cubemaps always have 6 layers. ---- ----3D and array textures have a variable number of layers. ---- ----@return number layers # The layer count of the Texture. -function Texture:getLayerCount() end - ---- ----Returns the number of mipmap levels in the Texture. ---- ----@return number mipmaps # The number of mipmap levels in the Texture. -function Texture:getMipmapCount() end - ---- ----Returns the parent of a Texture view, which is the Texture that it references. ---- ----Returns `nil` if the Texture is not a view. ---- ----@return lovr.Texture parent # The parent of the texture, or `nil` if the texture is not a view. -function Texture:getParent() end - ---- ----Returns the number of samples in the texture. ---- ----Multiple samples are used for multisample antialiasing when rendering to the texture. ---- ----Currently, the sample count is either 1 (not antialiased) or 4 (antialiased). ---- ----@return number samples # The number of samples in the Texture. -function Texture:getSampleCount() end - ---- ----Returns the type of the texture. ---- ----@return lovr.TextureType type # The type of the Texture. -function Texture:getType() end - ---- ----Returns the width of the Texture, in pixels. ---- ----@return number width # The width of the Texture, in pixels. -function Texture:getWidth() end - ---- ----Returns whether a Texture was created with a set of `TextureUsage` flags. ---- ----Usage flags are specified when the Texture is created, and restrict what you can do with a Texture object. ---- ----By default, only the `sample` usage is enabled. ---- ----Applying a smaller set of usage flags helps LÖVR optimize things better. ---- ----@vararg lovr.TextureUsage # One or more usage flags. ----@return boolean supported # Whether the Texture has all the provided usage flags. -function Texture:hasUsage(...) end - ---- ----Returns whether a Texture is a texture view, created with `Texture:newView`. ---- ----@return boolean view # Whether the Texture is a texture view. -function Texture:isView() end - ---- ----Creates a new Texture view. ---- ----A texture view does not store any pixels on its own, but instead uses the pixel data of a "parent" Texture object. ---- ----The width, height, format, sample count, and usage flags all match the parent. ---- ----The view may have a different `TextureType` from the parent, and it may reference a subset of the parent texture's layers and mipmap levels. ---- ----Texture views can be used as render targets in a render pass and they can be bound to Shaders. They can not currently be used for transfer operations. ---- ----They are used for: ---- ----- Reinterpretation of texture contents. ---- ----For example, a cubemap can be treated as ---- an array texture. ----- Rendering to a particular image or mipmap level of a texture. ----- Binding a particular image or mipmap level to a shader. ---- ----@param type lovr.TextureType # The texture type of the view. ----@param layer? number # The index of the first layer in the view. ----@param layerCount? number # The number of layers in the view, or `nil` to use all remaining layers. ----@param mipmap? number # The index of the first mipmap in the view. ----@param mipmapCount? number # The number of mipmaps in the view, or `nil` to use all remaining mipmaps. ----@return lovr.Texture view # The new texture view. -function Texture:newView(type, layer, layerCount, mipmap, mipmapCount) end - ---- ----Controls whether premultiplied alpha is enabled. ---- ---- ----### NOTE: ----The premultiplied mode should be used if pixels being drawn have already been blended, or "pre-multiplied", by the alpha channel. ---- ----This happens when rendering to a texture that contains pixels with transparent alpha values, since the stored color values have already been faded by alpha and don't need to be faded a second time with the alphamultiply blend mode. ---- ----@alias lovr.BlendAlphaMode ---- ----Color channel values are multiplied by the alpha channel during blending. ---- ----| "alphamultiply" ---- ----Color channel values are not multiplied by the alpha. ---- ----Instead, it's assumed that the colors have already been multiplied by the alpha. ---- ----This should be used if the pixels being drawn have already been blended, or "pre-multiplied". ---- ----| "premultiplied" - ---- ----Different ways pixels can blend with the pixels behind them. ---- ----@alias lovr.BlendMode ---- ----Colors will be mixed based on alpha. ---- ----| "alpha" ---- ----Colors will be added to the existing color, alpha will not be changed. ---- ----| "add" ---- ----Colors will be subtracted from the existing color, alpha will not be changed. ---- ----| "subtract" ---- ----All color channels will be multiplied together, producing a darkening effect. ---- ----| "multiply" ---- ----The maximum value of each color channel will be used. ---- ----| "lighten" ---- ----The minimum value of each color channel will be used. ---- ----| "darken" ---- ----The opposite of multiply: the pixel colors are inverted, multiplied, and inverted again, producing a lightening effect. ---- ----| "screen" - ---- ----The different ways to pack Buffer fields into memory. ---- ----The default is `packed`, which is suitable for vertex buffers and index buffers. ---- ----It doesn't add any padding between elements, and so it doesn't waste any space. ---- ----However, this layout won't necessarily work for uniform buffers and storage buffers. ---- ----The `std140` layout corresponds to the std140 layout used for uniform buffers in GLSL. ---- ----It adds the most padding between fields, and requires the stride to be a multiple of 16. ---- ----Example: ---- ---- layout(std140) uniform ObjectScales { float scales[64]; }; ---- ----The `std430` layout corresponds to the std430 layout used for storage buffers in GLSL. ---- ----It adds some padding between certain types, and may round up the stride. ---- ----Example: ---- ---- layout(std430) buffer TileSizes { vec2 sizes[]; } ---- ----@alias lovr.BufferLayout ---- ----The packed layout, without any padding. ---- ----| "packed" ---- ----The std140 layout. ---- ----| "std140" ---- ----The std430 layout. ---- ----| "std430" - ---- ----The method used to compare depth and stencil values when performing the depth and stencil tests. Also used for compare modes in `Sampler`s. ---- ---- ----### NOTE: ----This type can also be specified using mathematical notation, e.g. `=`, `>`, `<=`, etc. `notequal` can be provided as `~=` or `!=`. ---- ----@alias lovr.CompareMode ---- ----The test does not take place, and acts as though it always passes. ---- ----| "none" ---- ----The test passes if the values are equal. ---- ----| "equal" ---- ----The test passes if the values are not equal. ---- ----| "notequal" ---- ----The test passes if the value is less than the existing one. ---- ----| "less" ---- ----The test passes if the value is less than or equal to the existing one. ---- ----| "lequal" ---- ----The test passes if the value is greater than the existing one. ---- ----| "greater" ---- ----The test passes if the value is greater than or equal to the existing one. ---- ----| "gequal" - ---- ----The different ways of doing triangle backface culling. ---- ----@alias lovr.CullMode ---- ----Both sides of triangles will be drawn. ---- ----| "none" ---- ----Skips rendering the back side of triangles. ---- ----| "back" ---- ----Skips rendering the front side of triangles. ---- ----| "front" - ---- ----The set of shaders built in to LÖVR. ---- ----These can be passed to `Pass:setShader` or `lovr.graphics.newShader` instead of writing GLSL code. ---- ----The shaders can be further customized by using the `flags` option to change their behavior. ---- ----If the active shader is set to `nil`, LÖVR picks one of these shaders to use. ---- ----@alias lovr.DefaultShader ---- ----Basic shader without lighting that uses colors and a texture. ---- ----| "unlit" ---- ----Shades triangles based on their normal, resulting in a cool rainbow effect. ---- ----| "normal" ---- ----Renders font glyphs. ---- ----| "font" ---- ----Renders cubemaps. ---- ----| "cubemap" ---- ----Renders spherical textures. ---- ----| "equirect" ---- ----Renders a fullscreen triangle. ---- ----| "fill" - ---- ----Whether a shape should be drawn filled or outlined. ---- ----@alias lovr.DrawStyle ---- ----The shape will be filled in (the default). ---- ----| "fill" ---- ----The shape will be outlined. ---- ----| "line" - ---- ----Different types for `Buffer` fields. ---- ----These are scalar, vector, or matrix types, usually packed into small amounts of space to reduce the amount of memory they occupy. ---- ----The names are encoded as follows: ---- ----- The data type: ---- - `i` for signed integer ---- - `u` for unsigned integer ---- - `sn` for signed normalized (-1 to 1) ---- - `un` for unsigned normalized (0 to 1) ---- - `f` for floating point ----- The bit depth of each component ----- The letter `x` followed by the component count (for vectors) ---- ---- ----### NOTE: ----In addition to these values, the following aliases can be used: ---- ----<table> ---- <thead> ---- <tr> ---- <td>Alias</td> ---- <td>Maps to</td> ---- </tr> ---- </thead> ---- <tbody> ---- <tr> ---- <td><code>vec2</code></td> ---- <td><code>f32x2</code></td> ---- </tr> ---- <tr> ---- <td><code>vec3</code></td> ---- <td><code>f32x3</code></td> ---- </tr> ---- <tr> ---- <td><code>vec4</code></td> ---- <td><code>f32x4</code></td> ---- </tr> ---- <tr> ---- <td><code>int</code></td> ---- <td><code>i32</code></td> ---- </tr> ---- <tr> ---- <td><code>uint</code></td> ---- <td><code>u32</code></td> ---- </tr> ---- <tr> ---- <td><code>float</code></td> ---- <td><code>f32</code></td> ---- </tr> ---- <tr> ---- <td><code>color</code></td> ---- <td><code>un8x4</code></td> ---- </tr> ---- </tbody> </table> ---- ----Additionally, the following convenience rules apply: ---- ----- Field types can end in an `s`, which will be stripped off. ----- Field types can end in `x1`, which will be stripped off. ---- ----So you can write, e.g. `lovr.graphics.newBuffer(4, 'floats')`, which is cute! ---- ----@alias lovr.FieldType ---- ----Four 8-bit signed integers. ---- ----| "i8x4" ---- ----Four 8-bit unsigned integers. ---- ----| "u8x4" ---- ----Four 8-bit signed normalized values. ---- ----| "sn8x4" ---- ----Four 8-bit unsigned normalized values (aka `color`). ---- ----| "un8x4" ---- ----Three 10-bit unsigned normalized values, and 2 padding bits (aka `normal`). ---- ----| "un10x3" ---- ----One 16-bit signed integer. ---- ----| "i16" ---- ----Two 16-bit signed integers. ---- ----| "i16x2" ---- ----Four 16-bit signed integers. ---- ----| "i16x4" ---- ----One 16-bit unsigned integer. ---- ----| "u16" ---- ----Two 16-bit unsigned integers. ---- ----| "u16x2" ---- ----Four 16-bit unsigned integers. ---- ----| "u16x4" ---- ----Two 16-bit signed normalized values. ---- ----| "sn16x2" ---- ----Four 16-bit signed normalized values. ---- ----| "sn16x4" ---- ----Two 16-bit unsigned normalized values. ---- ----| "un16x2" ---- ----Four 16-bit unsigned normalized values. ---- ----| "un16x4" ---- ----One 32-bit signed integer (aka `int`). ---- ----| "i32" ---- ----Two 32-bit signed integers. ---- ----| "i32x2" ---- ----Two 32-bit signed integers. ---- ----| "i32x2" ---- ----Three 32-bit signed integers. ---- ----| "i32x3" ---- ----Four 32-bit signed integers. ---- ----| "i32x4" ---- ----One 32-bit unsigned integer (aka `uint`). ---- ----| "u32" ---- ----Two 32-bit unsigned integers. ---- ----| "u32x2" ---- ----Three 32-bit unsigned integers. ---- ----| "u32x3" ---- ----Four 32-bit unsigned integers. ---- ----| "u32x4" ---- ----Two 16-bit floating point numbers. ---- ----| "f16x2" ---- ----Four 16-bit floating point numbers. ---- ----| "f16x4" ---- ----One 32-bit floating point number (aka `float`). ---- ----| "f32" ---- ----Two 32-bit floating point numbers (aka `vec2`). ---- ----| "f32x2" ---- ----Three 32-bit floating point numbers (aka `vec3`). ---- ----| "f32x3" ---- ----Four 32-bit floating point numbers (aka `vec4`). ---- ----| "f32x4" ---- ----A 2x2 matrix containing four 32-bit floats. ---- ----| "mat2" ---- ----A 3x3 matrix containing nine 32-bit floats. ---- ----| "mat3" ---- ----A 4x4 matrix containing sixteen 32-bit floats. ---- ----| "mat4" ---- ----Like u16, but 1-indexed. ---- ----| "index16" ---- ----Like u32, but 1-indexed. ---- ----| "index32" - ---- ----Controls how `Sampler` objects smooth pixels in textures. ---- ----@alias lovr.FilterMode ---- ----A pixelated appearance where the "nearest neighbor" pixel is used. ---- ----| "nearest" ---- ----A smooth appearance where neighboring pixels are averaged. ---- ----| "linear" - ---- ----Different ways to horizontally align text with `Pass:text`. ---- ----@alias lovr.HorizontalAlign ---- ----Left-aligned text. ---- ----| "left" ---- ----Centered text. ---- ----| "center" ---- ----Right-aligned text. ---- ----| "right" - ---- ----Different ways vertices in a mesh can be connected together and filled in with pixels. ---- ----@alias lovr.MeshMode ---- ----Each vertex is rendered as a single point. ---- ----The size of the point can be controlled using the `pointSize` shader flag, or by writing to the `PointSize` variable in shaders. ---- ----The maximum point size is given by the `pointSize` limit from `lovr.graphics.getLimits`. ---- ----| "points" ---- ----Pairs of vertices are connected with line segments. ---- ----To draw a single line through all of the vertices, an index buffer can be used to repeat vertices. ---- ----It is not currently possible to change the width of the lines, although cylinders or capsules can be used as an alternative. ---- ----| "lines" ---- ----Every 3 vertices form a triangle, which is filled in with pixels (unless `Pass:setWireframe` is used). ---- ----This mode is the most commonly used. ---- ----| "triangles" - ---- ----Different coordinate spaces for nodes in a `Model`. ---- ----@alias lovr.OriginType ---- ----Transforms are relative to the origin (root) of the Model. ---- ----| "root" ---- ----Transforms are relative to the parent of the node. ---- ----| "parent" - ---- ----The three different types of `Pass` objects. ---- ----Each Pass has a single type, which determines the type of work it does and which functions can be called on it. ---- ----@alias lovr.PassType ---- ----A render pass renders graphics to a set of up to four color textures and an optional depth texture. ---- ----The textures all need to have the same dimensions and sample counts. ---- ----The textures can have multiple layers, and all rendering work will be broadcast to each layer. ---- ----Each layer can use a different camera pose, which is used for stereo rendering. ---- ----| "render" ---- ----A compute pass runs compute shaders. ---- ----Compute passes usually only call `Pass:setShader`, `Pass:send`, and `Pass:compute`. ---- ----All of the compute work in a single compute pass is run in parallel, so multiple compute passes should be used if one compute pass needs to happen after a different one. ---- ----| "compute" ---- ----A transfer pass copies data to and from GPU memory in `Buffer` and `Texture` objects. Transfer passes use `Pass:copy`, `Pass:clear`, `Pass:blit`, `Pass:mipmap`, and `Pass:read`. Similar to compute passes, all the work in a transfer pass happens in parallel, so multiple passes should be used if the transfers need to be ordered. ---- ----| "transfer" - ---- ----Different shader stages. ---- ----Graphics shaders have a `vertex` and `fragment` stage, and compute shaders have a single `compute` stage. ---- ----@alias lovr.ShaderStage ---- ----The vertex stage, which computes transformed vertex positions. ---- ----| "vertex" ---- ----The fragment stage, which computes pixel colors. ---- ----| "fragment" ---- ----The compute stage, which performs arbitrary computation. ---- ----| "compute" - ---- ----The two types of shaders that can be created. ---- ----@alias lovr.ShaderType ---- ----A graphics shader with a vertex and pixel stage. ---- ----| "graphics" ---- ----A compute shader with a single compute stage. ---- ----| "compute" - ---- ----Different types of stacks that can be pushed and popped with `Pass:push` and `Pass:pop`. ---- ----@alias lovr.StackType ---- ----The transform stack (`Pass:transform`, `Pass:translate`, etc.). ---- ----| "transform" ---- ----Graphics state, like `Pass:setColor`, `Pass:setFont`, etc. ---- ----Notably this does not include camera poses/projections or shader variables changed with `Pass:send`. ---- ----| "state" - ---- ----Different ways of updating the stencil buffer with `Pass:setStencilWrite`. ---- ----@alias lovr.StencilAction ---- ----Stencil buffer pixels will not be changed by draws. ---- ----| "keep" ---- ----Stencil buffer pixels will be set to zero. ---- ----| "zero" ---- ----Stencil buffer pixels will be replaced with a custom value. ---- ----| "replace" ---- ----Stencil buffer pixels will be incremented each time they're rendered to. ---- ----| "increment" ---- ----Stencil buffer pixels will be decremented each time they're rendered to. ---- ----| "decrement" ---- ----Similar to increment, but will wrap around to 0 when it exceeds 255. ---- ----| "incrementwrap" ---- ----Similar to decrement, but will wrap around to 255 when it goes below 0. ---- ----| "decrementwrap" ---- ----The bits in the stencil buffer pixels will be inverted. ---- ----| "invert" - ---- ----These are the different metrics a `Tally` can measure. ---- ----@alias lovr.TallyType ---- ----Each slot measures elapsed time in nanoseconds. ---- ----| "time" ---- ----Each slot measures 4 numbers: the total number of vertices processed, the number of times the vertex shader was run, the number of triangles that were visible in the view, and the number of times the fragment shader was run. ---- ----| "shader" ---- ----Each slot measures the approximate number of pixels affected by rendering. ---- ----| "pixel" - ---- ----These are the different ways `Texture` objects can be used. ---- ----These are passed in to `lovr.graphics.isFormatSupported` to see which texture operations are supported by the GPU for a given format. ---- ----@alias lovr.TextureFeature ---- ----The Texture can be sampled (e.g. a `texture2D` or `sampler2D` variable in shaders). ---- ----| "sample" ---- ----The Texture can be used with a `Sampler` using a `FilterMode` of `linear`. ---- ----| "filter" ---- ----The Texture can be rendered to by using it as a target in a render `Pass`. ---- ----| "render" ---- ----Blending can be enabled when rendering to this format in a render pass. ---- ----| "blend" ---- ----The Texture can be sent to an image variable in shaders (e.g. `image2D`). ---- ----| "storage" ---- ----Atomic operations can be used on storage textures with this format. ---- ----| "atomic" ---- ----Source textures in `Pass:blit` can use this format. ---- ----| "blitsrc" ---- ----Destination textures in `Pass:blit` can use this format. ---- ----| "blitdst" - ---- ----Different types of textures. ---- ----Textures are multidimensional blocks of GPU memory, and the texture's type determines how many dimensions there are, and adds some semantics about what the 3rd dimension means. ---- ----@alias lovr.TextureType ---- ----A single 2D image, the most common type. ---- ----| "2d" ---- ----A 3D image, where a sequence of 2D images defines a 3D volume. ---- ----Each mipmap level of a 3D texture gets smaller in the x, y, and z axes, unlike cubemap and array textures. ---- ----| "3d" ---- ----Six square 2D images with the same dimensions that define the faces of a cubemap, used for skyboxes or other "directional" images. ---- ----| "cube" ---- ----Array textures are sequences of distinct 2D images that all have the same dimensions. ---- ----| "array" - ---- ----These are the different things `Texture`s can be used for. ---- ----When creating a Texture, a set of these flags can be provided, restricting what operations are allowed on the texture. ---- ----Using a smaller set of flags may improve performance. ---- ----If none are provided, the only usage flag applied is `sample`. ---- ----@alias lovr.TextureUsage ---- ----Whether the texture can be sampled from in Shaders (i.e. used in a material, or bound to a variable with a `texture` type, like `texture2D`). ---- ----| "sample" ---- ----Whether the texture can be rendered to (i.e. by using it as a render target in `lovr.graphics.pass`). ---- ----| "render" ---- ----Whether the texture can be used as a storage texture for compute operations (i.e. bound to a variable with an `image` type, like `image2D`). ---- ----| "storage" ---- ----Whether the texture can be used in a transfer pass. ---- ----| "transfer" - ---- ----Different ways to vertically align text with `Pass:text`. ---- ----@alias lovr.VerticalAlign ---- ----Top-aligned text. ---- ----| "top" ---- ----Centered text. ---- ----| "middle" ---- ----Bottom-aligned text. ---- ----| "bottom" - ---- ----Indicates whether the front face of a triangle uses the clockwise or counterclockwise vertex order. ---- ----@alias lovr.Winding ---- ----Clockwise winding. ---- ----| "clockwise" ---- ----Counterclockwise winding. ---- ----| "counterclockwise" - ---- ----Controls how `Sampler` objects wrap textures. ---- ----@alias lovr.WrapMode ---- ----Pixels will be clamped to the edge, with pixels outside the 0-1 uv range using colors from the nearest edge. ---- ----| "clamp" ---- ----Tiles the texture. ---- ----| "repeat" diff --git a/meta/3rd/lovr/library/lovr/headset.lua b/meta/3rd/lovr/library/lovr/headset.lua deleted file mode 100644 index 82c0e6c4..00000000 --- a/meta/3rd/lovr/library/lovr/headset.lua +++ /dev/null @@ -1,826 +0,0 @@ ----@meta - ---- ----The `lovr.headset` module is where all the magical VR functionality is. ---- ----With it, you can access connected VR hardware and get information about the available space the player has. ---- ----Note that all units are reported in meters. ---- ----Position `(0, 0, 0)` is on the floor in the center of the play area. ---- ----@class lovr.headset -lovr.headset = {} - ---- ----Animates a device model to match its current input state. ---- ----The buttons and joysticks on a controller will move as they're pressed/moved and hand models will move to match skeletal input. ---- ----The model should have been created using `lovr.headset.newModel` with the `animated` flag set to `true`. ---- ---- ----### NOTE: ----Currently this function is only supported for hand models on the Oculus Quest. ---- ----It's possible to use models that weren't created with `lovr.headset.newModel` but they need to be set up carefully to have the same structure as the models provided by the headset SDK. ---- ----@param device? lovr.Device # The device to use for the animation data. ----@param model lovr.Model # The model to animate. ----@return boolean success # Whether the animation was applied successfully to the Model. If the Model was not compatible or animation data for the device was not available, this will be `false`. -function lovr.headset.animate(device, model) end - ---- ----Returns the current angular velocity of a device. ---- ---- ----### NOTE: ----If the device isn't tracked, all zeroes will be returned. ---- ----@param device? lovr.Device # The device to get the velocity of. ----@return number x # The x component of the angular velocity. ----@return number y # The y component of the angular velocity. ----@return number z # The z component of the angular velocity. -function lovr.headset.getAngularVelocity(device) end - ---- ----Get the current state of an analog axis on a device. ---- ----Some axes are multidimensional, for example a 2D touchpad or thumbstick with x/y axes. ---- ----For multidimensional axes, this function will return multiple values, one number for each axis. ---- ----In these cases, it can be useful to use the `select` function built in to Lua to select a particular axis component. ---- ---- ----### NOTE: ----The axis values will be between 0 and 1 for 1D axes, and between -1 and 1 for each component of a multidimensional axis. ---- ----When hand tracking is active, pinch strength will be mapped to the `trigger` axis. ---- ----@param device lovr.Device # The device. ----@param axis lovr.DeviceAxis # The axis. -function lovr.headset.getAxis(device, axis) end - ---- ----Returns the depth of the play area, in meters. ---- ----@return number depth # The depth of the play area, in meters. -function lovr.headset.getBoundsDepth() end - ---- ----Returns the size of the play area, in meters. ---- ----@return number width # The width of the play area, in meters. ----@return number depth # The depth of the play area, in meters. -function lovr.headset.getBoundsDimensions() end - ---- ----Returns a list of points representing the boundaries of the play area, or `nil` if the current headset driver does not expose this information. ---- ----@param t table # A table to fill with the points. If `nil`, a new table will be created. ----@return table points # A flat table of 3D points representing the play area boundaries. -function lovr.headset.getBoundsGeometry(t) end - ---- ----Returns the width of the play area, in meters. ---- ----@return number width # The width of the play area, in meters. -function lovr.headset.getBoundsWidth() end - ---- ----Returns the near and far clipping planes used to render to the headset. ---- ----Objects closer than the near clipping plane or further than the far clipping plane will be clipped out of view. ---- ---- ----### NOTE: ----The default near and far clipping planes are 0.01 meters and 0.0 meters. ---- ----@return number near # The distance to the near clipping plane, in meters. ----@return number far # The distance to the far clipping plane, in meters, or 0 for an infinite far clipping plane with a reversed Z range. -function lovr.headset.getClipDistance() end - ---- ----Returns the headset delta time, which is the difference between the current and previous predicted display times. ---- ----When the headset is active, this will be the `dt` value passed in to `lovr.update`. ---- ----@return number dt # The delta time. -function lovr.headset.getDeltaTime() end - ---- ----Returns the texture dimensions of the headset display (for one eye), in pixels. ---- ----@return number width # The width of the display. ----@return number height # The height of the display. -function lovr.headset.getDisplayDimensions() end - ---- ----Returns a table with all the refresh rates supported by the headset display, in Hz. ---- ----@return table frequencies # A flat table of the refresh rates supported by the headset display, nil if not supported. -function lovr.headset.getDisplayFrequencies() end - ---- ----Returns the refresh rate of the headset display, in Hz. ---- ----@return number frequency # The frequency of the display, or `nil` if I have no idea what it is. -function lovr.headset.getDisplayFrequency() end - ---- ----Returns the height of the headset display (for one eye), in pixels. ---- ----@return number height # The height of the display. -function lovr.headset.getDisplayHeight() end - ---- ----Returns the width of the headset display (for one eye), in pixels. ---- ----@return number width # The width of the display. -function lovr.headset.getDisplayWidth() end - ---- ----Returns the `HeadsetDriver` that is currently in use, optionally for a specific device. ---- ----The order of headset drivers can be changed using `lovr.conf` to prefer or exclude specific VR APIs. ---- ----@overload fun(device: lovr.Device):lovr.HeadsetDriver ----@return lovr.HeadsetDriver driver # The driver of the headset in use, e.g. "OpenVR". -function lovr.headset.getDriver() end - ---- ----Returns a table with all of the currently tracked hand devices. ---- ---- ----### NOTE: ----The hand paths will *always* be either `hand/left` or `hand/right`. ---- ----@return table hands # The currently tracked hand devices. -function lovr.headset.getHands() end - ---- ----Returns the name of the headset as a string. ---- ----The exact string that is returned depends on the hardware and VR SDK that is currently in use. ---- ---- ----### NOTE: ----The desktop driver name will always be `Simulator`. ---- ----@return string name # The name of the headset as a string. -function lovr.headset.getName() end - ---- ----Returns the current orientation of a device, in angle/axis form. ---- ---- ----### NOTE: ----If the device isn't tracked, all zeroes will be returned. ---- ----@param device? lovr.Device # The device to get the orientation of. ----@return number angle # The amount of rotation around the axis of rotation, in radians. ----@return number ax # The x component of the axis of rotation. ----@return number ay # The y component of the axis of rotation. ----@return number az # The z component of the axis of rotation. -function lovr.headset.getOrientation(device) end - ---- ----Returns the type of origin used for the tracking volume. ---- ----The different types of origins are explained on the `HeadsetOrigin` page. ---- ----@return lovr.HeadsetOrigin origin # The type of origin. -function lovr.headset.getOriginType() end - ---- ----Returns a `Pass` that renders to the headset display. ---- ---- ----### NOTE: ----The same Pass will be returned until `lovr.headset.submit` is called. ---- ----The first time this function is called during a frame, the views of the Pass will be initialized with the headset view poses and view angles. ---- ----The pass will be cleared to the background color, which can be changed using `lovr.graphics.setBackgroundColor`. ---- ----The pass will have a depth buffer. ---- ----If `t.headset.stencil` was set to a truthy value in `lovr.conf`, the depth buffer will use the `d32fs8` format, otherwise `d32f` will be used. ---- ----If `t.headset.antialias` was set to a truthy value in `lovr.conf`, the pass will be multisampled. ---- ----@return lovr.Pass pass # The pass. -function lovr.headset.getPass() end - ---- ----Returns the current position and orientation of a device. ---- ---- ----### NOTE: ----Units are in meters. ---- ----If the device isn't tracked, all zeroes will be returned. ---- ----@param device? lovr.Device # The device to get the pose of. ----@return number x # The x position. ----@return number y # The y position. ----@return number z # The z position. ----@return number angle # The amount of rotation around the axis of rotation, in radians. ----@return number ax # The x component of the axis of rotation. ----@return number ay # The y component of the axis of rotation. ----@return number az # The z component of the axis of rotation. -function lovr.headset.getPose(device) end - ---- ----Returns the current position of a device, in meters, relative to the play area. ---- ---- ----### NOTE: ----If the device isn't tracked, all zeroes will be returned. ---- ----@param device? lovr.Device # The device to get the position of. ----@return number x # The x position of the device. ----@return number y # The y position of the device. ----@return number z # The z position of the device. -function lovr.headset.getPosition(device) end - ---- ----Returns a list of joint transforms tracked by a device. ---- ----Currently, only hand devices are able to track joints. ---- ---- ----### NOTE: ----If the Device does not support tracking joints or the transforms are unavailable, `nil` is returned. ---- ----The joint orientation is similar to the graphics coordinate system: -Z is the forwards direction, pointing towards the fingertips. ---- ----The +Y direction is "up", pointing out of the back of the hand. ---- ----The +X direction is to the right, perpendicular to X and Z. ---- ----Hand joints are returned in the following order: ---- ----<table> ---- <thead> ---- <tr> ---- <td colspan="2">Joint</td> ---- <td>Index</td> ---- </tr> ---- </thead> ---- <tbody> ---- <tr> ---- <td colspan="2">Palm</td> ---- <td>1</td> ---- </tr> ---- <tr> ---- <td colspan="2">Wrist</td> ---- <td>2</td> ---- </tr> ---- <tr> ---- <td rowspan="4">Thumb</td> ---- <td>Metacarpal</td> ---- <td>3</td> ---- </tr> ---- <tr> ---- <td>Proximal</td> ---- <td>4</td> ---- </tr> ---- <tr> ---- <td>Distal</td> ---- <td>5</td> ---- </tr> ---- <tr> ---- <td>Tip</td> ---- <td>6</td> ---- </tr> ---- <tr> ---- <td rowspan="5">Index</td> ---- <td>Metacarpal</td> ---- <td>7</td> ---- </tr> ---- <tr> ---- <td>Proximal</td> ---- <td>8</td> ---- </tr> ---- <tr> ---- <td>Intermediate</td> ---- <td>9</td> ---- </tr> ---- <tr> ---- <td>Distal</td> ---- <td>10</td> ---- </tr> ---- <tr> ---- <td>Tip</td> ---- <td>11</td> ---- </tr> ---- <tr> ---- <td rowspan="5">Middle</td> ---- <td>Metacarpal</td> ---- <td>12</td> ---- </tr> ---- <tr> ---- <td>Proximal</td> ---- <td>13</td> ---- </tr> ---- <tr> ---- <td>Intermediate</td> ---- <td>14</td> ---- </tr> ---- <tr> ---- <td>Distal</td> ---- <td>15</td> ---- </tr> ---- <tr> ---- <td>Tip</td> ---- <td>16</td> ---- </tr> ---- <tr> ---- <td rowspan="5">Ring</td> ---- <td>Metacarpal</td> ---- <td>17</td> ---- </tr> ---- <tr> ---- <td>Proximal</td> ---- <td>18</td> ---- </tr> ---- <tr> ---- <td>Intermediate</td> ---- <td>19</td> ---- </tr> ---- <tr> ---- <td>Distal</td> ---- <td>20</td> ---- </tr> ---- <tr> ---- <td>Tip</td> ---- <td>21</td> ---- </tr> ---- <tr> ---- <td rowspan="5">Pinky</td> ---- <td>Metacarpal</td> ---- <td>22</td> ---- </tr> ---- <tr> ---- <td>Proximal</td> ---- <td>23</td> ---- </tr> ---- <tr> ---- <td>Intermediate</td> ---- <td>24</td> ---- </tr> ---- <tr> ---- <td>Distal</td> ---- <td>25</td> ---- </tr> ---- <tr> ---- <td>Tip</td> ---- <td>26</td> ---- </tr> ---- </tbody> </table> ---- ----@overload fun(device: lovr.Device, t: table):table ----@param device lovr.Device # The Device to query. ----@return table transforms # A list of joint transforms for the device. Each transform is a table with 3 numbers for the position of the joint, 1 number for the joint radius (in meters), and 4 numbers for the angle/axis orientation of the joint. -function lovr.headset.getSkeleton(device) end - ---- ----Returns a Texture that will be submitted to the headset display. ---- ----This will be the render target used in the headset's render pass. ---- ----The texture is not guaranteed to be the same every frame, and must be called every frame to get the current texture. ---- ---- ----### NOTE: ----This function may return `nil` if the headset is not being rendered to this frame. ---- ----@return lovr.Texture texture # The headset texture. -function lovr.headset.getTexture() end - ---- ----Returns the estimated time in the future at which the light from the pixels of the current frame will hit the eyes of the user. ---- ----This can be used as a replacement for `lovr.timer.getTime` for timestamps that are used for rendering to get a smoother result that is synchronized with the display of the headset. ---- ---- ----### NOTE: ----This has a different epoch than `lovr.timer.getTime`, so it is not guaranteed to be close to that value. ---- ----@return number time # The predicted display time, in seconds. -function lovr.headset.getTime() end - ---- ----Returns the current linear velocity of a device, in meters per second. ---- ---- ----### NOTE: ----If the device isn't tracked, all zeroes will be returned. ---- ----@param device? lovr.Device # The device to get the velocity of. ----@return number vx # The x component of the linear velocity. ----@return number vy # The y component of the linear velocity. ----@return number vz # The z component of the linear velocity. -function lovr.headset.getVelocity(device) end - ---- ----Returns the view angles of one of the headset views. ---- ----These can be used with `Mat4:fov` to create a projection matrix. ---- ----If tracking data is unavailable for the view or the index is invalid, `nil` is returned. ---- ----@param view number # The view index. ----@return number left # The left view angle, in radians. ----@return number right # The right view angle, in radians. ----@return number top # The top view angle, in radians. ----@return number bottom # The bottom view angle, in radians. -function lovr.headset.getViewAngles(view) end - ---- ----Returns the number of views used for rendering. ---- ----Each view consists of a pose in space and a set of angle values that determine the field of view. ---- ----This is usually 2 for stereo rendering configurations, but it can also be different. ---- ----For example, one way of doing foveated rendering uses 2 views for each eye -- one low quality view with a wider field of view, and a high quality view with a narrower field of view. ---- ----@return number count # The number of views. -function lovr.headset.getViewCount() end - ---- ----Returns the pose of one of the headset views. ---- ----This info can be used to create view matrices or do other eye-dependent calculations. ---- ----If tracking data is unavailable for the view or the index is invalid, `nil` is returned. ---- ----@param view number # The view index. ----@return number x # The x coordinate of the view position, in meters. ----@return number y # The y coordinate of the view position, in meters. ----@return number z # The z coordinate of the view position, in meters. ----@return number angle # The amount of rotation around the rotation axis, in radians. ----@return number ax # The x component of the axis of rotation. ----@return number ay # The y component of the axis of rotation. ----@return number az # The z component of the axis of rotation. -function lovr.headset.getViewPose(view) end - ---- ----Returns whether a button on a device is pressed. ---- ---- ----### NOTE: ----When hand tracking is active, pinching will be mapped to the `trigger` button. ---- ----@param device lovr.Device # The device. ----@param button lovr.DeviceButton # The button. ----@return boolean down # Whether the button on the device is currently pressed, or `nil` if the device does not have the specified button. -function lovr.headset.isDown(device, button) end - ---- ----Returns whether LÖVR has VR input focus. ---- ----Focus is lost when the VR system menu is shown. ---- ----The `lovr.focus` callback can be used to detect when this changes. ---- ----@return boolean focused # Whether the application is focused. -function lovr.headset.isFocused() end - ---- ----Returns whether passthrough is active. ---- ----When passthrough is active, the real world will be rendered behind any content rendered by LÖVR, using the alpha channel to blend between the two. ---- ---- ----### NOTE: ----This feature is currently only supported on Oculus Quest devices. ---- ----@return boolean active # Whether passthrough is active. -function lovr.headset.isPassthroughEnabled() end - ---- ----Returns whether a button on a device is currently touched. ---- ----@param device lovr.Device # The device. ----@param button lovr.DeviceButton # The button. ----@return boolean touched # Whether the button on the device is currently touched, or `nil` if the device does not have the button or it isn't touch-sensitive. -function lovr.headset.isTouched(device, button) end - ---- ----Returns whether any active headset driver is currently returning pose information for a device. ---- ---- ----### NOTE: ----If a device is tracked, it is guaranteed to return a valid pose until the next call to `lovr.headset.update`. ---- ----@param device? lovr.Device # The device to get the pose of. ----@return boolean tracked # Whether the device is currently tracked. -function lovr.headset.isTracked(device) end - ---- ----Returns a new Model for the specified device. ---- ---- ----### NOTE: ----Currently this is only implemented for hand models on the Oculus Quest. ---- ----@param device? lovr.Device # The device to load a model for. ----@param options? {animated: boolean} # Options for loading the model. ----@return lovr.Model model # The new Model, or `nil` if a model could not be loaded. -function lovr.headset.newModel(device, options) end - ---- ----Sets the near and far clipping planes used to render to the headset. ---- ----Objects closer than the near clipping plane or further than the far clipping plane will be clipped out of view. ---- ---- ----### NOTE: ----The default clip distances are 0.01 and 0.0. ---- ----@param near number # The distance to the near clipping plane, in meters. ----@param far number # The distance to the far clipping plane, in meters, or 0 for an infinite far clipping plane with a reversed Z range. -function lovr.headset.setClipDistance(near, far) end - ---- ----Sets the display refresh rate, in Hz. ---- ---- ----### NOTE: ----Changing the display refresh-rate also changes the frequency of lovr.update() and lovr.draw() as they depend on the display frequency. ---- ----@param frequency number # The new refresh rate, in Hz. ----@return boolean success # Whether the display refresh rate was successfully set. -function lovr.headset.setDisplayFrequency(frequency) end - ---- ----Sets whether passthrough is active. ---- ----When passthrough is active, the real world will be rendered behind any content rendered by LÖVR, using the alpha channel to blend between the two. ---- ---- ----### NOTE: ----This feature is currently only supported on Oculus Quest devices. ---- ----@param enable boolean # Whether passthrough should be enabled. ----@return boolean success # Whether the passthrough state was set successfully. -function lovr.headset.setPassthroughEnabled(enable) end - ---- ----Starts the headset session. ---- ----This must be called after the graphics module is initialized, and can only be called once. ---- ----Normally it is called automatically by `boot.lua`. ---- -function lovr.headset.start() end - ---- ----Submits the current headset texture to the VR display. ---- ----This should be called after calling `lovr.graphics.submit` with the headset render pass. ---- ----Normally this is taken care of by `lovr.run`. ---- -function lovr.headset.submit() end - ---- ----Causes the device to vibrate with a custom strength, duration, and frequency, if possible. ---- ----@param device? lovr.Device # The device to vibrate. ----@param strength? number # The strength of the vibration (amplitude), between 0 and 1. ----@param duration? number # The duration of the vibration, in seconds. ----@param frequency? number # The frequency of the vibration, in hertz. 0 will use a default frequency. ----@return boolean vibrated # Whether the vibration was successfully triggered by an active headset driver. -function lovr.headset.vibrate(device, strength, duration, frequency) end - ---- ----Returns whether a button on a device was pressed this frame. ---- ---- ----### NOTE: ----Some headset backends are not able to return pressed/released information. ---- ----These drivers will always return false for `lovr.headset.wasPressed` and `lovr.headset.wasReleased`. ---- ----Typically the internal `lovr.headset.update` function will update pressed/released status. ---- ----@param device lovr.Device # The device. ----@param button lovr.DeviceButton # The button to check. ----@return boolean pressed # Whether the button on the device was pressed this frame. -function lovr.headset.wasPressed(device, button) end - ---- ----Returns whether a button on a device was released this frame. ---- ---- ----### NOTE: ----Some headset backends are not able to return pressed/released information. ---- ----These drivers will always return false for `lovr.headset.wasPressed` and `lovr.headset.wasReleased`. ---- ----Typically the internal `lovr.headset.update` function will update pressed/released status. ---- ----@param device lovr.Device # The device. ----@param button lovr.DeviceButton # The button to check. ----@return boolean released # Whether the button on the device was released this frame. -function lovr.headset.wasReleased(device, button) end - ---- ----Different types of input devices supported by the `lovr.headset` module. ---- ---- ----### NOTE: ----The difference between `hand/left` and `hand/left/point` is the first represents an object held in the hand, whereas the second represents the laser pointer used to aim. ---- ----Drawing a controller model would use `hand/left`, whereas drawing a pointer or aiming would use `hand/left/point`. ---- ----@alias lovr.Device ---- ----The headset. ---- ----| "head" ---- ----A shorthand for hand/left. ---- ----| "left" ---- ----A shorthand for hand/right. ---- ----| "right" ---- ----The left controller. ---- ----| "hand/left" ---- ----The right controller. ---- ----| "hand/right" ---- ----The left controller pointer (pose only). ---- ----| "hand/left/point" ---- ----The right controller pointer (pose only). ---- ----| "hand/right/point" ---- ----A device tracking the left elbow. ---- ----| "elbow/left" ---- ----A device tracking the right elbow. ---- ----| "elbow/right" ---- ----A device tracking the left shoulder. ---- ----| "shoulder/left" ---- ----A device tracking the right shoulder. ---- ----| "shoulder/right" ---- ----A device tracking the chest. ---- ----| "chest" ---- ----A device tracking the waist. ---- ----| "waist" ---- ----A device tracking the left knee. ---- ----| "knee/left" ---- ----A device tracking the right knee. ---- ----| "knee/right" ---- ----A device tracking the left foot or ankle. ---- ----| "foot/left" ---- ----A device tracking the right foot or ankle. ---- ----| "foot/right" ---- ----A camera device, often used for recording "mixed reality" footage. ---- ----| "camera" ---- ----A tracked keyboard. ---- ----| "keyboard" ---- ----The left eye. ---- ----| "eye/left" ---- ----The right eye. ---- ----| "eye/right" - ---- ----Axes on an input device. ---- ----@alias lovr.DeviceAxis ---- ----A trigger (1D). ---- ----| "trigger" ---- ----A thumbstick (2D). ---- ----| "thumbstick" ---- ----A touchpad (2D). ---- ----| "touchpad" ---- ----A grip button or grab gesture (1D). ---- ----| "grip" - ---- ----Buttons on an input device. ---- ----@alias lovr.DeviceButton ---- ----The trigger button. ---- ----| "trigger" ---- ----The thumbstick. ---- ----| "thumbstick" ---- ----The touchpad. ---- ----| "touchpad" ---- ----The grip button. ---- ----| "grip" ---- ----The menu button. ---- ----| "menu" ---- ----The A button. ---- ----| "a" ---- ----The B button. ---- ----| "b" ---- ----The X button. ---- ----| "x" ---- ----The Y button. ---- ----| "y" ---- ----The proximity sensor on a headset. ---- ----| "proximity" - ---- ----These are all of the supported VR APIs that LÖVR can use to power the lovr.headset module. ---- ----You can change the order of headset drivers using `lovr.conf` to prefer or exclude specific VR APIs. ---- ----At startup, LÖVR searches through the list of drivers in order. ---- ----@alias lovr.HeadsetDriver ---- ----A VR simulator using keyboard/mouse. ---- ----| "desktop" ---- ----OpenXR. ---- ----| "openxr" - ---- ----Represents the different types of origins for coordinate spaces. ---- ----An origin of "floor" means that the origin is on the floor in the middle of a room-scale play area. ---- ----An origin of "head" means that no positional tracking is available, and consequently the origin is always at the position of the headset. ---- ----@alias lovr.HeadsetOrigin ---- ----The origin is at the head. ---- ----| "head" ---- ----The origin is on the floor. ---- ----| "floor" diff --git a/meta/3rd/lovr/library/lovr/math.lua b/meta/3rd/lovr/library/lovr/math.lua deleted file mode 100644 index 163e5954..00000000 --- a/meta/3rd/lovr/library/lovr/math.lua +++ /dev/null @@ -1,1268 +0,0 @@ ----@meta - ---- ----The `lovr.math` module provides math helpers commonly used for 3D applications. ---- ----@class lovr.math -lovr.math = {} - ---- ----Drains the temporary vector pool, invalidating existing temporary vectors. ---- ----This is called automatically at the end of each frame. ---- -function lovr.math.drain() end - ---- ----Converts a color from gamma space to linear space. ---- ----@overload fun(color: table):number, number, number ----@overload fun(x: number):number ----@param gr number # The red component of the gamma-space color. ----@param gg number # The green component of the gamma-space color. ----@param gb number # The blue component of the gamma-space color. ----@return number lr # The red component of the resulting linear-space color. ----@return number lg # The green component of the resulting linear-space color. ----@return number lb # The blue component of the resulting linear-space color. -function lovr.math.gammaToLinear(gr, gg, gb) end - ---- ----Get the seed used to initialize the random generator. ---- ----@return number seed # The new seed. -function lovr.math.getRandomSeed() end - ---- ----Converts a color from linear space to gamma space. ---- ----@overload fun(color: table):number, number, number ----@overload fun(x: number):number ----@param lr number # The red component of the linear-space color. ----@param lg number # The green component of the linear-space color. ----@param lb number # The blue component of the linear-space color. ----@return number gr # The red component of the resulting gamma-space color. ----@return number gg # The green component of the resulting gamma-space color. ----@return number gb # The blue component of the resulting gamma-space color. -function lovr.math.linearToGamma(lr, lg, lb) end - ---- ----Creates a temporary 4D matrix. ---- ----This function takes the same arguments as `Mat4:set`. ---- ----@overload fun(n: lovr.Mat4):lovr.Mat4 ----@overload fun(position?: lovr.Vec3, scale?: lovr.Vec3, rotation?: lovr.Quat):lovr.Mat4 ----@overload fun(position?: lovr.Vec3, rotation?: lovr.Quat):lovr.Mat4 ----@overload fun(...):lovr.Mat4 ----@overload fun(d: number):lovr.Mat4 ----@return lovr.Mat4 m # The new matrix. -function lovr.math.mat4() end - ---- ----Creates a new `Curve` from a list of control points. ---- ----@overload fun(v: lovr.Vec3, ...):lovr.Curve ----@overload fun(points: table):lovr.Curve ----@overload fun(n: number):lovr.Curve ----@param x number # The x coordinate of the first control point. ----@param y number # The y coordinate of the first control point. ----@param z number # The z coordinate of the first control point. ----@vararg any # Additional control points. ----@return lovr.Curve curve # The new Curve. -function lovr.math.newCurve(x, y, z, ...) end - ---- ----Creates a new 4D matrix. ---- ----This function takes the same arguments as `Mat4:set`. ---- ----@overload fun(n: lovr.Mat4):lovr.Mat4 ----@overload fun(position?: lovr.Vec3, scale?: lovr.Vec3, rotation?: lovr.Quat):lovr.Mat4 ----@overload fun(position?: lovr.Vec3, rotation?: lovr.Quat):lovr.Mat4 ----@overload fun(...):lovr.Mat4 ----@overload fun(d: number):lovr.Mat4 ----@return lovr.Mat4 m # The new matrix. -function lovr.math.newMat4() end - ---- ----Creates a new quaternion. ---- ----This function takes the same arguments as `Quat:set`. ---- ----@overload fun(r: lovr.Quat):lovr.Quat ----@overload fun(v: lovr.Vec3):lovr.Quat ----@overload fun(v: lovr.Vec3, u: lovr.Vec3):lovr.Quat ----@overload fun(m: lovr.Mat4):lovr.Quat ----@overload fun():lovr.Quat ----@param angle? number # An angle to use for the rotation, in radians. ----@param ax? number # The x component of the axis of rotation. ----@param ay? number # The y component of the axis of rotation. ----@param az? number # The z component of the axis of rotation. ----@param raw? boolean # Whether the components should be interpreted as raw `(x, y, z, w)` components. ----@return lovr.Quat q # The new quaternion. -function lovr.math.newQuat(angle, ax, ay, az, raw) end - ---- ----Creates a new `RandomGenerator`, which can be used to generate random numbers. If you just want some random numbers, you can use `lovr.math.random`. Individual RandomGenerator objects are useful if you need more control over the random sequence used or need a random generator isolated from other instances. ---- ----@overload fun(seed: number):lovr.RandomGenerator ----@overload fun(low: number, high: number):lovr.RandomGenerator ----@return lovr.RandomGenerator randomGenerator # The new RandomGenerator. -function lovr.math.newRandomGenerator() end - ---- ----Creates a new 2D vector. ---- ----This function takes the same arguments as `Vec2:set`. ---- ----@overload fun(u: lovr.Vec2):lovr.Vec2 ----@param x? number # The x value of the vector. ----@param y? number # The y value of the vector. ----@return lovr.Vec2 v # The new vector. -function lovr.math.newVec2(x, y) end - ---- ----Creates a new 3D vector. ---- ----This function takes the same arguments as `Vec3:set`. ---- ----@overload fun(u: lovr.Vec3):lovr.Vec3 ----@overload fun(m: lovr.Mat4):lovr.Vec3 ----@param x? number # The x value of the vector. ----@param y? number # The y value of the vector. ----@param z? number # The z value of the vector. ----@return lovr.Vec3 v # The new vector. -function lovr.math.newVec3(x, y, z) end - ---- ----Creates a new 4D vector. ---- ----This function takes the same arguments as `Vec4:set`. ---- ----@overload fun(u: lovr.Vec4):lovr.Vec4 ----@param x? number # The x value of the vector. ----@param y? number # The y value of the vector. ----@param z? number # The z value of the vector. ----@param w? number # The w value of the vector. ----@return lovr.Vec4 v # The new vector. -function lovr.math.newVec4(x, y, z, w) end - ---- ----Returns a 1D, 2D, 3D, or 4D simplex noise value. ---- ----The number will be between 0 and 1. ---- ----@overload fun(x: number, y: number):number ----@overload fun(x: number, y: number, z: number):number ----@overload fun(x: number, y: number, z: number, w: number):number ----@param x number # The x coordinate of the input. ----@return number noise # The noise value, between 0 and 1. -function lovr.math.noise(x) end - ---- ----Creates a temporary quaternion. ---- ----This function takes the same arguments as `Quat:set`. ---- ----@overload fun(r: lovr.Quat):lovr.Quat ----@overload fun(v: lovr.Vec3):lovr.Quat ----@overload fun(v: lovr.Vec3, u: lovr.Vec3):lovr.Quat ----@overload fun(m: lovr.Mat4):lovr.Quat ----@overload fun():lovr.Quat ----@param angle? number # An angle to use for the rotation, in radians. ----@param ax? number # The x component of the axis of rotation. ----@param ay? number # The y component of the axis of rotation. ----@param az? number # The z component of the axis of rotation. ----@param raw? boolean # Whether the components should be interpreted as raw `(x, y, z, w)` components. ----@return lovr.Quat q # The new quaternion. -function lovr.math.quat(angle, ax, ay, az, raw) end - ---- ----Returns a uniformly distributed pseudo-random number. ---- ----This function has improved randomness over Lua's `math.random` and also guarantees that the sequence of random numbers will be the same on all platforms (given the same seed). ---- ---- ----### NOTE: ----You can set the random seed using `lovr.math.setRandomSeed`. ---- ----@overload fun(high: number):number ----@overload fun(low: number, high: number):number ----@return number x # A pseudo-random number. -function lovr.math.random() end - ---- ----Returns a pseudo-random number from a normal distribution (a bell curve). ---- ----You can control the center of the bell curve (the mean value) and the overall width (sigma, or standard deviation). ---- ----@param sigma? number # The standard deviation of the distribution. This can be thought of how "wide" the range of numbers is or how much variability there is. ----@param mu? number # The average value returned. ----@return number x # A normally distributed pseudo-random number. -function lovr.math.randomNormal(sigma, mu) end - ---- ----Seed the random generator with a new seed. ---- ----Each seed will cause `lovr.math.random` and `lovr.math.randomNormal` to produce a unique sequence of random numbers. ---- ----This is done once automatically at startup by `lovr.run`. ---- ----@param seed number # The new seed. -function lovr.math.setRandomSeed(seed) end - ---- ----Creates a temporary 2D vector. ---- ----This function takes the same arguments as `Vec2:set`. ---- ----@overload fun(u: lovr.Vec2):lovr.Vec2 ----@param x? number # The x value of the vector. ----@param y? number # The y value of the vector. ----@return lovr.Vec2 v # The new vector. -function lovr.math.vec2(x, y) end - ---- ----Creates a temporary 3D vector. ---- ----This function takes the same arguments as `Vec3:set`. ---- ----@overload fun(u: lovr.Vec3):lovr.Vec3 ----@overload fun(m: lovr.Mat4):lovr.Vec3 ----@param x? number # The x value of the vector. ----@param y? number # The y value of the vector. ----@param z? number # The z value of the vector. ----@return lovr.Vec3 v # The new vector. -function lovr.math.vec3(x, y, z) end - ---- ----Creates a temporary 4D vector. ---- ----This function takes the same arguments as `Vec4:set`. ---- ----@overload fun(u: lovr.Vec4):lovr.Vec4 ----@param x? number # The x value of the vector. ----@param y? number # The y value of the vector. ----@param z? number # The z value of the vector. ----@param w? number # The w value of the vector. ----@return lovr.Vec4 v # The new vector. -function lovr.math.vec4(x, y, z, w) end - ---- ----A Curve is an object that represents a Bézier curve in three dimensions. ---- ----Curves are defined by an arbitrary number of control points (note that the curve only passes through the first and last control point). ---- ----Once a Curve is created with `lovr.math.newCurve`, you can use `Curve:evaluate` to get a point on the curve or `Curve:render` to get a list of all of the points on the curve. ---- ----These points can be passed directly to `Pass:points` or `Pass:line` to render the curve. ---- ----Note that for longer or more complicated curves (like in a drawing application) it can be easier to store the path as several Curve objects. ---- ----@class lovr.Curve -local Curve = {} - ---- ----Inserts a new control point into the Curve at the specified index. ---- ---- ----### NOTE: ----An error will be thrown if the index is less than one or more than the number of control points. ---- ----@param x number # The x coordinate of the control point. ----@param y number # The y coordinate of the control point. ----@param z number # The z coordinate of the control point. ----@param index? number # The index to insert the control point at. If nil, the control point is added to the end of the list of control points. -function Curve:addPoint(x, y, z, index) end - ---- ----Returns a point on the Curve given a parameter `t` from 0 to 1. ---- ----0 will return the first control point, 1 will return the last point, .5 will return a point in the "middle" of the Curve, etc. ---- ---- ----### NOTE: ----An error will be thrown if `t` is not between 0 and 1, or if the Curve has less than two points. ---- ----@param t number # The parameter to evaluate the Curve at. ----@return number x # The x position of the point. ----@return number y # The y position of the point. ----@return number z # The z position of the point. -function Curve:evaluate(t) end - ---- ----Returns a control point of the Curve. ---- ---- ----### NOTE: ----An error will be thrown if the index is less than one or more than the number of control points. ---- ----@param index number # The index to retrieve. ----@return number x # The x coordinate of the control point. ----@return number y # The y coordinate of the control point. ----@return number z # The z coordinate of the control point. -function Curve:getPoint(index) end - ---- ----Returns the number of control points in the Curve. ---- ----@return number count # The number of control points. -function Curve:getPointCount() end - ---- ----Returns a direction vector for the Curve given a parameter `t` from 0 to 1. ---- ----0 will return the direction at the first control point, 1 will return the direction at the last point, .5 will return the direction at the "middle" of the Curve, etc. ---- ---- ----### NOTE: ----The direction vector returned by this function will have a length of one. ---- ----@param t number # Where on the Curve to compute the direction. ----@return number x # The x position of the point. ----@return number y # The y position of the point. ----@return number z # The z position of the point. -function Curve:getTangent(t) end - ---- ----Removes a control point from the Curve. ---- ---- ----### NOTE: ----An error will be thrown if the index is less than one or more than the number of control points. ---- ----@param index number # The index of the control point to remove. -function Curve:removePoint(index) end - ---- ----Returns a list of points on the Curve. ---- ----The number of points can be specified to get a more or less detailed representation, and it is also possible to render a subsection of the Curve. ---- ---- ----### NOTE: ----This function will always return 2 points if the Curve is a line with only 2 control points. ---- ----@param n? number # The number of points to use. ----@param t1? number # How far along the curve to start rendering. ----@param t2? number # How far along the curve to stop rendering. ----@return table t # A (flat) table of 3D points along the curve. -function Curve:render(n, t1, t2) end - ---- ----Changes the position of a control point on the Curve. ---- ---- ----### NOTE: ----An error will be thrown if the index is less than one or more than the number of control points. ---- ----@param index number # The index to modify. ----@param x number # The new x coordinate. ----@param y number # The new y coordinate. ----@param z number # The new z coordinate. -function Curve:setPoint(index, x, y, z) end - ---- ----Returns a new Curve created by slicing the Curve at the specified start and end points. ---- ---- ----### NOTE: ----The new Curve will have the same number of control points as the existing curve. ---- ----An error will be thrown if t1 or t2 are not between 0 and 1, or if the Curve has less than two points. ---- ----@param t1 number # The starting point to slice at. ----@param t2 number # The ending point to slice at. ----@return lovr.Curve curve # A new Curve. -function Curve:slice(t1, t2) end - ---- ----A `mat4` is a math type that holds 16 values in a 4x4 grid. ---- ----@class lovr.Mat4 -local Mat4 = {} - ---- ----Returns whether a matrix is approximately equal to another matrix. ---- ----@param n lovr.Mat4 # The other matrix. ----@return boolean equal # Whether the 2 matrices approximately equal each other. -function Mat4:equals(n) end - ---- ----Sets a projection matrix using raw projection angles and clipping planes. ---- ----This can be used for asymmetric or oblique projections. ---- ----@param left number # The left half-angle of the projection, in radians. ----@param right number # The right half-angle of the projection, in radians. ----@param up number # The top half-angle of the projection, in radians. ----@param down number # The bottom half-angle of the projection, in radians. ----@param near number # The near plane of the projection. ----@param far? number # The far plane. Zero is a special value that will set an infinite far plane with a reversed Z range, which improves depth buffer precision and is the default. ----@return lovr.Mat4 self # The modified matrix. -function Mat4:fov(left, right, up, down, near, far) end - ---- ----Resets the matrix to the identity, effectively setting its translation to zero, its scale to 1, and clearing any rotation. ---- ----@return lovr.Mat4 self # The modified matrix. -function Mat4:identity() end - ---- ----Inverts the matrix, causing it to represent the opposite of its old transform. ---- ----@return lovr.Mat4 self # The inverted matrix. -function Mat4:invert() end - ---- ----Sets a view transform matrix that moves and orients camera to look at a target point. ---- ----This is useful for changing camera position and orientation. The resulting Mat4 matrix can be passed to `lovr.graphics.transform()` directly (without inverting) before rendering the scene. ---- ----The lookAt() function produces same result as target() after matrix inversion. ---- ----@param from lovr.Vec3 # The position of the viewer. ----@param to lovr.Vec3 # The position of the target. ----@param up? lovr.Vec3 # The up vector of the viewer. ----@return lovr.Mat4 self # The modified matrix. -function Mat4:lookAt(from, to, up) end - ---- ----Multiplies this matrix by another value. ---- ----Multiplying by a matrix combines their two transforms together. ---- ----Multiplying by a vector applies the transformation from the matrix to the vector and returns the vector. ---- ---- ----### NOTE: ----When multiplying by a vec4, the vector is treated as either a point if its w component is 1, or a direction vector if the w is 0 (the matrix translation won't be applied). ---- ----@overload fun(self: lovr.Mat4, v3: lovr.Vec3):lovr.Vec3 ----@overload fun(self: lovr.Mat4, v4: lovr.Vec4):lovr.Vec4 ----@param n lovr.Mat4 # The matrix. ----@return lovr.Mat4 self # The modified matrix. -function Mat4:mul(n) end - ---- ----Sets this matrix to represent an orthographic projection, useful for 2D/isometric rendering. ---- ----This can be used with `Pass:setProjection`, or it can be sent to a `Shader` for use in GLSL. ---- ----@overload fun(self: lovr.Mat4, width: number, height: number, near: number, far: number):lovr.Mat4 ----@param left number # The left edge of the projection. ----@param right number # The right edge of the projection. ----@param bottom number # The bottom edge of the projection. ----@param top number # The top edge of the projection. ----@param near number # The position of the near clipping plane. ----@param far number # The position of the far clipping plane. ----@return lovr.Mat4 self # The modified matrix. -function Mat4:orthographic(left, right, bottom, top, near, far) end - ---- ----Sets this matrix to represent a perspective projection. ---- ----This can be used with `Pass:setProjection`, or it can be sent to a `Shader` for use in GLSL. ---- ----@param fov number # The vertical field of view (in radians). ----@param aspect number # The horizontal aspect ratio of the projection (width / height). ----@param near number # The near plane. ----@param far? number # The far plane. Zero is a special value that will set an infinite far plane with a reversed Z range, which improves depth buffer precision and is the default. ----@return lovr.Mat4 self # The modified matrix. -function Mat4:perspective(fov, aspect, near, far) end - ---- ----Turns the matrix into a reflection matrix that transforms values as though they were reflected across a plane. ---- ----@param position lovr.Vec3 # The position of the plane. ----@param normal lovr.Vec3 # The normal vector of the plane. ----@return lovr.Mat4 self # The reflected matrix. -function Mat4:reflect(position, normal) end - ---- ----Rotates the matrix using a quaternion or an angle/axis rotation. ---- ----@overload fun(self: lovr.Mat4, angle: number, ax?: number, ay?: number, az?: number):lovr.Mat4 ----@param q lovr.Quat # The rotation to apply to the matrix. ----@return lovr.Mat4 self # The rotated matrix. -function Mat4:rotate(q) end - ---- ----Scales the matrix. ---- ----@overload fun(self: lovr.Mat4, sx: number, sy?: number, sz?: number):lovr.Mat4 ----@param scale lovr.Vec3 # The 3D scale to apply. ----@return lovr.Mat4 self # The modified matrix. -function Mat4:scale(scale) end - ---- ----Sets the components of the matrix from separate position, rotation, and scale arguments or an existing matrix. ---- ----@overload fun(self: lovr.Mat4, n: lovr.Mat4):lovr.Mat4 ----@overload fun(self: lovr.Mat4, x: number, y: number, z: number, sx: number, sy: number, sz: number, angle: number, ax: number, ay: number, az: number):lovr.Mat4 ----@overload fun(self: lovr.Mat4, x: number, y: number, z: number, angle: number, ax: number, ay: number, az: number):lovr.Mat4 ----@overload fun(self: lovr.Mat4, position: lovr.Vec3, scale: lovr.Vec3, rotation: lovr.Quat):lovr.Mat4 ----@overload fun(self: lovr.Mat4, position: lovr.Vec3, rotation: lovr.Quat):lovr.Mat4 ----@overload fun(self: lovr.Mat4, ...):lovr.Mat4 ----@overload fun(self: lovr.Mat4, d: number):lovr.Mat4 ----@return lovr.Mat4 m # The input matrix. -function Mat4:set() end - ---- ----Sets a model transform matrix that moves to `from` and orients model towards `to` point. ---- ----This is used when rendered model should always point towards a point of interest. The resulting Mat4 object can be used as model pose. ---- ----The target() function produces same result as lookAt() after matrix inversion. ---- ----@param from lovr.Vec3 # The position of the viewer. ----@param to lovr.Vec3 # The position of the target. ----@param up? lovr.Vec3 # The up vector of the viewer. ----@return lovr.Mat4 self # The modified matrix. -function Mat4:target(from, to, up) end - ---- ----Translates the matrix. ---- ----@overload fun(self: lovr.Mat4, x: number, y: number, z: number):lovr.Mat4 ----@param v lovr.Vec3 # The translation vector. ----@return lovr.Mat4 self # The translated matrix. -function Mat4:translate(v) end - ---- ----Transposes the matrix, mirroring its values along the diagonal. ---- ----@return lovr.Mat4 self # The transposed matrix. -function Mat4:transpose() end - ---- ----Returns the components of matrix, either as 10 separated numbers representing the position, scale, and rotation, or as 16 raw numbers representing the individual components of the matrix in column-major order. ---- ----@param raw? boolean # Whether to return the 16 raw components. -function Mat4:unpack(raw) end - ---- ----A `quat` is a math type that represents a 3D rotation, stored as four numbers. ---- ----@class lovr.Quat -local Quat = {} - ---- ----Conjugates the input quaternion in place, returning the input. ---- ----If the quaternion is normalized, this is the same as inverting it. ---- ----It negates the (x, y, z) components of the quaternion. ---- ----@return lovr.Quat self # The inverted quaternion. -function Quat:conjugate() end - ---- ----Creates a new temporary vec3 facing the forward direction, rotates it by this quaternion, and returns the vector. ---- ----@return lovr.Vec3 v # The direction vector. -function Quat:direction() end - ---- ----Returns whether a quaternion is approximately equal to another quaternion. ---- ----@param r lovr.Quat # The other quaternion. ----@return boolean equal # Whether the 2 quaternions approximately equal each other. -function Quat:equals(r) end - ---- ----Returns the length of the quaternion. ---- ----@return number length # The length of the quaternion. -function Quat:length() end - ---- ----Multiplies this quaternion by another value. ---- ----If the value is a quaternion, the rotations in the two quaternions are applied sequentially and the result is stored in the first quaternion. ---- ----If the value is a vector, then the input vector is rotated by the quaternion and returned. ---- ----@overload fun(self: lovr.Quat, v3: lovr.Vec3):lovr.Vec3 ----@param r lovr.Quat # A quaternion to combine with the original. ----@return lovr.Quat self # The modified quaternion. -function Quat:mul(r) end - ---- ----Adjusts the values in the quaternion so that its length becomes 1. ---- ---- ----### NOTE: ----A common source of bugs with quaternions is to forget to normalize them after performing a series of operations on them. ---- ----Try normalizing a quaternion if some of the calculations aren't working quite right! ---- ----@return lovr.Quat self # The normalized quaternion. -function Quat:normalize() end - ---- ----Sets the components of the quaternion. ---- ----There are lots of different ways to specify the new components, the summary is: ---- ----- Four numbers can be used to specify an angle/axis rotation, similar to other LÖVR functions. ----- Four numbers plus the fifth `raw` flag can be used to set the raw values of the quaternion. ----- An existing quaternion can be passed in to copy its values. ----- A single direction vector can be specified to turn its direction (relative to the default ---- forward direction of "negative z") into a rotation. ----- Two direction vectors can be specified to set the quaternion equal to the rotation between the ---- two vectors. ----- A matrix can be passed in to extract the rotation of the matrix into a quaternion. ---- ----@overload fun(self: lovr.Quat, r: lovr.Quat):lovr.Quat ----@overload fun(self: lovr.Quat, v: lovr.Vec3):lovr.Quat ----@overload fun(self: lovr.Quat, v: lovr.Vec3, u: lovr.Vec3):lovr.Quat ----@overload fun(self: lovr.Quat, m: lovr.Mat4):lovr.Quat ----@overload fun(self: lovr.Quat):lovr.Quat ----@param angle? number # The angle to use for the rotation, in radians. ----@param ax? number # The x component of the axis of rotation. ----@param ay? number # The y component of the axis of rotation. ----@param az? number # The z component of the axis of rotation. ----@param raw? boolean # Whether the components should be interpreted as raw `(x, y, z, w)` components. ----@return lovr.Quat self # The modified quaternion. -function Quat:set(angle, ax, ay, az, raw) end - ---- ----Performs a spherical linear interpolation between this quaternion and another one, which can be used for smoothly animating between two rotations. ---- ----The amount of interpolation is controlled by a parameter `t`. ---- ----A `t` value of zero leaves the original quaternion unchanged, whereas a `t` of one sets the original quaternion exactly equal to the target. ---- ----A value between `0` and `1` returns a rotation between the two based on the value. ---- ----@param r lovr.Quat # The quaternion to slerp towards. ----@param t number # The lerping parameter. ----@return lovr.Quat self # The modified quaternion, containing the new lerped values. -function Quat:slerp(r, t) end - ---- ----Returns the components of the quaternion as numbers, either in an angle/axis representation or as raw quaternion values. ---- ----@param raw? boolean # Whether the values should be returned as raw values instead of angle/axis. ----@return number a # The angle in radians, or the x value. ----@return number b # The x component of the rotation axis or the y value. ----@return number c # The y component of the rotation axis or the z value. ----@return number d # The z component of the rotation axis or the w value. -function Quat:unpack(raw) end - ---- ----A RandomGenerator is a standalone object that can be used to independently generate pseudo-random numbers. If you just need basic randomness, you can use `lovr.math.random` without needing to create a random generator. ---- ----@class lovr.RandomGenerator -local RandomGenerator = {} - ---- ----Returns the seed used to initialize the RandomGenerator. ---- ---- ----### NOTE: ----Since the seed is a 64 bit integer, each 32 bits of the seed are returned separately to avoid precision issues. ---- ----@return number low # The lower 32 bits of the seed. ----@return number high # The upper 32 bits of the seed. -function RandomGenerator:getSeed() end - ---- ----Returns the current state of the RandomGenerator. ---- ----This can be used with `RandomGenerator:setState` to reliably restore a previous state of the generator. ---- ---- ----### NOTE: ----The seed represents the starting state of the RandomGenerator, whereas the state represents the current state of the generator. ---- ----@return string state # The serialized state. -function RandomGenerator:getState() end - ---- ----Returns the next uniformly distributed pseudo-random number from the RandomGenerator's sequence. ---- ----@overload fun(self: lovr.RandomGenerator, high: number):number ----@overload fun(self: lovr.RandomGenerator, low: number, high: number):number ----@return number x # A pseudo-random number. -function RandomGenerator:random() end - ---- ----Returns a pseudo-random number from a normal distribution (a bell curve). ---- ----You can control the center of the bell curve (the mean value) and the overall width (sigma, or standard deviation). ---- ----@param sigma? number # The standard deviation of the distribution. This can be thought of how "wide" the range of numbers is or how much variability there is. ----@param mu? number # The average value returned. ----@return number x # A normally distributed pseudo-random number. -function RandomGenerator:randomNormal(sigma, mu) end - ---- ----Seed the RandomGenerator with a new seed. ---- ----Each seed will cause the RandomGenerator to produce a unique sequence of random numbers. ---- ---- ----### NOTE: ----For precise 64 bit seeds, you should specify the lower and upper 32 bits of the seed separately. Otherwise, seeds larger than 2^53 will start to lose precision. ---- ----@overload fun(self: lovr.RandomGenerator, low: number, high: number) ----@param seed number # The random seed. -function RandomGenerator:setSeed(seed) end - ---- ----Sets the state of the RandomGenerator, as previously obtained using `RandomGenerator:getState`. This can be used to reliably restore a previous state of the generator. ---- ---- ----### NOTE: ----The seed represents the starting state of the RandomGenerator, whereas the state represents the current state of the generator. ---- ----@param state string # The serialized state. -function RandomGenerator:setState(state) end - ---- ----A vector object that holds two numbers. ---- ----@class lovr.Vec2 -local Vec2 = {} - ---- ----Adds a vector or a number to the vector. ---- ----@overload fun(self: lovr.Vec2, x: number, y?: number):lovr.Vec2 ----@param u lovr.Vec2 # The other vector. ----@return lovr.Vec2 self # The modified vector. -function Vec2:add(u) end - ---- ----Returns the angle between vectors. ---- ---- ----### NOTE: ----If any of the two vectors have a length of zero, the angle between them is not well defined. ---- ----In this case the function returns `math.pi / 2`. ---- ----@overload fun(self: lovr.Vec2, x: number, y: number):number ----@param u lovr.Vec2 # The other vector. ----@return number angle # The angle to the other vector, in radians. -function Vec2:angle(u) end - ---- ----Returns the distance to another vector. ---- ----@overload fun(self: lovr.Vec2, x: number, y: number):number ----@param u lovr.Vec2 # The vector to measure the distance to. ----@return number distance # The distance to `u`. -function Vec2:distance(u) end - ---- ----Divides the vector by a vector or a number. ---- ----@overload fun(self: lovr.Vec2, x: number, y?: number):lovr.Vec2 ----@param u lovr.Vec2 # The other vector to divide the components by. ----@return lovr.Vec2 self # The modified vector. -function Vec2:div(u) end - ---- ----Returns the dot product between this vector and another one. ---- ---- ----### NOTE: ----This is computed as: ---- ---- dot = v.x * u.x + v.y * u.y ---- ----The vectors are not normalized before computing the dot product. ---- ----@overload fun(self: lovr.Vec2, x: number, y: number):number ----@param u lovr.Vec2 # The vector to compute the dot product with. ----@return number dot # The dot product between `v` and `u`. -function Vec2:dot(u) end - ---- ----Returns whether a vector is approximately equal to another vector. ---- ---- ----### NOTE: ----To handle floating point precision issues, this function returns true as long as the squared distance between the vectors is below `1e-10`. ---- ----@overload fun(self: lovr.Vec2, x: number, y: number):boolean ----@param u lovr.Vec2 # The other vector. ----@return boolean equal # Whether the 2 vectors approximately equal each other. -function Vec2:equals(u) end - ---- ----Returns the length of the vector. ---- ---- ----### NOTE: ----The length is equivalent to this: ---- ---- math.sqrt(v.x * v.x + v.y * v.y) ---- ----@return number length # The length of the vector. -function Vec2:length() end - ---- ----Performs a linear interpolation between this vector and another one, which can be used to smoothly animate between two vectors, based on a parameter value. ---- ----A parameter value of `0` will leave the vector unchanged, a parameter value of `1` will set the vector to be equal to the input vector, and a value of `.5` will set the components to be halfway between the two vectors. ---- ----@overload fun(self: lovr.Vec2, x: number, y: number, t: number):lovr.Vec2 ----@param u lovr.Vec2 # The vector to lerp towards. ----@param t number # The lerping parameter. ----@return lovr.Vec2 self # The interpolated vector. -function Vec2:lerp(u, t) end - ---- ----Multiplies the vector by a vector or a number. ---- ----@overload fun(self: lovr.Vec2, x: number, y?: number):lovr.Vec2 ----@param u lovr.Vec2 # The other vector to multiply the components by. ----@return lovr.Vec2 self # The modified vector. -function Vec2:mul(u) end - ---- ----Adjusts the values in the vector so that its direction stays the same but its length becomes 1. ---- ----@return lovr.Vec2 self # The normalized vector. -function Vec2:normalize() end - ---- ----Sets the components of the vector, either from numbers or an existing vector. ---- ----@overload fun(self: lovr.Vec2, u: lovr.Vec2):lovr.Vec2 ----@param x? number # The new x value of the vector. ----@param y? number # The new y value of the vector. ----@return lovr.Vec2 v # The input vector. -function Vec2:set(x, y) end - ---- ----Subtracts a vector or a number from the vector. ---- ----@overload fun(self: lovr.Vec2, x: number, y?: number):lovr.Vec2 ----@param u lovr.Vec2 # The other vector. ----@return lovr.Vec2 self # The modified vector. -function Vec2:sub(u) end - ---- ----Returns the 2 components of the vector as numbers. ---- ----@return number x # The x value. ----@return number y # The y value. -function Vec2:unpack() end - ---- ----A vector object that holds three numbers. ---- ----@class lovr.Vec3 -local Vec3 = {} - ---- ----Adds a vector or a number to the vector. ---- ----@overload fun(self: lovr.Vec3, x: number, y?: number, z?: number):lovr.Vec3 ----@param u lovr.Vec3 # The other vector. ----@return lovr.Vec3 self # The modified vector. -function Vec3:add(u) end - ---- ----Returns the angle between vectors. ---- ---- ----### NOTE: ----If any of the two vectors have a length of zero, the angle between them is not well defined. ---- ----In this case the function returns `math.pi / 2`. ---- ----@overload fun(self: lovr.Vec3, x: number, y: number, z: number):number ----@param u lovr.Vec3 # The other vector. ----@return number angle # The angle to the other vector, in radians. -function Vec3:angle(u) end - ---- ----Sets this vector to be equal to the cross product between this vector and another one. ---- ----The new `v` will be perpendicular to both the old `v` and `u`. ---- ---- ----### NOTE: ----The vectors are not normalized before or after computing the cross product. ---- ----@overload fun(self: lovr.Vec3, x: number, y: number, z: number):lovr.Vec3 ----@param u lovr.Vec3 # The vector to compute the cross product with. ----@return lovr.Vec3 self # The modified vector. -function Vec3:cross(u) end - ---- ----Returns the distance to another vector. ---- ----@overload fun(self: lovr.Vec3, x: number, y: number, z: number):number ----@param u lovr.Vec3 # The vector to measure the distance to. ----@return number distance # The distance to `u`. -function Vec3:distance(u) end - ---- ----Divides the vector by a vector or a number. ---- ----@overload fun(self: lovr.Vec3, x: number, y?: number, z?: number):lovr.Vec3 ----@param u lovr.Vec3 # The other vector to divide the components by. ----@return lovr.Vec3 self # The modified vector. -function Vec3:div(u) end - ---- ----Returns the dot product between this vector and another one. ---- ---- ----### NOTE: ----This is computed as: ---- ---- dot = v.x * u.x + v.y * u.y + v.z * u.z ---- ----The vectors are not normalized before computing the dot product. ---- ----@overload fun(self: lovr.Vec3, x: number, y: number, z: number):number ----@param u lovr.Vec3 # The vector to compute the dot product with. ----@return number dot # The dot product between `v` and `u`. -function Vec3:dot(u) end - ---- ----Returns whether a vector is approximately equal to another vector. ---- ---- ----### NOTE: ----To handle floating point precision issues, this function returns true as long as the squared distance between the vectors is below `1e-10`. ---- ----@overload fun(self: lovr.Vec3, x: number, y: number, z: number):boolean ----@param u lovr.Vec3 # The other vector. ----@return boolean equal # Whether the 2 vectors approximately equal each other. -function Vec3:equals(u) end - ---- ----Returns the length of the vector. ---- ---- ----### NOTE: ----The length is equivalent to this: ---- ---- math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z) ---- ----@return number length # The length of the vector. -function Vec3:length() end - ---- ----Performs a linear interpolation between this vector and another one, which can be used to smoothly animate between two vectors, based on a parameter value. ---- ----A parameter value of `0` will leave the vector unchanged, a parameter value of `1` will set the vector to be equal to the input vector, and a value of `.5` will set the components to be halfway between the two vectors. ---- ----@overload fun(self: lovr.Vec3, x: number, y: number, z: number, t: number):lovr.Vec3 ----@param u lovr.Vec3 # The vector to lerp towards. ----@param t number # The lerping parameter. ----@return lovr.Vec3 self # The interpolated vector. -function Vec3:lerp(u, t) end - ---- ----Multiplies the vector by a vector or a number. ---- ----@overload fun(self: lovr.Vec3, x: number, y?: number, z?: number):lovr.Vec3 ----@param u lovr.Vec3 # The other vector to multiply the components by. ----@return lovr.Vec3 self # The modified vector. -function Vec3:mul(u) end - ---- ----Adjusts the values in the vector so that its direction stays the same but its length becomes 1. ---- ----@return lovr.Vec3 self # The normalized vector. -function Vec3:normalize() end - ---- ----Sets the components of the vector, either from numbers or an existing vector. ---- ----@overload fun(self: lovr.Vec3, u: lovr.Vec3):lovr.Vec3 ----@overload fun(self: lovr.Vec3, q: lovr.Quat):lovr.Vec3 ----@overload fun(self: lovr.Vec3, m: lovr.Mat4):lovr.Vec3 ----@param x? number # The new x value of the vector. ----@param y? number # The new y value of the vector. ----@param z? number # The new z value of the vector. ----@return lovr.Vec3 v # The input vector. -function Vec3:set(x, y, z) end - ---- ----Subtracts a vector or a number from the vector. ---- ----@overload fun(self: lovr.Vec3, x: number, y?: number, z?: number):lovr.Vec3 ----@param u lovr.Vec3 # The other vector. ----@return lovr.Vec3 self # The modified vector. -function Vec3:sub(u) end - ---- ----Returns the 3 components of the vector as numbers. ---- ----@return number x # The x value. ----@return number y # The y value. ----@return number z # The z value. -function Vec3:unpack() end - ---- ----A vector object that holds four numbers. ---- ----@class lovr.Vec4 -local Vec4 = {} - ---- ----Adds a vector or a number to the vector. ---- ----@overload fun(self: lovr.Vec4, x: number, y?: number, z?: number, w?: number):lovr.Vec4 ----@param u lovr.Vec4 # The other vector. ----@return lovr.Vec4 self # The modified vector. -function Vec4:add(u) end - ---- ----Returns the angle between vectors. ---- ---- ----### NOTE: ----If any of the two vectors have a length of zero, the angle between them is not well defined. ---- ----In this case the function returns `math.pi / 2`. ---- ----@overload fun(self: lovr.Vec4, x: number, y: number, z: number, w: number):number ----@param u lovr.Vec4 # The other vector. ----@return number angle # The angle to other vector, in radians. -function Vec4:angle(u) end - ---- ----Returns the distance to another vector. ---- ----@overload fun(self: lovr.Vec4, x: number, y: number, z: number, w: number):number ----@param u lovr.Vec4 # The vector to measure the distance to. ----@return number distance # The distance to `u`. -function Vec4:distance(u) end - ---- ----Divides the vector by a vector or a number. ---- ----@overload fun(self: lovr.Vec4, x: number, y?: number, z?: number, w?: number):lovr.Vec4 ----@param u lovr.Vec4 # The other vector to divide the components by. ----@return lovr.Vec4 self # The modified vector. -function Vec4:div(u) end - ---- ----Returns the dot product between this vector and another one. ---- ---- ----### NOTE: ----This is computed as: ---- ---- dot = v.x * u.x + v.y * u.y + v.z * u.z + v.w * u.w ---- ----The vectors are not normalized before computing the dot product. ---- ----@overload fun(self: lovr.Vec4, x: number, y: number, z: number, w: number):number ----@param u lovr.Vec4 # The vector to compute the dot product with. ----@return number dot # The dot product between `v` and `u`. -function Vec4:dot(u) end - ---- ----Returns whether a vector is approximately equal to another vector. ---- ---- ----### NOTE: ----To handle floating point precision issues, this function returns true as long as the squared distance between the vectors is below `1e-10`. ---- ----@overload fun(self: lovr.Vec4, x: number, y: number, z: number, w: number):boolean ----@param u lovr.Vec4 # The other vector. ----@return boolean equal # Whether the 2 vectors approximately equal each other. -function Vec4:equals(u) end - ---- ----Returns the length of the vector. ---- ---- ----### NOTE: ----The length is equivalent to this: ---- ---- math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w) ---- ----@return number length # The length of the vector. -function Vec4:length() end - ---- ----Performs a linear interpolation between this vector and another one, which can be used to smoothly animate between two vectors, based on a parameter value. ---- ----A parameter value of `0` will leave the vector unchanged, a parameter value of `1` will set the vector to be equal to the input vector, and a value of `.5` will set the components to be halfway between the two vectors. ---- ----@overload fun(self: lovr.Vec4, x: number, y: number, z: number, w: number, t: number):lovr.Vec4 ----@param u lovr.Vec4 # The vector to lerp towards. ----@param t number # The lerping parameter. ----@return lovr.Vec4 self # The interpolated vector. -function Vec4:lerp(u, t) end - ---- ----Multiplies the vector by a vector or a number. ---- ----@overload fun(self: lovr.Vec4, x: number, y?: number, z?: number, w?: number):lovr.Vec4 ----@param u lovr.Vec4 # The other vector to multiply the components by. ----@return lovr.Vec4 self # The modified vector. -function Vec4:mul(u) end - ---- ----Adjusts the values in the vector so that its direction stays the same but its length becomes 1. ---- ----@return lovr.Vec4 self # The normalized vector. -function Vec4:normalize() end - ---- ----Sets the components of the vector, either from numbers or an existing vector. ---- ----@overload fun(self: lovr.Vec4, u: lovr.Vec4):lovr.Vec4 ----@param x? number # The new x value of the vector. ----@param y? number # The new y value of the vector. ----@param z? number # The new z value of the vector. ----@param w? number # The new w value of the vector. ----@return lovr.Vec4 v # The input vector. -function Vec4:set(x, y, z, w) end - ---- ----Subtracts a vector or a number from the vector. ---- ----@overload fun(self: lovr.Vec4, x: number, y?: number, z?: number, w?: number):lovr.Vec4 ----@param u lovr.Vec4 # The other vector. ----@return lovr.Vec4 self # The modified vector. -function Vec4:sub(u) end - ---- ----Returns the 4 components of the vector as numbers. ---- ----@return number x # The x value. ----@return number y # The y value. ----@return number z # The z value. ----@return number w # The w value. -function Vec4:unpack() end - ---- ----LÖVR has math objects for vectors, matrices, and quaternions, collectively called "vector objects". ---- ----Vectors are useful because they can represent a multidimensional quantity (like a 3D position) using just a single value. ---- ---- ----### NOTE: ----Most LÖVR functions that accept positions, orientations, transforms, velocities, etc. also accept vector objects, so they can be used interchangeably with numbers: ---- ---- function lovr.draw(pass) ---- -- position and size are vec3's, rotation is a quat ---- pass:box(position, size, rotation) ---- end ---- ----### Temporary vs. Permanent ---- ----Vectors can be created in two different ways: **permanent** and **temporary**. ---- ----**Permanent** vectors behave like normal Lua values. ---- ----They are individual objects that are garbage collected when no longer needed. ---- ----They're created using the usual `lovr.math.new<Type>` syntax: ---- ---- self.position = lovr.math.newVec3(x, y, z) ---- ----**Temporary** vectors are created from a shared pool of vector objects. ---- ----This makes them faster because they use temporary memory and do not need to be garbage collected. ---- ----To make a temporary vector, leave off the `new` prefix: ---- ---- local position = lovr.math.vec3(x, y, z) ---- ----As a shortcut, vector constructors are placed on the global scope. ---- ----The uppercase name of the vector is a function that will create a permanent vector, and the lowercase name will create a temporary vector. ---- ----This can be disabled using the `t.math.globals` option in `lovr.conf`. ---- ---- local position = vec3(x1, y1, z1) + vec3(x2, y2, z2) ---- local transform = Mat4() ---- ----Temporary vectors, with all their speed, come with an important restriction: they can only be used during the frame in which they were created. ---- ----Saving them into variables and using them later on will throw an error: ---- ---- local position = vec3(1, 2, 3) ---- ---- function lovr.update(dt) ---- -- Reusing the temporary 'position' vector across frames will error: ---- position:add(vec3(dt)) ---- end ---- ----It's possible to overflow the temporary vector pool. ---- ----If that happens, `lovr.math.drain` can be used to periodically drain the pool, invalidating any existing temporary vectors. ---- ----### Metamethods ---- ----Vectors have metamethods, allowing them to be used using the normal math operators like `+`, `-`, `*`, `/`, etc. ---- ---- print(vec3(2, 4, 6) * .5 + vec3(10, 20, 30)) ---- ----These metamethods will create new temporary vectors. ---- ----### Components and Swizzles ---- ----The raw components of a vector can be accessed like normal fields: ---- ---- print(vec3(1, 2, 3).z) --> 3 ---- print(mat4()[16]) --> 1 ---- ----Also, multiple fields can be accessed and combined into a new (temporary) vector, called swizzling: ---- ---- local position = vec3(10, 5, 1) ---- print(position.xy) --> vec2(10, 5) ---- print(position.xyy) --> vec3(10, 5, 5) ---- print(position.zyxz) --> vec4(1, 5, 10, 1) ---- ----The following fields are supported for vectors: ---- ----- `x`, `y`, `z`, `w` ----- `r`, `g`, `b`, `a` ----- `s`, `t`, `p`, `q` ---- ----Quaternions support `x`, `y`, `z`, and `w`. ---- ----Matrices use numbers for accessing individual components in "column-major" order. ---- ----All fields can also be assigned to. ---- ---- -- Swap the components of a 2D vector ---- v.xy = v.yx ---- ----The `unpack` function can be used (on any vector type) to access all of the individual components of a vector object. ---- ----For quaternions you can choose whether you want to unpack the angle/axis representation or the raw quaternion components. ---- ----Similarly, matrices support raw unpacking as well as decomposition into translation/scale/rotation values. ---- ----### Vector Constants ---- ----The following vector constants are available. ---- ----They return new temporary vectors each time they are used: ---- ----- `vec2.zero` (0, 0) ----- `vec2.one` (1, 1) ----- `vec3.zero` (0, 0, 0) ----- `vec3.one` (1, 1, 1) ----- `vec3.left` (-1, 0, 0) ----- `vec3.right` (1, 0, 0) ----- `vec3.up` (0, 1, 0) ----- `vec3.down` (0, -1, 0) ----- `vec3.back` (0, 0, 1) ----- `vec3.forward` (0, 0, -1) ----- `vec4.zero` (0, 0, 0, 0) ----- `vec4.one` (1, 1, 1, 1) ----- `quat.identity` (0, 0, 0, 1) ---- ----@class lovr.Vectors -local Vectors = {} diff --git a/meta/3rd/lovr/library/lovr/physics.lua b/meta/3rd/lovr/library/lovr/physics.lua deleted file mode 100644 index b699fc81..00000000 --- a/meta/3rd/lovr/library/lovr/physics.lua +++ /dev/null @@ -1,1843 +0,0 @@ ----@meta - ---- ----The `lovr.physics` module simulates 3D rigid body physics. ---- ----@class lovr.physics -lovr.physics = {} - ---- ----Creates a new BallJoint. ---- ---- ----### NOTE: ----A ball joint is like a ball and socket between the two colliders. ---- ----It tries to keep the distance between the colliders and the anchor position the same, but does not constrain the angle between them. ---- ----@overload fun(colliderA: lovr.Collider, colliderB: lovr.Collider, anchor: lovr.Vec3):lovr.BallJoint ----@param colliderA lovr.Collider # The first collider to attach the Joint to. ----@param colliderB lovr.Collider # The second collider to attach the Joint to. ----@param x number # The x position of the joint anchor point, in world coordinates. ----@param y number # The y position of the joint anchor point, in world coordinates. ----@param z number # The z position of the joint anchor point, in world coordinates. ----@return lovr.BallJoint ball # The new BallJoint. -function lovr.physics.newBallJoint(colliderA, colliderB, x, y, z) end - ---- ----Creates a new BoxShape. ---- ---- ----### NOTE: ----A Shape can be attached to a Collider using `Collider:addShape`. ---- ----@param width? number # The width of the box, in meters. ----@param height? number # The height of the box, in meters. ----@param depth? number # The depth of the box, in meters. ----@return lovr.BoxShape box # The new BoxShape. -function lovr.physics.newBoxShape(width, height, depth) end - ---- ----Creates a new CapsuleShape. ---- ----Capsules are cylinders with hemispheres on each end. ---- ---- ----### NOTE: ----A Shape can be attached to a Collider using `Collider:addShape`. ---- ----@param radius? number # The radius of the capsule, in meters. ----@param length? number # The length of the capsule, not including the caps, in meters. ----@return lovr.CapsuleShape capsule # The new CapsuleShape. -function lovr.physics.newCapsuleShape(radius, length) end - ---- ----Creates a new CylinderShape. ---- ---- ----### NOTE: ----A Shape can be attached to a Collider using `Collider:addShape`. ---- ----@param radius? number # The radius of the cylinder, in meters. ----@param length? number # The length of the cylinder, in meters. ----@return lovr.CylinderShape cylinder # The new CylinderShape. -function lovr.physics.newCylinderShape(radius, length) end - ---- ----Creates a new DistanceJoint. ---- ---- ----### NOTE: ----A distance joint tries to keep the two colliders a fixed distance apart. ---- ----The distance is determined by the initial distance between the anchor points. ---- ----The joint allows for rotation on the anchor points. ---- ----@overload fun(colliderA: lovr.Collider, colliderB: lovr.Collider, first: lovr.Vec3, second: lovr.Vec3):lovr.DistanceJoint ----@param colliderA lovr.Collider # The first collider to attach the Joint to. ----@param colliderB lovr.Collider # The second collider to attach the Joint to. ----@param x1 number # The x position of the first anchor point, in world coordinates. ----@param y1 number # The y position of the first anchor point, in world coordinates. ----@param z1 number # The z position of the first anchor point, in world coordinates. ----@param x2 number # The x position of the second anchor point, in world coordinates. ----@param y2 number # The y position of the second anchor point, in world coordinates. ----@param z2 number # The z position of the second anchor point, in world coordinates. ----@return lovr.DistanceJoint joint # The new DistanceJoint. -function lovr.physics.newDistanceJoint(colliderA, colliderB, x1, y1, z1, x2, y2, z2) end - ---- ----Creates a new HingeJoint. ---- ---- ----### NOTE: ----A hinge joint constrains two colliders to allow rotation only around the hinge's axis. ---- ----@overload fun(colliderA: lovr.Collider, colliderB: lovr.Collider, anchor: lovr.Vec3, axis: lovr.Vec3):lovr.HingeJoint ----@param colliderA lovr.Collider # The first collider to attach the Joint to. ----@param colliderB lovr.Collider # The second collider to attach the Joint to. ----@param x number # The x position of the hinge anchor, in world coordinates. ----@param y number # The y position of the hinge anchor, in world coordinates. ----@param z number # The z position of the hinge anchor, in world coordinates. ----@param ax number # The x component of the hinge axis direction. ----@param ay number # The y component of the hinge axis direction. ----@param az number # The z component of the hinge axis direction. ----@return lovr.HingeJoint hinge # The new HingeJoint. -function lovr.physics.newHingeJoint(colliderA, colliderB, x, y, z, ax, ay, az) end - ---- ----Creates a new MeshShape. ---- ---- ----### NOTE: ----A Shape can be attached to a Collider using `Collider:addShape`. ---- ----@overload fun(model: lovr.Model):lovr.MeshShape ----@param vertices table # The table of vertices in the mesh. Each vertex is a table with 3 numbers. ----@param indices table # A table of triangle indices representing how the vertices are connected in the Mesh. ----@return lovr.MeshShape mesh # The new MeshShape. -function lovr.physics.newMeshShape(vertices, indices) end - ---- ----Creates a new SliderJoint. ---- ---- ----### NOTE: ----A slider joint constrains two colliders to only allow movement along the slider's axis. ---- ----@overload fun(colliderA: lovr.Collider, colliderB: lovr.Collider, axis: lovr.Vec3):lovr.SliderJoint ----@param colliderA lovr.Collider # The first collider to attach the Joint to. ----@param colliderB lovr.Collider # The second collider to attach the Joint to. ----@param ax number # The x component of the slider axis. ----@param ay number # The y component of the slider axis. ----@param az number # The z component of the slider axis. ----@return lovr.SliderJoint slider # The new SliderJoint. -function lovr.physics.newSliderJoint(colliderA, colliderB, ax, ay, az) end - ---- ----Creates a new SphereShape. ---- ---- ----### NOTE: ----A Shape can be attached to a Collider using `Collider:addShape`. ---- ----@param radius? number # The radius of the sphere, in meters. ----@return lovr.SphereShape sphere # The new SphereShape. -function lovr.physics.newSphereShape(radius) end - ---- ----Creates a new TerrainShape. ---- ---- ----### NOTE: ----A Shape can be attached to a Collider using `Collider:addShape`. For immobile terrain use the `Collider:setKinematic`. ---- ----@overload fun(scale: number, heightmap: lovr.Image, stretch?: number):lovr.TerrainShape ----@overload fun(scale: number, callback: function, samples?: number):lovr.TerrainShape ----@param scale number # The width and depth of the terrain, in meters. ----@return lovr.TerrainShape terrain # The new TerrainShape. -function lovr.physics.newTerrainShape(scale) end - ---- ----Creates a new physics World, which tracks the overall physics simulation, holds collider objects, and resolves collisions between them. ---- ---- ----### NOTE: ----A World must be updated with `World:update` in `lovr.update` for the physics simulation to advance. ---- ----@param xg? number # The x component of the gravity force. ----@param yg? number # The y component of the gravity force. ----@param zg? number # The z component of the gravity force. ----@param allowSleep? boolean # Whether or not colliders will automatically be put to sleep. ----@param tags table # A list of collision tags colliders can be assigned to. ----@return lovr.World world # A whole new World. -function lovr.physics.newWorld(xg, yg, zg, allowSleep, tags) end - ---- ----A BallJoint is a type of `Joint` that acts like a ball and socket between two colliders. ---- ----It allows the colliders to rotate freely around an anchor point, but does not allow the colliders' distance from the anchor point to change. ---- ----@class lovr.BallJoint -local BallJoint = {} - ---- ----Returns the anchor points of the BallJoint, in world coordinates. ---- ----The first point is the anchor on the first collider, and the second point is on the second collider. ---- ----The joint tries to keep these points the same, but they may be different if the joint is forced apart by some other means. ---- ----@return number x1 # The x coordinate of the first anchor point, in world coordinates. ----@return number y1 # The y coordinate of the first anchor point, in world coordinates. ----@return number z1 # The z coordinate of the first anchor point, in world coordinates. ----@return number x2 # The x coordinate of the second anchor point, in world coordinates. ----@return number y2 # The y coordinate of the second anchor point, in world coordinates. ----@return number z2 # The z coordinate of the second anchor point, in world coordinates. -function BallJoint:getAnchors() end - ---- ----Returns the response time of the joint. ---- ----See `World:setResponseTime` for more info. ---- ----@return number responseTime # The response time setting for the joint. -function BallJoint:getResponseTime() end - ---- ----Returns the tightness of the joint. ---- ----See `World:setTightness` for how this affects the joint. ---- ----@return number tightness # The tightness of the joint. -function BallJoint:getTightness() end - ---- ----Sets a new anchor point for the BallJoint. ---- ----@overload fun(self: lovr.BallJoint, anchor: lovr.Vec3) ----@param x number # The x coordinate of the anchor point, in world coordinates. ----@param y number # The y coordinate of the anchor point, in world coordinates. ----@param z number # The z coordinate of the anchor point, in world coordinates. -function BallJoint:setAnchor(x, y, z) end - ---- ----Sets the response time of the joint. ---- ----See `World:setResponseTime` for more info. ---- ----@param responseTime number # The new response time setting for the joint. -function BallJoint:setResponseTime(responseTime) end - ---- ----Sets the tightness of the joint. ---- ----See `World:setTightness` for how this affects the joint. ---- ----@param tightness number # The tightness of the joint. -function BallJoint:setTightness(tightness) end - ---- ----A type of `Shape` that can be used for cubes or boxes. ---- ----@class lovr.BoxShape -local BoxShape = {} - ---- ----Returns the width, height, and depth of the BoxShape. ---- ----@return number width # The width of the box, in meters. ----@return number height # The height of the box, in meters. ----@return number depth # The depth of the box, in meters. -function BoxShape:getDimensions() end - ---- ----Sets the width, height, and depth of the BoxShape. ---- ----@param width number # The width of the box, in meters. ----@param height number # The height of the box, in meters. ----@param depth number # The depth of the box, in meters. -function BoxShape:setDimensions(width, height, depth) end - ---- ----A type of `Shape` that can be used for capsule-shaped things. ---- ----@class lovr.CapsuleShape -local CapsuleShape = {} - ---- ----Returns the length of the CapsuleShape, not including the caps. ---- ----@return number length # The length of the capsule, in meters. -function CapsuleShape:getLength() end - ---- ----Returns the radius of the CapsuleShape. ---- ----@return number radius # The radius of the capsule, in meters. -function CapsuleShape:getRadius() end - ---- ----Sets the length of the CapsuleShape. ---- ----@param length number # The new length, in meters, not including the caps. -function CapsuleShape:setLength(length) end - ---- ----Sets the radius of the CapsuleShape. ---- ----@param radius number # The new radius, in meters. -function CapsuleShape:setRadius(radius) end - ---- ----Colliders are objects that represent a single rigid body in a physics simulation. ---- ----They can have forces applied to them and collide with other colliders. ---- ----@class lovr.Collider -local Collider = {} - ---- ----Attaches a Shape to the collider. ---- ----Attached shapes will collide with other shapes in the world. ---- ----@param shape lovr.Shape # The Shape to attach. -function Collider:addShape(shape) end - ---- ----Applies a force to the Collider. ---- ---- ----### NOTE: ----If the Collider is asleep, it will need to be woken up with `Collider:setAwake` for this function to have any affect. ---- ----@overload fun(self: lovr.Collider, x: number, y: number, z: number, px: number, py: number, pz: number) ----@overload fun(self: lovr.Collider, force: lovr.Vec3) ----@overload fun(self: lovr.Collider, force: lovr.Vec3, position: lovr.Vec3) ----@param x number # The x component of the force to apply. ----@param y number # The y component of the force to apply. ----@param z number # The z component of the force to apply. -function Collider:applyForce(x, y, z) end - ---- ----Applies torque to the Collider. ---- ---- ----### NOTE: ----If the Collider is asleep, it will need to be woken up with `Collider:setAwake` for this function to have any effect. ---- ----@overload fun(self: lovr.Collider, torque: lovr.Vec3) ----@param x number # The x component of the torque. ----@param y number # The y component of the torque. ----@param z number # The z component of the torque. -function Collider:applyTorque(x, y, z) end - ---- ----Destroy the Collider, removing it from the World. ---- ---- ----### NOTE: ----Calling functions on the collider after destroying it is a bad idea. ---- -function Collider:destroy() end - ---- ----Returns the bounding box for the Collider, computed from attached shapes. ---- ----@return number minx # The minimum x coordinate of the box. ----@return number maxx # The maximum x coordinate of the box. ----@return number miny # The minimum y coordinate of the box. ----@return number maxy # The maximum y coordinate of the box. ----@return number minz # The minimum z coordinate of the box. ----@return number maxz # The maximum z coordinate of the box. -function Collider:getAABB() end - ---- ----Returns the angular damping parameters of the Collider. ---- ----Angular damping makes things less "spinny", making them slow down their angular velocity over time. ---- ---- ----### NOTE: ----Angular damping can also be set on the World. ---- ----@return number damping # The angular damping. ----@return number threshold # Velocity limit below which the damping is not applied. -function Collider:getAngularDamping() end - ---- ----Returns the angular velocity of the Collider. ---- ----@return number vx # The x component of the angular velocity. ----@return number vy # The y component of the angular velocity. ----@return number vz # The z component of the angular velocity. -function Collider:getAngularVelocity() end - ---- ----Returns the friction of the Collider. ---- ----By default, the friction of two Colliders is combined (multiplied) when they collide to generate a friction force. ---- ----The initial friction is 0. ---- ----@return number friction # The friction of the Collider. -function Collider:getFriction() end - ---- ----Returns a list of Joints attached to the Collider. ---- ----@return table joints # A list of Joints attached to the Collider. -function Collider:getJoints() end - ---- ----Returns the Collider's linear damping parameters. ---- ----Linear damping is similar to drag or air resistance, slowing the Collider down over time. ---- ---- ----### NOTE: ----A linear damping of 0 means the Collider won't slow down over time. ---- ----This is the default. ---- ----Linear damping can also be set on the World using `World:setLinearDamping`, which will affect all new colliders. ---- ----@return number damping # The linear damping. ----@return number threshold # Velocity limit below which the damping is not applied. -function Collider:getLinearDamping() end - ---- ----Returns the linear velocity of the Collider. ---- ----This is how fast the Collider is moving. ---- ----There is also angular velocity, which is how fast the Collider is spinning. ---- ----@return number vx # The x velocity of the Collider, in meters per second. ----@return number vy # The y velocity of the Collider, in meters per second. ----@return number vz # The z velocity of the Collider, in meters per second. -function Collider:getLinearVelocity() end - ---- ----Returns the linear velocity of a point relative to the Collider. ---- ----@overload fun(self: lovr.Collider, point: number):number, number, number ----@param x number # The x coordinate. ----@param y number # The y coordinate. ----@param z number # The z coordinate. ----@return number vx # The x component of the velocity of the point. ----@return number vy # The y component of the velocity of the point. ----@return number vz # The z component of the velocity of the point. -function Collider:getLinearVelocityFromLocalPoint(x, y, z) end - ---- ----Returns the linear velocity of a point on the Collider specified in world space. ---- ----@overload fun(self: lovr.Collider, point: lovr.Vec3):number, number, number ----@param x number # The x coordinate in world space. ----@param y number # The y coordinate in world space. ----@param z number # The z coordinate in world space. ----@return number vx # The x component of the velocity of the point. ----@return number vy # The y component of the velocity of the point. ----@return number vz # The z component of the velocity of the point. -function Collider:getLinearVelocityFromWorldPoint(x, y, z) end - ---- ----Returns the Collider's center of mass. ---- ----@return number cx # The x position of the center of mass. ----@return number cy # The y position of the center of mass. ----@return number cz # The z position of the center of mass. -function Collider:getLocalCenter() end - ---- ----Converts a point from world coordinates into local coordinates relative to the Collider. ---- ----@overload fun(self: lovr.Collider, point: lovr.Vec3):number, number, number ----@param wx number # The x coordinate of the world point. ----@param wy number # The y coordinate of the world point. ----@param wz number # The z coordinate of the world point. ----@return number x # The x position of the local-space point. ----@return number y # The y position of the local-space point. ----@return number z # The z position of the local-space point. -function Collider:getLocalPoint(wx, wy, wz) end - ---- ----Converts a direction vector from world space to local space. ---- ----@overload fun(self: lovr.Collider, vector: lovr.Vec3):number, number, number ----@param wx number # The x component of the world vector. ----@param wy number # The y component of the world vector. ----@param wz number # The z component of the world vector. ----@return number x # The x coordinate of the local vector. ----@return number y # The y coordinate of the local vector. ----@return number z # The z coordinate of the local vector. -function Collider:getLocalVector(wx, wy, wz) end - ---- ----Returns the total mass of the Collider. ---- ----The mass of a Collider depends on its attached shapes. ---- ----@return number mass # The mass of the Collider, in kilograms. -function Collider:getMass() end - ---- ----Computes mass properties for the Collider. ---- ----@return number cx # The x position of the center of mass. ----@return number cy # The y position of the center of mass. ----@return number cz # The z position of the center of mass. ----@return number mass # The computed mass of the Collider. ----@return table inertia # A table containing 6 values of the rotational inertia tensor matrix. The table contains the 3 diagonal elements of the matrix (upper left to bottom right), followed by the 3 elements of the upper right portion of the 3x3 matrix. -function Collider:getMassData() end - ---- ----Returns the orientation of the Collider in angle/axis representation. ---- ----@return number angle # The number of radians the Collider is rotated around its axis of rotation. ----@return number ax # The x component of the axis of rotation. ----@return number ay # The y component of the axis of rotation. ----@return number az # The z component of the axis of rotation. -function Collider:getOrientation() end - ---- ----Returns the position and orientation of the Collider. ---- ----@return number x # The x position of the Collider, in meters. ----@return number y # The y position of the Collider, in meters. ----@return number z # The z position of the Collider, in meters. ----@return number angle # The number of radians the Collider is rotated around its axis of rotation. ----@return number ax # The x component of the axis of rotation. ----@return number ay # The y component of the axis of rotation. ----@return number az # The z component of the axis of rotation. -function Collider:getPose() end - ---- ----Returns the position of the Collider. ---- ----@return number x # The x position of the Collider, in meters. ----@return number y # The y position of the Collider, in meters. ----@return number z # The z position of the Collider, in meters. -function Collider:getPosition() end - ---- ----Returns the restitution (bounciness) of the Collider. ---- ----By default, the restitution of two Colliders is combined (the max is used) when they collide to cause them to bounce away from each other. ---- ----The initial restitution is 0. ---- ----@return number restitution # The restitution of the Collider. -function Collider:getRestitution() end - ---- ----Returns a list of Shapes attached to the Collider. ---- ----@return table shapes # A list of Shapes attached to the Collider. -function Collider:getShapes() end - ---- ----Returns the Collider's tag. ---- ---- ----### NOTE: ----Collision between tags can be enabled and disabled using `World:enableCollisionBetween` and `World:disableCollisionBetween`. ---- ----@return string tag # The Collider's collision tag. -function Collider:getTag() end - ---- ----Returns the user data associated with the Collider. ---- ---- ----### NOTE: ----User data can be useful to identify the Collider in callbacks. ---- ----@return any data # The custom value associated with the Collider. -function Collider:getUserData() end - ---- ----Returns the World the Collider is in. ---- ---- ----### NOTE: ----Colliders can only be in one World at a time. ---- ----@return lovr.World world # The World the Collider is in. -function Collider:getWorld() end - ---- ----Convert a point relative to the collider to a point in world coordinates. ---- ----@overload fun(self: lovr.Collider, point: lovr.Vec3):number, number, number ----@param x number # The x position of the point. ----@param y number # The y position of the point. ----@param z number # The z position of the point. ----@return number wx # The x coordinate of the world point. ----@return number wy # The y coordinate of the world point. ----@return number wz # The z coordinate of the world point. -function Collider:getWorldPoint(x, y, z) end - ---- ----Converts a direction vector from local space to world space. ---- ----@overload fun(self: lovr.Collider, vector: lovr.Vec3):number, number, number ----@param x number # The x coordinate of the local vector. ----@param y number # The y coordinate of the local vector. ----@param z number # The z coordinate of the local vector. ----@return number wx # The x component of the world vector. ----@return number wy # The y component of the world vector. ----@return number wz # The z component of the world vector. -function Collider:getWorldVector(x, y, z) end - ---- ----Returns whether the Collider is currently awake. ---- ----@return boolean awake # Whether the Collider is awake. -function Collider:isAwake() end - ---- ----Returns whether the Collider is currently ignoring gravity. ---- ----@return boolean ignored # Whether gravity is ignored for this Collider. -function Collider:isGravityIgnored() end - ---- ----Returns whether the Collider is kinematic. ---- ---- ----### NOTE: ----Kinematic colliders behave as though they have infinite mass, ignoring external forces like gravity, joints, or collisions (though non-kinematic colliders will collide with them). They can be useful for static objects like floors or walls. ---- ----@return boolean kinematic # Whether the Collider is kinematic. -function Collider:isKinematic() end - ---- ----Returns whether the Collider is allowed to sleep. ---- ---- ----### NOTE: ----If sleeping is enabled, the simulation will put the Collider to sleep if it hasn't moved in a while. Sleeping colliders don't impact the physics simulation, which makes updates more efficient and improves physics performance. ---- ----However, the physics engine isn't perfect at waking up sleeping colliders and this can lead to bugs where colliders don't react to forces or collisions properly. ---- ----It is possible to set the default value for new colliders using `World:setSleepingAllowed`. ---- ----Colliders can be manually put to sleep or woken up using `Collider:setAwake`. ---- ----@return boolean allowed # Whether the Collider can go to sleep. -function Collider:isSleepingAllowed() end - ---- ----Removes a Shape from the Collider. ---- ---- ----### NOTE: ----Colliders without any shapes won't collide with anything. ---- ----@param shape lovr.Shape # The Shape to remove. -function Collider:removeShape(shape) end - ---- ----Sets the angular damping of the Collider. ---- ----Angular damping makes things less "spinny", causing them to slow down their angular velocity over time. Damping is only applied when angular velocity is over the threshold value. ---- ---- ----### NOTE: ----Angular damping can also be set on the World. ---- ----@param damping number # The angular damping. ----@param threshold? number # Velocity limit below which the damping is not applied. -function Collider:setAngularDamping(damping, threshold) end - ---- ----Sets the angular velocity of the Collider. ---- ----@overload fun(self: lovr.Collider, velocity: lovr.Vec3) ----@param vx number # The x component of the angular velocity. ----@param vy number # The y component of the angular velocity. ----@param vz number # The z component of the angular velocity. -function Collider:setAngularVelocity(vx, vy, vz) end - ---- ----Manually puts the Collider to sleep or wakes it up. ---- ----You can do this if you know a Collider won't be touched for a while or if you need to it be active. ---- ----@param awake boolean # Whether the Collider should be awake. -function Collider:setAwake(awake) end - ---- ----Sets the friction of the Collider. ---- ----By default, the friction of two Colliders is combined (multiplied) when they collide to generate a friction force. ---- ----The initial friction is 0. ---- ----@param friction number # The new friction. -function Collider:setFriction(friction) end - ---- ----Sets whether the Collider should ignore gravity. ---- ----@param ignored boolean # Whether gravity should be ignored. -function Collider:setGravityIgnored(ignored) end - ---- ----Sets whether the Collider is kinematic. ---- ---- ----### NOTE: ----Kinematic colliders behave as though they have infinite mass, ignoring external forces like gravity, joints, or collisions (though non-kinematic colliders will collide with them). They can be useful for static objects like floors or walls. ---- ----@param kinematic boolean # Whether the Collider is kinematic. -function Collider:setKinematic(kinematic) end - ---- ----Sets the Collider's linear damping parameter. ---- ----Linear damping is similar to drag or air resistance, slowing the Collider down over time. Damping is only applied when linear velocity is over the threshold value. ---- ---- ----### NOTE: ----A linear damping of 0 means the Collider won't slow down over time. ---- ----This is the default. ---- ----Linear damping can also be set on the World using `World:setLinearDamping`, which will affect all new colliders. ---- ----@param damping number # The linear damping. ----@param threshold? number # Velocity limit below which the damping is not applied. -function Collider:setLinearDamping(damping, threshold) end - ---- ----Sets the linear velocity of the Collider directly. ---- ----Usually it's preferred to use `Collider:applyForce` to change velocity since instantaneous velocity changes can lead to weird glitches. ---- ----@overload fun(self: lovr.Collider, velocity: lovr.Vec3) ----@param vx number # The x velocity of the Collider, in meters per second. ----@param vy number # The y velocity of the Collider, in meters per second. ----@param vz number # The z velocity of the Collider, in meters per second. -function Collider:setLinearVelocity(vx, vy, vz) end - ---- ----Sets the total mass of the Collider. ---- ----@param mass number # The new mass for the Collider, in kilograms. -function Collider:setMass(mass) end - ---- ----Sets mass properties for the Collider. ---- ----@param cx number # The x position of the center of mass. ----@param cy number # The y position of the center of mass. ----@param cz number # The z position of the center of mass. ----@param mass number # The computed mass of the Collider. ----@param inertia table # A table containing 6 values of the rotational inertia tensor matrix. The table contains the 3 diagonal elements of the matrix (upper left to bottom right), followed by the 3 elements of the upper right portion of the 3x3 matrix. -function Collider:setMassData(cx, cy, cz, mass, inertia) end - ---- ----Sets the orientation of the Collider in angle/axis representation. ---- ----@overload fun(self: lovr.Collider, orientation: lovr.Quat) ----@param angle number # The number of radians the Collider is rotated around its axis of rotation. ----@param ax number # The x component of the axis of rotation. ----@param ay number # The y component of the axis of rotation. ----@param az number # The z component of the axis of rotation. -function Collider:setOrientation(angle, ax, ay, az) end - ---- ----Sets the position and orientation of the Collider. ---- ----@overload fun(self: lovr.Collider, position: lovr.Vec3, orientation: lovr.Quat) ----@param x number # The x position of the Collider, in meters. ----@param y number # The y position of the Collider, in meters. ----@param z number # The z position of the Collider, in meters. ----@param angle number # The number of radians the Collider is rotated around its axis of rotation. ----@param ax number # The x component of the axis of rotation. ----@param ay number # The y component of the axis of rotation. ----@param az number # The z component of the axis of rotation. -function Collider:setPose(x, y, z, angle, ax, ay, az) end - ---- ----Sets the position of the Collider. ---- ----@overload fun(self: lovr.Collider, position: lovr.Vec3) ----@param x number # The x position of the Collider, in meters. ----@param y number # The y position of the Collider, in meters. ----@param z number # The z position of the Collider, in meters. -function Collider:setPosition(x, y, z) end - ---- ----Sets the restitution (bounciness) of the Collider. ---- ----By default, the restitution of two Colliders is combined (the max is used) when they collide to cause them to bounce away from each other. The initial restitution is 0. ---- ----@param restitution number # The new restitution. -function Collider:setRestitution(restitution) end - ---- ----Sets whether the Collider is allowed to sleep. ---- ---- ----### NOTE: ----If sleeping is enabled, the simulation will put the Collider to sleep if it hasn't moved in a while. Sleeping colliders don't impact the physics simulation, which makes updates more efficient and improves physics performance. ---- ----However, the physics engine isn't perfect at waking up sleeping colliders and this can lead to bugs where colliders don't react to forces or collisions properly. ---- ----It is possible to set the default value for new colliders using `World:setSleepingAllowed`. ---- ----Colliders can be manually put to sleep or woken up using `Collider:setAwake`. ---- ----@param allowed boolean # Whether the Collider can go to sleep. -function Collider:setSleepingAllowed(allowed) end - ---- ----Sets the Collider's tag. ---- ---- ----### NOTE: ----Collision between tags can be enabled and disabled using `World:enableCollisionBetween` and `World:disableCollisionBetween`. ---- ----@param tag string # The Collider's collision tag. -function Collider:setTag(tag) end - ---- ----Associates a custom value with the Collider. ---- ---- ----### NOTE: ----User data can be useful to identify the Collider in callbacks. ---- ----@param data any # The custom value to associate with the Collider. -function Collider:setUserData(data) end - ---- ----A type of `Shape` that can be used for cylinder-shaped things. ---- ----@class lovr.CylinderShape -local CylinderShape = {} - ---- ----Returns the length of the CylinderShape. ---- ----@return number length # The length of the cylinder, in meters. -function CylinderShape:getLength() end - ---- ----Returns the radius of the CylinderShape. ---- ----@return number radius # The radius of the cylinder, in meters. -function CylinderShape:getRadius() end - ---- ----Sets the length of the CylinderShape. ---- ----@param length number # The new length, in meters. -function CylinderShape:setLength(length) end - ---- ----Sets the radius of the CylinderShape. ---- ----@param radius number # The new radius, in meters. -function CylinderShape:setRadius(radius) end - ---- ----A DistanceJoint is a type of `Joint` that tries to keep two colliders a fixed distance apart. The distance is determined by the initial distance between the anchor points. ---- ----The joint allows for rotation on the anchor points. ---- ----@class lovr.DistanceJoint -local DistanceJoint = {} - ---- ----Returns the anchor points of the DistanceJoint. ---- ----@return number x1 # The x coordinate of the first anchor point, in world coordinates. ----@return number y1 # The y coordinate of the first anchor point, in world coordinates. ----@return number z1 # The z coordinate of the first anchor point, in world coordinates. ----@return number x2 # The x coordinate of the second anchor point, in world coordinates. ----@return number y2 # The y coordinate of the second anchor point, in world coordinates. ----@return number z2 # The z coordinate of the second anchor point, in world coordinates. -function DistanceJoint:getAnchors() end - ---- ----Returns the target distance for the DistanceJoint. ---- ----The joint tries to keep the Colliders this far apart. ---- ----@return number distance # The target distance. -function DistanceJoint:getDistance() end - ---- ----Returns the response time of the joint. ---- ----See `World:setResponseTime` for more info. ---- ----@return number responseTime # The response time setting for the joint. -function DistanceJoint:getResponseTime() end - ---- ----Returns the tightness of the joint. ---- ----See `World:setTightness` for how this affects the joint. ---- ----@return number tightness # The tightness of the joint. -function DistanceJoint:getTightness() end - ---- ----Sets the anchor points of the DistanceJoint. ---- ----@overload fun(self: lovr.DistanceJoint, first: lovr.Vec3, second: lovr.Vec3) ----@param x1 number # The x coordinate of the first anchor point, in world coordinates. ----@param y1 number # The y coordinate of the first anchor point, in world coordinates. ----@param z1 number # The z coordinate of the first anchor point, in world coordinates. ----@param x2 number # The x coordinate of the second anchor point, in world coordinates. ----@param y2 number # The y coordinate of the second anchor point, in world coordinates. ----@param z2 number # The z coordinate of the second anchor point, in world coordinates. -function DistanceJoint:setAnchors(x1, y1, z1, x2, y2, z2) end - ---- ----Sets the target distance for the DistanceJoint. ---- ----The joint tries to keep the Colliders this far apart. ---- ----@param distance number # The new target distance. -function DistanceJoint:setDistance(distance) end - ---- ----Sets the response time of the joint. ---- ----See `World:setResponseTime` for more info. ---- ----@param responseTime number # The new response time setting for the joint. -function DistanceJoint:setResponseTime(responseTime) end - ---- ----Sets the tightness of the joint. ---- ----See `World:setTightness` for how this affects the joint. ---- ----@param tightness number # The tightness of the joint. -function DistanceJoint:setTightness(tightness) end - ---- ----A HingeJoint is a type of `Joint` that only allows colliders to rotate on a single axis. ---- ----@class lovr.HingeJoint -local HingeJoint = {} - ---- ----Returns the anchor points of the HingeJoint. ---- ----@return number x1 # The x coordinate of the first anchor point, in world coordinates. ----@return number y1 # The y coordinate of the first anchor point, in world coordinates. ----@return number z1 # The z coordinate of the first anchor point, in world coordinates. ----@return number x2 # The x coordinate of the second anchor point, in world coordinates. ----@return number y2 # The y coordinate of the second anchor point, in world coordinates. ----@return number z2 # The z coordinate of the second anchor point, in world coordinates. -function HingeJoint:getAnchors() end - ---- ----Get the angle between the two colliders attached to the HingeJoint. ---- ----When the joint is created or when the anchor or axis is set, the current angle is the new "zero" angle. ---- ----@return number angle # The hinge angle, in radians. -function HingeJoint:getAngle() end - ---- ----Returns the axis of the hinge. ---- ----@return number x # The x component of the axis. ----@return number y # The y component of the axis. ----@return number z # The z component of the axis. -function HingeJoint:getAxis() end - ---- ----Returns the upper and lower limits of the hinge angle. ---- ----These will be between -π and π. ---- ----@return number lower # The lower limit, in radians. ----@return number upper # The upper limit, in radians. -function HingeJoint:getLimits() end - ---- ----Returns the lower limit of the hinge angle. ---- ----This will be greater than -π. ---- ----@return number limit # The lower limit, in radians. -function HingeJoint:getLowerLimit() end - ---- ----Returns the upper limit of the hinge angle. ---- ----This will be less than π. ---- ----@return number limit # The upper limit, in radians. -function HingeJoint:getUpperLimit() end - ---- ----Sets a new anchor point for the HingeJoint. ---- ----@overload fun(self: lovr.HingeJoint, anchor: lovr.Vec3) ----@param x number # The x coordinate of the anchor point, in world coordinates. ----@param y number # The y coordinate of the anchor point, in world coordinates. ----@param z number # The z coordinate of the anchor point, in world coordinates. -function HingeJoint:setAnchor(x, y, z) end - ---- ----Sets the axis of the hinge. ---- ----@overload fun(self: lovr.HingeJoint, axis: lovr.Vec3) ----@param x number # The x component of the axis. ----@param y number # The y component of the axis. ----@param z number # The z component of the axis. -function HingeJoint:setAxis(x, y, z) end - ---- ----Sets the upper and lower limits of the hinge angle. ---- ----These should be between -π and π. ---- ----@param lower number # The lower limit, in radians. ----@param upper number # The upper limit, in radians. -function HingeJoint:setLimits(lower, upper) end - ---- ----Sets the lower limit of the hinge angle. ---- ----This should be greater than -π. ---- ----@param limit number # The lower limit, in radians. -function HingeJoint:setLowerLimit(limit) end - ---- ----Sets the upper limit of the hinge angle. ---- ----This should be less than π. ---- ----@param limit number # The upper limit, in radians. -function HingeJoint:setUpperLimit(limit) end - ---- ----A Joint is a physics object that constrains the movement of two Colliders. ---- ----@class lovr.Joint -local Joint = {} - ---- ----Destroy the Joint, removing it from Colliders it's attached to. ---- ---- ----### NOTE: ----Calling functions on the Joint after destroying it is a bad idea. ---- -function Joint:destroy() end - ---- ----Returns the Colliders the Joint is attached to. ---- ----All Joints are attached to two colliders. ---- ----@return lovr.Collider colliderA # The first Collider. ----@return lovr.Collider colliderB # The second Collider. -function Joint:getColliders() end - ---- ----Returns the type of the Joint. ---- ----@return lovr.JointType type # The type of the Joint. -function Joint:getType() end - ---- ----Returns the user data associated with the Joint. ---- ----@return any data # The custom value associated with the Joint. -function Joint:getUserData() end - ---- ----Returns whether the Joint is enabled. ---- ----@return boolean enabled # Whether the Joint is enabled. -function Joint:isEnabled() end - ---- ----Enable or disable the Joint. ---- ----@param enabled boolean # Whether the Joint should be enabled. -function Joint:setEnabled(enabled) end - ---- ----Sets the user data associated with the Joint. ---- ----@param data any # The custom value associated with the Joint. -function Joint:setUserData(data) end - ---- ----A type of `Shape` that can be used for triangle meshes. ---- ----@class lovr.MeshShape -local MeshShape = {} - ---- ----A Shape is a physics object that can be attached to colliders to define their shape. ---- ----@class lovr.Shape -local Shape = {} - ---- ----Destroy the Shape, removing it from Colliders it's attached to. ---- ---- ----### NOTE: ----Calling functions on the Shape after destroying it is a bad idea. ---- -function Shape:destroy() end - ---- ----Returns the bounding box for the Shape. ---- ----@return number minx # The minimum x coordinate of the box. ----@return number maxx # The maximum x coordinate of the box. ----@return number miny # The minimum y coordinate of the box. ----@return number maxy # The maximum y coordinate of the box. ----@return number minz # The minimum z coordinate of the box. ----@return number maxz # The maximum z coordinate of the box. -function Shape:getAABB() end - ---- ----Returns the Collider the Shape is attached to. ---- ---- ----### NOTE: ----A Shape can only be attached to one Collider at a time. ---- ----@return lovr.Collider collider # The Collider the Shape is attached to. -function Shape:getCollider() end - ---- ----Computes mass properties of the Shape. ---- ----@param density number # The density to use, in kilograms per cubic meter. ----@return number cx # The x position of the center of mass. ----@return number cy # The y position of the center of mass. ----@return number cz # The z position of the center of mass. ----@return number mass # The mass of the Shape. ----@return table inertia # A table containing 6 values of the rotational inertia tensor matrix. The table contains the 3 diagonal elements of the matrix (upper left to bottom right), followed by the 3 elements of the upper right portion of the 3x3 matrix. -function Shape:getMass(density) end - ---- ----Get the orientation of the Shape relative to its Collider. ---- ----@return number angle # The number of radians the Shape is rotated. ----@return number ax # The x component of the rotation axis. ----@return number ay # The y component of the rotation axis. ----@return number az # The z component of the rotation axis. -function Shape:getOrientation() end - ---- ----Get the position of the Shape relative to its Collider. ---- ----@return number x # The x offset. ----@return number y # The y offset. ----@return number z # The z offset. -function Shape:getPosition() end - ---- ----Returns the type of the Shape. ---- ----@return lovr.ShapeType type # The type of the Shape. -function Shape:getType() end - ---- ----Returns the user data associated with the Shape. ---- ---- ----### NOTE: ----User data can be useful to identify the Shape in callbacks. ---- ----@return any data # The custom value associated with the Shape. -function Shape:getUserData() end - ---- ----Returns whether the Shape is enabled. ---- ---- ----### NOTE: ----Disabled shapes won't collide with anything. ---- ----@return boolean enabled # Whether the Shape is enabled. -function Shape:isEnabled() end - ---- ----Returns whether the Shape is a sensor. ---- ----Sensors do not trigger any collision response, but they still report collisions in `World:collide`. ---- ----@return boolean sensor # Whether the Shape is a sensor. -function Shape:isSensor() end - ---- ----Enable or disable the Shape. ---- ---- ----### NOTE: ----Disabled shapes won't collide with anything. ---- ----@param enabled boolean # Whether the Shape should be enabled. -function Shape:setEnabled(enabled) end - ---- ----Set the orientation of the Shape relative to its Collider. ---- ---- ----### NOTE: ----If the Shape isn't attached to a Collider, this will error. ---- ----@overload fun(self: lovr.Shape, orientation: lovr.Quat) ----@param angle number # The number of radians the Shape is rotated. ----@param ax number # The x component of the rotation axis. ----@param ay number # The y component of the rotation axis. ----@param az number # The z component of the rotation axis. -function Shape:setOrientation(angle, ax, ay, az) end - ---- ----Set the position of the Shape relative to its Collider. ---- ---- ----### NOTE: ----If the Shape isn't attached to a Collider, this will error. ---- ----@overload fun(self: lovr.Shape, position: lovr.Vec3) ----@param x number # The x offset. ----@param y number # The y offset. ----@param z number # The z offset. -function Shape:setPosition(x, y, z) end - ---- ----Sets whether this Shape is a sensor. ---- ----When a Shape is a sensor, it will not generate any collision response when it collides with things, but collisions can still be detected with `World:collide` and `World:getContacts`. ---- ----@param sensor boolean # Whether the Shape should be a sensor. -function Shape:setSensor(sensor) end - ---- ----Sets the user data associated with the Shape. ---- ---- ----### NOTE: ----User data can be useful to identify the Shape in callbacks. ---- ----@param data any # The custom value associated with the Shape. -function Shape:setUserData(data) end - ---- ----A SliderJoint is a type of `Joint` that only allows colliders to move on a single axis. ---- ----@class lovr.SliderJoint -local SliderJoint = {} - ---- ----Returns the axis of the slider. ---- ----@return number x # The x component of the axis. ----@return number y # The y component of the axis. ----@return number z # The z component of the axis. -function SliderJoint:getAxis() end - ---- ----Returns the upper and lower limits of the slider position. ---- ----@return number lower # The lower limit. ----@return number upper # The upper limit. -function SliderJoint:getLimits() end - ---- ----Returns the lower limit of the slider position. ---- ----@return number limit # The lower limit. -function SliderJoint:getLowerLimit() end - ---- ----Returns how far the slider joint is extended (zero is the position the slider was created at, positive values are further apart). ---- ----@return number position # The joint position along its axis. -function SliderJoint:getPosition() end - ---- ----Returns the upper limit of the slider position. ---- ----@return number limit # The upper limit. -function SliderJoint:getUpperLimit() end - ---- ----Sets the axis of the slider. ---- ----@overload fun(self: lovr.SliderJoint, axis: lovr.Vec3) ----@param x number # The x component of the axis. ----@param y number # The y component of the axis. ----@param z number # The z component of the axis. -function SliderJoint:setAxis(x, y, z) end - ---- ----Sets the upper and lower limits of the slider position. ---- ----@param lower number # The lower limit. ----@param upper number # The upper limit. -function SliderJoint:setLimits(lower, upper) end - ---- ----Sets the lower limit of the slider position. ---- ----@param limit number # The lower limit. -function SliderJoint:setLowerLimit(limit) end - ---- ----Sets the upper limit of the slider position. ---- ----@param limit number # The upper limit. -function SliderJoint:setUpperLimit(limit) end - ---- ----A type of `Shape` that can be used for spheres. ---- ----@class lovr.SphereShape -local SphereShape = {} - ---- ----Returns the radius of the SphereShape. ---- ----@return number radius # The radius of the sphere, in meters. -function SphereShape:getRadius() end - ---- ----Sets the radius of the SphereShape. ---- ----@param radius number # The radius of the sphere, in meters. -function SphereShape:setRadius(radius) end - ---- ----A type of `Shape` that can be used for terrains and irregular surfaces. ---- ----@class lovr.TerrainShape -local TerrainShape = {} - ---- ----A World is an object that holds the colliders, joints, and shapes in a physics simulation. ---- ---- ----### NOTE: ----Be sure to update the World in `lovr.update` using `World:update`, otherwise everything will stand still. ---- ----@class lovr.World -local World = {} - ---- ----Attempt to collide two shapes. ---- ----Internally this sets up constraint forces to move the shapes' colliders apart if they are touching. ---- ----The colliders won't actually move until `World:update` is called again to advance the physics simulation. ---- ----Collision responses can be customized using friction and restitution (bounciness) parameters, and default to using a mix between the parameters of the two colliders. ---- ----Usually this is called internally by `World:update`, or in a custom collision resolver passed to `World:update`. ---- ----If you want to detect if objects are touching without colliding them, use `World:getContacts` or make one or both of the shapes sensors using `Shape:setSensor`. ---- ---- ----### NOTE: ----For friction, numbers in the range of 0-1 are common, but larger numbers can also be used. ---- ----For restitution, numbers in the range 0-1 should be used. ---- ----This function respects collision tags, so using `World:disableCollisionBetween` and `World:enableCollisionBetween` will change the behavior of this function. ---- ----@param shapeA lovr.Shape # The first shape. ----@param shapeB lovr.Shape # The second shape. ----@param friction? number # The friction parameter for the collision. ----@param restitution? number # The restitution (bounciness) parameter for the collision. ----@return boolean collided # Whether the shapes collided. -function World:collide(shapeA, shapeB, friction, restitution) end - ---- ----Detects which pairs of shapes in the world are near each other and could be colliding. ---- ----After calling this function, the `World:overlaps` iterator can be used to iterate over the overlaps, and `World:collide` can be used to resolve a collision for the shapes (if any). Usually this is called automatically by `World:update`. ---- ---- ----### NOTE: ----This performs the "broad phase" culling of objects in the World, usually using a spatial hash or other acceleration structure like a quad tree or octree. ---- -function World:computeOverlaps() end - ---- ----Destroy the World! ---- ---- ----### NOTE: ----Bad things will happen if you destroy the world and then try to access it or anything that was in it. ---- -function World:destroy() end - ---- ----Disables collision between two collision tags. ---- ---- ----### NOTE: ----Tags must be set up when creating the World, see `lovr.physics.newWorld`. ---- ----By default, collision is enabled between all tags. ---- ----@param tag1 string # The first tag. ----@param tag2 string # The second tag. -function World:disableCollisionBetween(tag1, tag2) end - ---- ----Enables collision between two collision tags. ---- ---- ----### NOTE: ----Tags must be set up when creating the World, see `lovr.physics.newWorld`. ---- ----By default, collision is enabled between all tags. ---- ----@param tag1 string # The first tag. ----@param tag2 string # The second tag. -function World:enableCollisionBetween(tag1, tag2) end - ---- ----Returns the angular damping parameters of the World. ---- ----Angular damping makes things less "spinny", making them slow down their angular velocity over time. ---- ---- ----### NOTE: ----Angular damping can also be set on individual colliders. ---- ----@return number damping # The angular damping. ----@return number threshold # Velocity limit below which the damping is not applied. -function World:getAngularDamping() end - ---- ----Returns a table of all Colliders in the World. ---- ----@overload fun(self: lovr.World, t: table):table ----@return table colliders # A table of `Collider` objects. -function World:getColliders() end - ---- ----Computes collision information between two shapes and returns a list of contacts where the shapes intersect. ---- ----Each contact point consists of a position, a normal vector, and a penetration depth. ---- ---- ----### NOTE: ----This only detects collision information, it does not cause the shapes to collide with each other. ---- ----Use `World:collide` for that. ---- ----This function ignores collision tags. ---- ----@param shapeA lovr.Shape # The first shape. ----@param shapeB lovr.Shape # The second shape. ----@return table contacts # A list of contacts. Each contact consists of 7 numbers: the contact position, the normal vector, and a depth value indicating how far the shapes intersect each other at the contact point (`{ x, y, z, nx, ny, nz, depth }`). -function World:getContacts(shapeA, shapeB) end - ---- ----Returns the gravity of the World. ---- ----@return number xg # The x component of the gravity force. ----@return number yg # The y component of the gravity force. ----@return number zg # The z component of the gravity force. -function World:getGravity() end - ---- ----Returns the linear damping parameters of the World. ---- ----Linear damping is similar to drag or air resistance, slowing down colliders over time as they move. ---- ---- ----### NOTE: ----A linear damping of 0 means colliders won't slow down over time. ---- ----This is the default. ---- ----Linear damping can also be set on individual colliders. ---- ----@return number damping # The linear damping. ----@return number threshold # Velocity limit below which the damping is not applied. -function World:getLinearDamping() end - ---- ----Returns the response time factor of the World. ---- ----The response time controls how relaxed collisions and joints are in the physics simulation, and functions similar to inertia. ---- ----A low response time means collisions are resolved quickly, and higher values make objects more spongy and soft. ---- ----The value can be any positive number. ---- ----It can be changed on a per-joint basis for `DistanceJoint` and `BallJoint` objects. ---- ----@return number responseTime # The response time setting for the World. -function World:getResponseTime() end - ---- ----Returns the step count of the World. ---- ----The step count influences how many steps are taken during a call to `World:update`. ---- ----A higher number of steps will be slower, but more accurate. ---- ----The default step count is 20. ---- ----@return number steps # The step count. -function World:getStepCount() end - ---- ----Returns the list of collision tags used when creating the World. ---- ----@return table tags # A table of collision tags (strings). -function World:getTags() end - ---- ----Returns the tightness of joints in the World. ---- ----The tightness controls how much force is applied to colliders connected by joints. ---- ----With a value of 0, no force will be applied and joints won't have any effect. ---- ----With a tightness of 1, a strong force will be used to try to keep the Colliders constrained. ---- ----A tightness larger than 1 will overcorrect the joints, which can sometimes be desirable. ---- ----Negative tightness values are not supported. ---- ----@return number tightness # The tightness of the World. -function World:getTightness() end - ---- ----Returns whether collisions are currently enabled between two tags. ---- ---- ----### NOTE: ----Tags must be set up when creating the World, see `lovr.physics.newWorld`. ---- ----By default, collision is enabled between all tags. ---- ----@param tag1 string # The first tag. ----@param tag2 string # The second tag. ----@return boolean enabled # Whether or not two colliders with the specified tags will collide. -function World:isCollisionEnabledBetween(tag1, tag2) end - ---- ----Returns whether colliders can go to sleep in the World. ---- ---- ----### NOTE: ----If sleeping is enabled, the World will try to detect colliders that haven't moved for a while and put them to sleep. ---- ----Sleeping colliders don't impact the physics simulation, which makes updates more efficient and improves physics performance. ---- ----However, the physics engine isn't perfect at waking up sleeping colliders and this can lead to bugs where colliders don't react to forces or collisions properly. ---- ----This can be set on individual colliders. ---- ----Colliders can be manually put to sleep or woken up using `Collider:setAwake`. ---- ----@return boolean allowed # Whether colliders can sleep. -function World:isSleepingAllowed() end - ---- ----Adds a new Collider to the World with a BoxShape already attached. ---- ----@overload fun(self: lovr.World, position: lovr.Vec3, size: lovr.Vec3):lovr.Collider ----@param x? number # The x coordinate of the center of the box. ----@param y? number # The y coordinate of the center of the box. ----@param z? number # The z coordinate of the center of the box. ----@param width? number # The total width of the box, in meters. ----@param height? number # The total height of the box, in meters. ----@param depth? number # The total depth of the box, in meters. ----@return lovr.Collider collider # The new Collider. -function World:newBoxCollider(x, y, z, width, height, depth) end - ---- ----Adds a new Collider to the World with a CapsuleShape already attached. ---- ----@overload fun(self: lovr.World, position: lovr.Vec3, radius?: number, length?: number):lovr.Collider ----@param x? number # The x coordinate of the center of the capsule, in meters. ----@param y? number # The y coordinate of the center of the capsule, in meters. ----@param z? number # The z coordinate of the center of the capsule, in meters. ----@param radius? number # The radius of the capsule, in meters. ----@param length? number # The length of the capsule, not including the caps, in meters. ----@return lovr.Collider collider # The new Collider. -function World:newCapsuleCollider(x, y, z, radius, length) end - ---- ----Adds a new Collider to the World. ---- ---- ----### NOTE: ----This function creates a collider without any shapes attached to it, which means it won't collide with anything. ---- ----To add a shape to the collider, use `Collider:addShape`, or use one of the following functions to create the collider: ---- ----- `World:newBoxCollider` ----- `World:newCapsuleCollider` ----- `World:newCylinderCollider` ----- `World:newSphereCollider` ---- ----@overload fun(self: lovr.World, position: lovr.Vec3):lovr.Collider ----@param x? number # The x position of the Collider. ----@param y? number # The y position of the Collider. ----@param z? number # The z position of the Collider. ----@return lovr.Collider collider # The new Collider. -function World:newCollider(x, y, z) end - ---- ----Adds a new Collider to the World with a CylinderShape already attached. ---- ----@overload fun(self: lovr.World, position: lovr.Vec3, radius?: number, length?: number):lovr.Collider ----@param x? number # The x coordinate of the center of the cylinder, in meters. ----@param y? number # The y coordinate of the center of the cylinder, in meters. ----@param z? number # The z coordinate of the center of the cylinder, in meters. ----@param radius? number # The radius of the cylinder, in meters. ----@param length? number # The length of the cylinder, in meters. ----@return lovr.Collider collider # The new Collider. -function World:newCylinderCollider(x, y, z, radius, length) end - ---- ----Adds a new Collider to the World with a MeshShape already attached. ---- ----@overload fun(self: lovr.World, model: lovr.Model):lovr.Collider ----@param vertices table # The table of vertices in the mesh. Each vertex is a table with 3 numbers. ----@param indices table # A table of triangle indices representing how the vertices are connected in the Mesh. ----@return lovr.Collider collider # The new Collider. -function World:newMeshCollider(vertices, indices) end - ---- ----Adds a new Collider to the World with a SphereShape already attached. ---- ----@overload fun(self: lovr.World, position: lovr.Vec3, radius?: number):lovr.Collider ----@param x? number # The x coordinate of the center of the sphere, in meters. ----@param y? number # The y coordinate of the center of the sphere, in meters. ----@param z? number # The z coordinate of the center of the sphere, in meters. ----@param radius? number # The radius of the sphere, in meters. ----@return lovr.Collider collider # The new Collider. -function World:newSphereCollider(x, y, z, radius) end - ---- ----Adds a new Collider to the World with a TerrainShape already attached. ---- ---- ----### NOTE: ----The collider will be positioned at 0, 0, 0. ---- ----Unlike other colliders, it will automatically be set as kinematic when created. ---- ----@overload fun(self: lovr.World, scale: number, heightmap: lovr.Image, stretch?: number):lovr.Collider ----@overload fun(self: lovr.World, scale: number, callback: function, samples?: number):lovr.Collider ----@param scale number # The width and depth of the terrain, in meters. ----@return lovr.Collider collider # The new Collider. -function World:newTerrainCollider(scale) end - ---- ----Returns an iterator that can be used to iterate over "overlaps", or potential collisions between pairs of shapes in the World. ---- ----This should be called after using `World:computeOverlaps` to compute the list of overlaps. Usually this is called automatically by `World:update`. ---- ----@return function iterator # A Lua iterator, usable in a for loop. -function World:overlaps() end - ---- ----Casts a ray through the World, calling a function every time the ray intersects with a Shape. ---- ---- ----### NOTE: ----The callback is passed the shape that was hit, the hit position (in world coordinates), and the normal vector of the hit. ---- ----@overload fun(self: lovr.World, start: lovr.Vec3, end: lovr.Vec3, callback: function) ----@param x1 number # The x coordinate of the starting position of the ray. ----@param y1 number # The y coordinate of the starting position of the ray. ----@param z1 number # The z coordinate of the starting position of the ray. ----@param x2 number # The x coordinate of the ending position of the ray. ----@param y2 number # The y coordinate of the ending position of the ray. ----@param z2 number # The z coordinate of the ending position of the ray. ----@param callback function # The function to call when an intersection is detected. -function World:raycast(x1, y1, z1, x2, y2, z2, callback) end - ---- ----Sets the angular damping of the World. ---- ----Angular damping makes things less "spinny", making them slow down their angular velocity over time. Damping is only applied when angular velocity is over the threshold value. ---- ---- ----### NOTE: ----Angular damping can also be set on individual colliders. ---- ----@param damping number # The angular damping. ----@param threshold? number # Velocity limit below which the damping is not applied. -function World:setAngularDamping(damping, threshold) end - ---- ----Sets the gravity of the World. ---- ----@overload fun(self: lovr.World, gravity: lovr.Vec3) ----@param xg number # The x component of the gravity force. ----@param yg number # The y component of the gravity force. ----@param zg number # The z component of the gravity force. -function World:setGravity(xg, yg, zg) end - ---- ----Sets the linear damping of the World. ---- ----Linear damping is similar to drag or air resistance, slowing down colliders over time as they move. Damping is only applied when linear velocity is over the threshold value. ---- ---- ----### NOTE: ----A linear damping of 0 means colliders won't slow down over time. ---- ----This is the default. ---- ----Linear damping can also be set on individual colliders. ---- ----@param damping number # The linear damping. ----@param threshold? number # Velocity limit below which the damping is not applied. -function World:setLinearDamping(damping, threshold) end - ---- ----Sets the response time factor of the World. ---- ----The response time controls how relaxed collisions and joints are in the physics simulation, and functions similar to inertia. ---- ----A low response time means collisions are resolved quickly, and higher values make objects more spongy and soft. ---- ----The value can be any positive number. ---- ----It can be changed on a per-joint basis for `DistanceJoint` and `BallJoint` objects. ---- ----@param responseTime number # The new response time setting for the World. -function World:setResponseTime(responseTime) end - ---- ----Sets whether colliders can go to sleep in the World. ---- ---- ----### NOTE: ----If sleeping is enabled, the World will try to detect colliders that haven't moved for a while and put them to sleep. ---- ----Sleeping colliders don't impact the physics simulation, which makes updates more efficient and improves physics performance. ---- ----However, the physics engine isn't perfect at waking up sleeping colliders and this can lead to bugs where colliders don't react to forces or collisions properly. ---- ----This can be set on individual colliders. ---- ----Colliders can be manually put to sleep or woken up using `Collider:setAwake`. ---- ----@param allowed boolean # Whether colliders can sleep. -function World:setSleepingAllowed(allowed) end - ---- ----Sets the step count of the World. ---- ----The step count influences how many steps are taken during a call to `World:update`. ---- ----A higher number of steps will be slower, but more accurate. ---- ----The default step count is 20. ---- ----@param steps number # The new step count. -function World:setStepCount(steps) end - ---- ----Sets the tightness of joints in the World. ---- ----The tightness controls how much force is applied to colliders connected by joints. ---- ----With a value of 0, no force will be applied and joints won't have any effect. ---- ----With a tightness of 1, a strong force will be used to try to keep the Colliders constrained. ---- ----A tightness larger than 1 will overcorrect the joints, which can sometimes be desirable. ---- ----Negative tightness values are not supported. ---- ----@param tightness number # The new tightness for the World. -function World:setTightness(tightness) end - ---- ----Updates the World, advancing the physics simulation forward in time and resolving collisions between colliders in the World. ---- ---- ----### NOTE: ----It is common to pass the `dt` variable from `lovr.update` into this function. ---- ----The default collision resolver function is: ---- ---- function defaultResolver(world) ---- world:computeOverlaps() ---- for shapeA, shapeB in world:overlaps() do ---- world:collide(shapeA, shapeB) ---- end ---- end ---- ----Additional logic could be introduced to the collision resolver function to add custom collision behavior or to change the collision parameters (like friction and restitution) on a per-collision basis. ---- ----> If possible, use a fixed timestep value for updating the World. It will greatly improve the ----> accuracy of the simulation and reduce bugs. For more information on implementing a fixed ----> timestep loop, see [this article](http://gafferongames.com/game-physics/fix-your-timestep/). ---- ----@param dt number # The amount of time to advance the simulation forward. ----@param resolver? function # The collision resolver function to use. This will be called before updating to allow for custom collision processing. If absent, a default will be used. -function World:update(dt, resolver) end - ---- ----Represents the different types of physics Joints available. ---- ----@alias lovr.JointType ---- ----A BallJoint. ---- ----| "ball" ---- ----A DistanceJoint. ---- ----| "distance" ---- ----A HingeJoint. ---- ----| "hinge" ---- ----A SliderJoint. ---- ----| "slider" - ---- ----Represents the different types of physics Shapes available. ---- ----@alias lovr.ShapeType ---- ----A BoxShape. ---- ----| "box" ---- ----A CapsuleShape. ---- ----| "capsule" ---- ----A CylinderShape. ---- ----| "cylinder" ---- ----A SphereShape. ---- ----| "sphere" diff --git a/meta/3rd/lovr/library/lovr/system.lua b/meta/3rd/lovr/library/lovr/system.lua deleted file mode 100644 index c0a5b739..00000000 --- a/meta/3rd/lovr/library/lovr/system.lua +++ /dev/null @@ -1,136 +0,0 @@ ----@meta - ---- ----The `lovr.system` provides information about the current platform and hardware. ---- ----@class lovr.system -lovr.system = {} - ---- ----Returns the number of logical cores on the system. ---- ----@return number cores # The number of logical cores on the system. -function lovr.system.getCoreCount() end - ---- ----Returns the position of the mouse. ---- ----@return number x # The x position of the mouse, relative to the top-left of the window. ----@return number y # The y position of the mouse, relative to the top-left of the window. -function lovr.system.getMousePosition() end - ---- ----Returns the x position of the mouse. ---- ----@return number x # The x position of the mouse, relative to the top-left of the window. -function lovr.system.getMouseX() end - ---- ----Returns the y position of the mouse. ---- ----@return number y # The y position of the mouse, relative to the top-left of the window. -function lovr.system.getMouseY() end - ---- ----Returns the current operating system. ---- ----@return string os # Either "Windows", "macOS", "Linux", "Android" or "Web". -function lovr.system.getOS() end - ---- ----Returns the window pixel density. ---- ----High DPI windows will usually return 2.0 to indicate that there are 2 pixels for every window coordinate in each axis. ---- ----On a normal display, 1.0 is returned, indicating that window coordinates match up with pixels 1:1. ---- ----@return number density # The pixel density of the window. -function lovr.system.getWindowDensity() end - ---- ----Returns the dimensions of the desktop window. ---- ---- ----### NOTE: ----If the window is not open, this will return zeros. ---- ----@return number width # The width of the desktop window. ----@return number height # The height of the desktop window. -function lovr.system.getWindowDimensions() end - ---- ----Returns the height of the desktop window. ---- ---- ----### NOTE: ----If the window is not open, this will return zero. ---- ----@return number width # The height of the desktop window. -function lovr.system.getWindowHeight() end - ---- ----Returns the width of the desktop window. ---- ---- ----### NOTE: ----If the window is not open, this will return zero. ---- ----@return number width # The width of the desktop window. -function lovr.system.getWindowWidth() end - ---- ----Returns whether a key on the keyboard is pressed. ---- ----@param key lovr.KeyCode # The key. ----@return boolean down # Whether the key is currently pressed. -function lovr.system.isKeyDown(key) end - ---- ----Returns whether a mouse button is currently pressed. ---- ----@param button number # The index of a button to check. Use 1 for the primary mouse button, 2 for the secondary button, and 3 for the middle button. Other indices can be used, but are hardware-specific. ----@return boolean down # Whether the mouse button is currently down. -function lovr.system.isMouseDown(button) end - ---- ----Returns whether the desktop window is open. ---- ----`t.window` can be set to `nil` in `lovr.conf` to disable automatic opening of the window. ---- ----In this case, the window can be opened manually using `lovr.system.openWindow`. ---- ----@return boolean open # Whether the desktop window is open. -function lovr.system.isWindowOpen() end - ---- ----Opens the desktop window. ---- ----If the window is already open, this function does nothing. ---- ---- ----### NOTE: ----By default, the window is opened automatically, but this can be disabled by setting `t.window` to `nil` in `conf.lua`. ---- ----@param options {width: number, height: number, fullscreen: boolean, resizable: boolean, title: string, icon: string} # Window options. -function lovr.system.openWindow(options) end - ---- ----Requests permission to use a feature. ---- ----Usually this will pop up a dialog box that the user needs to confirm. ---- ----Once the permission request has been acknowledged, the `lovr.permission` callback will be called with the result. ---- ----Currently, this is only used for requesting microphone access on Android devices. ---- ----@param permission lovr.Permission # The permission to request. -function lovr.system.requestPermission(permission) end - ---- ----These are the different permissions that need to be requested using `lovr.system.requestPermission` on some platforms. ---- ----@alias lovr.Permission ---- ----Requests microphone access. ---- ----| "audiocapture" diff --git a/meta/3rd/lovr/library/lovr/thread.lua b/meta/3rd/lovr/library/lovr/thread.lua deleted file mode 100644 index 5b22c9c3..00000000 --- a/meta/3rd/lovr/library/lovr/thread.lua +++ /dev/null @@ -1,170 +0,0 @@ ----@meta - ---- ----The `lovr.thread` module provides functions for creating threads and communicating between them. ---- ----These are operating system level threads, which are different from Lua coroutines. ---- ----Threads are useful for performing expensive background computation without affecting the framerate or performance of the main thread. ---- ----Some examples of this include asset loading, networking and network requests, and physics simulation. ---- ----Threads come with some caveats: ---- ----- Threads run in a bare Lua environment. ---- ----The `lovr` module (and any of lovr's modules) need to ---- be required before they can be used. ---- - To get `require` to work properly, add `require 'lovr.filesystem'` to the thread code. ----- Threads are completely isolated from other threads. ---- ----They do not have access to the variables ---- or functions of other threads, and communication between threads must be coordinated through ---- `Channel` objects. ----- The graphics module (or any functions that perform rendering) cannot be used in a thread. ---- Note that this includes creating graphics objects like Models and Textures. ---- ----There are "data" ---- equivalent `ModelData` and `Image` objects that can be used in threads though. ----- `lovr.event.pump` cannot be called from a thread. ----- Crashes or problems can happen if two threads access the same object at the same time, so ---- special care must be taken to coordinate access to objects from multiple threads. ---- ----@class lovr.thread -lovr.thread = {} - ---- ----Returns a named Channel for communicating between threads. ---- ----@param name string # The name of the Channel to get. ----@return lovr.Channel channel # The Channel with the specified name. -function lovr.thread.getChannel(name) end - ---- ----Creates a new Thread from Lua code. ---- ---- ----### NOTE: ----The Thread won\'t start running immediately. ---- ----Use `Thread:start` to start it. ---- ----The string argument is assumed to be a filename if there isn't a newline in the first 1024 characters. ---- ----For really short thread code, an extra newline can be added to trick LÖVR into loading it properly. ---- ----@overload fun(filename: string):lovr.Thread ----@overload fun(blob: lovr.Blob):lovr.Thread ----@param code string # The code to run in the Thread. ----@return lovr.Thread thread # The new Thread. -function lovr.thread.newThread(code) end - ---- ----A Channel is an object used to communicate between `Thread` objects. ---- ----Channels are obtained by name using `lovr.thread.getChannel`. ---- ----Different threads can send messages on the same Channel to communicate with each other. ---- ----Messages can be sent and received on a Channel using `Channel:push` and `Channel:pop`, and are received in a first-in-first-out fashion. The following types of data can be passed through Channels: nil, boolean, number, string, and any LÖVR object. ---- ----@class lovr.Channel -local Channel = {} - ---- ----Removes all pending messages from the Channel. ---- -function Channel:clear() end - ---- ----Returns whether or not the message with the given ID has been read. ---- ----Every call to `Channel:push` returns a message ID. ---- ----@param id number # The ID of the message to check. ----@return boolean read # Whether the message has been read. -function Channel:hasRead(id) end - ---- ----Returns a message from the Channel without popping it from the queue. ---- ----If the Channel is empty, `nil` is returned. ---- ----This can be useful to determine if the Channel is empty. ---- ---- ----### NOTE: ----The second return value can be used to detect if a `nil` message is in the queue. ---- ----@return any message # The message, or `nil` if there is no message. ----@return boolean present # Whether a message was returned (use to detect nil). -function Channel:peek() end - ---- ----Pops a message from the Channel. ---- ----If the Channel is empty, an optional timeout argument can be used to wait for a message, otherwise `nil` is returned. ---- ---- ----### NOTE: ----Threads can get stuck forever waiting on Channel messages, so be careful. ---- ----@param wait? number # How long to wait for a message to be popped, in seconds. `true` can be used to wait forever and `false` can be used to avoid waiting. ----@return any message # The received message, or `nil` if nothing was received. -function Channel:pop(wait) end - ---- ----Pushes a message onto the Channel. ---- ----The following types of data can be pushed: nil, boolean, number, string, lightuserdata, vectors, and userdata (LÖVR objects). ---- ----Notably, tables are not currently supported and should be serialized to strings. ---- ---- ----### NOTE: ----Threads can get stuck forever waiting on Channel messages, so be careful. ---- ----@param message any # The message to push. ----@param wait? number # How long to wait for the message to be popped, in seconds. `true` can be used to wait forever and `false` can be used to avoid waiting. ----@return number id # The ID of the pushed message. ----@return boolean read # Whether the message was read by another thread before the wait timeout. -function Channel:push(message, wait) end - ---- ----A Thread is an object that runs a chunk of Lua code in the background. ---- ----Threads are completely isolated from other threads, meaning they have their own Lua context and can't access the variables and functions of other threads. ---- ----Communication between threads is limited and is accomplished by using `Channel` objects. ---- ----To get `require` to work properly, add `require 'lovr.filesystem'` to the thread code. ---- ----@class lovr.Thread -local Thread = {} - ---- ----Returns the message for the error that occurred on the Thread, or nil if no error has occurred. ---- ----@return string error # The error message, or `nil` if no error has occurred on the Thread. -function Thread:getError() end - ---- ----Returns whether or not the Thread is currently running. ---- ----@return boolean running # Whether or not the Thread is running. -function Thread:isRunning() end - ---- ----Starts the Thread. ---- ---- ----### NOTE: ----The arguments can be nil, booleans, numbers, strings, or LÖVR objects. ---- ----@param arguments any # Up to 4 arguments to pass to the Thread's function. -function Thread:start(arguments) end - ---- ----Waits for the Thread to complete, then returns. ---- -function Thread:wait() end diff --git a/meta/3rd/lovr/library/lovr/timer.lua b/meta/3rd/lovr/library/lovr/timer.lua deleted file mode 100644 index 4bcb02f1..00000000 --- a/meta/3rd/lovr/library/lovr/timer.lua +++ /dev/null @@ -1,59 +0,0 @@ ----@meta - ---- ----The `lovr.timer` module provides a few functions that deal with time. ---- ----All times are measured in seconds. ---- ----@class lovr.timer -lovr.timer = {} - ---- ----Returns the average delta over the last second. ---- ----@return number delta # The average delta, in seconds. -function lovr.timer.getAverageDelta() end - ---- ----Returns the time between the last two frames. ---- ----This is the same value as the `dt` argument provided to `lovr.update`. ---- ---- ----### NOTE: ----The return value of this function will remain the same until `lovr.timer.step` is called. ---- ----This function should not be used to measure times for game behavior or benchmarking, use `lovr.timer.getTime` for that. ---- ----@return number dt # The delta time, in seconds. -function lovr.timer.getDelta() end - ---- ----Returns the current frames per second, averaged over the last 90 frames. ---- ----@return number fps # The current FPS. -function lovr.timer.getFPS() end - ---- ----Returns the time since some time in the past. ---- ----This can be used to measure the difference between two points in time. ---- ----@return number time # The current time, in seconds. -function lovr.timer.getTime() end - ---- ----Sleeps the application for a specified number of seconds. ---- ----While the game is asleep, no code will be run, no graphics will be drawn, and the window will be unresponsive. ---- ----@param duration number # The number of seconds to sleep for. -function lovr.timer.sleep(duration) end - ---- ----Steps the timer, returning the new delta time. ---- ----This is called automatically in `lovr.run` and it's used to calculate the new `dt` to pass to `lovr.update`. ---- ----@return number delta # The amount of time since the last call to this function, in seconds. -function lovr.timer.step() end |