Sphere make_trail parameter issue

28 views
Skip to first unread message

Max DeMarr

unread,
May 16, 2025, 7:53:58 PMMay 16
to Glowscript Users
Good evening,

I am trying to pass parameters for creating a sphere through a kwargs dictionary in a function. Every parameter works as intended, but I run into an error when trying to pass 'make_trail':True. In my code, you will see the func() method takes in a dictionary called kwargs. I originally intended to mimic **kwargs from Python, but this does not work with the transpiler.

If you copy and run the code, you will get the error I've pasted in the bottom, something about 'start' not being defined. The fix I have found is by including 'make_trail=False' in the initialization of the sphere, which you can see commented out in the function. I am not sure as to why this is, but I figured it might help someone out in the future.

Web VPython 3.2

def func(kwargs={}):
    s = sphere(pos=vec(0,0,0), radius=0.2)
    # s = sphere(pos=vec(0,0,0), radius=0.2, make_trail=False)  # Specifying make_trail here fixes the error

    for k, val in kwargs.items():
        s[k] = val

    return s

# Driver code
s1 = func(kwargs={'color':color.red, 'make_trail':True})  # This breaks if 'make_trail' is included

while True:
    rate(20)
    s1.pos += vec(0.01, 0,0)
Error printout: "TypeError: Cannot read properties of undefined (reading 'start')"


Best,
- Maximillian

Steve Spicklemire

unread,
May 17, 2025, 9:24:18 AMMay 17
to glowscri...@googlegroups.com, Steve Spicklemire
Thanks for the report.

I’ll look into this and get back.

-steve
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "Glowscript Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to glowscript-use...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/glowscript-users/1e222e5f-f253-459f-b1c9-3e96ef53fac1n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages