UVManager: several changes
- new doesn't use self - better type checking for getUV - make parameters for .new optional
This commit is contained in:
parent
f2e42fcb24
commit
b79ec7db1f
@ -10,11 +10,11 @@ UVManager = {
|
|||||||
}
|
}
|
||||||
mt.__index=UVManager
|
mt.__index=UVManager
|
||||||
--- @return UVManager
|
--- @return UVManager
|
||||||
--- @param step Vector2 A vector representing the distance between UVs
|
--- @param step? Vector2 A vector representing the distance between UVs
|
||||||
--- @param offset Vector2 A vector represnting the starting point for UVs, or nil
|
--- @param offset? Vector2 A vector represnting the starting point for UVs, or nil
|
||||||
--- @param positions table A dictionary of names and offset vectors
|
--- @param positions? table A dictionary of names and offset vectors
|
||||||
--- @param part ModelPart Model part to manage
|
--- @param part? ModelPart Model part to manage
|
||||||
function UVManager.new(self, step, offset, positions, part)
|
function UVManager.new(step, offset, positions, part)
|
||||||
local t={}
|
local t={}
|
||||||
if step ~= nil then t.step=step end
|
if step ~= nil then t.step=step end
|
||||||
if offset ~= nil then t.offset=offset end
|
if offset ~= nil then t.offset=offset end
|
||||||
@ -34,15 +34,20 @@ function UVManager.setPart(self, part)
|
|||||||
self.dimensions=part:getTextureSize()
|
self.dimensions=part:getTextureSize()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---Get real UV from vec(x, y) or string representing preset
|
||||||
|
---@param input Vector2|string UV to get
|
||||||
function UVManager.getUV(self, input)
|
function UVManager.getUV(self, input)
|
||||||
local vect={}
|
local vect={}
|
||||||
local stp=self.step
|
local stp=self.step
|
||||||
local offset=self.offset
|
local offset=self.offset
|
||||||
|
assert(type(input)=="string" or type(input) == "Vector2")
|
||||||
if type(input) == "string" then
|
if type(input) == "string" then
|
||||||
if self.positions[input] == nil then return nil end
|
if self.positions[input] == nil then return nil end
|
||||||
vect=self.positions[input]
|
vect=self.positions[input]
|
||||||
else
|
elseif type(input) == "Vector2" then
|
||||||
vect=vectors.of(input)
|
-- vect=vectors.of(input)
|
||||||
|
vect=input
|
||||||
end
|
end
|
||||||
local u=offset.x+(vect.x*stp.x)
|
local u=offset.x+(vect.x*stp.x)
|
||||||
local v=offset.y+(vect.y*stp.y)
|
local v=offset.y+(vect.y*stp.y)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user