-
Notifications
You must be signed in to change notification settings - Fork 64
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
Missing scene/camera sync with browser view after web page-mouse interaction. #85
Comments
I don't understand. Run the following code and you will see scene.forward and scene.camera.axis changing as you use the mouse to rotate:
|
Correct, instead box()
forward = label(pos=vec(0,.2,0), text='')
axis = label(pos=vec(0,-.2,0), text='')
up = label(pos=vec(0,-.4,0), text='')
while True:
rate(50)
forward.text = scene.forward
axis.text = scene.camera.axis
up.text = scene.up |
That is how it currently works, though it could use some critical thought. I'm not entirely comfortable with this corner of the vpython world. |
Using the test below things became a little more clear. from math import pi as PI
from vpython import (box, label, vec, rate, scene)
box()
forward = label(pos=vec(0, .2, 0), text='')
axis = label(pos=vec(0, -.2, 0), text='')
up = label(pos=vec(0, -.4, 0), text='')
def keydown(ev):
if ev.key == 'right':
print('rotate')
scene.camera.rotate(PI / 8, axis=scene.camera.axis)
if ev.key == 'left':
print('rotate')
scene.camera.rotate(-PI / 8, axis=scene.camera.axis)
scene.bind('keydown', keydown)
while True:
rate(50)
forward.text = "F: %.3f, %.3f, %.3f" % (scene.forward.x, scene.forward.y, scene.forward.z)
axis.text = "A: %.3f, %.3f, %.3f" % (scene.camera.axis.x, scene.camera.axis.y, scene.camera.axis.z)
up.text = "U: %.3f, %.3f, %.3f" % (scene.up.x, scene.up.y, scene.up.z) |
If you change the point of view dragging with mouse in the browser window the camera and scene data are not updated.
It could be CPU intensive/inefficient so could be possible to add at least an explicit
sync
method to be able to retrieve correct parameters just before perform some action like camera movement after key pressure detection or just before an action is made on scene or camera ?The text was updated successfully, but these errors were encountered: