label not updated after modifying scene.center

27 views
Skip to first unread message

Rob Salgado

unread,
Jul 15, 2017, 5:31:33 PM7/15/17
to VPython-users
When scene.center is modified,
labels are not redrawn unless (presumably) a redraw is done,
for example, by zooming in with the mouse.
Touching a label by updating its visible seems to effect the redraw.

The following Glowscript code demonstrates this.
[For Jupyter VPython, import VPython and remove the wait in the rate()]
Remove the comment to touch the label.

In addition, scene.center += vec(.05,0,0)
works in Jupyter VPython, but not in Glowscript.
 
GlowScript 2.3 VPython

arrow
()
A
=label(text='arrow tail')

for i in range(10):
  rate
(2,wait)
  scene
.center = scene.center + vec(.05,0,0)
  #scene.center += vec(.05,0,0)  #in Glowscript:  Error: Property 'center' must be a vector.

#A.visible=A.visible  #touch the label


(By the way, I finally started using Glowscript and trinket.io, thanks to the recent 
Partnership for Integration of Computation into Undergraduate Physics (PICUP) meeting in River Falls.
I stumbled on these bugs in developing my project.) 

(Bruce... Thanks for all of your help!)

Rob

Bruce Sherwood

unread,
Jul 15, 2017, 8:17:35 PM7/15/17
to VPython-users
Thanks much for the report, Rob. FYI, there's no reason to use the "wait" argument in the rate function -- why in fact did you include it? It is required if the program is written in JavaScript or RapydScript, but not in the VPython version (in which some preprocessing inserts the "wait" for you).

Also, I'm very puzzled by the version 2.3. Is that just a typo, or did you actually use that old version? If you did use 2.3 rather than 2.5, why?


Rob Salgado

unread,
Jul 15, 2017, 8:30:59 PM7/15/17
to VPython-users
Oh, I must have misunderstood the use of wait in rate.

Concerning 2.3... that's the highest version available on trinket, after changing it from its default of 2.1.

Message has been deleted

Bruce Sherwood

unread,
Jul 29, 2017, 10:32:47 PM7/29/17
to VPython-users
For highly technical reasons it is not possible in GlowScript VPython to use the form A += B if A and B are vectors. Instead, you must use the form A = A+B.

The first page of the Help at glowscript.org, in the section "For those who have used Classic VPython", the vector addition issue and other such matters are explicitly discussed. This isn't required reading when getting started with GlowScript VPython, but at some point it's useful to read this section.
Reply all
Reply to author
Forward
0 new messages