tests/host: comments: specs only
This commit is contained in:
1 parent
70f50917fa
commit
54f53a35f6
1 file changed
+1
-7
@@ -1,6 +1,4 @@
|
|||||||
-- host/Roblox tests: the pure half of the EditableMesh adapter (meshPages: triangle runs within the triangle / vertex
|
-- host/Roblox tests: the pure half of the EditableMesh adapter (meshPages, pageData); toEditableMesh needs Roblox.
|
||||||
-- limits, corners mapping back to the source indices, double-sided counting, errors; pageData: centring, per-axis
|
|
||||||
-- scale, inverse-scaled unit normals, uvs + flipV, linear -> sRGB colours). toEditableMesh itself needs Roblox.
|
|
||||||
local T = require("@tests/T")
|
local T = require("@tests/T")
|
||||||
local Host = require("@rosetta/host/Roblox")
|
local Host = require("@rosetta/host/Roblox")
|
||||||
local Types = require("@rosetta/Types")
|
local Types = require("@rosetta/Types")
|
||||||
@@ -20,7 +18,6 @@ local function near(a: number, b: number, eps: number?): boolean
|
|||||||
return math.abs(a - b) <= (eps or 1e-5)
|
return math.abs(a - b) <= (eps or 1e-5)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- an n x n grid of quads in the xz plane (two triangles each), u16 indices, normals up, uvs, colours
|
|
||||||
local function grid(n: number): Types.Primitive
|
local function grid(n: number): Types.Primitive
|
||||||
local pos, nrm, uv, col = {}, {}, {}, {}
|
local pos, nrm, uv, col = {}, {}, {}, {}
|
||||||
for z = 0, n do
|
for z = 0, n do
|
||||||
@@ -59,7 +56,6 @@ local function grid(n: number): Types.Primitive
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 1. pages within the limits, covering every triangle once, corners = the source indices
|
|
||||||
local prim = grid(10) -- 121 vertices, 200 triangles
|
local prim = grid(10) -- 121 vertices, 200 triangles
|
||||||
local pages = assert(Host.meshPages(prim, { maxTriangles = 64 }))
|
local pages = assert(Host.meshPages(prim, { maxTriangles = 64 }))
|
||||||
t:eq(#pages, 4, "200 triangles / 64 per page")
|
t:eq(#pages, 4, "200 triangles / 64 per page")
|
||||||
@@ -100,7 +96,6 @@ local sp = assert(Host.meshPages(soup :: any))
|
|||||||
t:eq(sp[1].count, 2, "unindexed triangles")
|
t:eq(sp[1].count, 2, "unindexed triangles")
|
||||||
t:eq(#sp[1].vertices, 6, "unindexed vertices")
|
t:eq(#sp[1].vertices, 6, "unindexed vertices")
|
||||||
|
|
||||||
-- 2. errors
|
|
||||||
local _, e1 = Host.meshPages({ attributes = { POSITION = f32({ 0, 0, 0 }, 3) }, mode = "lines" } :: any)
|
local _, e1 = Host.meshPages({ attributes = { POSITION = f32({ 0, 0, 0 }, 3) }, mode = "lines" } :: any)
|
||||||
t:check(e1 and e1.code == Err.ARG, "lines are not triangles")
|
t:check(e1 and e1.code == Err.ARG, "lines are not triangles")
|
||||||
local _, e2 = Host.meshPages({} :: any)
|
local _, e2 = Host.meshPages({} :: any)
|
||||||
@@ -112,7 +107,6 @@ t:check(e3 and e3.code == Err.ARG, "index out of range")
|
|||||||
local _, e4 = Host.pageData(prim, {} :: any)
|
local _, e4 = Host.pageData(prim, {} :: any)
|
||||||
t:check(e4 and e4.code == Err.ARG, "pageData needs a page")
|
t:check(e4 and e4.code == Err.ARG, "pageData needs a page")
|
||||||
|
|
||||||
-- 3. pageData: centred, scaled, normals, uvs, colours
|
|
||||||
local pg = one[1]
|
local pg = one[1]
|
||||||
local d = assert(Host.pageData(prim, pg, { scale = { 2, 1, 4 } }))
|
local d = assert(Host.pageData(prim, pg, { scale = { 2, 1, 4 } }))
|
||||||
t:eq(d.vertexCount, 121, "vertex count")
|
t:eq(d.vertexCount, 121, "vertex count")
|
||||||
|
|||||||
Reference in new issue
Block a user