K3D-tools / K3D-jupyter

K3D lets you create 3D plots backed by WebGL with high-level API (surfaces, isosurfaces, voxels, mesh, cloud points, vtk objects, volume renderer, colormaps, etc). The primary aim of K3D-jupyter is to be easy for use as stand alone package like matplotlib, but also to allow interoperation with existing libraries as VTK.
MIT License
917 stars 123 forks source link

A fixed view #381

Closed Depth2World closed 1 year ago

Depth2World commented 1 year ago

Hi there, Appreciate your brilliant work! Now, I want to plot a 3d volume. How can I have an fixed view when I run the code?

renefritze commented 1 year ago

Plot instances have attributes to achieve what you want.

Plot().camera_no_pan = True
Plot().camera_no_rotate = True
Plot().camera_no_zoom = True
Depth2World commented 1 year ago

Yes, I found that. The attributes are boolean. I mean that I need a special view for showing the volume. How can I fix the view?

RossBencina commented 1 year ago

I think you mean "specific view" not "special view" -- very different!

You can set the camera matrix. For example, for a top down view I have:

cameraMatrix_= [
              xc, yc, zmax + 250,  
              xc ,  yc,  zc,
              0.0, 1.0, 0.0]
plot.camera = cameraMatrix_
artur-trzesiok commented 1 year ago

Hi @RossBencina show probably the best solution plot.camera = [ xcamera, y_camera, z_camera, x_target, y_target, z_target, x_up, y_up, z_up]

camera - camera position in space target - target where camera is pointed in space up - normal vector showing where is direction of up in projected view (control rotation of camera around line camera,target)

@Depth2World did that solve your problem?

artur-trzesiok commented 1 year ago

any updates?