vpython / vpython-jupyter

3D visualization made easy
MIT License
138 stars 64 forks source link

camera.rotation strange behavior. #82

Closed nastasi closed 4 years ago

nastasi commented 4 years ago

Using the code:

scene.camera.rotate(angle=-5.0 * PI / 180.0,
                                axis=scene.up,
                                origin=scene.center)

where:

From this top view: before

I obtain this: after

That doesn't seems what I was expecting, there is some error or I misunderstood the doc ?

BruceSherwood commented 4 years ago

Thanks for the report. There is indeed a typo in the machinery for scene.camera.rotate(). Here is a workaround. Not quite sure why the range statement is needed; it won't be needed when the code is corrected.

scene.range = 4 box(size=vec(2,5,3)) scene.camera.axis = scene.camera.axis.rotate(angle=-pi/4, axis=scene.up) scene.center = vec(0,0,0)

nastasi commented 4 years ago

@BruceSherwood I'm still in trouble: I was interested to rotate the camera at the right (or the left) of the current position still looking the center of the scene (like an helicopter when it flies around an target). Tnx.

nastasi commented 4 years ago

@BruceSherwood I think to have found the source of my problems: moving the view using the mouse on the web page the scene.camera.up vector is still (0,1,0)

BruceSherwood commented 4 years ago

I don't understand. I thought that the workaround code I provided did exactly that: move the camera around the center of the scene.