Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add transform gizmo (move/rotate/scale)#173

Draft
iammojogo-sudo wants to merge 17 commits into
lightningpixel:dev from
iammojogo-sudo:main
Draft

Add transform gizmo (move/rotate/scale) #173
iammojogo-sudo wants to merge 17 commits into
lightningpixel:dev from
iammojogo-sudo:main

Conversation

@iammojogo-sudo

@iammojogo-sudo iammojogo-sudo commented Jun 8, 2026

Copy link
Copy Markdown

Closes #161

Adds a gizmo to move/rotate/scale the mesh in the viewport. Shows when the
mesh is selected, W/E/R to switch modes. Apply bakes it into the GLB so it
sticks on export, Reset reverts.

New /optimize/transform endpoint on the backend handles the bake.

Tested locally, works.

Lightning Pixel and others added 16 commits May 11, 2026 09:33
Added links to Modly and Lightning Pixel on X for updates.
Added a sponsors section to acknowledge early supporters.
Added input path validation to prevent path traversal attacks.
Added autoCenter and resetToken props to MeshModel. Enhanced mesh centering logic and keyboard controls for gizmo modes.
@lightningpixel lightningpixel changed the base branch from main to dev June 9, 2026 08:53

lightningpixel commented Jun 9, 2026
edited
Loading

Copy link
Copy Markdown
Owner

You’ll need to resolve the conflicts on the PR

Edit:
And I added the new toolbar on the Generate page.
So instead of putting the buttons in the bar on the left side, you should use the second toolbar at the top.
I already added the transform buttons there. You’ll just need to adapt it

Copy link
Copy Markdown
Owner

The pushed branch isn't in a working state, so I have to request changes.

Blocking issues

  1. The branch doesn't run. Viewer3D.tsx uses gizmoMode, setGizmoMode, applying, resetToken, and meshObject but never declares them (no useState), and TransformControls is used without being imported from @react-three/drei. Running the app immediately
    throws Uncaught ReferenceError: setGizmoMode is not defined, and npm run build fails type-checking. It looks like part of your wiring commit was lost before pushing — could you push the complete version you actually tested?

  2. api/routers/optimize.py contains the entire module twice (paste/merge accident — router = APIRouter appears at lines 25 and 361, every endpoint is defined twice). The second router shadows the first, and since it's the old copy without /transform, the new
    endpoint is never registered: every "Apply" call will 404. Please reduce the file to a single copy that includes /transform.

  3. Gizmo wiring is incomplete. MeshModelProps declares onObject but MeshModel never calls it, so meshObject would stay null and the gizmo would never render. SceneMeshModel reads autoCenter and resetToken but those props are never added to its signature nor
    passed down.

  4. Out-of-scope changes — please remove these from the PR:

    • The README "Sponsors" section and the X/Twitter links. Sponsor recognition is a maintainer decision; adding yourself there isn't something we can merge from a feature PR.
    • The version bumps in package.json and api/main.pydev has already moved to 0.3.6 independently, so this will conflict anyway.

Smaller things to fix in the same pass

  • The {stem}_xf.glb output name means re-applying produces ..._xf_xf.glb, and applying twice from the same base overwrites the file while keeping the same URL — useGLTF's cache will then show the stale mesh. A unique suffix (we already use uuid elsewhere) would avoid
    both problems.
  • /transform reimplements its path check inline — please reuse _resolve_input_path like /mesh and /smooth do.
  • handleApplyTransform has no catch, so a backend failure is silent for the user.
  • The baked matrix includes the auto-centering offset applied on load, so "Apply" permanently moves the file's origin even for a pure rotation. If that's intentional ("bake what you see"), a comment explaining it would help.
  • The W/E/R/Escape handler only guards against HTMLInputElement/HTMLTextAreaElement — contenteditable elements would still trigger mode switches.
  • useApi.ts uses tab indentation against the file's spaces, and importMesh was re-indented without changes — this will fail npm run lint.

Happy to re-review once the complete, building version is pushed. Thanks again for the contribution !

Copy link
Copy Markdown
Author

The pushed branch isn't in a working state, so I have to request changes.

Blocking issues

1. **The branch doesn't run.** `Viewer3D.tsx` uses `gizmoMode`, `setGizmoMode`, `applying`, `resetToken`, and `meshObject` but never declares them (no `useState`), and `TransformControls` is used without being imported from `@react-three/drei`. Running the app immediately
 throws `Uncaught ReferenceError: setGizmoMode is not defined`, and `npm run build` fails type-checking. It looks like part of your wiring commit was lost before pushing — could you push the complete version you actually tested?
2. **`api/routers/optimize.py` contains the entire module twice** (paste/merge accident — `router = APIRouter` appears at lines 25 and 361, every endpoint is defined twice). The second `router` shadows the first, and since it's the old copy without `/transform`, the new
 endpoint is never registered: every "Apply" call will 404. Please reduce the file to a single copy that includes `/transform`.
3. **Gizmo wiring is incomplete.** `MeshModelProps` declares `onObject` but `MeshModel` never calls it, so `meshObject` would stay `null` and the gizmo would never render. `SceneMeshModel` reads `autoCenter` and `resetToken` but those props are never added to its signature nor
 passed down.
4. **Out-of-scope changes** — please remove these from the PR:
 
 * The README "Sponsors" section and the X/Twitter links. Sponsor recognition is a maintainer decision; adding yourself there isn't something we can merge from a feature PR.
 * The version bumps in `package.json` and `api/main.py` — `dev` has already moved to 0.3.6 independently, so this will conflict anyway.

Smaller things to fix in the same pass

* The `{stem}_xf.glb` output name means re-applying produces `..._xf_xf.glb`, and applying twice from the same base overwrites the file while keeping the same URL — `useGLTF`'s cache will then show the stale mesh. A unique suffix (we already use `uuid` elsewhere) would avoid
 both problems.
* `/transform` reimplements its path check inline — please reuse `_resolve_input_path` like `/mesh` and `/smooth` do.
* `handleApplyTransform` has no `catch`, so a backend failure is silent for the user.
* The baked matrix includes the auto-centering offset applied on load, so "Apply" permanently moves the file's origin even for a pure rotation. If that's intentional ("bake what you see"), a comment explaining it would help.
* The W/E/R/Escape handler only guards against `HTMLInputElement`/`HTMLTextAreaElement` — contenteditable elements would still trigger mode switches.
* `useApi.ts` uses tab indentation against the file's spaces, and `importMesh` was re-indented without changes — this will fail `npm run lint`.

Happy to re-review once the complete, building version is pushed. Thanks again for the contribution !

Not a worry, thank you and Ill work on this today until its ready. Sorry for the extra work. I hope to reduce that soon.

@iammojogo-sudo iammojogo-sudo marked this pull request as draft June 11, 2026 20:43

iammojogo-sudo commented Jun 11, 2026
edited
Loading

Copy link
Copy Markdown
Author

You know what I think I did wrong, is I attached the main branch rather than the transform-gizmo branch? Because it worked great when I tested it before the initial PR.
modly_clone-transform_gizmo.zip, I have to clone the newest with the toolbar at the top that you made and move the files over there I assume? Would it be ok if I just give the changes from now one instead of having to do all of that because I dont feel comfortable with github at all. I dont like it. I am having a very tough time trying to understand what to do next and I don't want to bog down anyone else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

FEATURE 1 - Interactive transform gizmo

AltStyle によって変換されたページ (->オリジナル) /