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

bug in camera #180

Closed
marcomusy opened this issue Aug 20, 2019 · 8 comments
Closed

bug in camera #180

marcomusy opened this issue Aug 20, 2019 · 8 comments
Assignees

Comments

@marcomusy
Copy link

It seems that camera is not updated when viewup is modified but camera position is not changed:

import k3d
import numpy as np
from numpy import sin,cos,pi
from ipywidgets import interact, interactive, fixed
import ipywidgets as widgets
import time
import math

plot = k3d.plot()

plot.camera_auto_fit = False

T = 1.618033988749895
r = 4.77
zmin,zmax = -r,r
xmin,xmax = -r,r
ymin,ymax = -r,r
Nx,Ny,Nz = 77,77,77

x = np.linspace(xmin,xmax,Nx)
y = np.linspace(ymin,ymax,Ny)
z = np.linspace(zmin,zmax,Nz)
x,y,z = np.meshgrid(x,y,z,indexing='ij')
p = 2 - (cos(x + T*y) + cos(x - T*y) + cos(y + T*z) + cos(y - T*z) + cos(z - T*x) + cos(z + T*x))
iso = k3d.marching_cubes(p.astype(np.float32),xmin=xmin,xmax=xmax,ymin=ymin,ymax=ymax, zmin=zmin, zmax=zmax, level=0.0)
plot += iso

plot.display()

this doesnt work:

@interact(rad=widgets.FloatSlider(value=0,min=0,max=1,step=0.01))
def g(rad):
    plot.camera = [8,0,8,
                   0,0,0,
                   0,1-rad,rad]

while this works:

@interact(rad=widgets.FloatSlider(value=0,min=0,max=1,step=0.01))
def g(rad):
    plot.camera = [8,0,8+rad/100,
                   0,0,0,
                   0,1-rad,rad]
@artur-trzesiok
Copy link
Collaborator

Nice spot! This is a issue in ThreeJs: https://github.com/mrdoob/three.js/blob/master/examples/js/controls/TrackballControls.js#L357

ThreeJs emite change event only if position change. They ignore a up vector. You can add them a issue.

artur-trzesiok added a commit that referenced this issue Oct 22, 2019
transfer function editor - new wiget
bug in camera #180
colormap refactor
line update fixed
@artur-trzesiok artur-trzesiok self-assigned this Oct 22, 2019
@artur-trzesiok
Copy link
Collaborator

@marcomusy can you confirm that in 2.7.0 this issue is already fixed?

@marcomusy
Copy link
Author

Hi @artur-trzesiok sorry for the late reply - this slipped off my mind - I just tried it again with the above example and I still get the same weird behavior in k3d 2.7.

@artur-trzesiok
Copy link
Collaborator

Can you double check version of js part of k3d?
image

@marcomusy
Copy link
Author

oh yes - that shows 2.6.9
what should i do to trigger the update?

@marcinofulus
Copy link
Contributor

If you use conda package and the same env for both notebook then it should work. You might want to restart notebook. In other cases it might be necessary to use:

  • jupyter nbextension install --sys-prefix --py k3d
  • jupyter nbextension enable --sys-prefix --py k3d

@marcomusy
Copy link
Author

Hi @marcinofulus I tried but still get the 2.6.9 js version..
I also tried restarting the browser.. any ideas?

image

@marcinofulus
Copy link
Contributor

marcinofulus commented Nov 4, 2019

check for jupyter --paths: - perhaps you have k3d installed in a multiple locations e.g both in system and user space. Also have a look at jupyter nbextension list. It is possible that you will have to delete some location if there are doubled.

In principle, if jupyter notebook is running kernel from some different env - then I use --user for nbextensions (like central jupyterhub installations)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants