Merge branch 'master' of https://github.com/koptilnya/starfall-modules
This commit is contained in:
commit
5c47485f7b
@ -69,5 +69,7 @@ function byteTable(str, start, length)
|
||||
end
|
||||
|
||||
function isURL(str)
|
||||
return string.match(str, "^https?://") ~= nil
|
||||
local _1, _2, prefix = tx:find("^(%w-):")
|
||||
|
||||
return prefix == "http" or prefix == "https" or prefix == "data
|
||||
end
|
||||
@ -1,7 +1,7 @@
|
||||
-- @name koptilnya/libs/workers
|
||||
|
||||
WORKERS = {}
|
||||
WORKERS_QUOTA = 0.4
|
||||
WORKERS_QUOTA = 0.5
|
||||
|
||||
local function execWorker(worker)
|
||||
local status
|
||||
|
||||
@ -99,10 +99,18 @@ function MeshBuilder:_applyMeshes()
|
||||
end
|
||||
end
|
||||
|
||||
function MeshBuilder:_setTexture(mat, name, texture)
|
||||
function MeshBuilder:_setTexture(mat, name, texture, layoutOptions)
|
||||
if isURL(texture) then
|
||||
texture = texture .. "#hack" .. math.random(1337)
|
||||
layoutOptions = layoutOptions or {}
|
||||
|
||||
mat:setTextureURL(name, texture, function(_, _, _, _, layout)
|
||||
layout(0, 0, 1024, 1024)
|
||||
local x = layoutOptions.x or 0
|
||||
local y = layoutOptions.y or 0
|
||||
local w = layoutOptions.w or 1024
|
||||
local h = layoutOptions.h or 1024
|
||||
|
||||
layout(x, y, w, h)
|
||||
end)
|
||||
else
|
||||
mat:setTexture(name, texture)
|
||||
@ -123,10 +131,10 @@ function MeshBuilder:_createMaterial(shader, basetexture, bumpmap, options)
|
||||
|
||||
local mat = material.create(shader)
|
||||
|
||||
self:_setTexture(mat, "$basetexture", basetexture)
|
||||
self:_setTexture(mat, "$basetexture", basetexture, options.baseLayout)
|
||||
|
||||
if bumpmap ~= "" then
|
||||
self:_setTexture(mat, "$bumpmap", bumpmap)
|
||||
self:_setTexture(mat, "$bumpmap", bumpmap, options.bumpLayout)
|
||||
end
|
||||
|
||||
for k, v in pairs(options) do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user