Skip to content

Earclipping issue #2519

@Blossomical

Description

@Blossomical

there's an issue where trimesh returns a version of the obj without Earclipping, image 1 is the input and image 2 is the output
the only thing that i did here is change the normals and that's all

the code used:

async def FlatNormals(model: discord.Attachment):
    async with manager.session.get(model.url) as response:
        mesh: trimesh.Trimesh = await asyncio.to_thread(
            trimesh.load_mesh, io.BytesIO(await response.read()), force="mesh", file_type="obj"
        )

    def job():
        mesh.vertex_normals = np.tile([0, 0, 1], (len(mesh.vertices), 1))
        mesh.face_normals = np.tile([0, 0, 1], (len(mesh.faces), 1))

        obj_bytes = mesh.export(file_type="obj")
        return io.BytesIO(obj_bytes)

    return await asyncio.to_thread(job) # ignore how i'm using to_thread alot, the bot gets blocked if i don't do this despite being put in an asyncio task

input:
Image1

output:

Image2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions