meshcat-dev / meshcat-python

WebGL-based 3D visualizer for Python
MIT License
258 stars 63 forks source link

Focusing point with camera #133

Open kingjin94 opened 1 year ago

kingjin94 commented 1 year ago

When generating more complex scenes I would like to guide the user's view to the most important elements.

The demos suggest using

viz.viewer["/Cameras/default"].set_transform(<Some 4x4 matrix>))
viz.viewer["/Cameras/default/rotated/<object>"].set_property("position", [x, y, z])

How do you use these to move the camera close to an arbitrary position, such as (10., 0., 0.) and look at this arbitrary position?

The set_property seems to be able to reposition the camera (in the three js system where "up" = z_meshcat = +y_three_js and z_three_js = -y_meshcat). The camera seems to keep focusing on the origin. How to do you change the position the camera points at and pans around?

ManifoldFR commented 1 year ago

Hi @kingjin94 ! I have an open PR about this: #109

kingjin94 commented 1 year ago

Great to hear that it is not just a problem of understanding the available API :sweat_smile: Is there any way I could help to expedite this PR?

ManifoldFR commented 1 year ago

Great to hear that it is not just a problem of understanding the available API sweat_smile Is there any way I could help to expedite this PR?

I'm not sure. The maintainer seems very busy and maybe would like some help to look at PRs and merge them.

@rdeits, are you open to onboarding some folks to help maintain meshcat?

GianniLunardi commented 6 months ago

Hi all,

I see that the pull request #109 has been merged. But in my code if do something like:

viz = pin.visualize.MeshcatVisualizer(rmodel, collision, visual)
viz.initViewer(loadModel=True, open=True)
viz.setCameraPosition(np.array([0.6, 0., -0.15]))
viz.setCameraTarget(np.array([0., 1, 0.]))

then setCameraTarget does not change anything and the camera keep focusing on the origin. Am I doing something wrong or the problem is still existing? I have installed the last versione from source.

zimmerman-pliant commented 5 months ago

It's set_cam_target() and set_cam_pos(), see here.

Working well for me installed from source.