ws-3d3-b: model/lwo: typed tables (no new type diagnostic)
This commit is contained in:
1 parent
1aaf8fce68
commit
27518c55c5
2 files changed
+12
-10
No files matched your search
@@ -108,7 +108,7 @@ local function groupLayer(layer: Parse.Layer, surfaceOf: (number?) -> number): {
|
||||
table.insert(g.polys, i - 1)
|
||||
end
|
||||
end
|
||||
local rank = { poly = 1, patch = 2, line = 3, point = 4 }
|
||||
local rank: { [string]: number } = { poly = 1, patch = 2, line = 3, point = 4 }
|
||||
table.sort(groups, function(a: Group, b: Group): boolean
|
||||
if a.material ~= b.material then
|
||||
return a.material < b.material
|
||||
@@ -121,7 +121,7 @@ end
|
||||
-- the corners of a face in output order (winding reversed for the handedness change, first corner kept)
|
||||
local function ordered(corners: { number }): { number }
|
||||
local n = #corners
|
||||
local out = table.create(n)
|
||||
local out = table.create(n) :: { number }
|
||||
out[1] = corners[1]
|
||||
for k = 2, n do
|
||||
out[k] = corners[n - k + 2]
|
||||
@@ -175,7 +175,7 @@ local function primitive(layer: Parse.Layer, g: Group, attrs: { Attr }, morphs:
|
||||
for _, f in g.polys do
|
||||
local corners = ordered(layer.polys[f + 1].corners)
|
||||
local n = #corners
|
||||
local vs = table.create(n)
|
||||
local vs = table.create(n) :: { number }
|
||||
for k = 1, n do
|
||||
vs[k] = vertex(f, corners[k])
|
||||
end
|
||||
@@ -249,8 +249,8 @@ local function primitive(layer: Parse.Layer, g: Group, attrs: { Attr }, morphs:
|
||||
end
|
||||
local prim: Types.Primitive = { attributes = attributes, mode = "triangles" }
|
||||
if #morphs > 0 then
|
||||
local targets = {}
|
||||
local targetNames = {}
|
||||
local targets: { { [string]: Types.Accessor } } = {}
|
||||
local targetNames: { string } = {}
|
||||
for _, m in morphs do
|
||||
local d = buffer.create(nv * 12)
|
||||
for v = 1, nv do
|
||||
@@ -267,7 +267,8 @@ local function primitive(layer: Parse.Layer, g: Group, attrs: { Attr }, morphs:
|
||||
writef32(d, (v - 1) * 12 + 8, -dz)
|
||||
end
|
||||
end
|
||||
table.insert(targets, { POSITION = Scene.accessor(d, "f32", 3, nv) })
|
||||
local tgt: { [string]: Types.Accessor } = { POSITION = Scene.accessor(d, "f32", 3, nv) }
|
||||
table.insert(targets, tgt)
|
||||
table.insert(targetNames, m.name)
|
||||
end
|
||||
prim.targets = targets
|
||||
@@ -403,7 +404,8 @@ function Build.scene(m: Parse.Model, opts: { triangulate: boolean? }?): (Types.S
|
||||
local prims = {}
|
||||
for _, g in groups do
|
||||
local mat = scene.materials[g.material]
|
||||
local vcol = mat and mat.extras and mat.extras.lwo and mat.extras.lwo.vcol
|
||||
local ex: any = mat and mat.extras
|
||||
local vcol = ex and ex.lwo and ex.lwo.vcol
|
||||
local pa = table.clone(attrs)
|
||||
nc = 0
|
||||
for _, map in layer.maps do
|
||||
|
||||
Reference in new issue
Block a user