Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add click-to-center feature #95

Open
eteq opened this issue Aug 31, 2024 · 3 comments
Open

Add click-to-center feature #95

eteq opened this issue Aug 31, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@eteq
Copy link

eteq commented Aug 31, 2024

While this tool is really amazing for build123d and cq workflows, there is one and only one feature that sometimes forces me to go back into freecad: the "click to center" feature in some of the freecad view modes. That is, you can middle-click on a spot in the view and it re-centers the camera there, which, more importantly, means if I orbit or zoom in, it zooms into the spot I selected. This is critical for inspecting small parts embedded in a larger part.

Right now I can of course pan to wherever I need to be with right-click, but I find that imprecise and awkward to use such that in practice I sometimes have to dump my object and load it in freecad to inspect things. Can a middle-click-to-center feature be added to vscode-ocp-cad-viewer ? (or maybe this belongs better in three-cad-viewer? I confess I don't really understand the boundary of what is where)

@eteq
Copy link
Author

eteq commented Aug 31, 2024

(Note I'm open to "well then make a PR for that!" but I am not really sure where to find the relevant interaction code, so pointers would be helpful on that...)

@bernhard-42
Copy link
Owner

Everything that is in the viewer window (cad tree, canvas with CAD object(s), mouse handling, ....) is the viewer component three-cad-viewer.

vscode-ocp-viewer does two things:

  • Use ocp-tessellate to convert OCP to mesh (tessellation)
  • transport the tessellated object from Python to VS Code and from there to the embedded viewer component (using websockets)

So the feature request you are asking about is in fact a three-cad-viewer topic as you suggested.

Currently it can be done by code:

set_viewer_config(target=(x,y,z))

center

@bernhard-42
Copy link
Owner

And something like that can be added to the viewer component, i.e. when doing a -click, then raytracing (already used) will be used to identify the nearest point on the object that this click would point to on an axis from the camera through the click point in the view projection point to the object. And set camera's target to this point.

The code approach above uses the measure/property mode to get the coords and then sets the target of the camera.

@bernhard-42 bernhard-42 added the enhancement New feature or request label Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants