Fix vector annotations: most methods can recive Position as params instead vector

This commit is contained in:
Alexander Chibrikin
2026-01-04 21:26:52 +03:00
parent 3a7a3550f9
commit cb4f88919d

View File

@@ -3,8 +3,8 @@
--- @class vector: Position --- @class vector: Position
--- @operator eq : boolean --- @operator eq : boolean
--- @operator unm : vector --- @operator unm : vector
--- @operator add(vector): vector --- @operator add(Position): vector
--- @operator sub(vector): vector --- @operator sub(Position): vector
--- @operator mul(number) : vector --- @operator mul(number) : vector
--- @operator div(number) : vector --- @operator div(number) : vector
vector = {} vector = {}
@@ -103,33 +103,33 @@ function vector:abs() end
function vector:apply(func, ...) end function vector:apply(func, ...) end
--- Returns a vector where the function func has combined both components of v and w for each component. --- Returns a vector where the function func has combined both components of v and w for each component.
--- @param v2 vector # Second vector to combine with. --- @param v2 Position # Second vector to combine with.
--- @param func fun(number, number): number --- @param func fun(number, number): number
--- @return vector # New vector with combined components. --- @return vector # New vector with combined components.
function vector:combine(v2, func) end function vector:combine(v2, func) end
--- Returns a boolean, true if the vectors are identical. --- Returns a boolean, true if the vectors are identical.
--- @param other vector --- @param other Position
--- @return boolean --- @return boolean
function vector:equals(other) end function vector:equals(other) end
--- Returns in order minp, maxp vectors of the cuboid defined by `v1`, `v2`. --- Returns in order minp, maxp vectors of the cuboid defined by `v1`, `v2`.
--- @param v1 vector --- @param v1 Position
--- @param v2 vector --- @param v2 Position
--- @return vector minp, vector maxp --- @return vector minp, vector maxp
function vector.sort(v1, v2) end function vector.sort(v1, v2) end
--- Returns the angle between vectors in radians. --- Returns the angle between vectors in radians.
--- @param other vector --- @param other Position
function vector:angle(other) end function vector:angle(other) end
--- Calculates the dot product (скалярное произведение) with another vector. --- Calculates the dot product (скалярное произведение) with another vector.
--- @param other vector --- @param other Position
--- @return number --- @return number
function vector:dot(other) end function vector:dot(other) end
--- Calculates the cross product (векторное произведение) with another vector. --- Calculates the cross product (векторное произведение) with another vector.
--- @param other vector --- @param other Position
--- @return vector --- @return vector
function vector:cross(other) end function vector:cross(other) end
@@ -167,23 +167,22 @@ function vector.random_in_area(min, max) end
--- Returns a vector. --- Returns a vector.
--- - If `x` is a vector: Returns the sum of the vector and `x`. --- - If `x` is a vector: Returns the sum of the vector and `x`.
--- - If `x` is a number: Adds `x` to each component of the vector. --- - If `x` is a number: Adds `x` to each component of the vector.
--- @param x vector|number --- @param x Position|number
--- @return vector --- @return vector
function vector:add(x) end function vector:add(x) end
--- Returns a vector. --- Returns a vector.
--- - If `x` is a vector: Returns the difference of the vector and `x`. --- - If `x` is a vector: Returns the difference of the vector and `x`.
--- - If `x` is a number: Subtracts `x` from each component of the vector. --- - If `x` is a number: Subtracts `x` from each component of the vector.
--- @param x vector|number --- @param x Position|number
--- @return vector --- @return vector
function vector:subtract(x) end function vector:subtract(x) end
--- Returns a scaled vector. --- Returns a scaled vector.
--- - Deprecated: If `scalar` is a vector: Returns the Schur product. --- - Deprecated: If `scalar` is a vector: Returns the Schur product.
--- @param self vector --- @param scalar number|Position
--- @param scalar number|vector
--- @return vector --- @return vector
function vector.multiply(self, scalar) end function vector:multiply(scalar) end
--- Returns a scaled vector. --- Returns a scaled vector.
--- - Deprecated: If `scalar` is a vector: Returns the Schur quotient. --- - Deprecated: If `scalar` is a vector: Returns the Schur quotient.
@@ -195,13 +194,13 @@ function vector:divide(scalar) end
--- - Uses (extrinsic) Z-X-Y rotation order and is right-handed, consistent with `ObjectRef:set_rotation`. --- - Uses (extrinsic) Z-X-Y rotation order and is right-handed, consistent with `ObjectRef:set_rotation`.
--- - `vector.rotate(vector.new(0, 0, 1), rotation)` and `vector.rotate(vector.new(0, 1, 0), rotation)` --- - `vector.rotate(vector.new(0, 0, 1), rotation)` and `vector.rotate(vector.new(0, 1, 0), rotation)`
--- return vectors pointing forward and up relative to an entity's rotation `rotation`. --- return vectors pointing forward and up relative to an entity's rotation `rotation`.
--- @param rotation vector --- @param rotation Position
--- @return vector --- @return vector
function vector:rotate(rotation) end function vector:rotate(rotation) end
--- Rotates the vector around `axis` by `angle` radians according to the right hand rule --- Rotates the vector around `axis` by `angle` radians according to the right hand rule
--- and returns the result vector. --- and returns the result vector.
--- @param axis vector --- @param axis Position
--- @param angle number # Angle in radians --- @param angle number # Angle in radians
--- @return vector --- @return vector
function vector:rotate_around_axis(axis, angle) end function vector:rotate_around_axis(axis, angle) end
@@ -209,7 +208,7 @@ function vector:rotate_around_axis(axis, angle) end
--- Returns a rotation vector for `direction` pointing forward using `up` as the up vector. --- Returns a rotation vector for `direction` pointing forward using `up` as the up vector.
--- - If `up` is omitted, the roll of the returned vector defaults to zero. --- - If `up` is omitted, the roll of the returned vector defaults to zero.
--- - Otherwise `direction` and `up` need to be vectors in a 90 degree angle to each other. --- - Otherwise `direction` and `up` need to be vectors in a 90 degree angle to each other.
--- @param direction vector --- @param direction Position
--- @param up? vector --- @param up? Position
--- @return vector --- @return vector
function vector.dir_to_rotation(direction, up) end function vector.dir_to_rotation(direction, up) end