Closed rbnvrw closed 4 years ago
From Python side:
If you want to rotate around (in xy) the scene, with vertical orientation of the camera at z=z0,
you can write :
plot.camera = [ rnp.sin(rad),rnp.cos(rad),z0, # xyz o the camera 0,0,0, # camera looks towards scene (middle of scene bbox) + this vector 0,0,1 # orientation of the camera - ]
It works well in ipywidget interact or a loop (but in a loop one might want to make some delay ;-)
Thanks for questions.
is there a way where I can "walk" around in the scene / fly over it?
At this moment K3D using TrackballControlls (https://threejs.org/docs/#examples/en/controls/TrackballControls). So that's true that mouse wheel event only changes the position of the camera (so this is not actual "zoom" - it doesn't modify a fov of a camera). You ask about "walk" option that probably means that you want to change position and target of a camera at this same moment by this same value. That's happened exactly on "pan" but it's only available on XY axis of the screen. This is a limitation of "TrackballControls" and I don't like it :).
There is in threejs fly controls module: https://threejs.org/examples/misc_controls_fly.html . I don't think that it's been useful - changing camera position base on hover event will be probably annoying for jupyter users.
As a solution, i think we can modify trackball behavior. Right-click is for pan, rights? So maybe using simultaneously right click with wheel should "pan through z-axis"?
Is there a way to ensure the "z" axis is pointing perfectly upwards? I have trouble getting it perfectly aligned manually sometimes.
Two potential solutions. The first one is giving a choice of controls module (trackball/orbit). Orbit controller is something that probably you want - https://threejs.org/examples/#misc_controls_orbit. Second - add button on GUI and function plot.camera_reset_z() to ensure that camera 'up vector' is pointed to (0,0,1).
Is there a method to programmatically move the camera to a certain position?
Yes - as @marcinofulus said. please read plot.camera property and look at example https://github.com/K3D-tools/K3D-jupyter/blob/master/examples/05_plot_options.ipynb
@marcinofulus please look at proposed solution
Thank you both for the insightful answers!
@marcinofulus great, I'll try that option!
@artur-trzesiok OK, your point concerning the TrackballControls makes sense. I tried the example of the "fly" controls but I did not find it very intuitive. Actually, the 'orbit' controls make a lot of sense to me and are very useful I think. Maybe it is easiest to provide a switch in the controls menu to toggle between trackball/orbit like you are suggesting. That would be really useful.
Let me know what you think. :+1:
It's already in test phase!
K3D@2.8.0 is released. You can update package via pypi or conda. This fix is included there.
Thank you so much! it is working great :+1:
This fly mode is really cool but as far as I tested it can be controlled only with the mouse, is it possible to fly using Keyboard arrows or WASD like in a videogame?
Thank you for creating this amazing library!
I'm using it for the visualization of spherical particles above a flat surface. My question concerns the manipulation of the camera.
When first starting, the field of view is like this:
I know I can rotate with the left mouse button, zoom by scrolling and pan by moving with the right mouse button. If I want to zoom in on a specific part, I can get something like this:
But at some point, when I then from that view try to zoom in on a more distant particle, I cannot zoom past a certain point and the right mouse button changes nothing anymore.
My questions are as follows:
I have also looked at the camera field of view parameter, but I have no idea what is does. How is it different from zooming in?
Thank you and keep up the good work! :+1: