diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-11-01 21:00:14 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-11-01 21:00:14 +0800 |
commit | dda6b1860cf9e2efbc6b06bad4a6174481c7e5d9 (patch) | |
tree | f307a7c89f2d422e14018aa5b2be4a97f4d93adb | |
parent | 0b81d41fff711a17e0856b55471909808c1a7812 (diff) | |
download | lua-language-server-dda6b1860cf9e2efbc6b06bad4a6174481c7e5d9.zip |
update lovr
-rw-r--r-- | meta/3rd/lovr/library/lovr.audio.lua | 207 | ||||
-rw-r--r-- | meta/3rd/lovr/library/lovr.data.lua | 295 | ||||
-rw-r--r-- | meta/3rd/lovr/library/lovr.graphics.lua | 750 | ||||
-rw-r--r-- | meta/3rd/lovr/library/lovr.lua | 13 | ||||
-rw-r--r-- | meta/3rd/lovr/library/lovr.math.lua | 644 | ||||
-rw-r--r-- | meta/3rd/lovr/library/lovr.physics.lua | 1142 | ||||
-rw-r--r-- | meta/3rd/lovr/library/lovr.thread.lua | 72 | ||||
-rw-r--r-- | tools/lovr-api.lua | 17 |
8 files changed, 3139 insertions, 1 deletions
diff --git a/meta/3rd/lovr/library/lovr.audio.lua b/meta/3rd/lovr/library/lovr.audio.lua index 269e5726..d8b1bd9d 100644 --- a/meta/3rd/lovr/library/lovr.audio.lua +++ b/meta/3rd/lovr/library/lovr.audio.lua @@ -176,6 +176,213 @@ function lovr.audio.start(type) end 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. +--- +---@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 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. +--- +---@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 + +--- +---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. +--- +---@return boolean success # Whether the Source successfully started playing. +function Source:play() end + +--- +---Seeks the Source to the specified position. +--- +---@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. +--- +---@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. +--- +---@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. +--- +---@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 position and orientation of the Source. +--- +---@param x number # The x position of the Source, in meters. +---@param y number # The y position of the Source, in meters. +---@param z number # The z position of the Source, in meters. +---@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, in meters. 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. +--- +---@param x number # The x coordinate. +---@param y number # The y coordinate. +---@param z number # The z coordinate. +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. +--- +---@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. +--- +---@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`. --- ---@class lovr.AudioMaterial diff --git a/meta/3rd/lovr/library/lovr.data.lua b/meta/3rd/lovr/library/lovr.data.lua index a3e75bea..e4ccdbf0 100644 --- a/meta/3rd/lovr/library/lovr.data.lua +++ b/meta/3rd/lovr/library/lovr.data.lua @@ -62,6 +62,301 @@ function lovr.data.newRasterizer(size) end 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. +--- +---@return string data # The Blob's data. +function Blob:getString() 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. +--- +---@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. +--- +---@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. +--- +---@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 = {} + +--- +---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 of the font, in pixels. The advance is how many pixels the font advances horizontally after each glyph is rendered. This does not include kerning. +--- +---@return number advance # The advance of the font, in pixels. +function Rasterizer:getAdvance() 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 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 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 metric of the font, in pixels. +--- +---@return number height # The height of the font, in pixels. +function Rasterizer:getHeight() end + +--- +---Returns the line height metric of the font, in pixels. This is how far apart lines are. +--- +---@return number height # The line height of the font, in pixels. +function Rasterizer:getLineHeight() end + +--- +---Check if the Rasterizer can rasterize a set of glyphs. +--- +---@return boolean hasGlyphs # true if the Rasterizer can rasterize all of the supplied characters, false otherwise. +function Rasterizer:hasGlyphs() 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. +--- +---@return lovr.Blob blob # The Blob instance containing the bytes for the `Sound`. +function Sound:getBlob() 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. +--- +---@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. +--- +---@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(t: table, count: number, srcOffset: number, dstOffset: number):table, number +---@overload fun(blob: lovr.Blob, count: number, srcOffset: number, dstOffset: number):number +---@overload fun(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. +--- +---@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(blob: lovr.Blob, count: number, dstOffset: number, srcOffset: number):number +---@overload fun(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 + +--- ---Sounds can have different numbers of channels, and those channels can map to various speaker layouts. --- ---@class lovr.ChannelLayout diff --git a/meta/3rd/lovr/library/lovr.graphics.lua b/meta/3rd/lovr/library/lovr.graphics.lua index 930c01f5..34aa2876 100644 --- a/meta/3rd/lovr/library/lovr.graphics.lua +++ b/meta/3rd/lovr/library/lovr.graphics.lua @@ -756,6 +756,756 @@ function lovr.graphics.transform(x, y, z, sx, sy, sz, angle, ax, ay, az) end function lovr.graphics.translate(x, y, z) end --- +---A Canvas is also known as a framebuffer or render-to-texture. It allows you to render to a texture instead of directly to the screen. This lets you postprocess or transform the results later before finally rendering them to the screen. +--- +---After creating a Canvas, you can attach Textures to it using `Canvas:setTexture`. +--- +---@class lovr.Canvas +local Canvas = {} + +--- +---Returns the depth buffer used by the Canvas as a Texture. If the Canvas was not created with a readable depth buffer (the `depth.readable` flag in `lovr.graphics.newCanvas`), then this function will return `nil`. +--- +---@return lovr.Texture texture # The depth Texture of the Canvas. +function Canvas:getDepthTexture() end + +--- +---Returns the dimensions of the Canvas, its Textures, and its depth buffer. +--- +---@return number width # The width of the Canvas, in pixels. +---@return number height # The height of the Canvas, in pixels. +function Canvas:getDimensions() end + +--- +---Returns the height of the Canvas, its Textures, and its depth buffer. +--- +---@return number height # The height of the Canvas, in pixels. +function Canvas:getHeight() end + +--- +---Returns the number of multisample antialiasing samples to use when rendering to the Canvas. Increasing this number will make the contents of the Canvas appear more smooth at the cost of performance. It is common to use powers of 2 for this value. +--- +---@return number samples # The number of MSAA samples. +function Canvas:getMSAA() end + +--- +---Returns the set of Textures currently attached to the Canvas. +--- +function Canvas:getTexture() end + +--- +---Returns the width of the Canvas, its Textures, and its depth buffer. +--- +---@return number width # The width of the Canvas, in pixels. +function Canvas:getWidth() end + +--- +---Returns whether the Canvas was created with the `stereo` flag. Drawing something to a stereo Canvas will draw it to two viewports in the left and right half of the Canvas, using transform information from two different eyes. +--- +---@return boolean stereo # Whether the Canvas is stereo. +function Canvas:isStereo() end + +--- +---Returns a new Image containing the contents of a Texture attached to the Canvas. +--- +---@param index? number # The index of the Texture to read from. +---@return lovr.Image image # The new Image. +function Canvas:newImage(index) end + +--- +---Renders to the Canvas using a function. All graphics functions inside the callback will affect the Canvas contents instead of directly rendering to the headset. This can be used in `lovr.update`. +--- +---@param callback function # The function to use to render to the Canvas. +function Canvas:renderTo(callback) end + +--- +---Attaches one or more Textures to the Canvas. When rendering to the Canvas, everything will be drawn to all attached Textures. You can attach different layers of an array, cubemap, or volume texture, and also attach different mipmap levels of Textures. +--- +function Canvas:setTexture() end + +--- +---A Font is an object created from a TTF file. It can be used to render text with `lovr.graphics.print`. +--- +---@class lovr.Font +local Font = {} + +--- +---Returns the maximum distance that any glyph will extend above the Font's baseline. Units are generally in meters, see `Font:getPixelDensity`. +--- +---@return number ascent # The ascent of the Font. +function Font:getAscent() end + +--- +---Returns the baseline of the Font. This is where the characters "rest on", relative to the y coordinate of the drawn text. Units are generally in meters, see `Font:setPixelDensity`. +--- +---@return number baseline # The baseline of the Font. +function Font:getBaseline() end + +--- +---Returns the maximum distance that any glyph will extend below the Font's baseline. Units are generally in meters, see `Font:getPixelDensity` for more information. Note that due to the coordinate system for fonts, this is a negative value. +--- +---@return number descent # The descent of the Font. +function Font:getDescent() end + +--- +---Returns the height of a line of text. Units are in meters, see `Font:setPixelDensity`. +--- +---@return number height # The height of a rendered line of text. +function Font:getHeight() end + +--- +---Returns the current line height multiplier of the Font. The default is 1.0. +--- +---@return number lineHeight # The line height. +function Font:getLineHeight() end + +--- +---Returns the current pixel density for the Font. The default is 1.0. Normally, this is in pixels per meter. When rendering to a 2D texture, the units are pixels. +--- +---@return number pixelDensity # The current pixel density. +function Font:getPixelDensity() end + +--- +---Returns the underlying `Rasterizer` object for a Font. +--- +---@return lovr.Rasterizer rasterizer # The rasterizer. +function Font:getRasterizer() end + +--- +---Returns the width and line count of a string when rendered using the font, taking into account an optional wrap limit. +--- +---@param text string # The text to get the width of. +---@param wrap? number # The width at which to wrap lines, or 0 for no wrap. +---@return number width # The maximum width of any line in the text. +---@return number lines # The number of lines in the wrapped text. +function Font:getWidth(text, wrap) end + +--- +---Returns whether the Font has a set of glyphs. Any combination of strings and numbers (corresponding to character codes) can be specified. This function will return true if the Font is able to render *all* of the glyphs. +--- +---@return boolean has # Whether the Font has the glyphs. +function Font:hasGlyphs() end + +--- +---Sets the line height of the Font, which controls how far lines apart lines are vertically separated. This value is a ratio and the default is 1.0. +--- +---@param lineHeight number # The new line height. +function Font:setLineHeight(lineHeight) end + +--- +---Sets the pixel density for the Font. Normally, this is in pixels per meter. When rendering to a 2D texture, the units are pixels. +--- +---@overload fun() +---@param pixelDensity number # The new pixel density. +function Font:setPixelDensity(pixelDensity) end + +--- +---A Material is an object used to control how objects appear, through coloring, texturing, and shading. The Material itself holds sets of colors, textures, and other parameters that are made available to Shaders. +--- +---@class lovr.Material +local Material = {} + +--- +---Returns a color property for a Material. Different types of colors are supported for different lighting parameters. Colors default to `(1.0, 1.0, 1.0, 1.0)` and are gamma corrected. +--- +---@param colorType? lovr.MaterialColor # The type of color to get. +---@return number r # The red component of the color. +---@return number g # The green component of the color. +---@return number b # The blue component of the color. +---@return number a # The alpha component of the color. +function Material:getColor(colorType) end + +--- +---Returns a numeric property of a Material. Scalar properties default to 1.0. +--- +---@param scalarType lovr.MaterialScalar # The type of property to get. +---@return number x # The value of the property. +function Material:getScalar(scalarType) end + +--- +---Returns a texture for a Material. Several predefined `MaterialTexture`s are supported. Any texture that is `nil` will use a single white pixel as a fallback. +--- +---@param textureType? lovr.MaterialTexture # The type of texture to get. +---@return lovr.Texture texture # The texture that is set, or `nil` if no texture is set. +function Material:getTexture(textureType) end + +--- +---Returns the transformation applied to texture coordinates of the Material. +--- +---@return number ox # The texture coordinate x offset. +---@return number oy # The texture coordinate y offset. +---@return number sx # The texture coordinate x scale. +---@return number sy # The texture coordinate y scale. +---@return number angle # The texture coordinate rotation, in radians. +function Material:getTransform() end + +--- +---Sets a color property for a Material. Different types of colors are supported for different lighting parameters. Colors default to `(1.0, 1.0, 1.0, 1.0)` and are gamma corrected. +--- +---@overload fun(r: number, g: number, b: number, a: number) +---@overload fun(colorType: lovr.MaterialColor, hex: number, a: number) +---@overload fun(hex: number, a: number) +---@param colorType? lovr.MaterialColor # The type of color to set. +---@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 Material:setColor(colorType, r, g, b, a) end + +--- +---Sets a numeric property of a Material. Scalar properties default to 1.0. +--- +---@param scalarType lovr.MaterialScalar # The type of property to set. +---@param x number # The value of the property. +function Material:setScalar(scalarType, x) end + +--- +---Sets a texture for a Material. Several predefined `MaterialTexture`s are supported. Any texture that is `nil` will use a single white pixel as a fallback. +--- +---@overload fun(texture: lovr.Texture) +---@param textureType? lovr.MaterialTexture # The type of texture to set. +---@param texture lovr.Texture # The texture to apply, or `nil` to use the default. +function Material:setTexture(textureType, texture) end + +--- +---Sets the transformation applied to texture coordinates of the Material. This lets you offset, scale, or rotate textures as they are applied to geometry. +--- +---@param ox number # The texture coordinate x offset. +---@param oy number # The texture coordinate y offset. +---@param sx number # The texture coordinate x scale. +---@param sy number # The texture coordinate y scale. +---@param angle number # The texture coordinate rotation, in radians. +function Material:setTransform(ox, oy, sx, sy, angle) end + +--- +---A Mesh is a low-level graphics object that stores and renders a list of vertices. +--- +---Meshes are really flexible since you can pack pretty much whatever you want in them. This makes them great for rendering arbitrary geometry, but it also makes them kinda difficult to use since you have to place each vertex yourself. +--- +---It's possible to batch geometry with Meshes too. Instead of drawing a shape 100 times, it's much faster to pack 100 copies of the shape into a Mesh and draw the Mesh once. Even storing just one copy in the Mesh and drawing that 100 times is usually faster. +--- +---Meshes are also a good choice if you have an object that changes its shape over time. +--- +---@class lovr.Mesh +local Mesh = {} + +--- +---Attaches attributes from another Mesh onto this one. This can be used to share vertex data across multiple meshes without duplicating the data, and can also be used for instanced rendering by using the `divisor` parameter. +--- +---@overload fun(mesh: lovr.Mesh, divisor: number, ...) +---@overload fun(mesh: lovr.Mesh, divisor: number, attributes: table) +---@param mesh lovr.Mesh # The Mesh to attach attributes from. +---@param divisor? number # The attribute divisor for all attached attributes. +function Mesh:attachAttributes(mesh, divisor) end + +--- +---Detaches attributes that were attached using `Mesh:attachAttributes`. +--- +---@overload fun(mesh: lovr.Mesh, ...) +---@overload fun(mesh: lovr.Mesh, attributes: table) +---@param mesh lovr.Mesh # A Mesh. The names of all of the attributes from this Mesh will be detached. +function Mesh:detachAttributes(mesh) end + +--- +---Draws the contents of the Mesh. +--- +---@overload fun(transform: lovr.mat4, instances: number) +---@param x? number # The x coordinate to draw the Mesh at. +---@param y? number # The y coordinate to draw the Mesh at. +---@param z? number # The z coordinate to draw the Mesh at. +---@param scale? number # The scale to draw the Mesh at. +---@param angle? number # The angle to rotate the Mesh around the axis of 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 instances? number # The number of copies of the Mesh to draw. +function Mesh:draw(x, y, z, scale, angle, ax, ay, az, instances) end + +--- +---Get the draw mode of the Mesh, which controls how the vertices are connected together. +--- +---@return lovr.DrawMode mode # The draw mode of the Mesh. +function Mesh:getDrawMode() end + +--- +---Retrieve the current draw range for the Mesh. The draw range is a subset of the vertices of the Mesh that will be drawn. +--- +---@return number start # The index of the first vertex that will be drawn, or nil if no draw range is set. +---@return number count # The number of vertices that will be drawn, or nil if no draw range is set. +function Mesh:getDrawRange() end + +--- +---Get the Material applied to the Mesh. +--- +---@return lovr.Material material # The current material applied to the Mesh. +function Mesh:getMaterial() end + +--- +---Gets the data for a single vertex in the Mesh. The set of data returned depends on the Mesh's vertex format. The default vertex format consists of 8 floating point numbers: the vertex position, the vertex normal, and the texture coordinates. +--- +---@param index number # The index of the vertex to retrieve. +function Mesh:getVertex(index) end + +--- +---Returns the components of a specific attribute of a single vertex in the Mesh. +--- +---@param index number # The index of the vertex to retrieve the attribute of. +---@param attribute number # The index of the attribute to retrieve the components of. +function Mesh:getVertexAttribute(index, attribute) end + +--- +---Returns the maximum number of vertices the Mesh can hold. +--- +---@return number size # The number of vertices the Mesh can hold. +function Mesh:getVertexCount() end + +--- +---Get the format table of the Mesh's vertices. The format table describes the set of data that each vertex contains. +--- +---@return table format # The table of vertex attributes. Each attribute is a table containing the name of the attribute, the `AttributeType`, and the number of components. +function Mesh:getVertexFormat() end + +--- +---Returns the current vertex map for the Mesh. The vertex map is a list of indices in the Mesh, allowing the reordering or reuse of vertices. +--- +---@overload fun(t: table):table +---@overload fun(blob: lovr.Blob) +---@return table map # The list of indices in the vertex map, or `nil` if no vertex map is set. +function Mesh:getVertexMap() end + +--- +---Returns whether or not a vertex attribute is enabled. Disabled attributes won't be sent to shaders. +--- +---@param attribute string # The name of the attribute. +---@return boolean enabled # Whether or not the attribute is enabled when drawing the Mesh. +function Mesh:isAttributeEnabled(attribute) end + +--- +---Sets whether a vertex attribute is enabled. Disabled attributes won't be sent to shaders. +--- +---@param attribute string # The name of the attribute. +---@param enabled boolean # Whether or not the attribute is enabled when drawing the Mesh. +function Mesh:setAttributeEnabled(attribute, enabled) end + +--- +---Set a new draw mode for the Mesh. +--- +---@param mode lovr.DrawMode # The new draw mode for the Mesh. +function Mesh:setDrawMode(mode) end + +--- +---Set the draw range for the Mesh. The draw range is a subset of the vertices of the Mesh that will be drawn. +--- +---@overload fun() +---@param start number # The first vertex that will be drawn. +---@param count number # The number of vertices that will be drawn. +function Mesh:setDrawRange(start, count) end + +--- +---Applies a Material to the Mesh. This will cause it to use the Material's properties whenever it is rendered. +--- +---@param material lovr.Material # The Material to apply. +function Mesh:setMaterial(material) end + +--- +---Update a single vertex in the Mesh. +--- +---@param index number # The index of the vertex to set. +function Mesh:setVertex(index) end + +--- +---Set the components of a specific attribute of a vertex in the Mesh. +--- +---@param index number # The index of the vertex to update. +---@param attribute number # The index of the attribute to update. +function Mesh:setVertexAttribute(index, attribute) end + +--- +---Sets the vertex map. The vertex map is a list of indices in the Mesh, allowing the reordering or reuse of vertices. +--- +---Often, a vertex map is used to improve performance, since it usually requires less data to specify the index of a vertex than it does to specify all of the data for a vertex. +--- +---@overload fun(blob: lovr.Blob, size: number) +---@param map table # The new vertex map. Each element of the table is an index of a vertex. +function Mesh:setVertexMap(map) end + +--- +---Updates multiple vertices in the Mesh. +--- +---@overload fun(blob: lovr.Blob, start: number, count: number) +---@param vertices table # The new set of vertices. +---@param start? number # The index of the vertex to start replacing at. +---@param count? number # The number of vertices to replace. If nil, all vertices will be used. +function Mesh:setVertices(vertices, start, count) end + +--- +---A Model is a drawable object loaded from a 3D file format. The supported 3D file formats are OBJ, glTF, and STL. +--- +---@class lovr.Model +local Model = {} + +--- +---Applies an animation to the current pose of the Model. +--- +---The animation is evaluated at the specified timestamp, and mixed with the current pose of the Model using the alpha value. An alpha value of 1.0 will completely override the pose of the Model with the animation's pose. +--- +---@overload fun(index: number, time: number, alpha: number) +---@param name string # The name of an animation. +---@param time number # The timestamp to evaluate the keyframes at, in seconds. +---@param alpha? number # How much of the animation to mix in, from 0 to 1. +function Model:animate(name, time, alpha) end + +--- +---Draw the Model. +--- +---@overload fun(transform: lovr.mat4, instances: number) +---@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 to draw the Model at. +---@param angle? number # The angle to rotate the Model around the axis of 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 instances? number # The number of copies of the Model to draw. +function Model:draw(x, y, z, scale, angle, ax, ay, az, instances) end + +--- +---Returns a bounding box that encloses the vertices of the Model. +--- +---@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 Model:getAABB() 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. +--- +function Model:getAnimationDuration() end + +--- +---Returns the name of one of the animations in the Model. +--- +---@param index number # The index of the animation to get the name of. +---@return string name # The name of the animation. +function Model:getAnimationName(index) end + +--- +---Returns a Material loaded from the Model, by name or index. +--- +---This includes `Texture` objects and other properties like colors, metalness/roughness, and more. +--- +---@overload fun(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 one of the materials in the Model. +--- +---@param index number # The index of the material to get the name of. +---@return string name # The name of the material. +function Model:getMaterialName(index) end + +--- +---Returns the number of nodes (bones) in the Model. +--- +---@return number count # The number of nodes in the Model. +function Model:getNodeCount() end + +--- +---Returns the name of one of the nodes (bones) in the Model. +--- +---@param index number # The index of the node to get the name of. +---@return string name # The name of the node. +function Model:getNodeName(index) end + +--- +---Returns the pose of a single node in the Model in a given `CoordinateSpace`. +--- +---@overload fun(index: number, space: lovr.CoordinateSpace):number, number, number, number, number, number, number +---@param name string # The name of the node. +---@param space? lovr.CoordinateSpace # Whether the pose should be returned relative to the node's parent or relative to the root node of the Model. +---@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 rotational axis. +---@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(name, space) 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. +--- +---@return table vertices # A flat table of numbers containing vertex positions. +---@return table indices # A flat table of numbers containing triangle vertex indices. +function Model:getTriangles() end + +--- +---Returns whether the Model has any nodes associated with animated joints. This can be used to approximately determine whether an animated shader needs to be used with an arbitrary Model. +--- +---@return boolean skeletal # Whether the Model has any nodes that use skeletal animation. +function Model:hasJoints() end + +--- +---Applies a pose to a single node of the Model. The input pose is assumed to be relative to the pose of the node's parent. This is useful for applying inverse kinematics (IK) to a chain of bones in a skeleton. +--- +---The alpha parameter can be used to mix between the node's current pose and the input pose. +--- +---@overload fun(index: number, x: number, y: number, z: number, angle: number, ax: number, ay: number, az: number, alpha: number) +---@overload fun() +---@param name string # The name of the node. +---@param x number # The x position. +---@param y number # The y position. +---@param z number # The z position. +---@param angle number # The angle of rotation around the axis, in radians. +---@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. +---@param alpha? number # How much of the pose to mix in, from 0 to 1. +function Model:pose(name, x, y, z, angle, ax, ay, az, alpha) end + +--- +---Shaders are GLSL programs that transform the way vertices and pixels show up on the screen. They can be used for lighting, postprocessing, particles, animation, and much more. You can use `lovr.graphics.setShader` to change the active Shader. +--- +---@class lovr.Shader +local Shader = {} + +--- +---Returns the type of the Shader, which will be "graphics" or "compute". +--- +---Graphics shaders are created with `lovr.graphics.newShader` and can be used for rendering with `lovr.graphics.setShader`. Compute shaders are created with `lovr.graphics.newComputeShader` and can be run using `lovr.graphics.compute`. +--- +---@return lovr.ShaderType type # The type of the Shader. +function Shader:getType() end + +--- +---Returns whether a Shader has a block. +--- +---A block is added to the Shader code at creation time using `ShaderBlock:getShaderCode`. The block name (not the namespace) is used to link up the ShaderBlock object to the Shader. This function can be used to check if a Shader was created with a block using the given name. +--- +---@param block string # The name of the block. +---@return boolean present # Whether the shader has the specified block. +function Shader:hasBlock(block) end + +--- +---Returns whether a Shader has a particular uniform variable. +--- +---@param uniform string # The name of the uniform variable. +---@return boolean present # Whether the shader has the specified uniform. +function Shader:hasUniform(uniform) end + +--- +---Updates a uniform variable in the Shader. +--- +---@param uniform string # The name of the uniform to update. +---@param value lovr.* # The new value of the uniform. +---@return boolean success # Whether the uniform exists and was updated. +function Shader:send(uniform, value) end + +--- +---Sends a ShaderBlock to a Shader. After the block is sent, you can update the data in the block without needing to resend the block. The block can be sent to multiple shaders and they will all see the same data from the block. +--- +---@param name string # The name of the block to send to. +---@param block lovr.ShaderBlock # The ShaderBlock to associate with the specified block. +---@param access? lovr.UniformAccess # How the Shader will use this block (used as an optimization hint). +function Shader:sendBlock(name, block, access) end + +--- +---Sends a Texture to a Shader for writing. This is meant to be used with compute shaders and only works with uniforms declared as `image2D`, `imageCube`, `image2DArray`, and `image3D`. The normal `Shader:send` function accepts Textures and should be used most of the time. +--- +---@overload fun(name: string, index: number, texture: lovr.Texture, slice: number, mipmap: number, access: lovr.UniformAccess) +---@param name string # The name of the image uniform. +---@param texture lovr.Texture # The Texture to assign. +---@param slice? number # The slice of a cube, array, or volume texture to use, or `nil` for all slices. +---@param mipmap? number # The mipmap of the texture to use. +---@param access? lovr.UniformAccess # Whether the image will be read from, written to, or both. +function Shader:sendImage(name, texture, slice, mipmap, access) end + +--- +---ShaderBlocks are objects that can hold large amounts of data and can be sent to Shaders. It is common to use "uniform" variables to send data to shaders, but uniforms are usually limited to a few kilobytes in size. ShaderBlocks are useful for a few reasons: +--- +---- They can hold a lot more data. +---- Shaders can modify the data in them, which is really useful for compute shaders. +---- Setting the data in a ShaderBlock updates the data for all Shaders using the block, so you +--- don't need to go around setting the same uniforms in lots of different shaders. +--- +---On systems that support compute shaders, ShaderBlocks can optionally be "writable". A writable ShaderBlock is a little bit slower than a non-writable one, but shaders can modify its contents and it can be much, much larger than a non-writable ShaderBlock. +--- +---@class lovr.ShaderBlock +local ShaderBlock = {} + +--- +---Returns the byte offset of a variable in a ShaderBlock. This is useful if you want to manually send binary data to the ShaderBlock using a `Blob` in `ShaderBlock:send`. +--- +---@param field string # The name of the variable to get the offset of. +---@return number offset # The byte offset of the variable. +function ShaderBlock:getOffset(field) end + +--- +---Before a ShaderBlock can be used in a Shader, the Shader has to have the block's variables defined in its source code. This can be a tedious process, so you can call this function to return a GLSL string that contains this definition. Roughly, it will look something like this: +--- +--- layout(std140) uniform <label> { +--- <type> <name>[<count>]; +--- } <namespace>; +--- +---@param label string # The label of the block in the shader code. This will be used to identify it when using `Shader:sendBlock`. +---@param namespace? string # The namespace to use when accessing the block's variables in the shader code. This can be used to prevent naming conflicts if two blocks have variables with the same name. If the namespace is nil, the block's variables will be available in the global scope. +---@return string code # The code that can be prepended to `Shader` code. +function ShaderBlock:getShaderCode(label, namespace) end + +--- +---Returns the size of the ShaderBlock's data, in bytes. +--- +---@return number size # The size of the ShaderBlock, in bytes. +function ShaderBlock:getSize() end + +--- +---Returns the type of the ShaderBlock. +--- +---@return lovr.BlockType type # The type of the ShaderBlock. +function ShaderBlock:getType() end + +--- +---Returns a variable in the ShaderBlock. +--- +---@param name string # The name of the variable to read. +---@return lovr.* value # The value of the variable. +function ShaderBlock:read(name) end + +--- +---Updates a variable in the ShaderBlock. +--- +---@overload fun(blob: lovr.Blob, offset: number, extent: number):number +---@param variable string # The name of the variable to update. +---@param value lovr.* # The new value of the uniform. +function ShaderBlock:send(variable, value) end + +--- +---A Texture is an image that can be applied to `Material`s. The supported file formats are `.png`, `.jpg`, `.hdr`, `.dds`, `.ktx`, and `.astc`. DDS and ASTC are compressed formats, which are recommended because they're smaller and faster. +--- +---@class lovr.Texture +local Texture = {} + +--- +---Returns the compare mode for the texture. +--- +---@return lovr.CompareMode compareMode # The current compare mode, or `nil` if none is set. +function Texture:getCompareMode() end + +--- +---Returns the depth of the Texture, or the number of images stored in the Texture. +--- +---@param mipmap? number # The mipmap level to get the depth of. This is only valid for volume textures. +---@return number depth # The depth of the Texture. +function Texture:getDepth(mipmap) end + +--- +---Returns the dimensions of the Texture. +--- +---@param mipmap? number # The mipmap level to get the dimensions of. +---@return number width # The width of the Texture, in pixels. +---@return number height # The height of the Texture, in pixels. +---@return number depth # The number of images stored in the Texture, for non-2D textures. +function Texture:getDimensions(mipmap) end + +--- +---Returns the current FilterMode for the Texture. +--- +---@return lovr.FilterMode mode # The filter mode for the Texture. +---@return number anisotropy # The level of anisotropic filtering. +function Texture:getFilter() end + +--- +---Returns the format of the Texture. This describes how many color channels are in the texture as well as the size of each one. The most common format used is `rgba`, which contains red, green, blue, and alpha color channels. See `TextureFormat` for all of the possible formats. +--- +---@return lovr.TextureFormat format # The format of the Texture. +function Texture:getFormat() end + +--- +---Returns the height of the Texture. +--- +---@param mipmap? number # The mipmap level to get the height of. +---@return number height # The height of the Texture, in pixels. +function Texture:getHeight(mipmap) end + +--- +---Returns the number of mipmap levels of the Texture. +--- +---@return number mipmaps # The number of mipmap levels in the Texture. +function Texture:getMipmapCount() 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. +--- +---@param mipmap? number # The mipmap level to get the width of. +---@return number width # The width of the Texture, in pixels. +function Texture:getWidth(mipmap) end + +--- +---Returns the current WrapMode for the Texture. +--- +---@return lovr.WrapMode horizontal # How the texture wraps horizontally. +---@return lovr.WrapMode vertical # How the texture wraps vertically. +function Texture:getWrap() end + +--- +---Replaces pixels in the Texture, sourcing from an `Image` object. +--- +---@param image lovr.Image # The Image containing the pixels to use. Currently, the Image needs to have the same dimensions as the source Texture. +---@param x? number # The x offset to replace at. +---@param y? number # The y offset to replace at. +---@param slice? number # The slice to replace. Not applicable for 2D textures. +---@param mipmap? number # The mipmap to replace. +function Texture:replacePixels(image, x, y, slice, mipmap) end + +--- +---Sets the compare mode for a texture. This is only used for "shadow samplers", which are uniform variables in shaders with type `sampler2DShadow`. Sampling a shadow sampler uses a sort of virtual depth test, and the compare mode of the texture is used to control how the depth test is performed. +--- +---@param compareMode? lovr.CompareMode # The new compare mode. Use `nil` to disable the compare mode. +function Texture:setCompareMode(compareMode) end + +--- +---Sets the `FilterMode` used by the texture. +--- +---@param mode lovr.FilterMode # The filter mode. +---@param anisotropy number # The level of anisotropy to use. +function Texture:setFilter(mode, anisotropy) end + +--- +---Sets the wrap mode of a texture. The wrap mode controls how the texture is sampled when texture coordinates lie outside the usual 0 - 1 range. The default for both directions is `repeat`. +--- +---@param horizontal lovr.WrapMode # How the texture should wrap horizontally. +---@param vertical? lovr.WrapMode # How the texture should wrap vertically. +function Texture:setWrap(horizontal, vertical) end + +--- ---Different ways arcs can be drawn with `lovr.graphics.arc`. --- ---@class lovr.ArcMode diff --git a/meta/3rd/lovr/library/lovr.lua b/meta/3rd/lovr/library/lovr.lua index 4d95e9c2..00a8f4b7 100644 --- a/meta/3rd/lovr/library/lovr.lua +++ b/meta/3rd/lovr/library/lovr.lua @@ -13,3 +13,16 @@ lovr = {} ---@return number minor # The minor version. ---@return number patch # The patch number. function lovr.getVersion() end + +--- +---This is not a real object, but describes the behavior shared by all objects. Think of it as 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 to check if a LÖVR object is an instance of "Blob", you can do `tostring(object) == 'Blob'`. +--- +---@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. +--- +function Object:release() end diff --git a/meta/3rd/lovr/library/lovr.math.lua b/meta/3rd/lovr/library/lovr.math.lua index 96a138f3..ddde6df1 100644 --- a/meta/3rd/lovr/library/lovr.math.lua +++ b/meta/3rd/lovr/library/lovr.math.lua @@ -145,3 +145,647 @@ function lovr.math.vec3() end ---Creates a temporary 4D vector. This function takes the same arguments as `Vec4:set`. --- function lovr.math.vec4() 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 `lovr.graphics.points` or `lovr.graphics.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. +--- +---@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. +--- +---@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. +--- +---@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. +--- +---@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. +--- +---@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. +--- +---@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. +--- +---@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. +--- +---@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 = {} + +--- +---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 of the projection. +---@return lovr.Mat4 m # The original 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 m # The original matrix. +function Mat4:identity() end + +--- +---Inverts the matrix, causing it to represent the opposite of its old transform. +--- +---@return lovr.Mat4 m # The original 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 m # The original 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. +--- +---@overload fun(v3: lovr.Vec3):lovr.Vec3 +---@overload fun(v4: lovr.Vec4):lovr.Vec4 +---@param n lovr.Mat4 # The matrix. +---@return lovr.Mat4 m # The original matrix, containing the result. +function Mat4:mul(n) end + +--- +---Sets this matrix to represent an orthographic projection, useful for 2D/isometric rendering. +--- +---This can be used with `lovr.graphics.setProjection`, or it can be sent to a `Shader` for use in GLSL. +--- +---@param left number # The left edge of the projection. +---@param right number # The right edge of the projection. +---@param top number # The top edge of the projection. +---@param bottom number # The bottom 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 m # The original matrix. +function Mat4:orthographic(left, right, top, bottom, near, far) end + +--- +---Sets this matrix to represent a perspective projection. +--- +---This can be used with `lovr.graphics.setProjection`, or it can be sent to a `Shader` for use in GLSL. +--- +---@param near number # The near plane. +---@param far number # The far plane. +---@param fov number # The vertical field of view (in radians). +---@param aspect number # The horizontal aspect ratio of the projection (width / height). +---@return lovr.Mat4 m # The original matrix. +function Mat4:perspective(near, far, fov, aspect) end + +--- +---Rotates the matrix using a quaternion or an angle/axis rotation. +--- +---@overload fun(angle: number, ax: number, ay: number, az: number):lovr.Mat4 +---@param q lovr.Quat # The rotation to apply to the matrix. +---@return lovr.Mat4 m # The original matrix. +function Mat4:rotate(q) end + +--- +---Scales the matrix. +--- +---@overload fun(sx: number, sy: number, sz: number):lovr.Mat4 +---@param scale lovr.Vec3 # The 3D scale to apply. +---@return lovr.Mat4 m # The original 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(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 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 torwards 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 m # The original matrix. +function Mat4:target(from, to, up) end + +--- +---Translates the matrix. +--- +---@overload fun(x: number, y: number, z: number):lovr.Mat4 +---@param v lovr.Vec3 # The translation vector. +---@return lovr.Mat4 m # The original matrix. +function Mat4:translate(v) end + +--- +---Transposes the matrix, mirroring its values along the diagonal. +--- +---@return lovr.Mat4 m # The original 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 q # The original 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 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(v3: lovr.vec3):lovr.vec3 +---@param r lovr.quat # A quaternion to combine with the original. +---@return lovr.quat q # The original quaternion. +function Quat:mul(r) end + +--- +---Adjusts the values in the quaternion so that its length becomes 1. +--- +---@return lovr.Quat q # The original 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(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? lovr.angle # 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 q # The original 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 q # The original 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. +--- +---@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. +--- +---@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(high: number):number +---@overload fun(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. +--- +function RandomGenerator:setSeed() 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. +--- +---@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(x: number, y: number):lovr.Vec2 +---@param u lovr.Vec2 # The other vector. +---@return lovr.Vec2 v # The original vector. +function Vec2:add(u) end + +--- +---Returns the distance to another vector. +--- +---@overload fun(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(x: number, y: number):lovr.Vec2 +---@param u lovr.Vec2 # The other vector to divide the components by. +---@return lovr.Vec2 v # The original vector. +function Vec2:div(u) end + +--- +---Returns the dot product between this vector and another one. +--- +---@overload fun(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 the length of the vector. +--- +---@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(x: number, y: number):lovr.Vec2 +---@return lovr.Vec2 v # The original vector, containing the new lerped values. +function Vec2:lerp() end + +--- +---Multiplies the vector by a vector or a number. +--- +---@overload fun(x: number, y: number):lovr.Vec2 +---@param u lovr.Vec2 # The other vector to multiply the components by. +---@return lovr.Vec2 v # The original 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 v # The original vector. +function Vec2:normalize() end + +--- +---Sets the components of the vector, either from numbers or an existing vector. +--- +---@overload fun(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(x: number, y: number):lovr.Vec2 +---@param u lovr.Vec2 # The other vector. +---@return lovr.Vec2 v # The original 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(x: number, y: number, z: number):lovr.Vec3 +---@param u lovr.Vec3 # The other vector. +---@return lovr.Vec3 v # The original vector. +function Vec3:add(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`. +--- +---@overload fun(x: number, y: number, z: number):lovr.Vec3 +---@param u lovr.Vec3 # The vector to compute the cross product with. +---@return lovr.Vec3 v # The original vector, with the cross product as its values. +function Vec3:cross(u) end + +--- +---Returns the distance to another vector. +--- +---@overload fun(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(x: number, y: number, z: number):lovr.Vec3 +---@param u lovr.Vec3 # The other vector to divide the components by. +---@return lovr.Vec3 v # The original vector. +function Vec3:div(u) end + +--- +---Returns the dot product between this vector and another one. +--- +---@overload fun(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 the length of the vector. +--- +---@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(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 v # The original vector, containing the new lerped values. +function Vec3:lerp(u, t) end + +--- +---Multiplies the vector by a vector or a number. +--- +---@overload fun(x: number, y: number, z: number):lovr.Vec3 +---@param u lovr.Vec3 # The other vector to multiply the components by. +---@return lovr.Vec3 v # The original 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 v # The original vector. +function Vec3:normalize() end + +--- +---Sets the components of the vector, either from numbers or an existing vector. +--- +---@overload fun(u: lovr.Vec3):lovr.Vec3 +---@overload fun(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(x: number, y: number, z: number):lovr.Vec3 +---@param u lovr.Vec3 # The other vector. +---@return lovr.Vec3 v # The original 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(x: number, y: number, z: number, w: number):lovr.Vec4 +---@param u lovr.Vec4 # The other vector. +---@return lovr.Vec4 v # The original vector. +function Vec4:add(u) end + +--- +---Returns the distance to another vector. +--- +---@overload fun(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(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 v # The original vector. +function Vec4:div(u) end + +--- +---Returns the dot product between this vector and another one. +--- +---@overload fun(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 the length of the vector. +--- +---@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(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 v # The original vector, containing the new lerped values. +function Vec4:lerp(u, t) end + +--- +---Multiplies the vector by a vector or a number. +--- +---@overload fun(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 v # The original 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 v # The original vector. +function Vec4:normalize() end + +--- +---Sets the components of the vector, either from numbers or an existing vector. +--- +---@overload fun(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(x: number, y: number, z: number, w: number):lovr.Vec4 +---@param u lovr.Vec4 # The other vector. +---@return lovr.Vec4 v # The original 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. +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. +--- +---@class lovr.Vectors +local Vectors = {} diff --git a/meta/3rd/lovr/library/lovr.physics.lua b/meta/3rd/lovr/library/lovr.physics.lua index a1c69740..9bb7e633 100644 --- a/meta/3rd/lovr/library/lovr.physics.lua +++ b/meta/3rd/lovr/library/lovr.physics.lua @@ -100,6 +100,1148 @@ function lovr.physics.newSphereShape(radius) end 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. +--- +---@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. +--- +---@overload fun(x: number, y: number, z: number, px: number, py: number, pz: number) +---@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. +--- +---@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. +--- +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. +--- +---@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. +--- +---@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. +--- +---@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. +--- +---@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. +--- +---@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. +--- +---@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. +--- +---@return string tag # The Collider's collision tag. +function Collider:getTag() end + +--- +---Returns the user data associated with the Collider. +--- +---@return lovr.* data # The custom value associated with the Collider. +function Collider:getUserData() end + +--- +---Returns the World the Collider is in. +--- +---@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. +--- +---@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. +--- +---@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. +--- +---@return boolean kinematic # Whether the Collider is kinematic. +function Collider:isKinematic() end + +--- +---Returns whether the Collider is allowed to sleep. +--- +---@return boolean allowed # Whether the Collider can go to sleep. +function Collider:isSleepingAllowed() end + +--- +---Removes a Shape from the Collider. +--- +---@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. +--- +---@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. +--- +---@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. +--- +---@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. +--- +---@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. +--- +---@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. +--- +---@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. +--- +---@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. +--- +---@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. +--- +---@param allowed boolean # Whether the Collider can go to sleep. +function Collider:setSleepingAllowed(allowed) end + +--- +---Sets the Collider's tag. +--- +---@param tag string # The Collider's collision tag. +function Collider:setTag(tag) end + +--- +---Associates a custom value with the Collider. +--- +---@param data lovr.* # 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. +--- +---@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. +--- +---@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. +--- +---@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. +--- +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 lovr.* 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 lovr.* # The custom value associated with the Joint. +function Joint:setUserData(data) end + +--- +---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. +--- +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. +--- +---@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. +--- +---@return lovr.* data # The custom value associated with the Shape. +function Shape:getUserData() end + +--- +---Returns whether the Shape is enabled. +--- +---@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. +--- +---@param enabled boolean # Whether the Shape should be enabled. +function Shape:setEnabled(enabled) end + +--- +---Set the orientation of the Shape relative to its Collider. +--- +---@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. +--- +---@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. Sensors do not trigger any collision response, but they still report collisions in `World:collide`. +--- +---@param sensor boolean # Whether the Shape should be a sensor. +function Shape:setSensor(sensor) end + +--- +---Sets the user data associated with the Shape. +--- +---@param data lovr.* # 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 the upper limit of the slider position. +--- +---@return number limit # The upper limit. +function SliderJoint:getUpperLimit() end + +--- +---Sets the axis of the slider. +--- +---@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:getDimensions() end + +--- +---Sets the radius of the SphereShape. +--- +---@param radius number # The radius of the sphere, in meters. +function SphereShape:setDimensions(radius) end + +--- +---A World is an object that holds the colliders, joints, and shapes in a physics simulation. +--- +---@class lovr.World +local World = {} + +--- +---Attempt to collide two shapes. Internally this uses joints and forces to ensure the colliders attached to the shapes do not pass through each other. Collisions can be customized using friction and restitution (bounciness) parameters, and default to using a mix of the colliders' friction and restitution parameters. Usually this is called automatically by `World:update`. +--- +---@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`. +--- +function World:computeOverlaps() end + +--- +---Destroy the World! +--- +function World:destroy() end + +--- +---Disables collision between two collision 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. +--- +---@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. +--- +---@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(t: table):table +---@return table colliders # A table of `Collider` objects. +function World:getColliders() 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. +--- +---@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 tightness of the joint. See `World:setTightness` for how this affects the joint. +--- +---@return number tightness # The tightness of the joint. +function World:getTightness() end + +--- +---Returns whether collisions are currently enabled between two 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. +--- +---@return boolean allowed # Whether colliders can sleep. +function World:isSleepingAllowed() end + +--- +---Adds a new Collider to the World with a BoxShape already attached. +--- +---@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. +--- +---@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, 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. +--- +---@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. +--- +---@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, 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(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. +--- +---@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, in meters. +---@return lovr.Collider collider # The new Collider. +function World:newSphereCollider(x, y, z, radius) 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:detectOverlaps` 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. +--- +---@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. +--- +---@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. +--- +---@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. +--- +---@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. +--- +---@param allowed boolean # Whether colliders can sleep. +function World:setSleepingAllowed(allowed) 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. +--- +---@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. --- ---@class lovr.JointType diff --git a/meta/3rd/lovr/library/lovr.thread.lua b/meta/3rd/lovr/library/lovr.thread.lua index 7e1218f7..bc0f7660 100644 --- a/meta/3rd/lovr/library/lovr.thread.lua +++ b/meta/3rd/lovr/library/lovr.thread.lua @@ -40,3 +40,75 @@ function lovr.thread.getChannel(name) end ---@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. +--- +---@return lovr.* 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. +--- +---@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 lovr.* 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, and userdata. Tables should be serialized to strings. +--- +---@param message lovr.* # 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. +--- +---@param arguments lovr.* # 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/tools/lovr-api.lua b/tools/lovr-api.lua index 5d382875..c5d7f95f 100644 --- a/tools/lovr-api.lua +++ b/tools/lovr-api.lua @@ -64,7 +64,7 @@ function buildType(param) if param.table then return buildDocTable(param.table) end - return getTypeName(param.type) + return getTypeName(param.type or param.name) end local function buildSuper(tp) @@ -168,6 +168,21 @@ local function buildFile(defs) text[#text+1] = buildFunction(func) end + for _, obj in ipairs(defs.objects or {}) do + local mark = {} + text[#text+1] = '' + text[#text+1] = buildDescription(obj.description) + text[#text+1] = ('---@class %s%s'):format(getTypeName(obj.name), buildSuper(obj)) + text[#text+1] = ('local %s = {}'):format(obj.name) + for _, func in ipairs(obj.methods or {}) do + if not mark[func.name] then + mark[func.name] = true + text[#text+1] = '' + text[#text+1] = buildFunction(func) + end + end + end + for _, cb in ipairs(defs.callbacks or {}) do text[#text+1] = '' text[#text+1] = buildDescription(cb.description) |