Materials throwing errors.

781 views
Skip to first unread message

samuel rodriguez

unread,
Sep 14, 2017, 9:18:55 PM9/14/17
to VPython-users
So when I try to run this small piece of code 


from vpython import *

ball = sphere(pos=vector(1,2,1), radius=0.5, make_trail=True, trail_type="points",
              interval=10, retain=50, material = earth)


I get the error



---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-5-e24e0b730fb2> in <module>()
      1 ball = sphere(pos=vector(1,2,1), radius=0.5, make_trail=True, trail_type="points",
----> 2               interval=10, retain=50, material = materials.earth)
      3 #ball.rotate(angle=pi/4.)

NameError: name 'materials' is not defined


I am running '7.1.3', 'jupyter'. I think it might have something to do with the version of vypthon that I am using but I am not sure.

Thank you for all of your help,

Best 
Samuel Rodriguez

Bruce Sherwood

unread,
Sep 14, 2017, 10:39:30 PM9/14/17
to VPython-users
"materials" was part of VPython 6 ("Classic VPython"). In VPython 7 there is a similar attribute, "texture". The documentation for VPython 7 is here:


Or go to glowscript.org and click "Help".

Here is the documentation page dealing with textures:


Your particular program will run if you change "material=earth" to "texture=textures.earth". Otherwise your program is okay.

Bruce

samuel rodriguez

unread,
Sep 15, 2017, 7:15:41 PM9/15/17
to VPython-users
Thank you so much! That worked right away. I spent so long trying to figure out why it wasn't working. Is there an emmisive texture?

Bruce Sherwood

unread,
Sep 15, 2017, 7:44:28 PM9/15/17
to VPython-users
Here is the documentation page that describes all of the standard attributes, of which "emissive" is one:


In addition to the documentation found at glowscript.org, note that at vpython.org there are links to a zip file of demo programs. You can also run these same demo programs simply by going to glowscript.org and clicking "Example programs".

Bruce
Reply all
Reply to author
Forward
0 new messages