ws-cleanup-types: image/pnm, model/*: type lookup tables, table.create results and literals; casts for known values
This commit is contained in:
1 parent
7c15b02354
commit
139441a37b
23 files changed
+139
-137
No files matched your search
@@ -275,7 +275,7 @@ local function parse(r: Bytes.Reader, opts: DecodeOptions?): (Parsed?, Err.Err?)
|
||||
if n < 1024 then
|
||||
return nil, Err.new(Err.CORRUPT, "short RGBA chunk", at)
|
||||
end
|
||||
local pal = table.create(255)
|
||||
local pal = table.create(255) :: { { number } }
|
||||
for i = 1, 255 do
|
||||
pal[i] = { c:u8(), c:u8(), c:u8(), c:u8() }
|
||||
end
|
||||
@@ -310,7 +310,7 @@ local function parse(r: Bytes.Reader, opts: DecodeOptions?): (Parsed?, Err.Err?)
|
||||
if c.err or nc < 0 or nc * 4 > c:remaining() then
|
||||
return nil, Err.new(Err.CORRUPT, "bad nGRP chunk", at)
|
||||
end
|
||||
local children = table.create(nc)
|
||||
local children = table.create(nc) :: { number }
|
||||
for k = 1, nc do
|
||||
children[k] = c:i32le()
|
||||
end
|
||||
@@ -625,7 +625,7 @@ function Vox.encode(value: any, opts: EncodeOptions?): (buffer?, Err.Err?)
|
||||
return nil, Err.new(Err.ARG, "voxels " .. i .. ": data is smaller than the grid")
|
||||
end
|
||||
end
|
||||
local meta = if type(scene.meta) == "table" and type(scene.meta.vox) == "table" then scene.meta.vox else {}
|
||||
local meta: any = if type(scene.meta) == "table" and type(scene.meta.vox) == "table" then scene.meta.vox else {}
|
||||
local w = Bytes.writer(65536)
|
||||
w:string("VOX ")
|
||||
w:u32le(version)
|
||||
@@ -675,7 +675,7 @@ function Vox.encode(value: any, opts: EncodeOptions?): (buffer?, Err.Err?)
|
||||
local failure: string? = nil
|
||||
local function shape(model: number, vx: any?): number
|
||||
local id = alloc()
|
||||
local ms = {}
|
||||
local ms: { { model: number, attributes: Dict? } } = {}
|
||||
local saved = vx and vx.shape
|
||||
if saved and type(saved.models) == "table" and saved.models[1] and saved.models[1].model == model then
|
||||
for _, sm in saved.models do
|
||||
|
||||
Reference in new issue
Block a user