my game is just one infinite vertical chunk.
Idk why it is scaled

local function example_7(self)
local mesh_go = create_mesh(self)
-- Define 8 vertices of a unit cube
local v = {
vmath.vector3(-0.5, -0.5, 0.5), -- 1
vmath.vector3(0.5, -0.5, 0.5), -- 2
vmath.vector3(0.5, 0.5, 0.5), -- 3
vmath.vector3(-0.5, 0.5, 0.5), -- 4
vmath.vector3(-0.5, -0.5, -0.5), -- 5
vmath.vector3(0.5, -0.5, -0.5), -- 6
vmath.vector3(0.5, 0.5, -0.5), -- 7
vmath.vector3(-0.5, 0.5, -0.5) -- 8
}
-- Define indices for 12 triangles (6 faces)
local indices = {
-- Front
1, 2, 3, 1, 3, 4,
-- Back
6, 5, 8, 6, 8, 7,
-- Top
4, 3, 7, 4, 7, 8,
-- Bottom
5, 6, 2, 5, 2, 1,
-- Right
2, 6, 7, 2, 7, 3,
-- Left
5, 1, 4, 5, 4, 8
}
-- create a buffer with a position and uv stream
local buf = buffer.create(#indices, {
{ name = hash("position"), type = buffer.VALUE_TYPE_FLOAT32, count = 3 },
{ name = hash("texcoord0"), type = buffer.VALUE_TYPE_FLOAT32, count = 2 }
})
local positions = buffer.get_stream(buf, "position")
local texcoord0 = buffer.get_stream(buf, "texcoord0")
-- Square UVs (repeated for each face)
local uv = {
0, 0, 1, 0, 1, 1,
0, 0, 1, 1, 0, 1
}
for i, idx in ipairs(indices) do
local vert = v[idx]
positions[(i - 1) * 3 + 1] = vert.x
positions[(i - 1) * 3 + 2] = vert.y
positions[(i - 1) * 3 + 3] = vert.z
-- Simple UV mapping
local uv_idx = ((i - 1) % 6) * 2 + 1
texcoord0[(i - 1) * 2 + 1] = uv[uv_idx]
texcoord0[(i - 1) * 2 + 2] = uv[uv_idx + 1]
end
local buffer_resource = resource.create_buffer(string.format(PATCH_BUFFER, 7), { buffer = buf })
go.set(mesh_go.mesh_url, "vertices", buffer_resource)
local atlas = resource.get_atlas(self.game_atlas)
go.set(mesh_go.mesh_url, "texture0", hash(atlas.texture))
-- Position the cube at origin
go.set_position(vmath.vector3(0, 0, 0), mesh_go.go_id)
-- Scale it up
go.set_scale(vmath.vector3(100, 100, 100), mesh_go.go_id)
end