Repository navigation
feat(mesh-ops): semantic transforms and one-call arrange (T-A3) - #377
Merged
Merged
Conversation
…point Four registry ops derive their 4x4 matrix from the mesh itself: recenter (centroid to origin), drop_to_ground (lowest point to y = 0), auto_orient (smallest rotation that turns the thinnest PCA axis vertical; meshes without a clear flat side are left alone) and normalize_scale (size in m/cm/mm along the longest side or one axis). apply_transforms composes requested steps in a fixed order (orient, scale, recenter, ground) on one load and writes a single file, so grounding is never undone by a later step. POST /optimize/arrange exposes it, validating each step's params through the registry, and the raw /transform endpoint now shares the same bake helper. The agent and MCP server get an arrange_mesh tool that takes every step at once and reports the new mesh path for chaining. The world-space geometry helpers move to mesh_ops/geometry.py, shared with inspect_mesh, and the registry exposes resolve_params. Closes #297
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #297
Summary
Adds high-level transforms on top of the raw 4×4
/transformendpoint, so "put it on the ground, center it and lay it flat" works in a single chat message — one tool call, one output file.recenter— moves the centroid to the origin.drop_to_ground— moves the lowest point to y = 0.auto_orient— lays the mesh flat: the smallest rotation that turns its thinnest PCA axis vertical. No spin about the vertical axis, never flipped upside down, and meshes without a clear flat side (cube, sphere) are left alone.normalize_scale— resizes tosizein m / cm / mm (glTF metres), along the longest side or a chosen axis. Scales around the origin, so a centred, grounded mesh stays so.Changes
api/services/mesh_ops/transforms.py— each step builds its matrix from the mesh as the previous steps left it.apply_transformsloads once, runs the steps in a fixed order (orient → scale → recenter → ground, whatever order they were requested in) and writes one file. The/transformgizmo endpoint now uses the sametransform_filehelper, unchanged in behaviour.transformcategory with flatparams_schema, ready for the edit panel (T-C1).POST /optimize/arrange— composes several steps into one file, validating each step's params through the registry (unknown step or bad param → 400).arrange_meshtool, with a prompt rule to pass every step in one call. Its result includes the new mesh path, so the model can chain another tool on it. MCP server:modly_arrange_mesh.mesh_ops/geometry.py(shared withinspect_mesh); the registry exposesresolve_params.Testing
npm run test:py— 257 tests pass (4 skipped). 17 new tests: canonical order on a tilted, offset plate; centroid to origin; vertical-only grounding; cube left alone; bowl not flipped; 20 cm / 5 mm; scaling keeps the mesh grounded; multi-node scenes in world space; textures preserved; input never modified; invalid steps rejected. Router (/arrangein a moved workspace) and agent tests added.Notes
recenteranddrop_to_groundchange the exported file but nothing on screen.auto_orientlays a standing figure down — that is what "lay flat" means.